Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / include / ipxe / edd.h
1 #ifndef _IPXE_EDD_H
2 #define _IPXE_EDD_H
3
4 /** @file
5  *
6  * Enhanced Disk Drive specification
7  *
8  */
9
10 FILE_LICENCE ( GPL2_OR_LATER );
11
12 #include <stdint.h>
13 #include <ipxe/interface.h>
14
15 /** An EDD host bus type */
16 struct edd_host_bus_type {
17         /** Type */
18         uint32_t type;
19 } __attribute__ (( packed ));
20
21 /** EDD bus type */
22 #define EDD_BUS_TYPE_FIXED( a, b, c, d, ... )                               \
23         ( ( (a) << 0 ) | ( (b) << 8 ) | ( (c) << 16 ) | ( (d) << 24 ) )
24 #define EDD_BUS_TYPE( ... )                                                 \
25         EDD_BUS_TYPE_FIXED ( __VA_ARGS__, ' ', ' ', ' ', ' ' )
26 /** EDD PCI bus type */
27 #define EDD_BUS_TYPE_PCI EDD_BUS_TYPE ( 'P', 'C', 'I' )
28 /** EDD ISA bus type */
29 #define EDD_BUS_TYPE_ISA EDD_BUS_TYPE ( 'I', 'S', 'A' )
30 /** EDD PCI-X bus type */
31 #define EDD_BUS_TYPE_PCIX EDD_BUS_TYPE ( 'P', 'C', 'I', 'X' )
32 /** EDD Infiniband bus type */
33 #define EDD_BUS_TYPE_IBND EDD_BUS_TYPE ( 'I', 'B', 'N', 'D' )
34 /** EDD PCI Express bus type */
35 #define EDD_BUS_TYPE_XPRS EDD_BUS_TYPE ( 'X', 'P', 'R', 'S' )
36 /** EDD HyperTransport bus type */
37 #define EDD_BUS_TYPE_HTPT EDD_BUS_TYPE ( 'H', 'T', 'P', 'T' )
38
39 /** An EDD interface type */
40 struct edd_interface_type {
41         /** Type */
42         uint64_t type;
43 } __attribute__ (( packed ));
44
45 /** EDD interface type */
46 #define EDD_INTF_TYPE_FIXED( a, b, c, d, e, f, g, h, ... )                  \
47         ( ( ( ( uint64_t ) (a) ) <<  0 ) | ( ( ( uint64_t ) (b) ) <<  8 ) | \
48           ( ( ( uint64_t ) (c) ) << 16 ) | ( ( ( uint64_t ) (d) ) << 24 ) | \
49           ( ( ( uint64_t ) (e) ) << 32 ) | ( ( ( uint64_t ) (f) ) << 40 ) | \
50           ( ( ( uint64_t ) (g) ) << 48 ) | ( ( ( uint64_t ) (h) ) << 56 ) )
51 #define EDD_INTF_TYPE( ... )                                                \
52         EDD_INTF_TYPE_FIXED ( __VA_ARGS__,                                  \
53                               ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' )
54 /** EDD ATA interface type */
55 #define EDD_INTF_TYPE_ATA EDD_INTF_TYPE ( 'A', 'T', 'A' )
56 /** EDD ATAPI interface type */
57 #define EDD_INTF_TYPE_ATAPI EDD_INTF_TYPE ( 'A', 'T', 'A', 'P', 'I' )
58 /** EDD SCSI interface type */
59 #define EDD_INTF_TYPE_SCSI EDD_INTF_TYPE ( 'S', 'C', 'S', 'I' )
60 /** EDD USB interface type */
61 #define EDD_INTF_TYPE_USB EDD_INTF_TYPE ( 'U', 'S', 'B' )
62 /** EDD 1394 interface type */
63 #define EDD_INTF_TYPE_1394 EDD_INTF_TYPE ( '1', '3', '9', '4' )
64 /** EDD Fibre Channel interface type */
65 #define EDD_INTF_TYPE_FIBRE EDD_INTF_TYPE ( 'F', 'I', 'B', 'R', 'E' )
66 /** EDD I2O interface type */
67 #define EDD_INTF_TYPE_I2O EDD_INTF_TYPE ( 'I', '2', 'O' )
68 /** EDD RAID interface type */
69 #define EDD_INTF_TYPE_RAID EDD_INTF_TYPE ( 'R', 'A', 'I', 'D' )
70 /** EDD SATA interface type */
71 #define EDD_INTF_TYPE_SATA EDD_INTF_TYPE ( 'S', 'A', 'T', 'A' )
72 /** EDD SAS interface type */
73 #define EDD_INTF_TYPE_SAS EDD_INTF_TYPE ( 'S', 'A', 'S' )
74
75 /** An EDD interface path */
76 union edd_interface_path {
77         /** Legacy bus type */
78         struct {
79                 /** Base address */
80                 uint16_t base;
81         } __attribute__ (( packed )) legacy;
82         /** PCI, PCI-X, PCI Express, or HyperTransport bus type */
83         struct {
84                 /** Bus */
85                 uint8_t bus;
86                 /** Slot */
87                 uint8_t slot;
88                 /** Function */
89                 uint8_t function;
90                 /** Channel number */
91                 uint8_t channel;
92         } __attribute__ (( packed )) pci;
93         /** Padding */
94         uint8_t pad[8];
95 } __attribute__ (( packed ));
96
97 /** An EDD device path */
98 union edd_device_path {
99         /** ATA interface type */
100         struct {
101                 /** Slave */
102                 uint8_t slave;
103         } __attribute__ (( packed )) ata;
104         /** ATAPI interface type */
105         struct {
106                 /** Slave */
107                 uint8_t slave;
108                 /** Logical Unit Number */
109                 uint8_t lun;
110         } __attribute__ (( packed )) atapi;
111         /** SCSI interface type */
112         struct {
113                 /** SCSI ID */
114                 uint16_t id;
115                 /** Logical Unit Number */
116                 uint64_t lun;
117         } __attribute__ (( packed )) scsi;
118         /** USB interface type */
119         struct {
120                 /** Serial number */
121                 uint64_t serial;
122         } __attribute__ (( packed )) usb;
123         /** IEEE1394 interface type */
124         struct {
125                 /** GUID */
126                 uint64_t guid;
127         } __attribute__ (( packed )) ieee1394;
128         /** Fibre Channel interface type */
129         struct {
130                 /** WWN */
131                 uint64_t wwn;
132                 /** Logical Unit Number */
133                 uint64_t lun;
134         } __attribute__ (( packed )) fibre;
135         /** I2O interface type */
136         struct {
137                 /** Identity tag */
138                 uint64_t tag;
139         } __attribute__ (( packed )) i2o;
140         /** RAID interface type */
141         struct {
142                 /** Array number */
143                 uint32_t array;
144         } __attribute__ (( packed )) raid;
145         /** SATA interface type */
146         struct {
147                 /** Port number */
148                 uint8_t port;
149                 /** Port multiplier number */
150                 uint8_t multiplier;
151         } __attribute__ (( packed )) sata;
152         /** SAS interface type */
153         struct {
154                 /** Address */
155                 uint64_t address;
156         } __attribute__ (( packed )) sas;
157         /** Padding */
158         uint8_t pad[16];
159 } __attribute__ (( packed ));
160
161 /** EDD device path information */
162 struct edd_device_path_information {
163         /** Key */
164         uint16_t key;
165         /** Length of this structure */
166         uint8_t len;
167         /** Reserved */
168         uint8_t reserved_a[3];
169         /** Host bus type */
170         struct edd_host_bus_type host_bus_type;
171         /** Interface type */
172         struct edd_interface_type interface_type;
173         /** Interface path */
174         union edd_interface_path interface_path;
175         /** Device path */
176         union edd_device_path device_path;
177         /** Reserved */
178         uint8_t reserved_b;
179         /** Checksum */
180         uint8_t checksum;
181 } __attribute__ (( packed ));
182
183 /** EDD device path information key */
184 #define EDD_DEVICE_PATH_INFO_KEY 0xbedd
185
186 extern int edd_describe ( struct interface *intf,
187                           struct edd_interface_type *type,
188                           union edd_device_path *path );
189 #define edd_describe_TYPE( object_type )                                \
190         typeof ( int ( object_type, struct edd_interface_type *type,    \
191                        union edd_device_path *path ) )
192
193 #endif /* _IPXE_EDD_H */