Subject: LKM
To: 'tech-kern@netbsd.org' <tech-kern@netbsd.org>
From: Sander Storms <s.storms@technology.asb.nl>
List: tech-kern
Date: 10/01/2004 08:48:50
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C4A782.B560B060
Content-Type: text/plain;
	charset="iso-8859-1"

Hello,

I already posted this message some month ago, but I never got an answer.
Either I am at the wrong
mailing-list, or the message did not arrive properly.
But anyway, here's my question:

I want to create a driver for a custom-made PCI-device. This device has
always been
put directly into the kernel (NetBSD 1.5.1 back then), and it worked
properly.
Now, our software-supplier upgraded to NetBSD 1.6.1 and the driver has to be
rewritten.
Since 1.6.1 has kernel module support, it is unlogical to hack the driver
into the kernel again.

Here's the problem:

In the kernel-version of the software, 3 device-nodes where created:
1 for the PCI communication (/dev/pciDevice0)  and 2 modem interfaces
(/dev/modem0 and /dev/modem1), 
present on the PCI device.
If I create a kernel-module, only the 1st device-node (/dev/pciDevice0) will
be created :

-------------- SAMPLE CODE -------------------

MOD_DEV("pciDevice", LM_DT_CHAR, -1, &pciDevice_cdevsw);

int device_pci_lkmmatch(struct pci_attach_args *pa)
{
  if (device_pci_match(NULL, NULL, pa))
  {
    struct device *sc = (struct device *) device_lkmalloc();
    if (sc != NULL)
    {
      printf("%s at pci%u", sc->dv_xname, pa->pa_bus);
      pciprint(pa, NULL);
      device_pci_attach(NULL, sc, pa);
    }
  }

  return 0;
}


static int device_lkmload(struct lkm_table *lkmt, int cmd)
{
  int error;
  struct pci_attach_args paa;
  
  if (lkmexists(lkmt))
  {
    return (EEXIST);
  }

  (void)pci_find_device(&paa, device_pci_lkmmatch);
  
  if (device_counter == 0)
  {
    return(ENXIO);
  }

  if ((error = modemIfattach ()))
  {
    return error;
  }
  return 0;
}

-------------- END SAMPLE CODE -------------------

Can anyone tell me how I can create the 2 modem-interfaces, accessed through
the function "modemIfattach ()" ?
The 'modload' function returns the major device-number for my PCI-device,
but NOT for my
2 modem-interfaces.

Thanks,

Sander.


------_=_NextPart_000_01C4A782.B560B060
Content-Type: application/ms-tnef
Content-Transfer-Encoding: base64

eJ8+IjQGAQaQCAAEAAAAAAABAAEAAQeQBgAIAAAA5AQAAAAAAADoAAEIgAcAGAAAAElQTS5NaWNy
b3NvZnQgTWFpbC5Ob3RlADEIAQWAAwAOAAAA1AcKAAEACAAwADIABQBVAQEggAMADgAAANQHCgAB
AAgAMAAyAAUAVQEBCYABACEAAAA1RjVDMEY2QjcyMTNEOTExQThEQjAwNTA4QjU1NjI5MgAIBwEE
gAEABAAAAExLTQDkAAENgAQAAgAAAAIAAgABA5AGABgKAAAuAAAAAwABbiAAAAADAASACCAGAAAA
AADAAAAAAAAARgAAAABShQAAc3kBAB4ABYAIIAYAAAAAAMAAAAAAAABGAAAAAFSFAAABAAAABAAA
ADkuMAALAA2ACCAGAAAAAADAAAAAAAAARgAAAAAGhQAAAAAAAAMABoAIIAYAAAAAAMAAAAAAAABG
AAAAAAGFAAAAAAAACwACgAggBgAAAAAAwAAAAAAAAEYAAAAAA4UAAAAAAAALAAeACCAGAAAAAADA
AAAAAAAARgAAAAAOhQAAAAAAAAMAA4AIIAYAAAAAAMAAAAAAAABGAAAAABCFAAAAAAAAAwAIgAgg
BgAAAAAAwAAAAAAAAEYAAAAAEYUAAAAAAAADAAmACCAGAAAAAADAAAAAAAAARgAAAAAYhQAAAAAA
AAIBCRABAAAAeQUAAHUFAADTCQAATFpGdaruF1wDAAoAcmNwZzEyNRYyAPgLYG4OEDAzM08B9wKk
A+MCAGNoCsBz8GV0MCAHEwKDAFAEVfECAHBycRIREOcIVQeylQKAfQqBdgiQd2sLgDRkNAxgYwBQ
CwNub2ED8GRjdGwKsQumIOhIZWwJACwKogqECoAMSSAHQAlwYWR5IBBwb3N0CYAgdGgFBAAgB4Fz
YWdlIF5zA3AaEARgAjBoGGBnMRdwIGJ1BUAYUG5lvnYUARrwBUADkQBxdwSQcC4gRWkZYBQBGFFt
5xhgBUAdASB3A2APIBeU5wDAAxALgGctHvA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