summaryrefslogtreecommitdiffstats
path: root/debian/grub-extras/disabled/gpxe/src/include/gpxe/mca.h
blob: da9d73e44acbbfe54b67be30a92a35efc94934d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
 * MCA bus driver code
 *
 * Abstracted from 3c509.c.
 *
 */

FILE_LICENCE ( GPL2_OR_LATER );

#ifndef MCA_H
#define MCA_H

#include <gpxe/isa_ids.h>
#include <gpxe/device.h>
#include <gpxe/tables.h>

/*
 * MCA constants
 *
 */
#define MCA_MOTHERBOARD_SETUP_REG	0x94
#define MCA_ADAPTER_SETUP_REG		0x96
#define MCA_MAX_SLOT_NR			0x07	/* Must be 2^n - 1 */
#define MCA_POS_REG(n)			(0x100+(n))

/* Is there a standard that would define this? */
#define GENERIC_MCA_VENDOR ISA_VENDOR ( 'M', 'C', 'A' )

/** An MCA device ID list entry */
struct mca_device_id {
	/** Name */
        const char *name;
	/** Device ID */
	uint16_t id;
};

/** An MCA device */
struct mca_device {
	/** Generic device */
	struct device dev;
	/** Slot number */
	unsigned int slot;
	/** POS register values */
	unsigned char pos[8];
	/** Driver for this device */
	struct mca_driver *driver;
	/** Driver-private data
	 *
	 * Use mca_set_drvdata() and mca_get_drvdata() to access
	 * this field.
	 */
	void *priv;
	/** Driver name */
	const char *driver_name;
};

#define MCA_ID(mca) ( ( (mca)->pos[1] << 8 ) + (mca)->pos[0] )

/** An MCA driver */
struct mca_driver {
	/** MCA ID table */
	struct mca_device_id *ids;
	/** Number of entries in MCA ID table */
	unsigned int id_count;
	/**
	 * Probe device
	 *
	 * @v mca	MCA device
	 * @v id	Matching entry in ID table
	 * @ret rc	Return status code
	 */
	int ( * probe ) ( struct mca_device *mca,
			  const struct mca_device_id *id );
	/**
	 * Remove device
	 *
	 * @v mca	MCA device
	 */
	void ( * remove ) ( struct mca_device *mca );
};

/** MCA driver table */
#define MCA_DRIVERS __table ( struct mca_driver, "mca_drivers" )

/** Declare an MCA driver */
#define __mca_driver __table_entry ( MCA_DRIVERS, 01 )

/**
 * Set MCA driver-private data
 *
 * @v mca		MCA device
 * @v priv		Private data
 */
static inline void mca_set_drvdata ( struct mca_device *mca, void *priv ) {
	mca->priv = priv;
}

/**
 * Get MCA driver-private data
 *
 * @v mca		MCA device
 * @ret priv		Private data
 */
static inline void * mca_get_drvdata ( struct mca_device *mca ) {
	return mca->priv;
}

#endif