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.

eisa.h 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #ifndef EISA_H
  2. #define EISA_H
  3. FILE_LICENCE ( GPL2_OR_LATER );
  4. #include <stdint.h>
  5. #include <gpxe/isa_ids.h>
  6. #include <gpxe/device.h>
  7. #include <gpxe/tables.h>
  8. /*
  9. * EISA constants
  10. *
  11. */
  12. #define EISA_MIN_SLOT (0x1)
  13. #define EISA_MAX_SLOT (0xf) /* Must be 2^n - 1 */
  14. #define EISA_SLOT_BASE( n ) ( 0x1000 * (n) )
  15. #define EISA_VENDOR_ID ( 0xc80 )
  16. #define EISA_PROD_ID ( 0xc82 )
  17. #define EISA_GLOBAL_CONFIG ( 0xc84 )
  18. #define EISA_CMD_RESET ( 1 << 2 )
  19. #define EISA_CMD_ENABLE ( 1 << 0 )
  20. /** An EISA device ID list entry */
  21. struct eisa_device_id {
  22. /** Name */
  23. const char *name;
  24. /** Manufacturer ID */
  25. uint16_t vendor_id;
  26. /** Product ID */
  27. uint16_t prod_id;
  28. };
  29. /** An EISA device */
  30. struct eisa_device {
  31. /** Generic device */
  32. struct device dev;
  33. /** Slot number */
  34. unsigned int slot;
  35. /** I/O address */
  36. uint16_t ioaddr;
  37. /** Manufacturer ID */
  38. uint16_t vendor_id;
  39. /** Product ID */
  40. uint16_t prod_id;
  41. /** Driver for this device */
  42. struct eisa_driver *driver;
  43. /** Driver-private data
  44. *
  45. * Use eisa_set_drvdata() and eisa_get_drvdata() to access
  46. * this field.
  47. */
  48. void *priv;
  49. /** Driver name */
  50. const char *driver_name;
  51. };
  52. /** An EISA driver */
  53. struct eisa_driver {
  54. /** EISA ID table */
  55. struct eisa_device_id *ids;
  56. /** Number of entries in EISA ID table */
  57. unsigned int id_count;
  58. /**
  59. * Probe device
  60. *
  61. * @v eisa EISA device
  62. * @v id Matching entry in ID table
  63. * @ret rc Return status code
  64. */
  65. int ( * probe ) ( struct eisa_device *eisa,
  66. const struct eisa_device_id *id );
  67. /**
  68. * Remove device
  69. *
  70. * @v eisa EISA device
  71. */
  72. void ( * remove ) ( struct eisa_device *eisa );
  73. };
  74. /** EISA driver table */
  75. #define EISA_DRIVERS __table ( struct eisa_driver, "eisa_drivers" )
  76. /** Declare an EISA driver */
  77. #define __eisa_driver __table_entry ( EISA_DRIVERS, 01 )
  78. extern void eisa_device_enabled ( struct eisa_device *eisa, int enabled );
  79. /**
  80. * Enable EISA device
  81. *
  82. * @v eisa EISA device
  83. */
  84. static inline void enable_eisa_device ( struct eisa_device *eisa ) {
  85. eisa_device_enabled ( eisa, 1 );
  86. }
  87. /**
  88. * Disable EISA device
  89. *
  90. * @v eisa EISA device
  91. */
  92. static inline void disable_eisa_device ( struct eisa_device *eisa ) {
  93. eisa_device_enabled ( eisa, 0 );
  94. }
  95. /**
  96. * Set EISA driver-private data
  97. *
  98. * @v eisa EISA device
  99. * @v priv Private data
  100. */
  101. static inline void eisa_set_drvdata ( struct eisa_device *eisa, void *priv ) {
  102. eisa->priv = priv;
  103. }
  104. /**
  105. * Get EISA driver-private data
  106. *
  107. * @v eisa EISA device
  108. * @ret priv Private data
  109. */
  110. static inline void * eisa_get_drvdata ( struct eisa_device *eisa ) {
  111. return eisa->priv;
  112. }
  113. #endif /* EISA_H */