tech-kern archive

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

Re: How to use the autoconf(9) interface alongside the module(9) one? (was: "How to compile a modified example kernel module")



> Hi,
> on NetBSD 6.1.5, I am failing to compile a modified version of the example found in
> /usr/src/sys/module/example/
> 
> I tried to mimic the modules found in /usr/src/sys/module/
> but nothing is compiling.
> 
> How I am doing things:
> ===================
> Test the original example by
> $ cp -R /usr/src/sys/module/example ~/
> $ cd ~/example
> $ make
> $ modload ./example.kmod
> And it worked.
> 
> After making the following modifications, the module stopped compiling
> 
> /*** example.c ======BEGIN=FILE====================***/
> struct example_softc {
>     device_t    sc_dev;
> };
> 
>     static int
> example_match(device_t parent, cfdata_t match, void *aux)
> {
>     struct pci_attach_args *pa = aux;
> 
>     printf("pci_vendor: %#x" ", pci_product: %#x"
>             ", pci_class: %#x" ", pci_subclass: %#x\n",
>             PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id),
>             PCI_CLASS(pa->pa_class), PCI_CLASS(pa->pa_class));
> 
>     return 0;
> }
> 
>     static void
> example_attach(device_t parent, device_t self, void *aux)
> {
>     return;
> }
> 
>     static int
> example_detach(device_t self, int flags)
> {
>     return 0;
> }
> 
> CFATTACH_DECL(
>         example,
>         sizeof(struct example_softc),
>         example_match,
>         example_attach,
>         example_detach,
>         NULL
>          );
> 
> MODULE(MODULE_CLASS_MISC, example, "pci");
> 
> #ifdef _MODULE
> #include "ioconf.c"
> #endif
> 
>     static int
> example_modcmd(modcmd_t cmd, void *arg)
> {
>     int error = 0;
> 
>     switch (cmd) {
>         case MODULE_CMD_INIT:
> #ifdef _MODULE
>             error = config_init_component(cfdriver_ioconf_example,
>                     cfattach_ioconf_example, cfdata_ioconf_example);
> #endif
>             return error;
>         case MODULE_CMD_FINI:
> #ifdef _MODULE
>             error = config_fini_component(cfdriver_ioconf_example,
>                     cfattach_ioconf_example, cfdata_ioconf_example);
> #endif
>             return error;
>         default:
>             return ENOTTY;
>     }
> }
> /*** example.c ======END=FILE====================***/
> 
> /*** Makefile ======BEGIN=FILE====================***/
> KMOD=   example
> SRCS=    example.c
> 
> .include <bsd.kmodule.mk>
> 
> /*** Makefile ======END=FILE====================***/
> 
> So, I'm asking how do I implement the example.ioconf which I'm obviously lacking ?
> 
> 
> ---mugius---

Is there any documentation that ​passed me by?
Or this (matching or probing) is something even more complex to do than what I'm imagining.


---mugius---



Home | Main Index | Thread Index | Old Index