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.

mca.c 2.6KB

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