]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/DevicePathDxe/DevicePath.h
Update DevicePath driver to reflect several device path update in UEFI spec: SATA...
[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
cf40f28a 112#pragma pack(1)\r
113\r
95276127 114typedef struct {\r
115 EFI_DEVICE_PATH_PROTOCOL Header;\r
116 EFI_GUID Guid;\r
117 UINT8 VendorDefinedData[1];\r
118} VENDOR_DEFINED_HARDWARE_DEVICE_PATH;\r
119\r
120typedef struct {\r
121 EFI_DEVICE_PATH_PROTOCOL Header;\r
122 EFI_GUID Guid;\r
123 UINT8 VendorDefinedData[1];\r
124} VENDOR_DEFINED_MESSAGING_DEVICE_PATH;\r
125\r
126typedef struct {\r
127 EFI_DEVICE_PATH_PROTOCOL Header;\r
128 EFI_GUID Guid;\r
129 UINT8 VendorDefinedData[1];\r
130} VENDOR_DEFINED_MEDIA_DEVICE_PATH;\r
131\r
132typedef struct {\r
133 EFI_DEVICE_PATH_PROTOCOL Header;\r
134 UINT32 HID;\r
135 UINT32 UID;\r
136 UINT32 CID;\r
137 CHAR8 HidUidCidStr[3];\r
138} ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR;\r
139\r
140typedef struct {\r
141 EFI_DEVICE_PATH_PROTOCOL Header;\r
142 UINT16 NetworkProtocol;\r
143 UINT16 LoginOption;\r
95276127 144 UINT64 Lun;\r
cf40f28a 145 UINT16 TargetPortalGroupTag;\r
146 CHAR8 iSCSITargetName[1];\r
95276127 147} ISCSI_DEVICE_PATH_WITH_NAME;\r
148\r
149typedef struct {\r
150 EFI_DEVICE_PATH_PROTOCOL Header;\r
151 EFI_GUID Guid;\r
152 UINT8 VendorDefinedData[1];\r
153} VENDOR_DEVICE_PATH_WITH_DATA;\r
154\r
cf40f28a 155#pragma pack()\r
156\r
95276127 157CHAR16 *\r
158ConvertDeviceNodeToText (\r
159 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
160 IN BOOLEAN DisplayOnly,\r
161 IN BOOLEAN AllowShortcuts\r
162 )\r
163/*++\r
164\r
165 Routine Description:\r
166 Convert a device node to its text representation.\r
167\r
168 Arguments:\r
169 DeviceNode - Points to the device node to be converted.\r
170 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation\r
171 of the display node is used, where applicable. If DisplayOnly\r
172 is FALSE, then the longer text representation of the display node\r
173 is used.\r
174 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text\r
175 representation for a device node can be used, where applicable.\r
176\r
177 Returns:\r
178 A pointer - a pointer to the allocated text representation of the device node.\r
179 NULL - if DeviceNode is NULL or there was insufficient memory.\r
180\r
181--*/\r
182;\r
183\r
184CHAR16 *\r
185ConvertDevicePathToText (\r
186 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
187 IN BOOLEAN DisplayOnly,\r
188 IN BOOLEAN AllowShortcuts\r
189 )\r
190/*++\r
191\r
192 Routine Description:\r
193 Convert a device path to its text representation.\r
194\r
195 Arguments:\r
196 DeviceNode - Points to the device path to be converted.\r
197 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation\r
198 of the display node is used, where applicable. If DisplayOnly\r
199 is FALSE, then the longer text representation of the display node\r
200 is used.\r
201 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text\r
202 representation for a device node can be used, where applicable.\r
203\r
204 Returns:\r
205 A pointer - a pointer to the allocated text representation of the device path.\r
206 NULL - if DeviceNode is NULL or there was insufficient memory.\r
207\r
208--*/\r
209;\r
210\r
211EFI_DEVICE_PATH_PROTOCOL *\r
212ConvertTextToDeviceNode (\r
213 IN CONST CHAR16 *TextDeviceNode\r
214 )\r
215/*++\r
216\r
217 Routine Description:\r
218 Convert text to the binary representation of a device node.\r
219\r
220 Arguments:\r
221 TextDeviceNode - TextDeviceNode points to the text representation of a device\r
222 node. Conversion starts with the first character and continues\r
223 until the first non-device node character.\r
224\r
225 Returns:\r
226 A pointer - Pointer to the EFI device node.\r
227 NULL - if TextDeviceNode is NULL or there was insufficient memory.\r
228\r
229--*/\r
230;\r
231\r
232EFI_DEVICE_PATH_PROTOCOL *\r
233ConvertTextToDevicePath (\r
234 IN CONST CHAR16 *TextDevicePath\r
235 )\r
236/*++\r
237\r
238 Routine Description:\r
239 Convert text to the binary representation of a device path.\r
240\r
241 Arguments:\r
242 TextDevicePath - TextDevicePath points to the text representation of a device\r
243 path. Conversion starts with the first character and continues\r
244 until the first non-device node character.\r
245\r
246 Returns:\r
247 A pointer - Pointer to the allocated device path.\r
248 NULL - if TextDeviceNode is NULL or there was insufficient memory.\r
249\r
250--*/\r
251;\r
252\r
253UINTN\r
254GetDevicePathSizeProtocolInterface (\r
255 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
256 )\r
257/*++\r
258\r
259 Routine Description:\r
260 Returns the size of the device path, in bytes.\r
261\r
262 Arguments:\r
263 DevicePath - Points to the start of the EFI device path.\r
264\r
265 Returns:\r
266 Size - Size of the specified device path, in bytes, including the end-of-path tag.\r
267\r
268--*/\r
269;\r
270\r
271EFI_DEVICE_PATH_PROTOCOL *\r
272DuplicateDevicePathProtocolInterface (\r
273 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
274 )\r
275/*++\r
276\r
277 Routine Description:\r
278 Create a duplicate of the specified path.\r
279\r
280 Arguments:\r
281 DevicePath - Points to the source EFI device path.\r
282\r
283 Returns:\r
284 Pointer - A pointer to the duplicate device path.\r
285 NULL - Insufficient memory.\r
286\r
287--*/\r
288;\r
289\r
290EFI_DEVICE_PATH_PROTOCOL *\r
291AppendDevicePathProtocolInterface (\r
292 IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,\r
293 IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2\r
294 )\r
295/*++\r
296\r
297 Routine Description:\r
298 Create a new path by appending the second device path to the first.\r
299\r
300 Arguments:\r
301 Src1 - Points to the first device path. If NULL, then it is ignored.\r
302 Src2 - Points to the second device path. If NULL, then it is ignored.\r
303\r
304 Returns:\r
305 Pointer - A pointer to the newly created device path.\r
306 NULL - Memory could not be allocated\r
307 or either DevicePath or DeviceNode is NULL.\r
308\r
309--*/\r
310;\r
311\r
312EFI_DEVICE_PATH_PROTOCOL *\r
313AppendDeviceNodeProtocolInterface (\r
314 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
315 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode\r
316 )\r
317/*++\r
318\r
319 Routine Description:\r
320 Creates a new path by appending the device node to the device path.\r
321\r
322 Arguments:\r
323 DevicePath - Points to the device path.\r
324 DeviceNode - Points to the device node.\r
325\r
326 Returns:\r
327 Pointer - A pointer to the allocated device node.\r
328 NULL - Memory could not be allocated\r
329 or either DevicePath or DeviceNode is NULL.\r
330\r
331--*/\r
332;\r
333\r
334EFI_DEVICE_PATH_PROTOCOL *\r
335AppendDevicePathInstanceProtocolInterface (\r
336 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
337 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r
338 )\r
339/*++\r
340\r
341 Routine Description:\r
342 Creates a new path by appending the specified device path instance to the specified device path.\r
343\r
344 Arguments:\r
345 DevicePath - Points to the device path. If NULL, then ignored.\r
346 DevicePathInstance - Points to the device path instance.\r
347\r
348 Returns:\r
349 Pointer - A pointer to the newly created device path\r
350 NULL - Memory could not be allocated or DevicePathInstance is NULL.\r
351\r
352--*/\r
353;\r
354\r
355EFI_DEVICE_PATH_PROTOCOL *\r
356GetNextDevicePathInstanceProtocolInterface (\r
357 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,\r
358 OUT UINTN *DevicePathInstanceSize\r
359 )\r
360/*++\r
361\r
362 Routine Description:\r
363 Creates a copy of the current device path instance and returns a pointer to the next device path instance.\r
364\r
365 Arguments:\r
366 DevicePathInstance - On input, this holds the pointer to the current device path\r
367 instance. On output, this holds the pointer to the next\r
368 device path instance or NULL if there are no more device\r
369 path instances in the device path.\r
370 DevicePathInstanceSize - On output, this holds the size of the device path instance,\r
371 in bytes or zero, if DevicePathInstance is zero.\r
372\r
373 Returns:\r
374 Pointer - A pointer to the copy of the current device path instance.\r
375 NULL - DevicePathInstace was NULL on entry or there was insufficient memory.\r
376\r
377--*/\r
378;\r
379\r
380BOOLEAN\r
381IsDevicePathMultiInstanceProtocolInterface (\r
382 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
383 )\r
384/*++\r
385\r
386 Routine Description:\r
387 Returns whether a device path is multi-instance.\r
388\r
389 Arguments:\r
390 DevicePath - Points to the device path. If NULL, then ignored.\r
391\r
392 Returns:\r
393 TRUE - The device path has more than one instance\r
394 FALSE - The device path is empty or contains only a single instance.\r
395\r
396--*/\r
397;\r
398\r
399EFI_DEVICE_PATH_PROTOCOL *\r
400CreateDeviceNodeProtocolInterface (\r
401 IN UINT8 NodeType,\r
402 IN UINT8 NodeSubType,\r
403 IN UINT16 NodeLength\r
404 )\r
405/*++\r
406\r
407 Routine Description:\r
408 Creates a device node\r
409\r
410 Arguments:\r
411 NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for\r
412 the new device node.\r
413 NodeSubType - NodeSubType is the device node sub-type\r
414 EFI_DEVICE_PATH.SubType) for the new device node.\r
415 NodeLength - NodeLength is the length of the device node\r
416 (EFI_DEVICE_PATH.Length) for the new device node.\r
417\r
418 Returns:\r
419 Pointer - A pointer to the newly created device node.\r
420 NULL - NodeLength is less than\r
421 the size of the header or there was insufficient memory.\r
422\r
423--*/\r
424;\r
425\r
426#endif\r