iPXE
eisa.h
Go to the documentation of this file.
00001 #ifndef EISA_H
00002 #define EISA_H
00003 
00004 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00005 
00006 #include <stdint.h>
00007 #include <ipxe/isa_ids.h>
00008 #include <ipxe/device.h>
00009 #include <ipxe/tables.h>
00010 
00011 /*
00012  * EISA constants
00013  *
00014  */
00015 
00016 #define EISA_MIN_SLOT (0x1)
00017 #define EISA_MAX_SLOT (0xf)     /* Must be 2^n - 1 */
00018 #define EISA_SLOT_BASE( n ) ( 0x1000 * (n) )
00019 
00020 #define EISA_VENDOR_ID ( 0xc80 )
00021 #define EISA_PROD_ID ( 0xc82 )
00022 #define EISA_GLOBAL_CONFIG ( 0xc84 )
00023 
00024 #define EISA_CMD_RESET ( 1 << 2 )
00025 #define EISA_CMD_ENABLE ( 1 << 0 )
00026 
00027 /** An EISA device ID list entry */
00028 struct eisa_device_id {
00029         /** Name */
00030         const char *name;
00031         /** Manufacturer ID */
00032         uint16_t vendor_id;
00033         /** Product ID */
00034         uint16_t prod_id;
00035 };
00036 
00037 /** An EISA device */
00038 struct eisa_device {
00039         /** Generic device */
00040         struct device dev;
00041         /** Slot number */
00042         unsigned int slot;
00043         /** I/O address */
00044         uint16_t ioaddr;
00045         /** Manufacturer ID */
00046         uint16_t vendor_id;
00047         /** Product ID */
00048         uint16_t prod_id;
00049         /** Driver for this device */
00050         struct eisa_driver *driver;
00051         /** Driver-private data
00052          *
00053          * Use eisa_set_drvdata() and eisa_get_drvdata() to access
00054          * this field.
00055          */
00056         void *priv;
00057 };
00058 
00059 /** An EISA driver */
00060 struct eisa_driver {
00061         /** EISA ID table */
00062         struct eisa_device_id *ids;
00063         /** Number of entries in EISA ID table */
00064         unsigned int id_count;
00065         /**
00066          * Probe device
00067          *
00068          * @v eisa      EISA device
00069          * @v id        Matching entry in ID table
00070          * @ret rc      Return status code
00071          */
00072         int ( * probe ) ( struct eisa_device *eisa,
00073                           const struct eisa_device_id *id );
00074         /**
00075          * Remove device
00076          *
00077          * @v eisa      EISA device
00078          */
00079         void ( * remove ) ( struct eisa_device *eisa );
00080 };
00081 
00082 /** EISA driver table */
00083 #define EISA_DRIVERS __table ( struct eisa_driver, "eisa_drivers" )
00084 
00085 /** Declare an EISA driver */
00086 #define __eisa_driver __table_entry ( EISA_DRIVERS, 01 )
00087 
00088 extern void eisa_device_enabled ( struct eisa_device *eisa, int enabled );
00089 
00090 /**
00091  * Enable EISA device
00092  *
00093  * @v eisa              EISA device
00094  */
00095 static inline void enable_eisa_device ( struct eisa_device *eisa ) {
00096         eisa_device_enabled ( eisa, 1 );
00097 }
00098 
00099 /**
00100  * Disable EISA device
00101  *
00102  * @v eisa              EISA device
00103  */
00104 static inline void disable_eisa_device ( struct eisa_device *eisa ) {
00105         eisa_device_enabled ( eisa, 0 );
00106 }
00107 
00108 /**
00109  * Set EISA driver-private data
00110  *
00111  * @v eisa              EISA device
00112  * @v priv              Private data
00113  */
00114 static inline void eisa_set_drvdata ( struct eisa_device *eisa, void *priv ) {
00115         eisa->priv = priv;
00116 }
00117 
00118 /**
00119  * Get EISA driver-private data
00120  *
00121  * @v eisa              EISA device
00122  * @ret priv            Private data
00123  */
00124 static inline void * eisa_get_drvdata ( struct eisa_device *eisa ) {
00125         return eisa->priv;
00126 }
00127 
00128 #endif /* EISA_H */