Check in following modules,
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePath.h
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 DevicePath.h
15
16 Abstract:
17 Definition for Device Path Utilities driver
18
19 --*/
20
21 #ifndef _DEVICE_PATH_DRIVER_H
22 #define _DEVICE_PATH_DRIVER_H
23
24 //
25 // Include common header file for this module.
26 //
27 #include "CommonHeader.h"
28
29 extern const EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid;
30 extern const EFI_GUID mEfiDevicePathMessagingSASGuid;
31
32 #define MAX_CHAR 480
33
34 #define MIN_ALIGNMENT_SIZE sizeof(UINTN)
35 #define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)
36
37 #define IS_COMMA(a) ((a) == L',')
38 #define IS_HYPHEN(a) ((a) == L'-')
39 #define IS_DOT(a) ((a) == L'.')
40 #define IS_LEFT_PARENTH(a) ((a) == L'(')
41 #define IS_RIGHT_PARENTH(a) ((a) == L')')
42 #define IS_SLASH(a) ((a) == L'/')
43 #define IS_NULL(a) ((a) == L'\0')
44
45 #define DEVICE_NODE_END 1
46 #define DEVICE_PATH_INSTANCE_END 2
47 #define DEVICE_PATH_END 3
48
49 #define SetDevicePathInstanceEndNode(a) { \
50 (a)->Type = END_DEVICE_PATH_TYPE; \
51 (a)->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; \
52 (a)->Length[0] = sizeof (EFI_DEVICE_PATH_PROTOCOL); \
53 (a)->Length[1] = 0; \
54 }
55
56 //
57 // Private Data structure
58 //
59 typedef struct {
60 CHAR16 *Str;
61 UINTN Len;
62 UINTN MaxLen;
63 } POOL_PRINT;
64
65 typedef struct {
66 UINT8 Type;
67 UINT8 SubType;
68 VOID (*Function) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);
69 } DEVICE_PATH_TO_TEXT_TABLE;
70
71 typedef struct {
72 CHAR16 *DevicePathNodeText;
73 EFI_DEVICE_PATH_PROTOCOL * (*Function) (CHAR16 *);
74 } DEVICE_PATH_FROM_TEXT_TABLE;
75
76 typedef struct {
77 BOOLEAN ClassExist;
78 UINT8 Class;
79 BOOLEAN SubClassExist;
80 UINT8 SubClass;
81 } USB_CLASS_TEXT;
82
83 #define USB_CLASS_AUDIO 1
84 #define USB_CLASS_CDCCONTROL 2
85 #define USB_CLASS_HID 3
86 #define USB_CLASS_IMAGE 6
87 #define USB_CLASS_PRINTER 7
88 #define USB_CLASS_MASS_STORAGE 8
89 #define USB_CLASS_HUB 9
90 #define USB_CLASS_CDCDATA 10
91 #define USB_CLASS_SMART_CARD 11
92 #define USB_CLASS_VIDEO 14
93 #define USB_CLASS_DIAGNOSTIC 220
94 #define USB_CLASS_WIRELESS 224
95
96 #define USB_CLASS_RESERVE 254
97 #define USB_SUBCLASS_FW_UPDATE 1
98 #define USB_SUBCLASS_IRDA_BRIDGE 2
99 #define USB_SUBCLASS_TEST 3
100
101 typedef struct {
102 EFI_DEVICE_PATH_PROTOCOL Header;
103 EFI_GUID Guid;
104 UINT8 VendorDefinedData[1];
105 } VENDOR_DEFINED_HARDWARE_DEVICE_PATH;
106
107 typedef struct {
108 EFI_DEVICE_PATH_PROTOCOL Header;
109 EFI_GUID Guid;
110 UINT8 VendorDefinedData[1];
111 } VENDOR_DEFINED_MESSAGING_DEVICE_PATH;
112
113 typedef struct {
114 EFI_DEVICE_PATH_PROTOCOL Header;
115 EFI_GUID Guid;
116 UINT8 VendorDefinedData[1];
117 } VENDOR_DEFINED_MEDIA_DEVICE_PATH;
118
119 typedef struct {
120 EFI_DEVICE_PATH_PROTOCOL Header;
121 UINT32 HID;
122 UINT32 UID;
123 UINT32 CID;
124 CHAR8 HidUidCidStr[3];
125 } ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR;
126
127 typedef struct {
128 EFI_DEVICE_PATH_PROTOCOL Header;
129 UINT16 NetworkProtocol;
130 UINT16 LoginOption;
131 UINT16 Reserved;
132 UINT16 TargetPortalGroupTag;
133 UINT64 Lun;
134 CHAR16 iSCSITargetName[1];
135 } ISCSI_DEVICE_PATH_WITH_NAME;
136
137 typedef struct {
138 EFI_DEVICE_PATH_PROTOCOL Header;
139 EFI_GUID Guid;
140 UINT8 VendorDefinedData[1];
141 } VENDOR_DEVICE_PATH_WITH_DATA;
142
143 CHAR16 *
144 ConvertDeviceNodeToText (
145 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
146 IN BOOLEAN DisplayOnly,
147 IN BOOLEAN AllowShortcuts
148 )
149 /*++
150
151 Routine Description:
152 Convert a device node to its text representation.
153
154 Arguments:
155 DeviceNode - Points to the device node to be converted.
156 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
157 of the display node is used, where applicable. If DisplayOnly
158 is FALSE, then the longer text representation of the display node
159 is used.
160 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
161 representation for a device node can be used, where applicable.
162
163 Returns:
164 A pointer - a pointer to the allocated text representation of the device node.
165 NULL - if DeviceNode is NULL or there was insufficient memory.
166
167 --*/
168 ;
169
170 CHAR16 *
171 ConvertDevicePathToText (
172 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
173 IN BOOLEAN DisplayOnly,
174 IN BOOLEAN AllowShortcuts
175 )
176 /*++
177
178 Routine Description:
179 Convert a device path to its text representation.
180
181 Arguments:
182 DeviceNode - Points to the device path to be converted.
183 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
184 of the display node is used, where applicable. If DisplayOnly
185 is FALSE, then the longer text representation of the display node
186 is used.
187 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
188 representation for a device node can be used, where applicable.
189
190 Returns:
191 A pointer - a pointer to the allocated text representation of the device path.
192 NULL - if DeviceNode is NULL or there was insufficient memory.
193
194 --*/
195 ;
196
197 EFI_DEVICE_PATH_PROTOCOL *
198 ConvertTextToDeviceNode (
199 IN CONST CHAR16 *TextDeviceNode
200 )
201 /*++
202
203 Routine Description:
204 Convert text to the binary representation of a device node.
205
206 Arguments:
207 TextDeviceNode - TextDeviceNode points to the text representation of a device
208 node. Conversion starts with the first character and continues
209 until the first non-device node character.
210
211 Returns:
212 A pointer - Pointer to the EFI device node.
213 NULL - if TextDeviceNode is NULL or there was insufficient memory.
214
215 --*/
216 ;
217
218 EFI_DEVICE_PATH_PROTOCOL *
219 ConvertTextToDevicePath (
220 IN CONST CHAR16 *TextDevicePath
221 )
222 /*++
223
224 Routine Description:
225 Convert text to the binary representation of a device path.
226
227 Arguments:
228 TextDevicePath - TextDevicePath points to the text representation of a device
229 path. Conversion starts with the first character and continues
230 until the first non-device node character.
231
232 Returns:
233 A pointer - Pointer to the allocated device path.
234 NULL - if TextDeviceNode is NULL or there was insufficient memory.
235
236 --*/
237 ;
238
239 UINTN
240 GetDevicePathSizeProtocolInterface (
241 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
242 )
243 /*++
244
245 Routine Description:
246 Returns the size of the device path, in bytes.
247
248 Arguments:
249 DevicePath - Points to the start of the EFI device path.
250
251 Returns:
252 Size - Size of the specified device path, in bytes, including the end-of-path tag.
253
254 --*/
255 ;
256
257 EFI_DEVICE_PATH_PROTOCOL *
258 DuplicateDevicePathProtocolInterface (
259 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
260 )
261 /*++
262
263 Routine Description:
264 Create a duplicate of the specified path.
265
266 Arguments:
267 DevicePath - Points to the source EFI device path.
268
269 Returns:
270 Pointer - A pointer to the duplicate device path.
271 NULL - Insufficient memory.
272
273 --*/
274 ;
275
276 EFI_DEVICE_PATH_PROTOCOL *
277 AppendDevicePathProtocolInterface (
278 IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,
279 IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2
280 )
281 /*++
282
283 Routine Description:
284 Create a new path by appending the second device path to the first.
285
286 Arguments:
287 Src1 - Points to the first device path. If NULL, then it is ignored.
288 Src2 - Points to the second device path. If NULL, then it is ignored.
289
290 Returns:
291 Pointer - A pointer to the newly created device path.
292 NULL - Memory could not be allocated
293 or either DevicePath or DeviceNode is NULL.
294
295 --*/
296 ;
297
298 EFI_DEVICE_PATH_PROTOCOL *
299 AppendDeviceNodeProtocolInterface (
300 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
301 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode
302 )
303 /*++
304
305 Routine Description:
306 Creates a new path by appending the device node to the device path.
307
308 Arguments:
309 DevicePath - Points to the device path.
310 DeviceNode - Points to the device node.
311
312 Returns:
313 Pointer - A pointer to the allocated device node.
314 NULL - Memory could not be allocated
315 or either DevicePath or DeviceNode is NULL.
316
317 --*/
318 ;
319
320 EFI_DEVICE_PATH_PROTOCOL *
321 AppendDevicePathInstanceProtocolInterface (
322 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
323 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
324 )
325 /*++
326
327 Routine Description:
328 Creates a new path by appending the specified device path instance to the specified device path.
329
330 Arguments:
331 DevicePath - Points to the device path. If NULL, then ignored.
332 DevicePathInstance - Points to the device path instance.
333
334 Returns:
335 Pointer - A pointer to the newly created device path
336 NULL - Memory could not be allocated or DevicePathInstance is NULL.
337
338 --*/
339 ;
340
341 EFI_DEVICE_PATH_PROTOCOL *
342 GetNextDevicePathInstanceProtocolInterface (
343 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,
344 OUT UINTN *DevicePathInstanceSize
345 )
346 /*++
347
348 Routine Description:
349 Creates a copy of the current device path instance and returns a pointer to the next device path instance.
350
351 Arguments:
352 DevicePathInstance - On input, this holds the pointer to the current device path
353 instance. On output, this holds the pointer to the next
354 device path instance or NULL if there are no more device
355 path instances in the device path.
356 DevicePathInstanceSize - On output, this holds the size of the device path instance,
357 in bytes or zero, if DevicePathInstance is zero.
358
359 Returns:
360 Pointer - A pointer to the copy of the current device path instance.
361 NULL - DevicePathInstace was NULL on entry or there was insufficient memory.
362
363 --*/
364 ;
365
366 BOOLEAN
367 IsDevicePathMultiInstanceProtocolInterface (
368 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
369 )
370 /*++
371
372 Routine Description:
373 Returns whether a device path is multi-instance.
374
375 Arguments:
376 DevicePath - Points to the device path. If NULL, then ignored.
377
378 Returns:
379 TRUE - The device path has more than one instance
380 FALSE - The device path is empty or contains only a single instance.
381
382 --*/
383 ;
384
385 EFI_DEVICE_PATH_PROTOCOL *
386 CreateDeviceNodeProtocolInterface (
387 IN UINT8 NodeType,
388 IN UINT8 NodeSubType,
389 IN UINT16 NodeLength
390 )
391 /*++
392
393 Routine Description:
394 Creates a device node
395
396 Arguments:
397 NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for
398 the new device node.
399 NodeSubType - NodeSubType is the device node sub-type
400 EFI_DEVICE_PATH.SubType) for the new device node.
401 NodeLength - NodeLength is the length of the device node
402 (EFI_DEVICE_PATH.Length) for the new device node.
403
404 Returns:
405 Pointer - A pointer to the newly created device node.
406 NULL - NodeLength is less than
407 the size of the header or there was insufficient memory.
408
409 --*/
410 ;
411
412 #endif