aboutsummaryrefslogtreecommitdiffstats
path: root/gpxe/src/include/gpxe/eisa.h
blob: f76e4b9d05419817740fa912b8ecb90ebfe43b61 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#ifndef EISA_H
#define EISA_H

FILE_LICENCE ( GPL2_OR_LATER );

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

/*
 * EISA constants
 *
 */

#define EISA_MIN_SLOT (0x1)
#define EISA_MAX_SLOT (0xf)	/* Must be 2^n - 1 */
#define EISA_SLOT_BASE( n ) ( 0x1000 * (n) )

#define EISA_VENDOR_ID ( 0xc80 )
#define EISA_PROD_ID ( 0xc82 )
#define EISA_GLOBAL_CONFIG ( 0xc84 )

#define EISA_CMD_RESET ( 1 << 2 )
#define EISA_CMD_ENABLE ( 1 << 0 )

/** An EISA device ID list entry */
struct eisa_device_id {
	/** Name */
        const char *name;
	/** Manufacturer ID */
	uint16_t vendor_id;
	/** Product ID */
	uint16_t prod_id;
};

/** An EISA device */
struct eisa_device {
	/** Generic device */
	struct device dev;
	/** Slot number */
	unsigned int slot;
	/** I/O address */
	uint16_t ioaddr;
	/** Manufacturer ID */
	uint16_t vendor_id;
	/** Product ID */
	uint16_t prod_id;
	/** Driver for this device */
	struct eisa_driver *driver;
	/** Driver-private data
	 *
	 * Use eisa_set_drvdata() and eisa_get_drvdata() to access
	 * this field.
	 */
	void *priv;
	/** Driver name */
	const char *driver_name;
};

/** An EISA driver */
struct eisa_driver {
	/** EISA ID table */
	struct eisa_device_id *ids;
	/** Number of entries in EISA ID table */
	unsigned int id_count;
	/**
	 * Probe device
	 *
	 * @v eisa	EISA device
	 * @v id	Matching entry in ID table
	 * @ret rc	Return status code
	 */
	int ( * probe ) ( struct eisa_device *eisa,
			  const struct eisa_device_id *id );
	/**
	 * Remove device
	 *
	 * @v eisa	EISA device
	 */
	void ( * remove ) ( struct eisa_device *eisa );
};

/** EISA driver table */
#define EISA_DRIVERS __table ( struct eisa_driver, "eisa_drivers" )

/** Declare an EISA driver */
#define __eisa_driver __table_entry ( EISA_DRIVERS, 01 )

extern void eisa_device_enabled ( struct eisa_device *eisa, int enabled );

/**
 * Enable EISA device
 *
 * @v eisa		EISA device
 */
static inline void enable_eisa_device ( struct eisa_device *eisa ) {
	eisa_device_enabled ( eisa, 1 );
}

/**
 * Disable EISA device
 *
 * @v eisa		EISA device
 */
static inline void disable_eisa_device ( struct eisa_device *eisa ) {
	eisa_device_enabled ( eisa, 0 );
}

/**
 * Set EISA driver-private data
 *
 * @v eisa		EISA device
 * @v priv		Private data
 */
static inline void eisa_set_drvdata ( struct eisa_device *eisa, void *priv ) {
	eisa->priv = priv;
}

/**
 * Get EISA driver-private data
 *
 * @v eisa		EISA device
 * @ret priv		Private data
 */
static inline void * eisa_get_drvdata ( struct eisa_device *eisa ) {
	return eisa->priv;
}

#endif /* EISA_H */