]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/DevicePathDxe/DevicePath.h
Using sizeof(EFO_BLOCK_IO_MEDIA) replace Macro.
[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 - 2008, 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 struct {\r
69 UINT8 Type;\r
70 UINT8 SubType;\r
71 VOID (*Function) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
72} DEVICE_PATH_TO_TEXT_TABLE;\r
73\r
74typedef struct {\r
75 CHAR16 *DevicePathNodeText;\r
76 DUMP_NODE Function;\r
77} DEVICE_PATH_FROM_TEXT_TABLE;\r
78\r
79typedef struct {\r
80 BOOLEAN ClassExist;\r
81 UINT8 Class;\r
82 BOOLEAN SubClassExist;\r
83 UINT8 SubClass;\r
84} USB_CLASS_TEXT;\r
85\r
86#define USB_CLASS_AUDIO 1\r
87#define USB_CLASS_CDCCONTROL 2\r
88#define USB_CLASS_HID 3\r
89#define USB_CLASS_IMAGE 6\r
90#define USB_CLASS_PRINTER 7\r
91#define USB_CLASS_MASS_STORAGE 8\r
92#define USB_CLASS_HUB 9\r
93#define USB_CLASS_CDCDATA 10\r
94#define USB_CLASS_SMART_CARD 11\r
95#define USB_CLASS_VIDEO 14\r
96#define USB_CLASS_DIAGNOSTIC 220\r
97#define USB_CLASS_WIRELESS 224\r
98\r
99#define USB_CLASS_RESERVE 254\r
100#define USB_SUBCLASS_FW_UPDATE 1\r
101#define USB_SUBCLASS_IRDA_BRIDGE 2\r
102#define USB_SUBCLASS_TEST 3\r
103\r
104#pragma pack(1)\r
105\r
106typedef struct {\r
107 EFI_DEVICE_PATH_PROTOCOL Header;\r
108 EFI_GUID Guid;\r
109 UINT8 VendorDefinedData[1];\r
110} VENDOR_DEFINED_HARDWARE_DEVICE_PATH;\r
111\r
112typedef struct {\r
113 EFI_DEVICE_PATH_PROTOCOL Header;\r
114 EFI_GUID Guid;\r
115 UINT8 VendorDefinedData[1];\r
116} VENDOR_DEFINED_MESSAGING_DEVICE_PATH;\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_MEDIA_DEVICE_PATH;\r
123\r
124typedef struct {\r
125 EFI_DEVICE_PATH_PROTOCOL Header;\r
126 UINT32 HID;\r
127 UINT32 UID;\r
128 UINT32 CID;\r
129 CHAR8 HidUidCidStr[3];\r
130} ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR;\r
131\r
132typedef struct {\r
133 EFI_DEVICE_PATH_PROTOCOL Header;\r
134 UINT16 NetworkProtocol;\r
135 UINT16 LoginOption;\r
136 UINT64 Lun;\r
137 UINT16 TargetPortalGroupTag;\r
138 CHAR8 iSCSITargetName[1];\r
139} ISCSI_DEVICE_PATH_WITH_NAME;\r
140\r
141typedef struct {\r
142 EFI_DEVICE_PATH_PROTOCOL Header;\r
143 EFI_GUID Guid;\r
144 UINT8 VendorDefinedData[1];\r
145} VENDOR_DEVICE_PATH_WITH_DATA;\r
146\r
147#pragma pack()\r
148\r
149/**\r
150 Converts a device node to its string representation.\r
151\r
152 @param DeviceNode A Pointer to the device node to be converted.\r
153 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
154 of the display node is used, where applicable. If DisplayOnly\r
155 is FALSE, then the longer text representation of the display node\r
156 is used.\r
157 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
158 representation for a device node can be used, where applicable.\r
159\r
160 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
161 is NULL or there was insufficient memory.\r
162\r
163**/\r
164CHAR16 *\r
165EFIAPI\r
166ConvertDeviceNodeToText (\r
167 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
168 IN BOOLEAN DisplayOnly,\r
169 IN BOOLEAN AllowShortcuts\r
170 );\r
171\r
172/**\r
173 Converts a device path to its text representation.\r
174\r
175 @param DevicePath A Pointer to the device to be converted.\r
176 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
177 of the display node is used, where applicable. If DisplayOnly\r
178 is FALSE, then the longer text representation of the display node\r
179 is used.\r
180 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
181 representation for a device node can be used, where applicable.\r
182\r
183 @return A pointer to the allocated text representation of the device path or\r
184 NULL if DeviceNode is NULL or there was insufficient memory.\r
185\r
186**/\r
187CHAR16 *\r
188EFIAPI\r
189ConvertDevicePathToText (\r
190 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
191 IN BOOLEAN DisplayOnly,\r
192 IN BOOLEAN AllowShortcuts\r
193 );\r
194\r
195/**\r
196 Convert text to the binary representation of a device node.\r
197\r
198 @param TextDeviceNode TextDeviceNode points to the text representation of a device\r
199 node. Conversion starts with the first character and continues\r
200 until the first non-device node character.\r
201\r
202 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
203 insufficient memory or text unsupported.\r
204\r
205**/\r
206EFI_DEVICE_PATH_PROTOCOL *\r
207EFIAPI\r
208ConvertTextToDeviceNode (\r
209 IN CONST CHAR16 *TextDeviceNode\r
210 );\r
211\r
212/**\r
213 Convert text to the binary representation of a device path.\r
214\r
215\r
216 @param TextDevicePath TextDevicePath points to the text representation of a device\r
217 path. Conversion starts with the first character and continues\r
218 until the first non-device node character.\r
219\r
220 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
221 there was insufficient memory.\r
222\r
223**/\r
224EFI_DEVICE_PATH_PROTOCOL *\r
225EFIAPI\r
226ConvertTextToDevicePath (\r
227 IN CONST CHAR16 *TextDevicePath\r
228 );\r
229\r
230/**\r
231 Returns the size of a device path in bytes.\r
232\r
233 This function returns the size, in bytes, of the device path data structure specified by\r
234 DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned.\r
235\r
236 @param DevicePath A pointer to a device path data structure.\r
237\r
238 @return The size of a device path in bytes.\r
239\r
240**/\r
241UINTN\r
242EFIAPI\r
243GetDevicePathSizeProtocolInterface (\r
244 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
245 );\r
246\r
247/**\r
248 Creates a new device path by appending a second device path to a first device path.\r
249\r
250 This function allocates space for a new copy of the device path specified by DevicePath. If\r
251 DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the\r
252 contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer\r
253 is returned. Otherwise, NULL is returned.\r
254\r
255 @param DevicePath A pointer to a device path data structure.\r
256\r
257 @return A pointer to the duplicated device path.\r
258\r
259**/\r
260EFI_DEVICE_PATH_PROTOCOL *\r
261EFIAPI\r
262DuplicateDevicePathProtocolInterface (\r
263 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
264 );\r
265\r
266/**\r
267 Creates a new device path by appending a second device path to a first device path.\r
268\r
269 This function creates a new device path by appending a copy of SecondDevicePath to a copy of\r
270 FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from\r
271 SecondDevicePath is retained. The newly created device path is returned.\r
272 If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.\r
273 If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.\r
274 If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is\r
275 returned.\r
276 If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
277 The memory for the new device path is allocated from EFI boot services memory. It is the\r
278 responsibility of the caller to free the memory allocated.\r
279\r
280 @param FirstDevicePath A pointer to a device path data structure.\r
281 @param SecondDevicePath A pointer to a device path data structure.\r
282\r
283 @return A pointer to the new device path.\r
284\r
285**/\r
286EFI_DEVICE_PATH_PROTOCOL *\r
287EFIAPI\r
288AppendDevicePathProtocolInterface (\r
289 IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath,\r
290 IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath\r
291 );\r
292\r
293/**\r
294 Creates a new path by appending the device node to the device path.\r
295\r
296 This function creates a new device path by appending a copy of the device node specified by\r
297 DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.\r
298 The end-of-device-path device node is moved after the end of the appended device node.\r
299 If DevicePathNode is NULL then a copy of DevicePath is returned.\r
300 If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device\r
301 node is returned.\r
302 If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node\r
303 is returned.\r
304 If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
305 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
306 free the memory allocated.\r
307\r
308 @param DevicePath A pointer to a device path data structure.\r
309 @param DevicePathNode A pointer to a single device path node.\r
310\r
311 @return A pointer to the new device path.\r
312\r
313**/\r
314EFI_DEVICE_PATH_PROTOCOL *\r
315EFIAPI\r
316AppendDeviceNodeProtocolInterface (\r
317 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
318 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode\r
319 );\r
320\r
321/**\r
322 Creates a new device path by appending the specified device path instance to the specified device\r
323 path.\r
324\r
325 This function creates a new device path by appending a copy of the device path instance specified\r
326 by DevicePathInstance to a copy of the device path specified by DevicePath in a allocated buffer.\r
327 The end-of-device-path device node is moved after the end of the appended device path instance\r
328 and a new end-of-device-path-instance node is inserted between.\r
329 If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r
330 If DevicePathInstance is NULL, then NULL is returned.\r
331 If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
332 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
333 free the memory allocated.\r
334\r
335 @param DevicePath A pointer to a device path data structure.\r
336 @param DevicePathInstance A pointer to a device path instance.\r
337\r
338 @return A pointer to the new device path.\r
339\r
340**/\r
341EFI_DEVICE_PATH_PROTOCOL *\r
342EFIAPI\r
343AppendDevicePathInstanceProtocolInterface (\r
344 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
345 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r
346 );\r
347\r
348/**\r
349 Creates a copy of the current device path instance and returns a pointer to the next device path\r
350 instance.\r
351\r
352 This function creates a copy of the current device path instance. It also updates DevicePath to\r
353 point to the next device path instance in the device path (or NULL if no more) and updates Size\r
354 to hold the size of the device path instance copy.\r
355 If DevicePath is NULL, then NULL is returned.\r
356 If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
357 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
358 free the memory allocated.\r
359 If Size is NULL, then ASSERT().\r
360\r
361 @param DevicePath On input, this holds the pointer to the current device path\r
362 instance. On output, this holds the pointer to the next device\r
363 path instance or NULL if there are no more device path\r
364 instances in the device path pointer to a device path data\r
365 structure.\r
366 @param Size On output, this holds the size of the device path instance, in\r
367 bytes or zero, if DevicePath is NULL.\r
368\r
369 @return A pointer to the current device path instance.\r
370\r
371**/\r
372EFI_DEVICE_PATH_PROTOCOL *\r
373EFIAPI\r
374GetNextDevicePathInstanceProtocolInterface (\r
375 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r
376 OUT UINTN *Size\r
377 );\r
378\r
379/**\r
380 Determines if a device path is single or multi-instance.\r
381\r
382 This function returns TRUE if the device path specified by DevicePath is multi-instance.\r
383 Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned.\r
384\r
385 @param DevicePath A pointer to a device path data structure.\r
386\r
387 @retval TRUE DevicePath is multi-instance.\r
388 @retval FALSE DevicePath is not multi-instance or DevicePath is NULL.\r
389\r
390**/\r
391BOOLEAN\r
392EFIAPI\r
393IsDevicePathMultiInstanceProtocolInterface (\r
394 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
395 );\r
396\r
397/**\r
398 Creates a copy of the current device path instance and returns a pointer to the next device path\r
399 instance.\r
400\r
401 This function creates a new device node in a newly allocated buffer of size NodeLength and\r
402 initializes the device path node header with NodeType and NodeSubType. The new device path node\r
403 is returned.\r
404 If NodeLength is smaller than a device path header, then NULL is returned.\r
405 If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
406 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
407 free the memory allocated.\r
408\r
409 @param NodeType The device node type for the new device node.\r
410 @param NodeSubType The device node sub-type for the new device node.\r
411 @param NodeLength The length of the new device node.\r
412\r
413 @return The new device path.\r
414\r
415**/\r
416EFI_DEVICE_PATH_PROTOCOL *\r
417EFIAPI\r
418CreateDeviceNodeProtocolInterface (\r
419 IN UINT8 NodeType,\r
420 IN UINT8 NodeSubType,\r
421 IN UINT16 NodeLength\r
422 );\r
423\r
424#endif\r