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