You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pci_probe.c 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifdef CONFIG_PCI
  2. /*
  3. * This program is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU General Public License as
  5. * published by the Free Software Foundation; either version 2, or (at
  6. * your option) any later version.
  7. */
  8. #include "etherboot.h"
  9. #include "nic.h"
  10. #include "pci.h"
  11. void pci_enumerate(void)
  12. {
  13. const struct pci_driver *driver;
  14. for(driver = pci_drivers; driver < pci_drivers_end; driver++) {
  15. printf("%s ", driver->name);
  16. }
  17. }
  18. int pci_probe(struct dev *dev, const char *type_name)
  19. {
  20. /*
  21. * NIC probing is in pci device order, followed by the
  22. * link order of the drivers. A driver that matches
  23. * on vendor and device id will supersede a driver
  24. * that matches on pci class.
  25. *
  26. * If you want to probe for another device behind the same pci
  27. * device just increment index. And the previous probe call
  28. * will be repeated.
  29. */
  30. struct pci_probe_state *state = &dev->state.pci;
  31. printf("Probing pci %s...\n", type_name);
  32. if (dev->how_probe == PROBE_FIRST) {
  33. state->advance = 1;
  34. state->dev.driver = 0;
  35. state->dev.bus = 0;
  36. state->dev.devfn = 0;
  37. dev->index = -1;
  38. }
  39. for(;;) {
  40. if ((dev->how_probe != PROBE_AWAKE) && state->advance) {
  41. find_pci(dev->type, &state->dev);
  42. dev->index = -1;
  43. }
  44. state->advance = 1;
  45. if (state->dev.driver == 0)
  46. break;
  47. if (dev->how_probe != PROBE_AWAKE) {
  48. dev->type_index++;
  49. }
  50. dev->devid.bus_type = PCI_BUS_TYPE;
  51. dev->devid.vendor_id = htons(state->dev.vendor);
  52. dev->devid.device_id = htons(state->dev.dev_id);
  53. /* FIXME how do I handle dev->index + PROBE_AGAIN?? */
  54. printf("[%s]", state->dev.name);
  55. if (state->dev.driver->probe(dev, &state->dev)) {
  56. state->advance = (dev->index == -1);
  57. return PROBE_WORKED;
  58. }
  59. putchar('\n');
  60. }
  61. return PROBE_FAILED;
  62. }
  63. #endif