Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

isa.c 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #include "etherboot.h"
  2. #include "isa.h"
  3. /*
  4. * isa.c implements a "classical" port-scanning method of ISA device
  5. * detection. The driver must provide a list of probe addresses
  6. * (probe_addrs), together with a function (probe_addr) that can be
  7. * used to test for the physical presence of a device at any given
  8. * address.
  9. *
  10. * Note that this should probably be considered the "last resort" for
  11. * device probing. If the card supports ISAPnP or EISA, use that
  12. * instead. Some cards (e.g. the 3c509) implement a proprietary
  13. * ISAPnP-like mechanism.
  14. *
  15. * The ISA probe address list can be overridden by config.c; if
  16. */
  17. /*
  18. * Ensure that there is sufficient space in the shared dev_bus
  19. * structure for a struct isa_device.
  20. *
  21. */
  22. DEV_BUS( struct isa_device, isa_dev );
  23. static char isa_magic[0]; /* guaranteed unique symbol */
  24. /*
  25. * Find an ISA device matching the specified driver
  26. *
  27. */
  28. int find_isa_device ( struct isa_device *isa, struct isa_driver *driver ) {
  29. unsigned int i;
  30. uint16_t ioaddr;
  31. /* Initialise struct isa if it's the first time it's been used. */
  32. if ( isa->magic != isa_magic ) {
  33. memset ( isa, 0, sizeof ( *isa ) );
  34. isa->magic = isa_magic;
  35. }
  36. /* Iterate through any ISA probe addresses specified by
  37. * config.c, starting where we left off.
  38. */
  39. for ( i = isa->probe_idx ; i < isa_extra_probe_addr_count ; i++ ) {
  40. /* If we've already used this device, skip it */
  41. if ( isa->already_tried ) {
  42. isa->already_tried = 0;
  43. continue;
  44. }
  45. /* Set I/O address */
  46. ioaddr = isa_extra_probe_addrs[i].addr;
  47. /* An I/O address of 0 in extra_probe_addrs list means
  48. * stop probing (i.e. don't continue to the
  49. * driver-provided list)
  50. */
  51. if ( ! ioaddr )
  52. goto notfound;
  53. /* Use probe_addr method to see if there's a device
  54. * present at this address.
  55. */
  56. if ( driver->probe_addr ( ioaddr ) ) {
  57. isa->probe_idx = i;
  58. goto found;
  59. }
  60. }
  61. /* Iterate through all ISA probe addresses provided by the
  62. * driver, starting where we left off.
  63. */
  64. for ( i = isa->probe_idx - isa_extra_probe_addr_count ;
  65. i < driver->addr_count ; i++ ) {
  66. /* If we've already used this device, skip it */
  67. if ( isa->already_tried ) {
  68. isa->already_tried = 0;
  69. continue;
  70. }
  71. /* Set I/O address */
  72. ioaddr = driver->probe_addrs[i].addr;
  73. /* Use probe_addr method to see if there's a device
  74. * present at this address.
  75. */
  76. if ( driver->probe_addr ( ioaddr ) ) {
  77. isa->probe_idx = i + isa_extra_probe_addr_count;
  78. goto found;
  79. }
  80. }
  81. notfound:
  82. /* No device found */
  83. isa->probe_idx = 0;
  84. return 0;
  85. found:
  86. DBG ( "Found %s ISA device at address %hx\n", driver->name, ioaddr );
  87. isa->ioaddr = ioaddr;
  88. isa->already_tried = 1;
  89. return 1;
  90. }
  91. /*
  92. * Find the next ISA device that can be used to boot using the
  93. * specified driver.
  94. *
  95. */
  96. int find_isa_boot_device ( struct dev *dev, struct isa_driver *driver ) {
  97. struct isa_device *isa = ( struct isa_device * )dev->bus;
  98. if ( ! find_isa_device ( isa, driver ) )
  99. return 0;
  100. dev->name = driver->name;
  101. dev->devid.bus_type = ISA_BUS_TYPE;
  102. dev->devid.vendor_id = driver->mfg_id;
  103. dev->devid.device_id = driver->prod_id;
  104. return 1;
  105. }