gpxe import
[grub-extras.git] / gpxe / src / include / gpxe / mca.h
blobda9d73e44acbbfe54b67be30a92a35efc94934d4
1 /*
2 * MCA bus driver code
4 * Abstracted from 3c509.c.
6 */
8 FILE_LICENCE ( GPL2_OR_LATER );
10 #ifndef MCA_H
11 #define MCA_H
13 #include <gpxe/isa_ids.h>
14 #include <gpxe/device.h>
15 #include <gpxe/tables.h>
18 * MCA constants
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))
26 /* Is there a standard that would define this? */
27 #define GENERIC_MCA_VENDOR ISA_VENDOR ( 'M', 'C', 'A' )
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;
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
49 * Use mca_set_drvdata() and mca_get_drvdata() to access
50 * this field.
52 void *priv;
53 /** Driver name */
54 const char *driver_name;
57 #define MCA_ID(mca) ( ( (mca)->pos[1] << 8 ) + (mca)->pos[0] )
59 /** An MCA driver */
60 struct mca_driver {
61 /** MCA ID table */
62 struct mca_device_id *ids;
63 /** Number of entries in MCA ID table */
64 unsigned int id_count;
65 /**
66 * Probe device
68 * @v mca MCA device
69 * @v id Matching entry in ID table
70 * @ret rc Return status code
72 int ( * probe ) ( struct mca_device *mca,
73 const struct mca_device_id *id );
74 /**
75 * Remove device
77 * @v mca MCA device
79 void ( * remove ) ( struct mca_device *mca );
82 /** MCA driver table */
83 #define MCA_DRIVERS __table ( struct mca_driver, "mca_drivers" )
85 /** Declare an MCA driver */
86 #define __mca_driver __table_entry ( MCA_DRIVERS, 01 )
88 /**
89 * Set MCA driver-private data
91 * @v mca MCA device
92 * @v priv Private data
94 static inline void mca_set_drvdata ( struct mca_device *mca, void *priv ) {
95 mca->priv = priv;
98 /**
99 * Get MCA driver-private data
101 * @v mca MCA device
102 * @ret priv Private data
104 static inline void * mca_get_drvdata ( struct mca_device *mca ) {
105 return mca->priv;
108 #endif