Date: Thu, 21 Mar 1996 00:37:51 -0800 From: Paul Traina <pst@shockwave.com> To: bde@freebsd.org Cc: hackers@freebsd.org, bugs@freebsd.org, jmz@freebsd.org Subject: modloaded block/char device drivers Message-ID: <199603210837.AAA00354@precipice.shockwave.com>
next in thread | raw e-mail | index | archive | help
Well, I've succesfully gotten the qcam driver to work as a modloaded device. Some notes from the experience: (a) calling dev_attach() from a modloaded device panics the system. I have not even attempted to mess with this yet, but it can be trivially reproduced by removing the #ifndef ACTUALL_LKM_NOT_KERNEL wrappers around the call in qcam.c. It panics with a kernel page fault, but the current calling chain did /not/ include any of the qcam routines in the stack frame. I just found this by scratching my head and looking to see what I did that the joystick routine didn't do. (b) I was forced to manually call qcam_registerdev() which is the code that attaches the driver's cdevsw structure to the rest of the kernel. Without this, of course, devices are not reachable via their inodes. I feel that it's not proper for the LKM <driver>_load function to be doing this. This really should be done as part of the LKM load process since you already have the major number and the pointer to the structure passed in. (c) LKMs for device drivers with hardware that is not at a fixed address (e.g. the joystick) or completely auto-scanable are really kludgy right now. There's no easy way, other than editing the driver source, to say: "Hey, I want the xxx driver, and I want it to look for the device over here." I was thinking of kludging something together to make auto-scanning work for the qcam driver, but that would remove the pressure to deal with this properly. :-) The joys of early adoption. In any case, a lot of this is judgement call stuff, so please tell me which you'd like me to file PR's on and which you think I'm wrong in understanding. Paul
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603210837.AAA00354>