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