Subject: LKM for kernel 1.6.1
To: NetBSD Mailinglist (E-mail) <tech-kern@netbsd.org>
From: Sander Storms <s.storms@technology.asb.nl>
List: tech-kern
Date: 08/09/2004 09:42:24
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_01C47DE4.6DFA9F80
Content-Type: text/plain;
	charset="iso-8859-1"

Hello,

Can anyone help me with the next problem:

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 Storms.

--------------------------------------------

ASB Technology BV
De Ronde 15A
5683 CZ  Best
The Netherlands
tel. ++31 499 365077
fax. ++31 499 365099

S.Storms@technology.asb.nl
--------------------------------------------


------_=_NextPart_000_01C47DE4.6DFA9F80
Content-Type: application/ms-tnef
Content-Transfer-Encoding: base64

eJ8+IiIHAQaQCAAEAAAAAAABAAEAAQeQBgAIAAAA5AQAAAAAAADoAAEIgAcAGAAAAElQTS5NaWNy
b3NvZnQgTWFpbC5Ob3RlADEIAQWAAwAOAAAA1AcIAAkACQAqABgAAQA4AQEggAMADgAAANQHCAAJ
AAkAKgAgAAEAQAEBCYABACEAAAAyMDI5ODAxRTFBRTVEODExQThEODAwNTA4QjU1NjI5MgDmBgEE
gAEAFQAAAExLTSBmb3Iga2VybmVsIDEuNi4xAAAGAQ2ABAACAAAAAgACAAEDkAYAVAoAAC4AAAAD
AAFuIAAAAAMABIAIIAYAAAAAAMAAAAAAAABGAAAAAFKFAABzeQEAHgAFgAggBgAAAAAAwAAAAAAA
AEYAAAAAVIUAAAEAAAAEAAAAOS4wAAsADYAIIAYAAAAAAMAAAAAAAABGAAAAAAaFAAAAAAAAAwAG
gAggBgAAAAAAwAAAAAAAAEYAAAAAAYUAAAAAAAALAAKACCAGAAAAAADAAAAAAAAARgAAAAADhQAA
AAAAAAsAB4AIIAYAAAAAAMAAAAAAAABGAAAAAA6FAAAAAAAAAwADgAggBgAAAAAAwAAAAAAAAEYA
AAAAEIUAAAAAAAADAAiACCAGAAAAAADAAAAAAAAARgAAAAARhQAAAAAAAAMACYAIIAYAAAAAAMAA
AAAAAABGAAAAABiFAAAAAAAAAgEJEAEAAACJBQAAhQUAAE4KAABMWkZ1fz+aogMACgByY3BnMTI1
FjIA+Atgbg4QMDMzTwH3AqQD4wIAY2gKwHPwZXQwIAcTAoMAUARV8QIAcHJxEhEQ5whVB7KVAoB9
CoF2CJB3awuAdGQ0DGBjAFALAwu1IOhIZWwJACwKogqECoAWQwORAHB5AiBlIGgpFoBwIAeAIAPw
dGhuIBjgGCAYEHgFQBLAb9ECYG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