00001 /* 00002 * MCA bus driver code 00003 * 00004 * Abstracted from 3c509.c. 00005 * 00006 */ 00007 00008 FILE_LICENCE ( GPL2_OR_LATER ); 00009 00010 #ifndef MCA_H 00011 #define MCA_H 00012 00013 #include <gpxe/isa_ids.h> 00014 #include <gpxe/device.h> 00015 #include <gpxe/tables.h> 00016 00017 /* 00018 * MCA constants 00019 * 00020 */ 00021 #define MCA_MOTHERBOARD_SETUP_REG 0x94 00022 #define MCA_ADAPTER_SETUP_REG 0x96 00023 #define MCA_MAX_SLOT_NR 0x07 /* Must be 2^n - 1 */ 00024 #define MCA_POS_REG(n) (0x100+(n)) 00025 00026 /* Is there a standard that would define this? */ 00027 #define GENERIC_MCA_VENDOR ISA_VENDOR ( 'M', 'C', 'A' ) 00028 00029 /** An MCA device ID list entry */ 00030 struct mca_device_id { 00031 /** Name */ 00032 const char *name; 00033 /** Device ID */ 00034 uint16_t id; 00035 }; 00036 00037 /** An MCA device */ 00038 struct mca_device { 00039 /** Generic device */ 00040 struct device dev; 00041 /** Slot number */ 00042 unsigned int slot; 00043 /** POS register values */ 00044 unsigned char pos[8]; 00045 /** Driver for this device */ 00046 struct mca_driver *driver; 00047 /** Driver-private data 00048 * 00049 * Use mca_set_drvdata() and mca_get_drvdata() to access 00050 * this field. 00051 */ 00052 void *priv; 00053 /** Driver name */ 00054 const char *driver_name; 00055 }; 00056 00057 #define MCA_ID(mca) ( ( (mca)->pos[1] << 8 ) + (mca)->pos[0] ) 00058 00059 /** An MCA driver */ 00060 struct mca_driver { 00061 /** MCA ID table */ 00062 struct mca_device_id *ids; 00063 /** Number of entries in MCA ID table */ 00064 unsigned int id_count; 00065 /** 00066 * Probe device 00067 * 00068 * @v mca MCA device 00069 * @v id Matching entry in ID table 00070 * @ret rc Return status code 00071 */ 00072 int ( * probe ) ( struct mca_device *mca, 00073 const struct mca_device_id *id ); 00074 /** 00075 * Remove device 00076 * 00077 * @v mca MCA device 00078 */ 00079 void ( * remove ) ( struct mca_device *mca ); 00080 }; 00081 00082 /** MCA driver table */ 00083 #define MCA_DRIVERS __table ( struct mca_driver, "mca_drivers" ) 00084 00085 /** Declare an MCA driver */ 00086 #define __mca_driver __table_entry ( MCA_DRIVERS, 01 ) 00087 00088 /** 00089 * Set MCA driver-private data 00090 * 00091 * @v mca MCA device 00092 * @v priv Private data 00093 */ 00094 static inline void mca_set_drvdata ( struct mca_device *mca, void *priv ) { 00095 mca->priv = priv; 00096 } 00097 00098 /** 00099 * Get MCA driver-private data 00100 * 00101 * @v mca MCA device 00102 * @ret priv Private data 00103 */ 00104 static inline void * mca_get_drvdata ( struct mca_device *mca ) { 00105 return mca->priv; 00106 } 00107 00108 #endif
1.5.7.1