iPXE
mca.h
Go to the documentation of this file.
00001 /*
00002  * MCA bus driver code
00003  *
00004  * Abstracted from 3c509.c.
00005  *
00006  */
00007 
00008 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00009 
00010 #ifndef MCA_H
00011 #define MCA_H
00012 
00013 #include <ipxe/isa_ids.h>
00014 #include <ipxe/device.h>
00015 #include <ipxe/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 };
00054 
00055 #define MCA_ID(mca) ( ( (mca)->pos[1] << 8 ) + (mca)->pos[0] )
00056 
00057 /** An MCA driver */
00058 struct mca_driver {
00059         /** MCA ID table */
00060         struct mca_device_id *ids;
00061         /** Number of entries in MCA ID table */
00062         unsigned int id_count;
00063         /**
00064          * Probe device
00065          *
00066          * @v mca       MCA device
00067          * @v id        Matching entry in ID table
00068          * @ret rc      Return status code
00069          */
00070         int ( * probe ) ( struct mca_device *mca,
00071                           const struct mca_device_id *id );
00072         /**
00073          * Remove device
00074          *
00075          * @v mca       MCA device
00076          */
00077         void ( * remove ) ( struct mca_device *mca );
00078 };
00079 
00080 /** MCA driver table */
00081 #define MCA_DRIVERS __table ( struct mca_driver, "mca_drivers" )
00082 
00083 /** Declare an MCA driver */
00084 #define __mca_driver __table_entry ( MCA_DRIVERS, 01 )
00085 
00086 /**
00087  * Set MCA driver-private data
00088  *
00089  * @v mca               MCA device
00090  * @v priv              Private data
00091  */
00092 static inline void mca_set_drvdata ( struct mca_device *mca, void *priv ) {
00093         mca->priv = priv;
00094 }
00095 
00096 /**
00097  * Get MCA driver-private data
00098  *
00099  * @v mca               MCA device
00100  * @ret priv            Private data
00101  */
00102 static inline void * mca_get_drvdata ( struct mca_device *mca ) {
00103         return mca->priv;
00104 }
00105 
00106 #endif