Subject: Pci's cfdriver cd_ndevs incoherency
To: None <tech-kern@netbsd.org>
From: yannick montulet <yannick.montulet@epitech.net>
List: tech-kern
Date: 03/05/2001 23:56:01
Hi, while playing with the cfdriver structures,
i encountered the following for the pci cfdriver structure :

---

	No of devices = 4
	device ptr is 0xc04a0f00
	device ptr is 0xc04a0e80
	device ptr is 0x0
	device ptr is 0x0

---

And here is the code which made this :

---

short get_cfdriver_index(int (*cfdrivermatch)(struct cfdriver *))
{
  short                 i;

  for (i = 0; cfdata[i].cf_driver != NULL; i++)
    if (cfdrivermatch(cfdata[i].cf_driver))
      return i;
  return -1;
}

int pci_driver_match(struct cfdriver *cf_driver)
{
  if (cf_driver->cd_class == DV_DULL &&
      strcmp(cf_driver->cd_name, "pci") == 0)
    return 1;
  return 0;
}

void test_pci(void)
{
  int			cd_ndevs;
  short			cfindex, i;
  struct cfdriver	*cf_driver;
  void			*cd_devs[];

  if ((cfindex = get_cfdriver_index(pci_driver_match)) == -1)
    {
      printf("pci driver not found !!\n");
      return ENOENT;
    }
  cf_driver = cfdata[cfindex].cf_driver;
  cd_ndevs = cf_driver->cd_ndevs;
  cd_devs = cf_driver->cd_devs;
  printf("No of devices = %d\n", cd_ndevs);
  for (i = 0; i < cd_ndevs; i++)
    printf("device ptr is %p\n", cd_devs[i]);
}

---

NOTE : These functions are enclosed in a lkm chr device.

Is it normal that cd_ndevs says 4 and that the cd_devs[2] and cd_devs[3] are
NULL pointers ?

Thanks for your help,

Yannick