Return to BSD News archive
Received: by minnie.vk1xwt.ampr.org with NNTP id AA1912 ; Tue, 23 Feb 93 15:03:44 EST Path: sserve!manuel.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!haven.umd.edu!umd5!roissy.umd.edu!mark From: mark@roissy.umd.edu (Mark Sienkiewicz) Newsgroups: comp.os.386bsd.questions Subject: Loadable drivers (was Re: WFJ's talk last night...) Message-ID: <18629@umd5.umd.edu> Date: 22 Feb 93 17:31:58 GMT References: <C2nHuD.5EC@raistlin.udev.cdc.com> <1m1a0oINN8ds@jethro.Corp.Sun.COM> <C2pJHs.Dsp@sugar.neosoft.com> Sender: news@umd5.umd.edu Organization: University of Maryland Lines: 44 In article <C2pJHs.Dsp@sugar.neosoft.com> peter@NeoSoft.com (Peter da Silva) writes: >> - loadable drivers > >Any comments on mechanism? I've done loadable device drivers for 386bsd. The only problem is it doesn't work. :) The problem is that the system crashes if you execute code out of malloc()'ed memory. I suspect one of these two things: - The segmenting thing is biting me. Maybe CS: is not using the same page table as DS:. If not, I wonder why not. - The thing that builds the initial page table marks pages as executable only up to the end of the loaded kernel text. I supposed the latter and did a bit of digging in locore.s and what 386 documentation I could find, but I don't yet understand the 386 well enough to know what's going on. My approach is this: make foo.o which contains your device driver read the .o file and figure out how much text+data+bss you need do a system call to allocate a loadable device driver with this much space. The kernel mallocs some space for you. use a patched ld to relocate foo.o to the address allocated by the kernel (ld -A doesn't do it quite right) do a system call to copy the relocated foo.o into the kernel the kernel calls the init routine, which does any initialization the driver needs. to unload, the kernel calls the deinit routine and frees the memory. It looks pretty much like what the AT&T Unixpc (aka 3B1) does, except that I made the drivers init() routine responsible for setting bdevsw[] and cdevsw[] because it was easier that way. Is anybody out there interested in this? Does anybody know what I have to do to the page tables so I can execute that code I have loaded into the kernel? Send me mail! Mark S.