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