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