Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

mca.c 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * MCA bus driver code
  3. *
  4. * Abstracted from 3c509.c.
  5. *
  6. */
  7. #include "etherboot.h"
  8. #include "dev.h"
  9. #include "io.h"
  10. #include "mca.h"
  11. #define DEBUG_MCA
  12. #undef DBG
  13. #ifdef DEBUG_MCA
  14. #define DBG(...) printf ( __VA_ARGS__ )
  15. #else
  16. #define DBG(...)
  17. #endif
  18. /*
  19. * Ensure that there is sufficient space in the shared dev_bus
  20. * structure for a struct pci_device.
  21. *
  22. */
  23. DEV_BUS( struct mca_device, mca_dev );
  24. static char mca_magic[0]; /* guaranteed unique symbol */
  25. /*
  26. * Fill in parameters for an MCA device based on slot number
  27. *
  28. */
  29. static int fill_mca_device ( struct mca_device *mca ) {
  30. unsigned int i;
  31. /* Make sure motherboard setup is off */
  32. outb_p ( 0xff, MCA_MOTHERBOARD_SETUP_REG );
  33. /* Select the slot */
  34. outb_p ( 0x8 | ( mca->slot & 0xf ), MCA_ADAPTER_SETUP_REG );
  35. /* Read the POS registers */
  36. for ( i = 0 ; i < ( sizeof ( mca->pos ) / sizeof ( mca->pos[0] ) ) ;
  37. i++ ) {
  38. mca->pos[i] = inb_p ( MCA_POS_REG ( i ) );
  39. }
  40. /* Kill all setup modes */
  41. outb_p ( 0, MCA_ADAPTER_SETUP_REG );
  42. DBG ( "MCA slot %d id %hx (%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx)\n",
  43. mca->slot, MCA_ID ( mca ),
  44. mca->pos[0], mca->pos[1], mca->pos[2], mca->pos[3],
  45. mca->pos[4], mca->pos[5], mca->pos[6], mca->pos[7] );
  46. return 1;
  47. }
  48. /*
  49. * Obtain a struct mca * from a struct dev *
  50. *
  51. * If dev has not previously been used for an MCA device scan, blank
  52. * out struct mca
  53. */
  54. struct mca_device * mca_device ( struct dev *dev ) {
  55. struct mca_device *mca = dev->bus;
  56. if ( mca->magic != mca_magic ) {
  57. memset ( mca, 0, sizeof ( *mca ) );
  58. mca->magic = mca_magic;
  59. }
  60. mca->dev = dev;
  61. return mca;
  62. }
  63. /*
  64. * Find an MCA device matching the specified driver
  65. *
  66. */
  67. int find_mca_device ( struct mca_device *mca, struct mca_driver *driver ) {
  68. unsigned int i;
  69. /* Iterate through all possible MCA slots, starting where we
  70. * left off/
  71. */
  72. for ( ; mca->slot < MCA_MAX_SLOT_NR ; mca->slot++ ) {
  73. /* If we've already used this device, skip it */
  74. if ( mca->already_tried ) {
  75. mca->already_tried = 0;
  76. continue;
  77. }
  78. /* Fill in device parameters */
  79. if ( ! fill_mca_device ( mca ) ) {
  80. continue;
  81. }
  82. /* Compare against driver's ID list */
  83. for ( i = 0 ; i < driver->id_count ; i++ ) {
  84. struct mca_id *id = &driver->ids[i];
  85. if ( MCA_ID ( mca ) == id->id ) {
  86. DBG ( "Device %s (driver %s) matches ID %hx\n",
  87. id->name, driver->name, id->id );
  88. if ( mca->dev ) {
  89. mca->dev->name = driver->name;
  90. mca->dev->devid.bus_type
  91. = MCA_BUS_TYPE;
  92. mca->dev->devid.vendor_id
  93. = GENERIC_MCA_VENDOR;
  94. mca->dev->devid.device_id = id->id;
  95. }
  96. mca->already_tried = 1;
  97. return 1;
  98. }
  99. }
  100. }
  101. /* No device found */
  102. mca->slot = 0;
  103. return 0;
  104. }