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