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