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.h 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * MCA bus driver code
  3. *
  4. * Abstracted from 3c509.c.
  5. *
  6. */
  7. #ifndef MCA_H
  8. #define MCA_H
  9. #include <gpxe/isa_ids.h>
  10. #include <gpxe/device.h>
  11. #include <gpxe/tables.h>
  12. /*
  13. * MCA constants
  14. *
  15. */
  16. #define MCA_MOTHERBOARD_SETUP_REG 0x94
  17. #define MCA_ADAPTER_SETUP_REG 0x96
  18. #define MCA_MAX_SLOT_NR 0x07 /* Must be 2^n - 1 */
  19. #define MCA_POS_REG(n) (0x100+(n))
  20. /* Is there a standard that would define this? */
  21. #define GENERIC_MCA_VENDOR ISA_VENDOR ( 'M', 'C', 'A' )
  22. /** An MCA device ID list entry */
  23. struct mca_device_id {
  24. /** Name */
  25. const char *name;
  26. /** Device ID */
  27. uint16_t id;
  28. };
  29. /** An MCA device */
  30. struct mca_device {
  31. /** Generic device */
  32. struct device dev;
  33. /** Slot number */
  34. unsigned int slot;
  35. /** POS register values */
  36. unsigned char pos[8];
  37. /** Driver for this device */
  38. struct mca_driver *driver;
  39. /** Driver-private data
  40. *
  41. * Use mca_set_drvdata() and mca_get_drvdata() to access
  42. * this field.
  43. */
  44. void *priv;
  45. /** Driver name */
  46. const char *driver_name;
  47. };
  48. #define MCA_ID(mca) ( ( (mca)->pos[1] << 8 ) + (mca)->pos[0] )
  49. /** An MCA driver */
  50. struct mca_driver {
  51. /** MCA ID table */
  52. struct mca_device_id *ids;
  53. /** Number of entries in MCA ID table */
  54. unsigned int id_count;
  55. /**
  56. * Probe device
  57. *
  58. * @v mca MCA device
  59. * @v id Matching entry in ID table
  60. * @ret rc Return status code
  61. */
  62. int ( * probe ) ( struct mca_device *mca,
  63. const struct mca_device_id *id );
  64. /**
  65. * Remove device
  66. *
  67. * @v mca MCA device
  68. */
  69. void ( * remove ) ( struct mca_device *mca );
  70. };
  71. /** Declare an MCA driver */
  72. #define __mca_driver __table ( struct mca_driver, mca_drivers, 01 )
  73. /**
  74. * Set MCA driver-private data
  75. *
  76. * @v mca MCA device
  77. * @v priv Private data
  78. */
  79. static inline void mca_set_drvdata ( struct mca_device *mca, void *priv ) {
  80. mca->priv = priv;
  81. }
  82. /**
  83. * Get MCA driver-private data
  84. *
  85. * @v mca MCA device
  86. * @ret priv Private data
  87. */
  88. static inline void * mca_get_drvdata ( struct mca_device *mca ) {
  89. return mca->priv;
  90. }
  91. #endif