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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * MCA bus driver code
  3. *
  4. * Abstracted from 3c509.c.
  5. *
  6. */
  7. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  8. #ifndef MCA_H
  9. #define MCA_H
  10. #include <ipxe/isa_ids.h>
  11. #include <ipxe/device.h>
  12. #include <ipxe/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. };
  47. #define MCA_ID(mca) ( ( (mca)->pos[1] << 8 ) + (mca)->pos[0] )
  48. /** An MCA driver */
  49. struct mca_driver {
  50. /** MCA ID table */
  51. struct mca_device_id *ids;
  52. /** Number of entries in MCA ID table */
  53. unsigned int id_count;
  54. /**
  55. * Probe device
  56. *
  57. * @v mca MCA device
  58. * @v id Matching entry in ID table
  59. * @ret rc Return status code
  60. */
  61. int ( * probe ) ( struct mca_device *mca,
  62. const struct mca_device_id *id );
  63. /**
  64. * Remove device
  65. *
  66. * @v mca MCA device
  67. */
  68. void ( * remove ) ( struct mca_device *mca );
  69. };
  70. /** MCA driver table */
  71. #define MCA_DRIVERS __table ( struct mca_driver, "mca_drivers" )
  72. /** Declare an MCA driver */
  73. #define __mca_driver __table_entry ( MCA_DRIVERS, 01 )
  74. /**
  75. * Set MCA driver-private data
  76. *
  77. * @v mca MCA device
  78. * @v priv Private data
  79. */
  80. static inline void mca_set_drvdata ( struct mca_device *mca, void *priv ) {
  81. mca->priv = priv;
  82. }
  83. /**
  84. * Get MCA driver-private data
  85. *
  86. * @v mca MCA device
  87. * @ret priv Private data
  88. */
  89. static inline void * mca_get_drvdata ( struct mca_device *mca ) {
  90. return mca->priv;
  91. }
  92. #endif