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