iPXE
device.h
Go to the documentation of this file.
1#ifndef _IPXE_DEVICE_H
2#define _IPXE_DEVICE_H
3
4/**
5 * @file
6 *
7 * Device model
8 *
9 */
10
11FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
12FILE_SECBOOT ( PERMITTED );
13
14#include <ipxe/list.h>
15#include <ipxe/tables.h>
16
17struct interface;
18
19/** A hardware device description */
21 /** Bus type
22 *
23 * This must be a BUS_TYPE_XXX constant.
24 */
25 unsigned int bus_type;
26 /** Location
27 *
28 * The interpretation of this field is bus-type-specific.
29 */
30 unsigned int location;
31 /** Vendor ID */
32 unsigned int vendor;
33 /** Device ID */
34 unsigned int device;
35 /** Device class */
36 unsigned long class;
37 /** I/O address */
38 unsigned long ioaddr;
39 /** IRQ */
40 unsigned int irq;
41};
42
43/** PCI bus type */
44#define BUS_TYPE_PCI 1
45
46/** ISAPnP bus type */
47#define BUS_TYPE_ISAPNP 2
48
49/** EISA bus type */
50#define BUS_TYPE_EISA 3
51
52/** MCA bus type */
53#define BUS_TYPE_MCA 4
54
55/** ISA bus type */
56#define BUS_TYPE_ISA 5
57
58/** TAP bus type */
59#define BUS_TYPE_TAP 6
60
61/** EFI bus type */
62#define BUS_TYPE_EFI 7
63
64/** Xen bus type */
65#define BUS_TYPE_XEN 8
66
67/** Hyper-V bus type */
68#define BUS_TYPE_HV 9
69
70/** USB bus type */
71#define BUS_TYPE_USB 10
72
73/** Devicetree bus type */
74#define BUS_TYPE_DT 11
75
76/** A hardware device */
77struct device {
78 /** Name */
79 char name[40];
80 /** Driver name */
81 const char *driver_name;
82 /** Device description */
84 /** Devices on the same bus */
86 /** Devices attached to this device */
88 /** Bus device */
89 struct device *parent;
90};
91
92/**
93 * A root device
94 *
95 * Root devices are system buses such as PCI, EISA, etc.
96 *
97 */
99 /** Device chain
100 *
101 * A root device has a NULL parent field.
102 */
103 struct device dev;
104 /** Root device driver */
106 /** Driver-private data */
107 void *priv;
108};
109
110/** A root device driver */
112 /**
113 * Add root device
114 *
115 * @v rootdev Root device
116 * @ret rc Return status code
117 *
118 * Called from probe_devices() for all root devices in the build.
119 */
120 int ( * probe ) ( struct root_device *rootdev );
121 /**
122 * Remove root device
123 *
124 * @v rootdev Root device
125 *
126 * Called from remove_device() for all successfully-probed
127 * root devices.
128 */
129 void ( * remove ) ( struct root_device *rootdev );
130};
131
132/** Root device table */
133#define ROOT_DEVICES __table ( struct root_device, "root_devices" )
134
135/** Declare a root device */
136#define __root_device __table_entry ( ROOT_DEVICES, 01 )
137
138/**
139 * Set root device driver-private data
140 *
141 * @v rootdev Root device
142 * @v priv Private data
143 */
144static inline void rootdev_set_drvdata ( struct root_device *rootdev,
145 void *priv ){
146 rootdev->priv = priv;
147}
148
149/**
150 * Get root device driver-private data
151 *
152 * @v rootdev Root device
153 * @ret priv Private data
154 */
155static inline void * rootdev_get_drvdata ( struct root_device *rootdev ) {
156 return rootdev->priv;
157}
158
159extern int device_keep_count;
160
161/**
162 * Prevent devices from being removed on shutdown
163 *
164 */
165static inline void devices_get ( void ) {
167}
168
169/**
170 * Allow devices to be removed on shutdown
171 *
172 */
173static inline void devices_put ( void ) {
175}
176
177extern struct device * identify_device ( struct interface *intf );
178#define identify_device_TYPE( object_type ) \
179 typeof ( struct device * ( object_type ) )
180
181#endif /* _IPXE_DEVICE_H */
int device_keep_count
Device removal inhibition counter.
Definition device.c:45
static void devices_get(void)
Prevent devices from being removed on shutdown.
Definition device.h:165
static void * rootdev_get_drvdata(struct root_device *rootdev)
Get root device driver-private data.
Definition device.h:155
static void rootdev_set_drvdata(struct root_device *rootdev, void *priv)
Set root device driver-private data.
Definition device.h:144
struct device * identify_device(struct interface *intf)
Identify a device behind an interface.
Definition device.c:126
static void devices_put(void)
Allow devices to be removed on shutdown.
Definition device.h:173
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
Linked lists.
A hardware device description.
Definition device.h:20
unsigned int bus_type
Bus type.
Definition device.h:25
unsigned int device
Device ID.
Definition device.h:34
unsigned int vendor
Vendor ID.
Definition device.h:32
unsigned int location
Location.
Definition device.h:30
unsigned int irq
IRQ.
Definition device.h:40
unsigned long ioaddr
I/O address.
Definition device.h:38
A hardware device.
Definition device.h:77
struct device_description desc
Device description.
Definition device.h:83
struct device * parent
Bus device.
Definition device.h:89
struct list_head children
Devices attached to this device.
Definition device.h:87
struct list_head siblings
Devices on the same bus.
Definition device.h:85
const char * driver_name
Driver name.
Definition device.h:81
char name[40]
Name.
Definition device.h:79
An object interface.
Definition interface.h:125
A doubly-linked list entry (or list head)
Definition list.h:19
A root device.
Definition device.h:98
void * priv
Driver-private data.
Definition device.h:107
struct root_driver * driver
Root device driver.
Definition device.h:105
struct device dev
Device chain.
Definition device.h:103
A root device driver.
Definition device.h:111
int(* probe)(struct root_device *rootdev)
Add root device.
Definition device.h:120
void(* remove)(struct root_device *rootdev)
Remove root device.
Definition device.h:129
Linker tables.
static struct tlan_private * priv
Definition tlan.c:225