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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 found slot %d id %hx "
  35. "(POS %hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx)\n",
  36. mca->slot, MCA_ID ( mca ),
  37. mca->pos[0], mca->pos[1], mca->pos[2], mca->pos[3],
  38. mca->pos[4], mca->pos[5], mca->pos[6], mca->pos[7] );
  39. return 1;
  40. }
  41. /*
  42. * Find an MCA device matching the specified driver
  43. *
  44. */
  45. int find_mca_device ( struct mca_device *mca, struct mca_driver *driver ) {
  46. unsigned int i;
  47. /* Initialise struct mca if it's the first time it's been used. */
  48. if ( mca->magic != mca_magic ) {
  49. memset ( mca, 0, sizeof ( *mca ) );
  50. mca->magic = mca_magic;
  51. }
  52. /* Iterate through all possible MCA slots, starting where we
  53. * left off
  54. */
  55. for ( ; mca->slot < MCA_MAX_SLOT_NR ; mca->slot++ ) {
  56. /* If we've already used this device, skip it */
  57. if ( mca->already_tried ) {
  58. mca->already_tried = 0;
  59. continue;
  60. }
  61. /* Fill in device parameters */
  62. if ( ! fill_mca_device ( mca ) ) {
  63. continue;
  64. }
  65. /* Compare against driver's ID list */
  66. for ( i = 0 ; i < driver->id_count ; i++ ) {
  67. struct mca_id *id = &driver->ids[i];
  68. if ( MCA_ID ( mca ) == id->id ) {
  69. DBG ( "Device %s (driver %s) matches ID %hx\n",
  70. id->name, driver->name, id->id );
  71. mca->name = id->name;
  72. mca->already_tried = 1;
  73. return 1;
  74. }
  75. }
  76. }
  77. /* No device found */
  78. mca->slot = 0;
  79. return 0;
  80. }
  81. /*
  82. * Find the next MCA device that can be used to boot using the
  83. * specified driver.
  84. *
  85. */
  86. int find_mca_boot_device ( struct dev *dev, struct mca_driver *driver ) {
  87. struct mca_device *mca = ( struct mca_device * )dev->bus;
  88. if ( ! find_mca_device ( mca, driver ) )
  89. return 0;
  90. dev->name = mca->name;
  91. dev->devid.bus_type = MCA_BUS_TYPE;
  92. dev->devid.vendor_id = GENERIC_MCA_VENDOR;
  93. dev->devid.device_id = MCA_ID ( mca );
  94. return 1;
  95. }