initial commit
[freebsd-arm:freebsd-arm.git] / boot / efi / include / efidevp.h
1 /* $FreeBSD$ */
2 #ifndef _DEVPATH_H
3 #define _DEVPATH_H
4
5 /*++
6
7 Copyright (c)  1999 - 2002 Intel Corporation. All rights reserved
8 This software and associated documentation (if any) is furnished
9 under a license and may only be used or copied in accordance
10 with the terms of the license. Except as permitted by such
11 license, no part of this software or documentation may be
12 reproduced, stored in a retrieval system, or transmitted in any
13 form or by any means without the express written consent of
14 Intel Corporation.
15
16 Module Name:
17
18     devpath.h
19
20 Abstract:
21
22     Defines for parsing the EFI Device Path structures
23
24
25
26 Revision History
27
28 --*/
29
30 //
31 // Device Path structures - Section C
32 //
33
34 typedef struct _EFI_DEVICE_PATH {
35         UINT8                           Type;
36         UINT8                           SubType;
37         UINT8                           Length[2];
38 } EFI_DEVICE_PATH;
39
40 #define EFI_DP_TYPE_MASK                    0x7F
41 #define EFI_DP_TYPE_UNPACKED                0x80
42
43 //#define END_DEVICE_PATH_TYPE                0xff
44 #define END_DEVICE_PATH_TYPE                0x7f
45 //#define END_DEVICE_PATH_TYPE_UNPACKED       0x7f
46
47 #define END_ENTIRE_DEVICE_PATH_SUBTYPE      0xff
48 #define END_INSTANCE_DEVICE_PATH_SUBTYPE    0x01
49 #define END_DEVICE_PATH_LENGTH              (sizeof(EFI_DEVICE_PATH))
50
51
52 #define DP_IS_END_TYPE(a)
53 #define DP_IS_END_SUBTYPE(a)        ( ((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE )
54
55 #define DevicePathType(a)           ( ((a)->Type) & EFI_DP_TYPE_MASK )
56 #define DevicePathSubType(a)        ( (a)->SubType )
57 #define DevicePathNodeLength(a)     ( ((a)->Length[0]) | ((a)->Length[1] << 8) )
58 #define NextDevicePathNode(a)       ( (EFI_DEVICE_PATH *) ( ((UINT8 *) (a)) + DevicePathNodeLength(a)))
59 //#define IsDevicePathEndType(a)      ( DevicePathType(a) == END_DEVICE_PATH_TYPE_UNPACKED )
60 #define IsDevicePathEndType(a)      ( DevicePathType(a) == END_DEVICE_PATH_TYPE )
61 #define IsDevicePathEndSubType(a)   ( (a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE )
62 #define IsDevicePathEnd(a)          ( IsDevicePathEndType(a) && IsDevicePathEndSubType(a) )
63 #define IsDevicePathUnpacked(a)     ( (a)->Type & EFI_DP_TYPE_UNPACKED )
64
65
66 #define SetDevicePathNodeLength(a,l) {                  \
67             (a)->Length[0] = (UINT8) (l);               \
68             (a)->Length[1] = (UINT8) ((l) >> 8);        \
69             }
70
71 #define SetDevicePathEndNode(a)  {                      \
72             (a)->Type = END_DEVICE_PATH_TYPE;           \
73             (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;     \
74             (a)->Length[0] = sizeof(EFI_DEVICE_PATH);   \
75             (a)->Length[1] = 0;                         \
76             }
77
78
79
80 /*
81  *
82  */
83 #define HARDWARE_DEVICE_PATH            0x01
84
85 #define HW_PCI_DP                       0x01
86 typedef struct _PCI_DEVICE_PATH {
87         EFI_DEVICE_PATH                 Header;
88         UINT8                           Function;
89         UINT8                           Device;
90 } PCI_DEVICE_PATH;
91
92 #define HW_PCCARD_DP                    0x02
93 typedef struct _PCCARD_DEVICE_PATH {
94         EFI_DEVICE_PATH                 Header;
95         UINT8                           FunctionNumber;
96 } PCCARD_DEVICE_PATH;
97
98 #define HW_MEMMAP_DP                    0x03
99 typedef struct _MEMMAP_DEVICE_PATH {
100         EFI_DEVICE_PATH                 Header;
101         UINT32                          MemoryType;
102         EFI_PHYSICAL_ADDRESS            StartingAddress;
103         EFI_PHYSICAL_ADDRESS            EndingAddress;
104 } MEMMAP_DEVICE_PATH;
105
106 #define HW_VENDOR_DP                    0x04
107 typedef struct _VENDOR_DEVICE_PATH {
108         EFI_DEVICE_PATH                 Header;
109         EFI_GUID                        Guid;
110 } VENDOR_DEVICE_PATH;
111
112 #define UNKNOWN_DEVICE_GUID \
113     { 0xcf31fac5, 0xc24e, 0x11d2,  0x85, 0xf3, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b  }
114
115 typedef struct _UKNOWN_DEVICE_VENDOR_DP {
116     VENDOR_DEVICE_PATH      DevicePath;
117     UINT8                   LegacyDriveLetter;
118 } UNKNOWN_DEVICE_VENDOR_DEVICE_PATH;
119
120 #define HW_CONTROLLER_DP            0x05
121 typedef struct _CONTROLLER_DEVICE_PATH {
122         EFI_DEVICE_PATH     Header;
123         UINT32              Controller;
124 } CONTROLLER_DEVICE_PATH;
125
126 /*
127  *
128  */
129 #define ACPI_DEVICE_PATH                 0x02
130
131 #define ACPI_DP                         0x01
132 typedef struct _ACPI_HID_DEVICE_PATH {
133         EFI_DEVICE_PATH                 Header;
134         UINT32                          HID;
135         UINT32                          UID;
136 } ACPI_HID_DEVICE_PATH;
137
138 #define ACPI_EXTENDED_DP          0x02
139 typedef struct _ACPI_EXTENDED_HID_DEVICE_PATH {
140   EFI_DEVICE_PATH                 Header;
141   UINT32                          HID;
142   UINT32                          UID;
143   UINT32                          CID;
144 } ACPI_EXTENDED_HID_DEVICE_PATH;
145
146 //
147 // EISA ID Macro
148 // EISA ID Definition 32-bits
149 //  bits[15:0] - three character compressed ASCII EISA ID.
150 //  bits[31:16] - binary number
151 //   Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z'
152 //
153 #define PNP_EISA_ID_CONST       0x41d0    
154 #define EISA_ID(_Name, _Num)    ((UINT32) ((_Name) | (_Num) << 16))   
155 #define EISA_PNP_ID(_PNPId)     (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
156 #define EFI_PNP_ID(_PNPId)      (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
157
158 #define PNP_EISA_ID_MASK        0xffff
159 #define EISA_ID_TO_NUM(_Id)     ((_Id) >> 16)
160 /*
161  *
162  */
163 #define MESSAGING_DEVICE_PATH           0x03 
164
165 #define MSG_ATAPI_DP                    0x01
166 typedef struct _ATAPI_DEVICE_PATH {
167         EFI_DEVICE_PATH                 Header;
168         UINT8                           PrimarySecondary;
169         UINT8                           SlaveMaster;
170         UINT16                          Lun;
171 } ATAPI_DEVICE_PATH;
172
173 #define MSG_SCSI_DP                     0x02
174 typedef struct _SCSI_DEVICE_PATH {
175         EFI_DEVICE_PATH                 Header;
176         UINT16                          Pun;
177         UINT16                          Lun; 
178 } SCSI_DEVICE_PATH;
179
180 #define MSG_FIBRECHANNEL_DP             0x03
181 typedef struct _FIBRECHANNEL_DEVICE_PATH {
182         EFI_DEVICE_PATH                 Header;
183         UINT32                          Reserved;
184         UINT64                          WWN;
185         UINT64                          Lun;
186 } FIBRECHANNEL_DEVICE_PATH;
187
188 #define MSG_1394_DP                     0x04
189 typedef struct _F1394_DEVICE_PATH {
190         EFI_DEVICE_PATH                 Header;
191         UINT32                          Reserved;
192         UINT64                          Guid;
193 } F1394_DEVICE_PATH;
194
195 #define MSG_USB_DP                      0x05
196 typedef struct _USB_DEVICE_PATH {
197     EFI_DEVICE_PATH                     Header;
198     UINT8                                                             ParentPortNumber;
199     UINT8                                                             InterfaceNumber;
200 } USB_DEVICE_PATH;
201
202 #define MSG_USB_CLASS_DP                0x0F
203 typedef struct _USB_CLASS_DEVICE_PATH {
204         EFI_DEVICE_PATH                 Header;
205         UINT16                          VendorId;
206         UINT16                          ProductId;
207         UINT8                           DeviceClass;
208         UINT8                           DeviceSubClass;
209         UINT8                           DeviceProtocol;
210 } USB_CLASS_DEVICE_PATH;
211
212 #define MSG_I2O_DP                      0x06
213 typedef struct _I2O_DEVICE_PATH {
214         EFI_DEVICE_PATH                 Header;
215         UINT32                          Tid;
216 } I2O_DEVICE_PATH;
217
218 #define MSG_MAC_ADDR_DP                 0x0b
219 typedef struct _MAC_ADDR_DEVICE_PATH {
220         EFI_DEVICE_PATH                 Header;
221         EFI_MAC_ADDRESS                 MacAddress;
222         UINT8                           IfType;
223 } MAC_ADDR_DEVICE_PATH;
224
225 #define MSG_IPv4_DP                     0x0c
226 typedef struct _IPv4_DEVICE_PATH {
227         EFI_DEVICE_PATH                 Header;
228         EFI_IPv4_ADDRESS                LocalIpAddress;
229         EFI_IPv4_ADDRESS                RemoteIpAddress;
230         UINT16                          LocalPort;
231         UINT16                          RemotePort;
232         UINT16                          Protocol;
233         BOOLEAN                         StaticIpAddress;
234 } IPv4_DEVICE_PATH;
235
236 #define MSG_IPv6_DP                     0x0d
237 typedef struct _IPv6_DEVICE_PATH {
238         EFI_DEVICE_PATH                 Header;
239         EFI_IPv6_ADDRESS                LocalIpAddress;
240         EFI_IPv6_ADDRESS                RemoteIpAddress;
241         UINT16                          LocalPort;
242         UINT16                          RemotePort;
243         UINT16                          Protocol;
244         BOOLEAN                         StaticIpAddress;
245 } IPv6_DEVICE_PATH;
246
247 #define MSG_INFINIBAND_DP               0x09
248 typedef struct _INFINIBAND_DEVICE_PATH {
249   EFI_DEVICE_PATH                       Header;
250   UINT32                                ResourceFlags;
251   UINT8                                 PortGid[16];
252   UINT64                                ServiceId;
253   UINT64                                TargetPortId;
254   UINT64                                DeviceId;
255 } INFINIBAND_DEVICE_PATH;
256
257 #define INFINIBAND_RESOURCE_FLAG_IOC_SERVICE                0x01
258 #define INFINIBAND_RESOURCE_FLAG_EXTENDED_BOOT_ENVIRONMENT  0x02
259 #define INFINIBAND_RESOURCE_FLAG_CONSOLE_PROTOCOL           0x04
260 #define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL           0x08
261 #define INFINIBAND_RESOURCE_FLAG_NETWORK_PROTOCOL           0x10
262
263 #define MSG_UART_DP                     0x0e
264 typedef struct _UART_DEVICE_PATH {
265         EFI_DEVICE_PATH                 Header;
266         UINT32                          Reserved;
267         UINT64                          BaudRate;
268         UINT8                           DataBits;
269         UINT8                           Parity;
270         UINT8                           StopBits;
271 } UART_DEVICE_PATH;
272
273 #define MSG_VENDOR_DP                   0x0A
274 /* Use VENDOR_DEVICE_PATH struct */
275
276 #define DEVICE_PATH_MESSAGING_PC_ANSI \
277     { 0xe0c14753, 0xf9be, 0x11d2,  0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d  }
278
279 #define DEVICE_PATH_MESSAGING_VT_100 \
280     { 0xdfa66065, 0xb419, 0x11d3,  0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d  }
281
282 #define DEVICE_PATH_MESSAGING_VT_100_PLUS \
283     { 0x7baec70b, 0x57e0, 0x4c76, 0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43  }
284     
285 #define DEVICE_PATH_MESSAGING_VT_UTF8 \
286     { 0xad15a0d6, 0x8bec, 0x4acf, 0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88 }   
287
288
289 #define MEDIA_DEVICE_PATH               0x04
290
291 #define MEDIA_HARDDRIVE_DP              0x01
292 typedef struct _HARDDRIVE_DEVICE_PATH {
293         EFI_DEVICE_PATH                 Header;
294         UINT32                          PartitionNumber;
295         UINT64                          PartitionStart;
296         UINT64                          PartitionSize;
297         UINT8                           Signature[16];
298         UINT8                           MBRType;
299         UINT8                           SignatureType;
300 } HARDDRIVE_DEVICE_PATH;
301
302 #define MBR_TYPE_PCAT                       0x01
303 #define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02
304
305 #define SIGNATURE_TYPE_MBR                  0x01
306 #define SIGNATURE_TYPE_GUID                 0x02
307
308 #define MEDIA_CDROM_DP                  0x02
309 typedef struct _CDROM_DEVICE_PATH {
310         EFI_DEVICE_PATH                 Header;
311         UINT32                          BootEntry;
312         UINT64                          PartitionStart;
313         UINT64                          PartitionSize;
314 } CDROM_DEVICE_PATH;
315
316 #define MEDIA_VENDOR_DP                 0x03
317 /* Use VENDOR_DEVICE_PATH struct */
318
319 #define MEDIA_FILEPATH_DP               0x04
320 typedef struct _FILEPATH_DEVICE_PATH {
321         EFI_DEVICE_PATH                 Header;
322         CHAR16                          PathName[1];
323 } FILEPATH_DEVICE_PATH;
324
325 #define SIZE_OF_FILEPATH_DEVICE_PATH EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName)
326
327 #define MEDIA_PROTOCOL_DP               0x05
328 typedef struct _MEDIA_PROTOCOL_DEVICE_PATH {
329         EFI_DEVICE_PATH                 Header;
330         EFI_GUID                        Protocol;
331 } MEDIA_PROTOCOL_DEVICE_PATH;
332
333
334 #define BBS_DEVICE_PATH                 0x05
335 #define BBS_BBS_DP                      0x01
336 typedef struct _BBS_BBS_DEVICE_PATH {
337         EFI_DEVICE_PATH                 Header;
338         UINT16                          DeviceType;
339         UINT16                          StatusFlag;
340         CHAR8                           String[1];
341 } BBS_BBS_DEVICE_PATH;
342
343 /* DeviceType definitions - from BBS specification */
344 #define BBS_TYPE_FLOPPY                 0x01
345 #define BBS_TYPE_HARDDRIVE              0x02
346 #define BBS_TYPE_CDROM                  0x03
347 #define BBS_TYPE_PCMCIA                 0x04
348 #define BBS_TYPE_USB                    0x05
349 #define BBS_TYPE_EMBEDDED_NETWORK       0x06
350 #define BBS_TYPE_DEV                    0x80
351 #define BBS_TYPE_UNKNOWN                0xFF
352
353 typedef union {
354     EFI_DEVICE_PATH                      DevPath;
355     PCI_DEVICE_PATH                      Pci;
356     PCCARD_DEVICE_PATH                   PcCard;
357     MEMMAP_DEVICE_PATH                   MemMap;
358     VENDOR_DEVICE_PATH                   Vendor;
359     UNKNOWN_DEVICE_VENDOR_DEVICE_PATH    UnknownVendor;   
360     CONTROLLER_DEVICE_PATH               Controller;
361     ACPI_HID_DEVICE_PATH                 Acpi;
362
363     ATAPI_DEVICE_PATH                    Atapi;
364     SCSI_DEVICE_PATH                     Scsi;
365     FIBRECHANNEL_DEVICE_PATH             FibreChannel;
366
367     F1394_DEVICE_PATH                    F1394;
368     USB_DEVICE_PATH                      Usb;
369     USB_CLASS_DEVICE_PATH                UsbClass;
370     I2O_DEVICE_PATH                      I2O;
371     MAC_ADDR_DEVICE_PATH                 MacAddr;
372     IPv4_DEVICE_PATH                     Ipv4;
373     IPv6_DEVICE_PATH                     Ipv6;
374     INFINIBAND_DEVICE_PATH               InfiniBand;
375     UART_DEVICE_PATH                     Uart;
376
377     HARDDRIVE_DEVICE_PATH                HardDrive;
378     CDROM_DEVICE_PATH                    CD;
379
380     FILEPATH_DEVICE_PATH                 FilePath;
381     MEDIA_PROTOCOL_DEVICE_PATH           MediaProtocol;
382
383     BBS_BBS_DEVICE_PATH                  Bbs;
384
385 } EFI_DEV_PATH;
386
387 typedef union {
388     EFI_DEVICE_PATH                      *DevPath;
389     PCI_DEVICE_PATH                      *Pci;
390     PCCARD_DEVICE_PATH                   *PcCard;
391     MEMMAP_DEVICE_PATH                   *MemMap;
392     VENDOR_DEVICE_PATH                   *Vendor;
393     UNKNOWN_DEVICE_VENDOR_DEVICE_PATH    *UnknownVendor;   
394     CONTROLLER_DEVICE_PATH               *Controller;
395     ACPI_HID_DEVICE_PATH                 *Acpi;
396     ACPI_EXTENDED_HID_DEVICE_PATH        *ExtendedAcpi;
397
398     ATAPI_DEVICE_PATH                    *Atapi;
399     SCSI_DEVICE_PATH                     *Scsi;
400     FIBRECHANNEL_DEVICE_PATH             *FibreChannel;
401
402     F1394_DEVICE_PATH                    *F1394;
403     USB_DEVICE_PATH                      *Usb;
404     USB_CLASS_DEVICE_PATH                *UsbClass;
405     I2O_DEVICE_PATH                      *I2O;
406     MAC_ADDR_DEVICE_PATH                 *MacAddr;
407     IPv4_DEVICE_PATH                     *Ipv4;
408     IPv6_DEVICE_PATH                     *Ipv6;
409     INFINIBAND_DEVICE_PATH               *InfiniBand;
410     UART_DEVICE_PATH                     *Uart;
411
412     HARDDRIVE_DEVICE_PATH                *HardDrive;
413
414     FILEPATH_DEVICE_PATH                 *FilePath;
415     MEDIA_PROTOCOL_DEVICE_PATH           *MediaProtocol;
416
417     CDROM_DEVICE_PATH                    *CD;
418     BBS_BBS_DEVICE_PATH                  *Bbs;
419
420 } EFI_DEV_PATH_PTR;
421
422
423 #endif