tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

MODULE_CLASS_DRIVER and locators stuff



Hey,

I wanted to add locators functionality to the new modules framework, and
after adding some stuff based in the LKM code I have something that works
somehow... there are still some problems that I'd like to fix :-)

Basically what I have done is:

- Add DRIVER_MODULE(class, name, parent, locs, required) and
  DRIVER_RESCAN(name, bus) macros.

DRIVER_MODULE defines the cfattach/cfdata/cfattachlkm stuff and
DRIVER_RESCAN defines cfiattrdata.

So I tried this hackish code with auich(4):

$ cat Makefile main.c
S=      ${.CURDIR}/../..
.PATH:  $S/dev/pci

KMOD=           auich
SRCS=           auich.c main.c
WARNS=          4

.include <bsd.kmodule.mk>

#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/module.h>

static int locs[] = { -1, -1 };

DRIVER_MODULE_RESCAN(auich, audiobus);
DRIVER_MODULE(MODULE_CLASS_DRIVER, auich, pci, locs, NULL);

static int
auich_modcmd(modcmd_t cmd, void *arg)
{
        switch (cmd) {
        case MODULE_CMD_INIT:
                printf("module loaded\n");
                break;
        case MODULE_CMD_FINI:
                printf("module unloaded\n");
                break;
        default:
                return ENOTTY;
        }

        return 0;
}
$

Loading and unloading it seems to work, but as the bus was rescaned
this also found the devices that weren't matched before:

module loaded
auich: cfdriver_attach sucess
auich: cfattach_attach success
Intel 82915GM/GMS IGD Companion (miscellaneous display, revision 0x04) at
pci0 dev 2 function 1 not configured

auich0 at pci0 dev 30 function 2: i82801FB (ICH6) AC-97 Audio
auich0: interrupting at ioapic0 pin 17 (irq 10)
auich0: ac97: Analog Devices AD1981B codec; headphone, 20 bit DAC, no 3D
stereo
auich0: ac97: ext id 605<AC97_22,AMAP,SPDIF,VRA>
auich0: measured ac97 link rate at 47999 Hz, will use 48000 Hz
audio1 at auich0: full duplex, mmap, independent
Intel 82801FB/FR AC'97 Modem Controller (modem communications, revision
0x04) at pci0 dev 30 function 3 not configured
Texas Instruments PCI7x21/7x11 Integrated FlashMedia Controller
(miscellaneous mass storage) at pci2 dev 6 function 3 not configured
Texas Instruments product 0x8034 (SD Host Controller system) at pci2 dev 6
function 4 not configured
auich: cfdata_attach success

audio1: detached
auich0: detached
auich: cfdata_detach success
auich: cfattach_detach success
auich: cfdriver_detach success
module unloaded

The patch is available at:
http://www.netbsd.org/~xtraeme/locs_kmod.diff

Future work:
  
-  Get rid of DRIVER_RESCAN() and find a way to declare multiple
    interface attributes.
- Remove the locs param in DRIVER_MODULE() and pass them via
   a proplib dictionary.

-- 
Juan Romero Pardines - xtraeme at gmail|netbsd dot org
        The NetBSD Project

Make your own NetBSD/x86 Live CD:
http://www.netbsd.org/~xtraeme/mklivecd/


Home | Main Index | Thread Index | Old Index