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.1KB

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