]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.h
aa333453ea97b2dd70010573eb7a5f74b772c871
[mirror_edk2.git] / EdkModulePkg / Universal / DevicePath / Dxe / 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 DevicePathDriver.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 extern EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid;
25 extern EFI_GUID mEfiDevicePathMessagingSASGuid;
26
27 #define DEVICE_PATH_DRIVER_SIGNATURE EFI_SIGNATURE_32 ('D', 'P', 'D', 'V')
28
29 typedef struct {
30
31 UINT32 Signature;
32 EFI_HANDLE Handle;
33 //
34 // Produced protocols
35 //
36 EFI_DEVICE_PATH_UTILITIES_PROTOCOL DevicePathUtilities;
37 EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL DevicePathFromText;
38 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL DevicePathToText;
39
40 } DEVICE_PATH_DRIVER_PRIVATE_DATA;
41
42 #define MAX_CHAR 480
43
44 #define MIN_ALIGNMENT_SIZE sizeof(UINTN)
45 #define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)
46
47 #define IS_COMMA(a) ((a) == L',')
48 #define IS_HYPHEN(a) ((a) == L'-')
49 #define IS_DOT(a) ((a) == L'.')
50 #define IS_LEFT_PARENTH(a) ((a) == L'(')
51 #define IS_RIGHT_PARENTH(a) ((a) == L')')
52 #define IS_SLASH(a) ((a) == L'/')
53 #define IS_NULL(a) ((a) == L'\0')
54
55 #define DEVICE_NODE_END 1
56 #define DEVICE_PATH_INSTANCE_END 2
57 #define DEVICE_PATH_END 3
58
59 #define SetDevicePathInstanceEndNode(a) { \
60 (a)->Type = END_DEVICE_PATH_TYPE; \
61 (a)->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; \
62 (a)->Length[0] = sizeof (EFI_DEVICE_PATH_PROTOCOL); \
63 (a)->Length[1] = 0; \
64 }
65
66 //
67 // Private Data structure
68 //
69 typedef struct {
70 CHAR16 *Str;
71 UINTN Len;
72 UINTN MaxLen;
73 } POOL_PRINT;
74
75 typedef struct {
76 UINT8 Type;
77 UINT8 SubType;
78 VOID (*Function) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);
79 } DEVICE_PATH_TO_TEXT_TABLE;
80
81 typedef struct {
82 CHAR16 *DevicePathNodeText;
83 EFI_DEVICE_PATH_PROTOCOL * (*Function) (CHAR16 *);
84 } DEVICE_PATH_FROM_TEXT_TABLE;
85
86 typedef struct {
87 BOOLEAN ClassExist;
88 UINT8 Class;
89 BOOLEAN SubClassExist;
90 UINT8 SubClass;
91 } USB_CLASS_TEXT;
92
93 #define USB_CLASS_AUDIO 1
94 #define USB_CLASS_CDCCONTROL 2
95 #define USB_CLASS_HID 3
96 #define USB_CLASS_IMAGE 6
97 #define USB_CLASS_PRINTER 7
98 #define USB_CLASS_MASS_STORAGE 8
99 #define USB_CLASS_HUB 9
100 #define USB_CLASS_CDCDATA 10
101 #define USB_CLASS_SMART_CARD 11
102 #define USB_CLASS_VIDEO 14
103 #define USB_CLASS_DIAGNOSTIC 220
104 #define USB_CLASS_WIRELESS 224
105
106 #define USB_CLASS_RESERVE 254
107 #define USB_SUBCLASS_FW_UPDATE 1
108 #define USB_SUBCLASS_IRDA_BRIDGE 2
109 #define USB_SUBCLASS_TEST 3
110
111 typedef struct {
112 EFI_DEVICE_PATH_PROTOCOL Header;
113 EFI_GUID Guid;
114 UINT8 VendorDefinedData[1];
115 } VENDOR_DEFINED_HARDWARE_DEVICE_PATH;
116
117 typedef struct {
118 EFI_DEVICE_PATH_PROTOCOL Header;
119 EFI_GUID Guid;
120 UINT8 VendorDefinedData[1];
121 } VENDOR_DEFINED_MESSAGING_DEVICE_PATH;
122
123 typedef struct {
124 EFI_DEVICE_PATH_PROTOCOL Header;
125 EFI_GUID Guid;
126 UINT8 VendorDefinedData[1];
127 } VENDOR_DEFINED_MEDIA_DEVICE_PATH;
128
129 typedef struct {
130 EFI_DEVICE_PATH_PROTOCOL Header;
131 UINT32 HID;
132 UINT32 UID;
133 UINT32 CID;
134 CHAR8 HidUidCidStr[3];
135 } ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR;
136
137 typedef struct {
138 EFI_DEVICE_PATH_PROTOCOL Header;
139 UINT16 NetworkProtocol;
140 UINT16 LoginOption;
141 UINT16 Reserved;
142 UINT16 TargetPortalGroupTag;
143 UINT64 Lun;
144 CHAR16 iSCSITargetName[1];
145 } ISCSI_DEVICE_PATH_WITH_NAME;
146
147 typedef struct {
148 EFI_DEVICE_PATH_PROTOCOL Header;
149 EFI_GUID Guid;
150 UINT8 VendorDefinedData[1];
151 } VENDOR_DEVICE_PATH_WITH_DATA;
152
153 CHAR16 *
154 ConvertDeviceNodeToText (
155 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
156 IN BOOLEAN DisplayOnly,
157 IN BOOLEAN AllowShortcuts
158 )
159 /*++
160
161 Routine Description:
162 Convert a device node to its text representation.
163
164 Arguments:
165 DeviceNode - Points to the device node to be converted.
166 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
167 of the display node is used, where applicable. If DisplayOnly
168 is FALSE, then the longer text representation of the display node
169 is used.
170 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
171 representation for a device node can be used, where applicable.
172
173 Returns:
174 A pointer - a pointer to the allocated text representation of the device node.
175 NULL - if DeviceNode is NULL or there was insufficient memory.
176
177 --*/
178 ;
179
180 CHAR16 *
181 ConvertDevicePathToText (
182 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
183 IN BOOLEAN DisplayOnly,
184 IN BOOLEAN AllowShortcuts
185 )
186 /*++
187
188 Routine Description:
189 Convert a device path to its text representation.
190
191 Arguments:
192 DeviceNode - Points to the device path to be converted.
193 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
194 of the display node is used, where applicable. If DisplayOnly
195 is FALSE, then the longer text representation of the display node
196 is used.
197 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
198 representation for a device node can be used, where applicable.
199
200 Returns:
201 A pointer - a pointer to the allocated text representation of the device path.
202 NULL - if DeviceNode is NULL or there was insufficient memory.
203
204 --*/
205 ;
206
207 EFI_DEVICE_PATH_PROTOCOL *
208 ConvertTextToDeviceNode (
209 IN CONST CHAR16 *TextDeviceNode
210 )
211 /*++
212
213 Routine Description:
214 Convert text to the binary representation of a device node.
215
216 Arguments:
217 TextDeviceNode - TextDeviceNode points to the text representation of a device
218 node. Conversion starts with the first character and continues
219 until the first non-device node character.
220
221 Returns:
222 A pointer - Pointer to the EFI device node.
223 NULL - if TextDeviceNode is NULL or there was insufficient memory.
224
225 --*/
226 ;
227
228 EFI_DEVICE_PATH_PROTOCOL *
229 ConvertTextToDevicePath (
230 IN CONST CHAR16 *TextDevicePath
231 )
232 /*++
233
234 Routine Description:
235 Convert text to the binary representation of a device path.
236
237 Arguments:
238 TextDevicePath - TextDevicePath points to the text representation of a device
239 path. Conversion starts with the first character and continues
240 until the first non-device node character.
241
242 Returns:
243 A pointer - Pointer to the allocated device path.
244 NULL - if TextDeviceNode is NULL or there was insufficient memory.
245
246 --*/
247 ;
248
249 UINTN
250 GetDevicePathSize (
251 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
252 )
253 /*++
254
255 Routine Description:
256 Returns the size of the device path, in bytes.
257
258 Arguments:
259 DevicePath - Points to the start of the EFI device path.
260
261 Returns:
262 Size - Size of the specified device path, in bytes, including the end-of-path tag.
263
264 --*/
265 ;
266
267 EFI_DEVICE_PATH_PROTOCOL *
268 DuplicateDevicePath (
269 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
270 )
271 /*++
272
273 Routine Description:
274 Create a duplicate of the specified path.
275
276 Arguments:
277 DevicePath - Points to the source EFI device path.
278
279 Returns:
280 Pointer - A pointer to the duplicate device path.
281 NULL - Insufficient memory.
282
283 --*/
284 ;
285
286 EFI_DEVICE_PATH_PROTOCOL *
287 AppendDevicePath (
288 IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,
289 IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2
290 )
291 /*++
292
293 Routine Description:
294 Create a new path by appending the second device path to the first.
295
296 Arguments:
297 Src1 - Points to the first device path. If NULL, then it is ignored.
298 Src2 - Points to the second device path. If NULL, then it is ignored.
299
300 Returns:
301 Pointer - A pointer to the newly created device path.
302 NULL - Memory could not be allocated
303 or either DevicePath or DeviceNode is NULL.
304
305 --*/
306 ;
307
308 EFI_DEVICE_PATH_PROTOCOL *
309 AppendDeviceNode (
310 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
311 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode
312 )
313 /*++
314
315 Routine Description:
316 Creates a new path by appending the device node to the device path.
317
318 Arguments:
319 DevicePath - Points to the device path.
320 DeviceNode - Points to the device node.
321
322 Returns:
323 Pointer - A pointer to the allocated device node.
324 NULL - Memory could not be allocated
325 or either DevicePath or DeviceNode is NULL.
326
327 --*/
328 ;
329
330 EFI_DEVICE_PATH_PROTOCOL *
331 AppendDevicePathInstance (
332 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
333 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
334 )
335 /*++
336
337 Routine Description:
338 Creates a new path by appending the specified device path instance to the specified device path.
339
340 Arguments:
341 DevicePath - Points to the device path. If NULL, then ignored.
342 DevicePathInstance - Points to the device path instance.
343
344 Returns:
345 Pointer - A pointer to the newly created device path
346 NULL - Memory could not be allocated or DevicePathInstance is NULL.
347
348 --*/
349 ;
350
351 EFI_DEVICE_PATH_PROTOCOL *
352 GetNextDevicePathInstance (
353 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,
354 OUT UINTN *DevicePathInstanceSize
355 )
356 /*++
357
358 Routine Description:
359 Creates a copy of the current device path instance and returns a pointer to the next device path instance.
360
361 Arguments:
362 DevicePathInstance - On input, this holds the pointer to the current device path
363 instance. On output, this holds the pointer to the next
364 device path instance or NULL if there are no more device
365 path instances in the device path.
366 DevicePathInstanceSize - On output, this holds the size of the device path instance,
367 in bytes or zero, if DevicePathInstance is zero.
368
369 Returns:
370 Pointer - A pointer to the copy of the current device path instance.
371 NULL - DevicePathInstace was NULL on entry or there was insufficient memory.
372
373 --*/
374 ;
375
376 BOOLEAN
377 IsDevicePathMultiInstance (
378 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
379 )
380 /*++
381
382 Routine Description:
383 Returns whether a device path is multi-instance.
384
385 Arguments:
386 DevicePath - Points to the device path. If NULL, then ignored.
387
388 Returns:
389 TRUE - The device path has more than one instance
390 FALSE - The device path is empty or contains only a single instance.
391
392 --*/
393 ;
394
395 EFI_DEVICE_PATH_PROTOCOL *
396 CreateDeviceNode (
397 IN UINT8 NodeType,
398 IN UINT8 NodeSubType,
399 IN UINT16 NodeLength
400 )
401 /*++
402
403 Routine Description:
404 Creates a device node
405
406 Arguments:
407 NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for
408 the new device node.
409 NodeSubType - NodeSubType is the device node sub-type
410 EFI_DEVICE_PATH.SubType) for the new device node.
411 NodeLength - NodeLength is the length of the device node
412 (EFI_DEVICE_PATH.Length) for the new device node.
413
414 Returns:
415 Pointer - A pointer to the newly created device node.
416 NULL - NodeLength is less than
417 the size of the header or there was insufficient memory.
418
419 --*/
420 ;
421
422 #endif