]>
Commit | Line | Data |
---|---|---|
7dbc50bd YZ |
1 | /** @file\r |
2 | DevicePathFromText protocol as defined in the UEFI 2.0 specification.\r | |
3 | \r | |
46cced28 | 4 | Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>\r |
2e351cbe | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
7dbc50bd YZ |
6 | \r |
7 | **/\r | |
8 | \r | |
9 | #include "UefiDevicePathLib.h"\r | |
10 | \r | |
11 | /**\r | |
12 | \r | |
13 | Duplicates a string.\r | |
14 | \r | |
15 | @param Src Source string.\r | |
16 | \r | |
17 | @return The duplicated string.\r | |
18 | \r | |
19 | **/\r | |
20 | CHAR16 *\r | |
21 | UefiDevicePathLibStrDuplicate (\r | |
22 | CONST CHAR16 *Src\r | |
23 | )\r | |
24 | {\r | |
25 | return AllocateCopyPool (StrSize (Src), Src);\r | |
26 | }\r | |
27 | \r | |
28 | /**\r | |
29 | \r | |
30 | Get parameter in a pair of parentheses follow the given node name.\r | |
31 | For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".\r | |
32 | \r | |
33 | @param Str Device Path Text.\r | |
34 | @param NodeName Name of the node.\r | |
35 | \r | |
36 | @return Parameter text for the node.\r | |
37 | \r | |
38 | **/\r | |
39 | CHAR16 *\r | |
40 | GetParamByNodeName (\r | |
41 | CHAR16 *Str,\r | |
42 | CHAR16 *NodeName\r | |
43 | )\r | |
44 | {\r | |
45 | CHAR16 *ParamStr;\r | |
46 | CHAR16 *StrPointer;\r | |
47 | UINTN NodeNameLength;\r | |
48 | UINTN ParameterLength;\r | |
49 | \r | |
50 | //\r | |
51 | // Check whether the node name matchs\r | |
52 | //\r | |
53 | NodeNameLength = StrLen (NodeName);\r | |
54 | if (StrnCmp (Str, NodeName, NodeNameLength) != 0) {\r | |
55 | return NULL;\r | |
56 | }\r | |
57 | \r | |
58 | ParamStr = Str + NodeNameLength;\r | |
59 | if (!IS_LEFT_PARENTH (*ParamStr)) {\r | |
60 | return NULL;\r | |
61 | }\r | |
62 | \r | |
63 | //\r | |
64 | // Skip the found '(' and find first occurrence of ')'\r | |
65 | //\r | |
66 | ParamStr++;\r | |
67 | ParameterLength = 0;\r | |
68 | StrPointer = ParamStr;\r | |
69 | while (!IS_NULL (*StrPointer)) {\r | |
70 | if (IS_RIGHT_PARENTH (*StrPointer)) {\r | |
71 | break;\r | |
72 | }\r | |
73 | StrPointer++;\r | |
74 | ParameterLength++;\r | |
75 | }\r | |
76 | if (IS_NULL (*StrPointer)) {\r | |
77 | //\r | |
78 | // ')' not found\r | |
79 | //\r | |
80 | return NULL;\r | |
81 | }\r | |
82 | \r | |
83 | ParamStr = AllocateCopyPool ((ParameterLength + 1) * sizeof (CHAR16), ParamStr);\r | |
84 | if (ParamStr == NULL) {\r | |
85 | return NULL;\r | |
86 | }\r | |
87 | //\r | |
88 | // Terminate the parameter string\r | |
89 | //\r | |
90 | ParamStr[ParameterLength] = L'\0';\r | |
91 | \r | |
92 | return ParamStr;\r | |
93 | }\r | |
94 | \r | |
95 | /**\r | |
96 | Gets the next parameter string from the list.\r | |
97 | \r | |
98 | @param List A string list separated by the specified separator\r | |
99 | \r | |
100 | @return A pointer to the current sub-string\r | |
101 | \r | |
102 | **/\r | |
103 | CHAR16 *\r | |
104 | GetNextParamStr (\r | |
105 | CHAR16 **List\r | |
106 | )\r | |
107 | {\r | |
108 | //\r | |
109 | // The separator is comma\r | |
110 | //\r | |
111 | return SplitStr (List, L',');\r | |
112 | }\r | |
113 | \r | |
114 | /**\r | |
115 | Get one device node from entire device path text.\r | |
116 | \r | |
117 | @param DevicePath On input, the current Device Path node; on output, the next device path node\r | |
118 | @param IsInstanceEnd This node is the end of a device path instance\r | |
119 | \r | |
120 | @return A device node text or NULL if no more device node available\r | |
121 | \r | |
122 | **/\r | |
123 | CHAR16 *\r | |
124 | GetNextDeviceNodeStr (\r | |
125 | CHAR16 **DevicePath,\r | |
126 | BOOLEAN *IsInstanceEnd\r | |
127 | )\r | |
128 | {\r | |
129 | CHAR16 *Str;\r | |
130 | CHAR16 *ReturnStr;\r | |
131 | UINTN ParenthesesStack;\r | |
132 | \r | |
133 | Str = *DevicePath;\r | |
134 | if (IS_NULL (*Str)) {\r | |
135 | return NULL;\r | |
136 | }\r | |
137 | \r | |
138 | //\r | |
139 | // Skip the leading '/', '(', ')' and ','\r | |
140 | //\r | |
141 | while (!IS_NULL (*Str)) {\r | |
142 | if (!IS_SLASH (*Str) &&\r | |
143 | !IS_COMMA (*Str) &&\r | |
144 | !IS_LEFT_PARENTH (*Str) &&\r | |
145 | !IS_RIGHT_PARENTH (*Str)) {\r | |
146 | break;\r | |
147 | }\r | |
148 | Str++;\r | |
149 | }\r | |
150 | \r | |
151 | ReturnStr = Str;\r | |
152 | \r | |
153 | //\r | |
154 | // Scan for the separator of this device node, '/' or ','\r | |
155 | //\r | |
156 | ParenthesesStack = 0;\r | |
157 | while (!IS_NULL (*Str)) {\r | |
158 | if ((IS_COMMA (*Str) || IS_SLASH (*Str)) && (ParenthesesStack == 0)) {\r | |
159 | break;\r | |
160 | }\r | |
161 | \r | |
162 | if (IS_LEFT_PARENTH (*Str)) {\r | |
163 | ParenthesesStack++;\r | |
164 | } else if (IS_RIGHT_PARENTH (*Str)) {\r | |
165 | ParenthesesStack--;\r | |
166 | }\r | |
167 | \r | |
168 | Str++;\r | |
169 | }\r | |
170 | \r | |
171 | if (ParenthesesStack != 0) {\r | |
172 | //\r | |
173 | // The '(' doesn't pair with ')', invalid device path text\r | |
174 | //\r | |
175 | return NULL;\r | |
176 | }\r | |
177 | \r | |
178 | if (IS_COMMA (*Str)) {\r | |
179 | *IsInstanceEnd = TRUE;\r | |
180 | *Str = L'\0';\r | |
181 | Str++;\r | |
182 | } else {\r | |
183 | *IsInstanceEnd = FALSE;\r | |
184 | if (!IS_NULL (*Str)) {\r | |
185 | *Str = L'\0';\r | |
186 | Str++;\r | |
187 | }\r | |
188 | }\r | |
189 | \r | |
190 | *DevicePath = Str;\r | |
191 | \r | |
192 | return ReturnStr;\r | |
193 | }\r | |
194 | \r | |
195 | /**\r | |
196 | Converts a generic text device path node to device path structure.\r | |
197 | \r | |
198 | @param Type The type of the device path node.\r | |
199 | @param TextDeviceNode The input text device path node.\r | |
200 | \r | |
201 | @return A pointer to device path structure.\r | |
202 | **/\r | |
203 | EFI_DEVICE_PATH_PROTOCOL *\r | |
204 | DevPathFromTextGenericPath (\r | |
205 | UINT8 Type,\r | |
206 | CHAR16 *TextDeviceNode\r | |
207 | )\r | |
208 | {\r | |
209 | EFI_DEVICE_PATH_PROTOCOL *Node;\r | |
210 | CHAR16 *SubtypeStr;\r | |
211 | CHAR16 *DataStr;\r | |
212 | UINTN DataLength;\r | |
213 | \r | |
214 | SubtypeStr = GetNextParamStr (&TextDeviceNode);\r | |
215 | DataStr = GetNextParamStr (&TextDeviceNode);\r | |
216 | \r | |
217 | if (DataStr == NULL) {\r | |
218 | DataLength = 0;\r | |
219 | } else {\r | |
220 | DataLength = StrLen (DataStr) / 2;\r | |
221 | }\r | |
222 | Node = CreateDeviceNode (\r | |
223 | Type,\r | |
224 | (UINT8) Strtoi (SubtypeStr),\r | |
225 | (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength)\r | |
226 | );\r | |
227 | \r | |
228 | StrHexToBytes (DataStr, DataLength * 2, (UINT8 *) (Node + 1), DataLength);\r | |
229 | return Node;\r | |
230 | }\r | |
231 | \r | |
232 | /**\r | |
233 | Converts a generic text device path node to device path structure.\r | |
234 | \r | |
235 | @param TextDeviceNode The input Text device path node.\r | |
236 | \r | |
237 | @return A pointer to device path structure.\r | |
238 | \r | |
239 | **/\r | |
240 | EFI_DEVICE_PATH_PROTOCOL *\r | |
241 | DevPathFromTextPath (\r | |
242 | CHAR16 *TextDeviceNode\r | |
243 | )\r | |
244 | {\r | |
245 | CHAR16 *TypeStr;\r | |
246 | \r | |
247 | TypeStr = GetNextParamStr (&TextDeviceNode);\r | |
248 | \r | |
249 | return DevPathFromTextGenericPath ((UINT8) Strtoi (TypeStr), TextDeviceNode);\r | |
250 | }\r | |
251 | \r | |
252 | /**\r | |
253 | Converts a generic hardware text device path node to Hardware device path structure.\r | |
254 | \r | |
255 | @param TextDeviceNode The input Text device path node.\r | |
256 | \r | |
257 | @return A pointer to Hardware device path structure.\r | |
258 | \r | |
259 | **/\r | |
260 | EFI_DEVICE_PATH_PROTOCOL *\r | |
261 | DevPathFromTextHardwarePath (\r | |
262 | CHAR16 *TextDeviceNode\r | |
263 | )\r | |
264 | {\r | |
265 | return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH, TextDeviceNode);\r | |
266 | }\r | |
267 | \r | |
268 | /**\r | |
269 | Converts a text device path node to Hardware PCI device path structure.\r | |
270 | \r | |
271 | @param TextDeviceNode The input Text device path node.\r | |
272 | \r | |
273 | @return A pointer to Hardware PCI device path structure.\r | |
274 | \r | |
275 | **/\r | |
276 | EFI_DEVICE_PATH_PROTOCOL *\r | |
277 | DevPathFromTextPci (\r | |
278 | CHAR16 *TextDeviceNode\r | |
279 | )\r | |
280 | {\r | |
281 | CHAR16 *FunctionStr;\r | |
282 | CHAR16 *DeviceStr;\r | |
283 | PCI_DEVICE_PATH *Pci;\r | |
284 | \r | |
285 | DeviceStr = GetNextParamStr (&TextDeviceNode);\r | |
286 | FunctionStr = GetNextParamStr (&TextDeviceNode);\r | |
287 | Pci = (PCI_DEVICE_PATH *) CreateDeviceNode (\r | |
288 | HARDWARE_DEVICE_PATH,\r | |
289 | HW_PCI_DP,\r | |
290 | (UINT16) sizeof (PCI_DEVICE_PATH)\r | |
291 | );\r | |
292 | \r | |
293 | Pci->Function = (UINT8) Strtoi (FunctionStr);\r | |
294 | Pci->Device = (UINT8) Strtoi (DeviceStr);\r | |
295 | \r | |
296 | return (EFI_DEVICE_PATH_PROTOCOL *) Pci;\r | |
297 | }\r | |
298 | \r | |
299 | /**\r | |
300 | Converts a text device path node to Hardware PC card device path structure.\r | |
301 | \r | |
302 | @param TextDeviceNode The input Text device path node.\r | |
303 | \r | |
304 | @return A pointer to Hardware PC card device path structure.\r | |
305 | \r | |
306 | **/\r | |
307 | EFI_DEVICE_PATH_PROTOCOL *\r | |
308 | DevPathFromTextPcCard (\r | |
309 | CHAR16 *TextDeviceNode\r | |
310 | )\r | |
311 | {\r | |
312 | CHAR16 *FunctionNumberStr;\r | |
313 | PCCARD_DEVICE_PATH *Pccard;\r | |
314 | \r | |
315 | FunctionNumberStr = GetNextParamStr (&TextDeviceNode);\r | |
316 | Pccard = (PCCARD_DEVICE_PATH *) CreateDeviceNode (\r | |
317 | HARDWARE_DEVICE_PATH,\r | |
318 | HW_PCCARD_DP,\r | |
319 | (UINT16) sizeof (PCCARD_DEVICE_PATH)\r | |
320 | );\r | |
321 | \r | |
322 | Pccard->FunctionNumber = (UINT8) Strtoi (FunctionNumberStr);\r | |
323 | \r | |
324 | return (EFI_DEVICE_PATH_PROTOCOL *) Pccard;\r | |
325 | }\r | |
326 | \r | |
327 | /**\r | |
328 | Converts a text device path node to Hardware memory map device path structure.\r | |
329 | \r | |
330 | @param TextDeviceNode The input Text device path node.\r | |
331 | \r | |
332 | @return A pointer to Hardware memory map device path structure.\r | |
333 | \r | |
334 | **/\r | |
335 | EFI_DEVICE_PATH_PROTOCOL *\r | |
336 | DevPathFromTextMemoryMapped (\r | |
337 | CHAR16 *TextDeviceNode\r | |
338 | )\r | |
339 | {\r | |
340 | CHAR16 *MemoryTypeStr;\r | |
341 | CHAR16 *StartingAddressStr;\r | |
342 | CHAR16 *EndingAddressStr;\r | |
343 | MEMMAP_DEVICE_PATH *MemMap;\r | |
344 | \r | |
345 | MemoryTypeStr = GetNextParamStr (&TextDeviceNode);\r | |
346 | StartingAddressStr = GetNextParamStr (&TextDeviceNode);\r | |
347 | EndingAddressStr = GetNextParamStr (&TextDeviceNode);\r | |
348 | MemMap = (MEMMAP_DEVICE_PATH *) CreateDeviceNode (\r | |
349 | HARDWARE_DEVICE_PATH,\r | |
350 | HW_MEMMAP_DP,\r | |
351 | (UINT16) sizeof (MEMMAP_DEVICE_PATH)\r | |
352 | );\r | |
353 | \r | |
354 | MemMap->MemoryType = (UINT32) Strtoi (MemoryTypeStr);\r | |
355 | Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);\r | |
356 | Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);\r | |
357 | \r | |
358 | return (EFI_DEVICE_PATH_PROTOCOL *) MemMap;\r | |
359 | }\r | |
360 | \r | |
361 | /**\r | |
362 | Converts a text device path node to Vendor device path structure based on the input Type\r | |
363 | and SubType.\r | |
364 | \r | |
365 | @param TextDeviceNode The input Text device path node.\r | |
366 | @param Type The type of device path node.\r | |
367 | @param SubType The subtype of device path node.\r | |
368 | \r | |
369 | @return A pointer to the newly-created Vendor device path structure.\r | |
370 | \r | |
371 | **/\r | |
372 | EFI_DEVICE_PATH_PROTOCOL *\r | |
373 | ConvertFromTextVendor (\r | |
374 | CHAR16 *TextDeviceNode,\r | |
375 | UINT8 Type,\r | |
376 | UINT8 SubType\r | |
377 | )\r | |
378 | {\r | |
379 | CHAR16 *GuidStr;\r | |
380 | CHAR16 *DataStr;\r | |
381 | UINTN Length;\r | |
382 | VENDOR_DEVICE_PATH *Vendor;\r | |
383 | \r | |
384 | GuidStr = GetNextParamStr (&TextDeviceNode);\r | |
385 | \r | |
386 | DataStr = GetNextParamStr (&TextDeviceNode);\r | |
387 | Length = StrLen (DataStr);\r | |
388 | //\r | |
389 | // Two hex characters make up 1 buffer byte\r | |
390 | //\r | |
391 | Length = (Length + 1) / 2;\r | |
392 | \r | |
393 | Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r | |
394 | Type,\r | |
395 | SubType,\r | |
396 | (UINT16) (sizeof (VENDOR_DEVICE_PATH) + Length)\r | |
397 | );\r | |
398 | \r | |
399 | StrToGuid (GuidStr, &Vendor->Guid);\r | |
400 | StrHexToBytes (DataStr, Length * 2, (UINT8 *) (Vendor + 1), Length);\r | |
401 | \r | |
402 | return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r | |
403 | }\r | |
404 | \r | |
405 | /**\r | |
406 | Converts a text device path node to Vendor Hardware device path structure.\r | |
407 | \r | |
408 | @param TextDeviceNode The input Text device path node.\r | |
409 | \r | |
410 | @return A pointer to the newly-created Vendor Hardware device path structure.\r | |
411 | \r | |
412 | **/\r | |
413 | EFI_DEVICE_PATH_PROTOCOL *\r | |
414 | DevPathFromTextVenHw (\r | |
415 | CHAR16 *TextDeviceNode\r | |
416 | )\r | |
417 | {\r | |
418 | return ConvertFromTextVendor (\r | |
419 | TextDeviceNode,\r | |
420 | HARDWARE_DEVICE_PATH,\r | |
421 | HW_VENDOR_DP\r | |
422 | );\r | |
423 | }\r | |
424 | \r | |
425 | /**\r | |
426 | Converts a text device path node to Hardware Controller device path structure.\r | |
427 | \r | |
428 | @param TextDeviceNode The input Text device path node.\r | |
429 | \r | |
430 | @return A pointer to the newly-created Hardware Controller device path structure.\r | |
431 | \r | |
432 | **/\r | |
433 | EFI_DEVICE_PATH_PROTOCOL *\r | |
434 | DevPathFromTextCtrl (\r | |
435 | CHAR16 *TextDeviceNode\r | |
436 | )\r | |
437 | {\r | |
438 | CHAR16 *ControllerStr;\r | |
439 | CONTROLLER_DEVICE_PATH *Controller;\r | |
440 | \r | |
441 | ControllerStr = GetNextParamStr (&TextDeviceNode);\r | |
442 | Controller = (CONTROLLER_DEVICE_PATH *) CreateDeviceNode (\r | |
443 | HARDWARE_DEVICE_PATH,\r | |
444 | HW_CONTROLLER_DP,\r | |
445 | (UINT16) sizeof (CONTROLLER_DEVICE_PATH)\r | |
446 | );\r | |
447 | Controller->ControllerNumber = (UINT32) Strtoi (ControllerStr);\r | |
448 | \r | |
449 | return (EFI_DEVICE_PATH_PROTOCOL *) Controller;\r | |
450 | }\r | |
451 | \r | |
452 | /**\r | |
453 | Converts a text device path node to BMC device path structure.\r | |
454 | \r | |
455 | @param TextDeviceNode The input Text device path node.\r | |
456 | \r | |
457 | @return A pointer to the newly-created BMC device path structure.\r | |
458 | \r | |
459 | **/\r | |
460 | EFI_DEVICE_PATH_PROTOCOL *\r | |
461 | DevPathFromTextBmc (\r | |
462 | CHAR16 *TextDeviceNode\r | |
463 | )\r | |
464 | {\r | |
465 | CHAR16 *InterfaceTypeStr;\r | |
466 | CHAR16 *BaseAddressStr;\r | |
467 | BMC_DEVICE_PATH *BmcDp;\r | |
468 | \r | |
469 | InterfaceTypeStr = GetNextParamStr (&TextDeviceNode);\r | |
470 | BaseAddressStr = GetNextParamStr (&TextDeviceNode);\r | |
471 | BmcDp = (BMC_DEVICE_PATH *) CreateDeviceNode (\r | |
472 | HARDWARE_DEVICE_PATH,\r | |
473 | HW_BMC_DP,\r | |
474 | (UINT16) sizeof (BMC_DEVICE_PATH)\r | |
475 | );\r | |
476 | \r | |
477 | BmcDp->InterfaceType = (UINT8) Strtoi (InterfaceTypeStr);\r | |
478 | WriteUnaligned64 (\r | |
479 | (UINT64 *) (&BmcDp->BaseAddress),\r | |
480 | StrHexToUint64 (BaseAddressStr)\r | |
481 | );\r | |
482 | \r | |
483 | return (EFI_DEVICE_PATH_PROTOCOL *) BmcDp;\r | |
484 | }\r | |
485 | \r | |
486 | /**\r | |
487 | Converts a generic ACPI text device path node to ACPI device path structure.\r | |
488 | \r | |
489 | @param TextDeviceNode The input Text device path node.\r | |
490 | \r | |
491 | @return A pointer to ACPI device path structure.\r | |
492 | \r | |
493 | **/\r | |
494 | EFI_DEVICE_PATH_PROTOCOL *\r | |
495 | DevPathFromTextAcpiPath (\r | |
496 | CHAR16 *TextDeviceNode\r | |
497 | )\r | |
498 | {\r | |
499 | return DevPathFromTextGenericPath (ACPI_DEVICE_PATH, TextDeviceNode);\r | |
500 | }\r | |
501 | \r | |
502 | /**\r | |
503 | Converts a string to EisaId.\r | |
504 | \r | |
505 | @param Text The input string.\r | |
506 | \r | |
507 | @return UINT32 EISA ID.\r | |
508 | **/\r | |
509 | UINT32\r | |
510 | EisaIdFromText (\r | |
511 | CHAR16 *Text\r | |
512 | )\r | |
513 | {\r | |
514 | return (((Text[0] - 'A' + 1) & 0x1f) << 10)\r | |
515 | + (((Text[1] - 'A' + 1) & 0x1f) << 5)\r | |
516 | + (((Text[2] - 'A' + 1) & 0x1f) << 0)\r | |
6e2d15e3 | 517 | + (UINT32) (StrHexToUint64 (&Text[3]) << 16)\r |
7dbc50bd YZ |
518 | ;\r |
519 | }\r | |
520 | \r | |
521 | /**\r | |
522 | Converts a text device path node to ACPI HID device path structure.\r | |
523 | \r | |
524 | @param TextDeviceNode The input Text device path node.\r | |
525 | \r | |
526 | @return A pointer to the newly-created ACPI HID device path structure.\r | |
527 | \r | |
528 | **/\r | |
529 | EFI_DEVICE_PATH_PROTOCOL *\r | |
530 | DevPathFromTextAcpi (\r | |
531 | CHAR16 *TextDeviceNode\r | |
532 | )\r | |
533 | {\r | |
534 | CHAR16 *HIDStr;\r | |
535 | CHAR16 *UIDStr;\r | |
536 | ACPI_HID_DEVICE_PATH *Acpi;\r | |
537 | \r | |
538 | HIDStr = GetNextParamStr (&TextDeviceNode);\r | |
539 | UIDStr = GetNextParamStr (&TextDeviceNode);\r | |
540 | Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r | |
541 | ACPI_DEVICE_PATH,\r | |
542 | ACPI_DP,\r | |
543 | (UINT16) sizeof (ACPI_HID_DEVICE_PATH)\r | |
544 | );\r | |
545 | \r | |
546 | Acpi->HID = EisaIdFromText (HIDStr);\r | |
547 | Acpi->UID = (UINT32) Strtoi (UIDStr);\r | |
548 | \r | |
549 | return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r | |
550 | }\r | |
551 | \r | |
552 | /**\r | |
553 | Converts a text device path node to ACPI HID device path structure.\r | |
554 | \r | |
555 | @param TextDeviceNode The input Text device path node.\r | |
556 | @param PnPId The input plug and play identification.\r | |
557 | \r | |
558 | @return A pointer to the newly-created ACPI HID device path structure.\r | |
559 | \r | |
560 | **/\r | |
561 | EFI_DEVICE_PATH_PROTOCOL *\r | |
562 | ConvertFromTextAcpi (\r | |
563 | CHAR16 *TextDeviceNode,\r | |
564 | UINT32 PnPId\r | |
565 | )\r | |
566 | {\r | |
567 | CHAR16 *UIDStr;\r | |
568 | ACPI_HID_DEVICE_PATH *Acpi;\r | |
569 | \r | |
570 | UIDStr = GetNextParamStr (&TextDeviceNode);\r | |
571 | Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r | |
572 | ACPI_DEVICE_PATH,\r | |
573 | ACPI_DP,\r | |
574 | (UINT16) sizeof (ACPI_HID_DEVICE_PATH)\r | |
575 | );\r | |
576 | \r | |
577 | Acpi->HID = EFI_PNP_ID (PnPId);\r | |
578 | Acpi->UID = (UINT32) Strtoi (UIDStr);\r | |
579 | \r | |
580 | return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r | |
581 | }\r | |
582 | \r | |
583 | /**\r | |
584 | Converts a text device path node to PCI root device path structure.\r | |
585 | \r | |
586 | @param TextDeviceNode The input Text device path node.\r | |
587 | \r | |
588 | @return A pointer to the newly-created PCI root device path structure.\r | |
589 | \r | |
590 | **/\r | |
591 | EFI_DEVICE_PATH_PROTOCOL *\r | |
592 | DevPathFromTextPciRoot (\r | |
593 | CHAR16 *TextDeviceNode\r | |
594 | )\r | |
595 | {\r | |
596 | return ConvertFromTextAcpi (TextDeviceNode, 0x0a03);\r | |
597 | }\r | |
598 | \r | |
599 | /**\r | |
600 | Converts a text device path node to PCIE root device path structure.\r | |
601 | \r | |
602 | @param TextDeviceNode The input Text device path node.\r | |
603 | \r | |
604 | @return A pointer to the newly-created PCIE root device path structure.\r | |
605 | \r | |
606 | **/\r | |
607 | EFI_DEVICE_PATH_PROTOCOL *\r | |
608 | DevPathFromTextPcieRoot (\r | |
609 | CHAR16 *TextDeviceNode\r | |
610 | )\r | |
611 | {\r | |
612 | return ConvertFromTextAcpi (TextDeviceNode, 0x0a08);\r | |
613 | }\r | |
614 | \r | |
615 | /**\r | |
616 | Converts a text device path node to Floppy device path structure.\r | |
617 | \r | |
618 | @param TextDeviceNode The input Text device path node.\r | |
619 | \r | |
620 | @return A pointer to the newly-created Floppy device path structure.\r | |
621 | \r | |
622 | **/\r | |
623 | EFI_DEVICE_PATH_PROTOCOL *\r | |
624 | DevPathFromTextFloppy (\r | |
625 | CHAR16 *TextDeviceNode\r | |
626 | )\r | |
627 | {\r | |
628 | return ConvertFromTextAcpi (TextDeviceNode, 0x0604);\r | |
629 | }\r | |
630 | \r | |
631 | /**\r | |
632 | Converts a text device path node to Keyboard device path structure.\r | |
633 | \r | |
634 | @param TextDeviceNode The input Text device path node.\r | |
635 | \r | |
636 | @return A pointer to the newly-created Keyboard device path structure.\r | |
637 | \r | |
638 | **/\r | |
639 | EFI_DEVICE_PATH_PROTOCOL *\r | |
640 | DevPathFromTextKeyboard (\r | |
641 | CHAR16 *TextDeviceNode\r | |
642 | )\r | |
643 | {\r | |
644 | return ConvertFromTextAcpi (TextDeviceNode, 0x0301);\r | |
645 | }\r | |
646 | \r | |
647 | /**\r | |
648 | Converts a text device path node to Serial device path structure.\r | |
649 | \r | |
650 | @param TextDeviceNode The input Text device path node.\r | |
651 | \r | |
652 | @return A pointer to the newly-created Serial device path structure.\r | |
653 | \r | |
654 | **/\r | |
655 | EFI_DEVICE_PATH_PROTOCOL *\r | |
656 | DevPathFromTextSerial (\r | |
657 | CHAR16 *TextDeviceNode\r | |
658 | )\r | |
659 | {\r | |
660 | return ConvertFromTextAcpi (TextDeviceNode, 0x0501);\r | |
661 | }\r | |
662 | \r | |
663 | /**\r | |
664 | Converts a text device path node to Parallel Port device path structure.\r | |
665 | \r | |
666 | @param TextDeviceNode The input Text device path node.\r | |
667 | \r | |
668 | @return A pointer to the newly-created Parallel Port device path structure.\r | |
669 | \r | |
670 | **/\r | |
671 | EFI_DEVICE_PATH_PROTOCOL *\r | |
672 | DevPathFromTextParallelPort (\r | |
673 | CHAR16 *TextDeviceNode\r | |
674 | )\r | |
675 | {\r | |
676 | return ConvertFromTextAcpi (TextDeviceNode, 0x0401);\r | |
677 | }\r | |
678 | \r | |
679 | /**\r | |
680 | Converts a text device path node to ACPI extension device path structure.\r | |
681 | \r | |
682 | @param TextDeviceNode The input Text device path node.\r | |
683 | \r | |
684 | @return A pointer to the newly-created ACPI extension device path structure.\r | |
685 | \r | |
686 | **/\r | |
687 | EFI_DEVICE_PATH_PROTOCOL *\r | |
688 | DevPathFromTextAcpiEx (\r | |
689 | CHAR16 *TextDeviceNode\r | |
690 | )\r | |
691 | {\r | |
692 | CHAR16 *HIDStr;\r | |
693 | CHAR16 *CIDStr;\r | |
694 | CHAR16 *UIDStr;\r | |
695 | CHAR16 *HIDSTRStr;\r | |
696 | CHAR16 *CIDSTRStr;\r | |
697 | CHAR16 *UIDSTRStr;\r | |
698 | CHAR8 *AsciiStr;\r | |
699 | UINT16 Length;\r | |
700 | ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;\r | |
701 | \r | |
702 | HIDStr = GetNextParamStr (&TextDeviceNode);\r | |
703 | CIDStr = GetNextParamStr (&TextDeviceNode);\r | |
704 | UIDStr = GetNextParamStr (&TextDeviceNode);\r | |
705 | HIDSTRStr = GetNextParamStr (&TextDeviceNode);\r | |
706 | CIDSTRStr = GetNextParamStr (&TextDeviceNode);\r | |
707 | UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r | |
708 | \r | |
709 | Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (HIDSTRStr) + 1);\r | |
710 | Length = (UINT16) (Length + StrLen (UIDSTRStr) + 1);\r | |
711 | Length = (UINT16) (Length + StrLen (CIDSTRStr) + 1);\r | |
712 | AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r | |
713 | ACPI_DEVICE_PATH,\r | |
714 | ACPI_EXTENDED_DP,\r | |
715 | Length\r | |
716 | );\r | |
717 | \r | |
718 | AcpiEx->HID = EisaIdFromText (HIDStr);\r | |
719 | AcpiEx->CID = EisaIdFromText (CIDStr);\r | |
720 | AcpiEx->UID = (UINT32) Strtoi (UIDStr);\r | |
721 | \r | |
722 | AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r | |
723 | StrToAscii (HIDSTRStr, &AsciiStr);\r | |
724 | StrToAscii (UIDSTRStr, &AsciiStr);\r | |
725 | StrToAscii (CIDSTRStr, &AsciiStr);\r | |
726 | \r | |
727 | return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r | |
728 | }\r | |
729 | \r | |
730 | /**\r | |
731 | Converts a text device path node to ACPI extension device path structure.\r | |
732 | \r | |
733 | @param TextDeviceNode The input Text device path node.\r | |
734 | \r | |
735 | @return A pointer to the newly-created ACPI extension device path structure.\r | |
736 | \r | |
737 | **/\r | |
738 | EFI_DEVICE_PATH_PROTOCOL *\r | |
739 | DevPathFromTextAcpiExp (\r | |
740 | CHAR16 *TextDeviceNode\r | |
741 | )\r | |
742 | {\r | |
743 | CHAR16 *HIDStr;\r | |
744 | CHAR16 *CIDStr;\r | |
745 | CHAR16 *UIDSTRStr;\r | |
746 | CHAR8 *AsciiStr;\r | |
747 | UINT16 Length;\r | |
748 | ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;\r | |
749 | \r | |
750 | HIDStr = GetNextParamStr (&TextDeviceNode);\r | |
751 | CIDStr = GetNextParamStr (&TextDeviceNode);\r | |
752 | UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r | |
753 | Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (UIDSTRStr) + 3);\r | |
754 | AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r | |
755 | ACPI_DEVICE_PATH,\r | |
756 | ACPI_EXTENDED_DP,\r | |
757 | Length\r | |
758 | );\r | |
759 | \r | |
760 | AcpiEx->HID = EisaIdFromText (HIDStr);\r | |
23a62c69 FY |
761 | //\r |
762 | // According to UEFI spec, the CID parametr is optional and has a default value of 0.\r | |
763 | // So when the CID parametr is not specified or specified as 0 in the text device node.\r | |
764 | // Set the CID to 0 in the ACPI extension device path structure.\r | |
765 | //\r | |
766 | if (*CIDStr == L'\0' || *CIDStr == L'0') {\r | |
767 | AcpiEx->CID = 0;\r | |
768 | } else {\r | |
769 | AcpiEx->CID = EisaIdFromText (CIDStr);\r | |
770 | }\r | |
7dbc50bd YZ |
771 | AcpiEx->UID = 0;\r |
772 | \r | |
773 | AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r | |
774 | //\r | |
775 | // HID string is NULL\r | |
776 | //\r | |
777 | *AsciiStr = '\0';\r | |
778 | //\r | |
779 | // Convert UID string\r | |
780 | //\r | |
781 | AsciiStr++;\r | |
782 | StrToAscii (UIDSTRStr, &AsciiStr);\r | |
783 | //\r | |
784 | // CID string is NULL\r | |
785 | //\r | |
786 | *AsciiStr = '\0';\r | |
787 | \r | |
788 | return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r | |
789 | }\r | |
790 | \r | |
791 | /**\r | |
792 | Converts a text device path node to ACPI _ADR device path structure.\r | |
793 | \r | |
794 | @param TextDeviceNode The input Text device path node.\r | |
795 | \r | |
796 | @return A pointer to the newly-created ACPI _ADR device path structure.\r | |
797 | \r | |
798 | **/\r | |
799 | EFI_DEVICE_PATH_PROTOCOL *\r | |
800 | DevPathFromTextAcpiAdr (\r | |
801 | CHAR16 *TextDeviceNode\r | |
802 | )\r | |
803 | {\r | |
804 | CHAR16 *DisplayDeviceStr;\r | |
805 | ACPI_ADR_DEVICE_PATH *AcpiAdr;\r | |
806 | UINTN Index;\r | |
807 | UINTN Length;\r | |
808 | \r | |
809 | AcpiAdr = (ACPI_ADR_DEVICE_PATH *) CreateDeviceNode (\r | |
810 | ACPI_DEVICE_PATH,\r | |
811 | ACPI_ADR_DP,\r | |
812 | (UINT16) sizeof (ACPI_ADR_DEVICE_PATH)\r | |
813 | );\r | |
814 | ASSERT (AcpiAdr != NULL);\r | |
815 | \r | |
816 | for (Index = 0; ; Index++) {\r | |
817 | DisplayDeviceStr = GetNextParamStr (&TextDeviceNode);\r | |
818 | if (IS_NULL (*DisplayDeviceStr)) {\r | |
819 | break;\r | |
820 | }\r | |
821 | if (Index > 0) {\r | |
822 | Length = DevicePathNodeLength (AcpiAdr);\r | |
823 | AcpiAdr = ReallocatePool (\r | |
824 | Length,\r | |
825 | Length + sizeof (UINT32),\r | |
826 | AcpiAdr\r | |
827 | );\r | |
828 | ASSERT (AcpiAdr != NULL);\r | |
829 | SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32));\r | |
830 | }\r | |
831 | \r | |
832 | (&AcpiAdr->ADR)[Index] = (UINT32) Strtoi (DisplayDeviceStr);\r | |
833 | }\r | |
834 | \r | |
835 | return (EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr;\r | |
836 | }\r | |
837 | \r | |
838 | /**\r | |
839 | Converts a generic messaging text device path node to messaging device path structure.\r | |
840 | \r | |
841 | @param TextDeviceNode The input Text device path node.\r | |
842 | \r | |
843 | @return A pointer to messaging device path structure.\r | |
844 | \r | |
845 | **/\r | |
846 | EFI_DEVICE_PATH_PROTOCOL *\r | |
847 | DevPathFromTextMsg (\r | |
848 | CHAR16 *TextDeviceNode\r | |
849 | )\r | |
850 | {\r | |
851 | return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH, TextDeviceNode);\r | |
852 | }\r | |
853 | \r | |
854 | /**\r | |
855 | Converts a text device path node to Parallel Port device path structure.\r | |
856 | \r | |
857 | @param TextDeviceNode The input Text device path node.\r | |
858 | \r | |
859 | @return A pointer to the newly-created Parallel Port device path structure.\r | |
860 | \r | |
861 | **/\r | |
862 | EFI_DEVICE_PATH_PROTOCOL *\r | |
863 | DevPathFromTextAta (\r | |
864 | CHAR16 *TextDeviceNode\r | |
865 | )\r | |
866 | {\r | |
867 | CHAR16 *PrimarySecondaryStr;\r | |
868 | CHAR16 *SlaveMasterStr;\r | |
869 | CHAR16 *LunStr;\r | |
870 | ATAPI_DEVICE_PATH *Atapi;\r | |
871 | \r | |
872 | Atapi = (ATAPI_DEVICE_PATH *) CreateDeviceNode (\r | |
873 | MESSAGING_DEVICE_PATH,\r | |
874 | MSG_ATAPI_DP,\r | |
875 | (UINT16) sizeof (ATAPI_DEVICE_PATH)\r | |
876 | );\r | |
877 | \r | |
878 | PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);\r | |
879 | SlaveMasterStr = GetNextParamStr (&TextDeviceNode);\r | |
880 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
881 | \r | |
882 | if (StrCmp (PrimarySecondaryStr, L"Primary") == 0) {\r | |
883 | Atapi->PrimarySecondary = 0;\r | |
884 | } else if (StrCmp (PrimarySecondaryStr, L"Secondary") == 0) {\r | |
885 | Atapi->PrimarySecondary = 1;\r | |
886 | } else {\r | |
887 | Atapi->PrimarySecondary = (UINT8) Strtoi (PrimarySecondaryStr);\r | |
888 | }\r | |
889 | if (StrCmp (SlaveMasterStr, L"Master") == 0) {\r | |
890 | Atapi->SlaveMaster = 0;\r | |
891 | } else if (StrCmp (SlaveMasterStr, L"Slave") == 0) {\r | |
892 | Atapi->SlaveMaster = 1;\r | |
893 | } else {\r | |
894 | Atapi->SlaveMaster = (UINT8) Strtoi (SlaveMasterStr);\r | |
895 | }\r | |
896 | \r | |
897 | Atapi->Lun = (UINT16) Strtoi (LunStr);\r | |
898 | \r | |
899 | return (EFI_DEVICE_PATH_PROTOCOL *) Atapi;\r | |
900 | }\r | |
901 | \r | |
902 | /**\r | |
903 | Converts a text device path node to SCSI device path structure.\r | |
904 | \r | |
905 | @param TextDeviceNode The input Text device path node.\r | |
906 | \r | |
907 | @return A pointer to the newly-created SCSI device path structure.\r | |
908 | \r | |
909 | **/\r | |
910 | EFI_DEVICE_PATH_PROTOCOL *\r | |
911 | DevPathFromTextScsi (\r | |
912 | CHAR16 *TextDeviceNode\r | |
913 | )\r | |
914 | {\r | |
915 | CHAR16 *PunStr;\r | |
916 | CHAR16 *LunStr;\r | |
917 | SCSI_DEVICE_PATH *Scsi;\r | |
918 | \r | |
919 | PunStr = GetNextParamStr (&TextDeviceNode);\r | |
920 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
921 | Scsi = (SCSI_DEVICE_PATH *) CreateDeviceNode (\r | |
922 | MESSAGING_DEVICE_PATH,\r | |
923 | MSG_SCSI_DP,\r | |
924 | (UINT16) sizeof (SCSI_DEVICE_PATH)\r | |
925 | );\r | |
926 | \r | |
927 | Scsi->Pun = (UINT16) Strtoi (PunStr);\r | |
928 | Scsi->Lun = (UINT16) Strtoi (LunStr);\r | |
929 | \r | |
930 | return (EFI_DEVICE_PATH_PROTOCOL *) Scsi;\r | |
931 | }\r | |
932 | \r | |
933 | /**\r | |
934 | Converts a text device path node to Fibre device path structure.\r | |
935 | \r | |
936 | @param TextDeviceNode The input Text device path node.\r | |
937 | \r | |
938 | @return A pointer to the newly-created Fibre device path structure.\r | |
939 | \r | |
940 | **/\r | |
941 | EFI_DEVICE_PATH_PROTOCOL *\r | |
942 | DevPathFromTextFibre (\r | |
943 | CHAR16 *TextDeviceNode\r | |
944 | )\r | |
945 | {\r | |
946 | CHAR16 *WWNStr;\r | |
947 | CHAR16 *LunStr;\r | |
948 | FIBRECHANNEL_DEVICE_PATH *Fibre;\r | |
949 | \r | |
950 | WWNStr = GetNextParamStr (&TextDeviceNode);\r | |
951 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
952 | Fibre = (FIBRECHANNEL_DEVICE_PATH *) CreateDeviceNode (\r | |
953 | MESSAGING_DEVICE_PATH,\r | |
954 | MSG_FIBRECHANNEL_DP,\r | |
955 | (UINT16) sizeof (FIBRECHANNEL_DEVICE_PATH)\r | |
956 | );\r | |
957 | \r | |
958 | Fibre->Reserved = 0;\r | |
959 | Strtoi64 (WWNStr, &Fibre->WWN);\r | |
960 | Strtoi64 (LunStr, &Fibre->Lun);\r | |
961 | \r | |
962 | return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;\r | |
963 | }\r | |
964 | \r | |
965 | /**\r | |
966 | Converts a text device path node to FibreEx device path structure.\r | |
967 | \r | |
968 | @param TextDeviceNode The input Text device path node.\r | |
969 | \r | |
970 | @return A pointer to the newly-created FibreEx device path structure.\r | |
971 | \r | |
972 | **/\r | |
973 | EFI_DEVICE_PATH_PROTOCOL *\r | |
974 | DevPathFromTextFibreEx (\r | |
975 | CHAR16 *TextDeviceNode\r | |
976 | )\r | |
977 | {\r | |
978 | CHAR16 *WWNStr;\r | |
979 | CHAR16 *LunStr;\r | |
980 | FIBRECHANNELEX_DEVICE_PATH *FibreEx;\r | |
981 | \r | |
982 | WWNStr = GetNextParamStr (&TextDeviceNode);\r | |
983 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
984 | FibreEx = (FIBRECHANNELEX_DEVICE_PATH *) CreateDeviceNode (\r | |
985 | MESSAGING_DEVICE_PATH,\r | |
986 | MSG_FIBRECHANNELEX_DP,\r | |
987 | (UINT16) sizeof (FIBRECHANNELEX_DEVICE_PATH)\r | |
988 | );\r | |
989 | \r | |
990 | FibreEx->Reserved = 0;\r | |
991 | Strtoi64 (WWNStr, (UINT64 *) (&FibreEx->WWN));\r | |
992 | Strtoi64 (LunStr, (UINT64 *) (&FibreEx->Lun));\r | |
993 | \r | |
994 | *(UINT64 *) (&FibreEx->WWN) = SwapBytes64 (*(UINT64 *) (&FibreEx->WWN));\r | |
995 | *(UINT64 *) (&FibreEx->Lun) = SwapBytes64 (*(UINT64 *) (&FibreEx->Lun));\r | |
996 | \r | |
997 | return (EFI_DEVICE_PATH_PROTOCOL *) FibreEx;\r | |
998 | }\r | |
999 | \r | |
1000 | /**\r | |
1001 | Converts a text device path node to 1394 device path structure.\r | |
1002 | \r | |
1003 | @param TextDeviceNode The input Text device path node.\r | |
1004 | \r | |
1005 | @return A pointer to the newly-created 1394 device path structure.\r | |
1006 | \r | |
1007 | **/\r | |
1008 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1009 | DevPathFromText1394 (\r | |
1010 | CHAR16 *TextDeviceNode\r | |
1011 | )\r | |
1012 | {\r | |
1013 | CHAR16 *GuidStr;\r | |
1014 | F1394_DEVICE_PATH *F1394DevPath;\r | |
1015 | \r | |
1016 | GuidStr = GetNextParamStr (&TextDeviceNode);\r | |
1017 | F1394DevPath = (F1394_DEVICE_PATH *) CreateDeviceNode (\r | |
1018 | MESSAGING_DEVICE_PATH,\r | |
1019 | MSG_1394_DP,\r | |
1020 | (UINT16) sizeof (F1394_DEVICE_PATH)\r | |
1021 | );\r | |
1022 | \r | |
1023 | F1394DevPath->Reserved = 0;\r | |
1024 | F1394DevPath->Guid = StrHexToUint64 (GuidStr);\r | |
1025 | \r | |
1026 | return (EFI_DEVICE_PATH_PROTOCOL *) F1394DevPath;\r | |
1027 | }\r | |
1028 | \r | |
1029 | /**\r | |
1030 | Converts a text device path node to USB device path structure.\r | |
1031 | \r | |
1032 | @param TextDeviceNode The input Text device path node.\r | |
1033 | \r | |
1034 | @return A pointer to the newly-created USB device path structure.\r | |
1035 | \r | |
1036 | **/\r | |
1037 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1038 | DevPathFromTextUsb (\r | |
1039 | CHAR16 *TextDeviceNode\r | |
1040 | )\r | |
1041 | {\r | |
1042 | CHAR16 *PortStr;\r | |
1043 | CHAR16 *InterfaceStr;\r | |
1044 | USB_DEVICE_PATH *Usb;\r | |
1045 | \r | |
1046 | PortStr = GetNextParamStr (&TextDeviceNode);\r | |
1047 | InterfaceStr = GetNextParamStr (&TextDeviceNode);\r | |
1048 | Usb = (USB_DEVICE_PATH *) CreateDeviceNode (\r | |
1049 | MESSAGING_DEVICE_PATH,\r | |
1050 | MSG_USB_DP,\r | |
1051 | (UINT16) sizeof (USB_DEVICE_PATH)\r | |
1052 | );\r | |
1053 | \r | |
1054 | Usb->ParentPortNumber = (UINT8) Strtoi (PortStr);\r | |
1055 | Usb->InterfaceNumber = (UINT8) Strtoi (InterfaceStr);\r | |
1056 | \r | |
1057 | return (EFI_DEVICE_PATH_PROTOCOL *) Usb;\r | |
1058 | }\r | |
1059 | \r | |
1060 | /**\r | |
1061 | Converts a text device path node to I20 device path structure.\r | |
1062 | \r | |
1063 | @param TextDeviceNode The input Text device path node.\r | |
1064 | \r | |
1065 | @return A pointer to the newly-created I20 device path structure.\r | |
1066 | \r | |
1067 | **/\r | |
1068 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1069 | DevPathFromTextI2O (\r | |
1070 | CHAR16 *TextDeviceNode\r | |
1071 | )\r | |
1072 | {\r | |
1073 | CHAR16 *TIDStr;\r | |
1074 | I2O_DEVICE_PATH *I2ODevPath;\r | |
1075 | \r | |
1076 | TIDStr = GetNextParamStr (&TextDeviceNode);\r | |
1077 | I2ODevPath = (I2O_DEVICE_PATH *) CreateDeviceNode (\r | |
1078 | MESSAGING_DEVICE_PATH,\r | |
1079 | MSG_I2O_DP,\r | |
1080 | (UINT16) sizeof (I2O_DEVICE_PATH)\r | |
1081 | );\r | |
1082 | \r | |
1083 | I2ODevPath->Tid = (UINT32) Strtoi (TIDStr);\r | |
1084 | \r | |
1085 | return (EFI_DEVICE_PATH_PROTOCOL *) I2ODevPath;\r | |
1086 | }\r | |
1087 | \r | |
1088 | /**\r | |
1089 | Converts a text device path node to Infini Band device path structure.\r | |
1090 | \r | |
1091 | @param TextDeviceNode The input Text device path node.\r | |
1092 | \r | |
1093 | @return A pointer to the newly-created Infini Band device path structure.\r | |
1094 | \r | |
1095 | **/\r | |
1096 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1097 | DevPathFromTextInfiniband (\r | |
1098 | CHAR16 *TextDeviceNode\r | |
1099 | )\r | |
1100 | {\r | |
1101 | CHAR16 *FlagsStr;\r | |
1102 | CHAR16 *GuidStr;\r | |
1103 | CHAR16 *SidStr;\r | |
1104 | CHAR16 *TidStr;\r | |
1105 | CHAR16 *DidStr;\r | |
1106 | INFINIBAND_DEVICE_PATH *InfiniBand;\r | |
1107 | \r | |
1108 | FlagsStr = GetNextParamStr (&TextDeviceNode);\r | |
1109 | GuidStr = GetNextParamStr (&TextDeviceNode);\r | |
1110 | SidStr = GetNextParamStr (&TextDeviceNode);\r | |
1111 | TidStr = GetNextParamStr (&TextDeviceNode);\r | |
1112 | DidStr = GetNextParamStr (&TextDeviceNode);\r | |
1113 | InfiniBand = (INFINIBAND_DEVICE_PATH *) CreateDeviceNode (\r | |
1114 | MESSAGING_DEVICE_PATH,\r | |
1115 | MSG_INFINIBAND_DP,\r | |
1116 | (UINT16) sizeof (INFINIBAND_DEVICE_PATH)\r | |
1117 | );\r | |
1118 | \r | |
1119 | InfiniBand->ResourceFlags = (UINT32) Strtoi (FlagsStr);\r | |
1120 | StrToGuid (GuidStr, (EFI_GUID *) InfiniBand->PortGid);\r | |
1121 | Strtoi64 (SidStr, &InfiniBand->ServiceId);\r | |
1122 | Strtoi64 (TidStr, &InfiniBand->TargetPortId);\r | |
1123 | Strtoi64 (DidStr, &InfiniBand->DeviceId);\r | |
1124 | \r | |
1125 | return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand;\r | |
1126 | }\r | |
1127 | \r | |
1128 | /**\r | |
1129 | Converts a text device path node to Vendor-Defined Messaging device path structure.\r | |
1130 | \r | |
1131 | @param TextDeviceNode The input Text device path node.\r | |
1132 | \r | |
1133 | @return A pointer to the newly-created Vendor-Defined Messaging device path structure.\r | |
1134 | \r | |
1135 | **/\r | |
1136 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1137 | DevPathFromTextVenMsg (\r | |
1138 | CHAR16 *TextDeviceNode\r | |
1139 | )\r | |
1140 | {\r | |
1141 | return ConvertFromTextVendor (\r | |
1142 | TextDeviceNode,\r | |
1143 | MESSAGING_DEVICE_PATH,\r | |
1144 | MSG_VENDOR_DP\r | |
1145 | );\r | |
1146 | }\r | |
1147 | \r | |
1148 | /**\r | |
1149 | Converts a text device path node to Vendor defined PC-ANSI device path structure.\r | |
1150 | \r | |
1151 | @param TextDeviceNode The input Text device path node.\r | |
1152 | \r | |
1153 | @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.\r | |
1154 | \r | |
1155 | **/\r | |
1156 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1157 | DevPathFromTextVenPcAnsi (\r | |
1158 | CHAR16 *TextDeviceNode\r | |
1159 | )\r | |
1160 | {\r | |
1161 | VENDOR_DEVICE_PATH *Vendor;\r | |
1162 | \r | |
1163 | Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r | |
1164 | MESSAGING_DEVICE_PATH,\r | |
1165 | MSG_VENDOR_DP,\r | |
1166 | (UINT16) sizeof (VENDOR_DEVICE_PATH));\r | |
1167 | CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);\r | |
1168 | \r | |
1169 | return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r | |
1170 | }\r | |
1171 | \r | |
1172 | /**\r | |
1173 | Converts a text device path node to Vendor defined VT100 device path structure.\r | |
1174 | \r | |
1175 | @param TextDeviceNode The input Text device path node.\r | |
1176 | \r | |
1177 | @return A pointer to the newly-created Vendor defined VT100 device path structure.\r | |
1178 | \r | |
1179 | **/\r | |
1180 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1181 | DevPathFromTextVenVt100 (\r | |
1182 | CHAR16 *TextDeviceNode\r | |
1183 | )\r | |
1184 | {\r | |
1185 | VENDOR_DEVICE_PATH *Vendor;\r | |
1186 | \r | |
1187 | Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r | |
1188 | MESSAGING_DEVICE_PATH,\r | |
1189 | MSG_VENDOR_DP,\r | |
1190 | (UINT16) sizeof (VENDOR_DEVICE_PATH));\r | |
1191 | CopyGuid (&Vendor->Guid, &gEfiVT100Guid);\r | |
1192 | \r | |
1193 | return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r | |
1194 | }\r | |
1195 | \r | |
1196 | /**\r | |
1197 | Converts a text device path node to Vendor defined VT100 Plus device path structure.\r | |
1198 | \r | |
1199 | @param TextDeviceNode The input Text device path node.\r | |
1200 | \r | |
1201 | @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.\r | |
1202 | \r | |
1203 | **/\r | |
1204 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1205 | DevPathFromTextVenVt100Plus (\r | |
1206 | CHAR16 *TextDeviceNode\r | |
1207 | )\r | |
1208 | {\r | |
1209 | VENDOR_DEVICE_PATH *Vendor;\r | |
1210 | \r | |
1211 | Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r | |
1212 | MESSAGING_DEVICE_PATH,\r | |
1213 | MSG_VENDOR_DP,\r | |
1214 | (UINT16) sizeof (VENDOR_DEVICE_PATH));\r | |
1215 | CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);\r | |
1216 | \r | |
1217 | return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r | |
1218 | }\r | |
1219 | \r | |
1220 | /**\r | |
1221 | Converts a text device path node to Vendor defined UTF8 device path structure.\r | |
1222 | \r | |
1223 | @param TextDeviceNode The input Text device path node.\r | |
1224 | \r | |
1225 | @return A pointer to the newly-created Vendor defined UTF8 device path structure.\r | |
1226 | \r | |
1227 | **/\r | |
1228 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1229 | DevPathFromTextVenUtf8 (\r | |
1230 | CHAR16 *TextDeviceNode\r | |
1231 | )\r | |
1232 | {\r | |
1233 | VENDOR_DEVICE_PATH *Vendor;\r | |
1234 | \r | |
1235 | Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r | |
1236 | MESSAGING_DEVICE_PATH,\r | |
1237 | MSG_VENDOR_DP,\r | |
1238 | (UINT16) sizeof (VENDOR_DEVICE_PATH));\r | |
1239 | CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);\r | |
1240 | \r | |
1241 | return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r | |
1242 | }\r | |
1243 | \r | |
1244 | /**\r | |
1245 | Converts a text device path node to UART Flow Control device path structure.\r | |
1246 | \r | |
1247 | @param TextDeviceNode The input Text device path node.\r | |
1248 | \r | |
1249 | @return A pointer to the newly-created UART Flow Control device path structure.\r | |
1250 | \r | |
1251 | **/\r | |
1252 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1253 | DevPathFromTextUartFlowCtrl (\r | |
1254 | CHAR16 *TextDeviceNode\r | |
1255 | )\r | |
1256 | {\r | |
1257 | CHAR16 *ValueStr;\r | |
1258 | UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;\r | |
1259 | \r | |
1260 | ValueStr = GetNextParamStr (&TextDeviceNode);\r | |
1261 | UartFlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) CreateDeviceNode (\r | |
1262 | MESSAGING_DEVICE_PATH,\r | |
1263 | MSG_VENDOR_DP,\r | |
1264 | (UINT16) sizeof (UART_FLOW_CONTROL_DEVICE_PATH)\r | |
1265 | );\r | |
1266 | \r | |
1267 | CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);\r | |
1268 | if (StrCmp (ValueStr, L"XonXoff") == 0) {\r | |
1269 | UartFlowControl->FlowControlMap = 2;\r | |
1270 | } else if (StrCmp (ValueStr, L"Hardware") == 0) {\r | |
1271 | UartFlowControl->FlowControlMap = 1;\r | |
1272 | } else {\r | |
1273 | UartFlowControl->FlowControlMap = 0;\r | |
1274 | }\r | |
1275 | \r | |
1276 | return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl;\r | |
1277 | }\r | |
1278 | \r | |
1279 | /**\r | |
1280 | Converts a text device path node to Serial Attached SCSI device path structure.\r | |
1281 | \r | |
1282 | @param TextDeviceNode The input Text device path node.\r | |
1283 | \r | |
1284 | @return A pointer to the newly-created Serial Attached SCSI device path structure.\r | |
1285 | \r | |
1286 | **/\r | |
1287 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1288 | DevPathFromTextSAS (\r | |
1289 | CHAR16 *TextDeviceNode\r | |
1290 | )\r | |
1291 | {\r | |
1292 | CHAR16 *AddressStr;\r | |
1293 | CHAR16 *LunStr;\r | |
1294 | CHAR16 *RTPStr;\r | |
1295 | CHAR16 *SASSATAStr;\r | |
1296 | CHAR16 *LocationStr;\r | |
1297 | CHAR16 *ConnectStr;\r | |
1298 | CHAR16 *DriveBayStr;\r | |
1299 | CHAR16 *ReservedStr;\r | |
1300 | UINT16 Info;\r | |
1301 | UINT16 Uint16;\r | |
1302 | SAS_DEVICE_PATH *Sas;\r | |
1303 | \r | |
1304 | AddressStr = GetNextParamStr (&TextDeviceNode);\r | |
1305 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
1306 | RTPStr = GetNextParamStr (&TextDeviceNode);\r | |
1307 | SASSATAStr = GetNextParamStr (&TextDeviceNode);\r | |
1308 | LocationStr = GetNextParamStr (&TextDeviceNode);\r | |
1309 | ConnectStr = GetNextParamStr (&TextDeviceNode);\r | |
1310 | DriveBayStr = GetNextParamStr (&TextDeviceNode);\r | |
1311 | ReservedStr = GetNextParamStr (&TextDeviceNode);\r | |
1312 | Sas = (SAS_DEVICE_PATH *) CreateDeviceNode (\r | |
1313 | MESSAGING_DEVICE_PATH,\r | |
1314 | MSG_VENDOR_DP,\r | |
1315 | (UINT16) sizeof (SAS_DEVICE_PATH)\r | |
1316 | );\r | |
1317 | \r | |
1318 | CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid);\r | |
1319 | Strtoi64 (AddressStr, &Sas->SasAddress);\r | |
1320 | Strtoi64 (LunStr, &Sas->Lun);\r | |
1321 | Sas->RelativeTargetPort = (UINT16) Strtoi (RTPStr);\r | |
1322 | \r | |
1323 | if (StrCmp (SASSATAStr, L"NoTopology") == 0) {\r | |
1324 | Info = 0x0;\r | |
1325 | \r | |
1326 | } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {\r | |
1327 | \r | |
1328 | Uint16 = (UINT16) Strtoi (DriveBayStr);\r | |
1329 | if (Uint16 == 0) {\r | |
1330 | Info = 0x1;\r | |
1331 | } else {\r | |
1332 | Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));\r | |
1333 | }\r | |
1334 | \r | |
1335 | if (StrCmp (SASSATAStr, L"SATA") == 0) {\r | |
1336 | Info |= BIT4;\r | |
1337 | }\r | |
1338 | \r | |
1339 | //\r | |
1340 | // Location is an integer between 0 and 1 or else\r | |
1341 | // the keyword Internal (0) or External (1).\r | |
1342 | //\r | |
1343 | if (StrCmp (LocationStr, L"External") == 0) {\r | |
1344 | Uint16 = 1;\r | |
1345 | } else if (StrCmp (LocationStr, L"Internal") == 0) {\r | |
1346 | Uint16 = 0;\r | |
1347 | } else {\r | |
1348 | Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);\r | |
1349 | }\r | |
1350 | Info |= (Uint16 << 5);\r | |
1351 | \r | |
1352 | //\r | |
1353 | // Connect is an integer between 0 and 3 or else\r | |
1354 | // the keyword Direct (0) or Expanded (1).\r | |
1355 | //\r | |
1356 | if (StrCmp (ConnectStr, L"Expanded") == 0) {\r | |
1357 | Uint16 = 1;\r | |
1358 | } else if (StrCmp (ConnectStr, L"Direct") == 0) {\r | |
1359 | Uint16 = 0;\r | |
1360 | } else {\r | |
1361 | Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));\r | |
1362 | }\r | |
1363 | Info |= (Uint16 << 6);\r | |
1364 | \r | |
1365 | } else {\r | |
1366 | Info = (UINT16) Strtoi (SASSATAStr);\r | |
1367 | }\r | |
1368 | \r | |
1369 | Sas->DeviceTopology = Info;\r | |
1370 | Sas->Reserved = (UINT32) Strtoi (ReservedStr);\r | |
1371 | \r | |
1372 | return (EFI_DEVICE_PATH_PROTOCOL *) Sas;\r | |
1373 | }\r | |
1374 | \r | |
1375 | /**\r | |
1376 | Converts a text device path node to Serial Attached SCSI Ex device path structure.\r | |
1377 | \r | |
1378 | @param TextDeviceNode The input Text device path node.\r | |
1379 | \r | |
1380 | @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.\r | |
1381 | \r | |
1382 | **/\r | |
1383 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1384 | DevPathFromTextSasEx (\r | |
1385 | CHAR16 *TextDeviceNode\r | |
1386 | )\r | |
1387 | {\r | |
1388 | CHAR16 *AddressStr;\r | |
1389 | CHAR16 *LunStr;\r | |
1390 | CHAR16 *RTPStr;\r | |
1391 | CHAR16 *SASSATAStr;\r | |
1392 | CHAR16 *LocationStr;\r | |
1393 | CHAR16 *ConnectStr;\r | |
1394 | CHAR16 *DriveBayStr;\r | |
1395 | UINT16 Info;\r | |
1396 | UINT16 Uint16;\r | |
1397 | UINT64 SasAddress;\r | |
1398 | UINT64 Lun;\r | |
1399 | SASEX_DEVICE_PATH *SasEx;\r | |
1400 | \r | |
1401 | AddressStr = GetNextParamStr (&TextDeviceNode);\r | |
1402 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
1403 | RTPStr = GetNextParamStr (&TextDeviceNode);\r | |
1404 | SASSATAStr = GetNextParamStr (&TextDeviceNode);\r | |
1405 | LocationStr = GetNextParamStr (&TextDeviceNode);\r | |
1406 | ConnectStr = GetNextParamStr (&TextDeviceNode);\r | |
1407 | DriveBayStr = GetNextParamStr (&TextDeviceNode);\r | |
1408 | SasEx = (SASEX_DEVICE_PATH *) CreateDeviceNode (\r | |
1409 | MESSAGING_DEVICE_PATH,\r | |
1410 | MSG_SASEX_DP,\r | |
1411 | (UINT16) sizeof (SASEX_DEVICE_PATH)\r | |
1412 | );\r | |
1413 | \r | |
1414 | Strtoi64 (AddressStr, &SasAddress);\r | |
1415 | Strtoi64 (LunStr, &Lun);\r | |
1416 | WriteUnaligned64 ((UINT64 *) &SasEx->SasAddress, SwapBytes64 (SasAddress));\r | |
1417 | WriteUnaligned64 ((UINT64 *) &SasEx->Lun, SwapBytes64 (Lun));\r | |
1418 | SasEx->RelativeTargetPort = (UINT16) Strtoi (RTPStr);\r | |
1419 | \r | |
1420 | if (StrCmp (SASSATAStr, L"NoTopology") == 0) {\r | |
1421 | Info = 0x0;\r | |
1422 | \r | |
1423 | } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {\r | |
1424 | \r | |
1425 | Uint16 = (UINT16) Strtoi (DriveBayStr);\r | |
1426 | if (Uint16 == 0) {\r | |
1427 | Info = 0x1;\r | |
1428 | } else {\r | |
1429 | Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));\r | |
1430 | }\r | |
1431 | \r | |
1432 | if (StrCmp (SASSATAStr, L"SATA") == 0) {\r | |
1433 | Info |= BIT4;\r | |
1434 | }\r | |
1435 | \r | |
1436 | //\r | |
1437 | // Location is an integer between 0 and 1 or else\r | |
1438 | // the keyword Internal (0) or External (1).\r | |
1439 | //\r | |
1440 | if (StrCmp (LocationStr, L"External") == 0) {\r | |
1441 | Uint16 = 1;\r | |
1442 | } else if (StrCmp (LocationStr, L"Internal") == 0) {\r | |
1443 | Uint16 = 0;\r | |
1444 | } else {\r | |
1445 | Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);\r | |
1446 | }\r | |
1447 | Info |= (Uint16 << 5);\r | |
1448 | \r | |
1449 | //\r | |
1450 | // Connect is an integer between 0 and 3 or else\r | |
1451 | // the keyword Direct (0) or Expanded (1).\r | |
1452 | //\r | |
1453 | if (StrCmp (ConnectStr, L"Expanded") == 0) {\r | |
1454 | Uint16 = 1;\r | |
1455 | } else if (StrCmp (ConnectStr, L"Direct") == 0) {\r | |
1456 | Uint16 = 0;\r | |
1457 | } else {\r | |
1458 | Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));\r | |
1459 | }\r | |
1460 | Info |= (Uint16 << 6);\r | |
1461 | \r | |
1462 | } else {\r | |
1463 | Info = (UINT16) Strtoi (SASSATAStr);\r | |
1464 | }\r | |
1465 | \r | |
1466 | SasEx->DeviceTopology = Info;\r | |
1467 | \r | |
1468 | return (EFI_DEVICE_PATH_PROTOCOL *) SasEx;\r | |
1469 | }\r | |
1470 | \r | |
1471 | /**\r | |
1472 | Converts a text device path node to NVM Express Namespace device path structure.\r | |
1473 | \r | |
1474 | @param TextDeviceNode The input Text device path node.\r | |
1475 | \r | |
1476 | @return A pointer to the newly-created NVM Express Namespace device path structure.\r | |
1477 | \r | |
1478 | **/\r | |
1479 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1480 | DevPathFromTextNVMe (\r | |
1481 | CHAR16 *TextDeviceNode\r | |
1482 | )\r | |
1483 | {\r | |
1484 | CHAR16 *NamespaceIdStr;\r | |
1485 | CHAR16 *NamespaceUuidStr;\r | |
1486 | NVME_NAMESPACE_DEVICE_PATH *Nvme;\r | |
1487 | UINT8 *Uuid;\r | |
1488 | UINTN Index;\r | |
1489 | \r | |
1490 | NamespaceIdStr = GetNextParamStr (&TextDeviceNode);\r | |
1491 | NamespaceUuidStr = GetNextParamStr (&TextDeviceNode);\r | |
1492 | Nvme = (NVME_NAMESPACE_DEVICE_PATH *) CreateDeviceNode (\r | |
1493 | MESSAGING_DEVICE_PATH,\r | |
1494 | MSG_NVME_NAMESPACE_DP,\r | |
1495 | (UINT16) sizeof (NVME_NAMESPACE_DEVICE_PATH)\r | |
1496 | );\r | |
1497 | \r | |
1498 | Nvme->NamespaceId = (UINT32) Strtoi (NamespaceIdStr);\r | |
1499 | Uuid = (UINT8 *) &Nvme->NamespaceUuid;\r | |
1500 | \r | |
1501 | Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8);\r | |
1502 | while (Index-- != 0) {\r | |
6e2d15e3 | 1503 | Uuid[Index] = (UINT8) StrHexToUint64 (SplitStr (&NamespaceUuidStr, L'-'));\r |
7dbc50bd YZ |
1504 | }\r |
1505 | \r | |
1506 | return (EFI_DEVICE_PATH_PROTOCOL *) Nvme;\r | |
1507 | }\r | |
1508 | \r | |
1509 | /**\r | |
1510 | Converts a text device path node to UFS device path structure.\r | |
1511 | \r | |
1512 | @param TextDeviceNode The input Text device path node.\r | |
1513 | \r | |
1514 | @return A pointer to the newly-created UFS device path structure.\r | |
1515 | \r | |
1516 | **/\r | |
1517 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1518 | DevPathFromTextUfs (\r | |
1519 | CHAR16 *TextDeviceNode\r | |
1520 | )\r | |
1521 | {\r | |
1522 | CHAR16 *PunStr;\r | |
1523 | CHAR16 *LunStr;\r | |
1524 | UFS_DEVICE_PATH *Ufs;\r | |
1525 | \r | |
1526 | PunStr = GetNextParamStr (&TextDeviceNode);\r | |
1527 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
1528 | Ufs = (UFS_DEVICE_PATH *) CreateDeviceNode (\r | |
1529 | MESSAGING_DEVICE_PATH,\r | |
1530 | MSG_UFS_DP,\r | |
1531 | (UINT16) sizeof (UFS_DEVICE_PATH)\r | |
1532 | );\r | |
1533 | \r | |
1534 | Ufs->Pun = (UINT8) Strtoi (PunStr);\r | |
1535 | Ufs->Lun = (UINT8) Strtoi (LunStr);\r | |
1536 | \r | |
1537 | return (EFI_DEVICE_PATH_PROTOCOL *) Ufs;\r | |
1538 | }\r | |
1539 | \r | |
1540 | /**\r | |
1541 | Converts a text device path node to SD (Secure Digital) device path structure.\r | |
1542 | \r | |
1543 | @param TextDeviceNode The input Text device path node.\r | |
1544 | \r | |
1545 | @return A pointer to the newly-created SD device path structure.\r | |
1546 | \r | |
1547 | **/\r | |
1548 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1549 | DevPathFromTextSd (\r | |
1550 | CHAR16 *TextDeviceNode\r | |
1551 | )\r | |
1552 | {\r | |
1553 | CHAR16 *SlotNumberStr;\r | |
1554 | SD_DEVICE_PATH *Sd;\r | |
1555 | \r | |
1556 | SlotNumberStr = GetNextParamStr (&TextDeviceNode);\r | |
1557 | Sd = (SD_DEVICE_PATH *) CreateDeviceNode (\r | |
1558 | MESSAGING_DEVICE_PATH,\r | |
1559 | MSG_SD_DP,\r | |
1560 | (UINT16) sizeof (SD_DEVICE_PATH)\r | |
1561 | );\r | |
1562 | \r | |
1563 | Sd->SlotNumber = (UINT8) Strtoi (SlotNumberStr);\r | |
1564 | \r | |
1565 | return (EFI_DEVICE_PATH_PROTOCOL *) Sd;\r | |
1566 | }\r | |
1567 | \r | |
1568 | /**\r | |
1569 | Converts a text device path node to EMMC (Embedded MMC) device path structure.\r | |
1570 | \r | |
1571 | @param TextDeviceNode The input Text device path node.\r | |
1572 | \r | |
1573 | @return A pointer to the newly-created EMMC device path structure.\r | |
1574 | \r | |
1575 | **/\r | |
1576 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1577 | DevPathFromTextEmmc (\r | |
1578 | CHAR16 *TextDeviceNode\r | |
1579 | )\r | |
1580 | {\r | |
1581 | CHAR16 *SlotNumberStr;\r | |
1582 | EMMC_DEVICE_PATH *Emmc;\r | |
1583 | \r | |
1584 | SlotNumberStr = GetNextParamStr (&TextDeviceNode);\r | |
1585 | Emmc = (EMMC_DEVICE_PATH *) CreateDeviceNode (\r | |
1586 | MESSAGING_DEVICE_PATH,\r | |
1587 | MSG_EMMC_DP,\r | |
1588 | (UINT16) sizeof (EMMC_DEVICE_PATH)\r | |
1589 | );\r | |
1590 | \r | |
1591 | Emmc->SlotNumber = (UINT8) Strtoi (SlotNumberStr);\r | |
1592 | \r | |
1593 | return (EFI_DEVICE_PATH_PROTOCOL *) Emmc;\r | |
1594 | }\r | |
1595 | \r | |
1596 | /**\r | |
1597 | Converts a text device path node to Debug Port device path structure.\r | |
1598 | \r | |
1599 | @param TextDeviceNode The input Text device path node.\r | |
1600 | \r | |
1601 | @return A pointer to the newly-created Debug Port device path structure.\r | |
1602 | \r | |
1603 | **/\r | |
1604 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1605 | DevPathFromTextDebugPort (\r | |
1606 | CHAR16 *TextDeviceNode\r | |
1607 | )\r | |
1608 | {\r | |
23a62c69 | 1609 | VENDOR_DEVICE_PATH *Vend;\r |
7dbc50bd | 1610 | \r |
23a62c69 | 1611 | Vend = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r |
7dbc50bd YZ |
1612 | MESSAGING_DEVICE_PATH,\r |
1613 | MSG_VENDOR_DP,\r | |
23a62c69 | 1614 | (UINT16) sizeof (VENDOR_DEVICE_PATH)\r |
7dbc50bd YZ |
1615 | );\r |
1616 | \r | |
23a62c69 | 1617 | CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);\r |
7dbc50bd YZ |
1618 | \r |
1619 | return (EFI_DEVICE_PATH_PROTOCOL *) Vend;\r | |
1620 | }\r | |
1621 | \r | |
1622 | /**\r | |
1623 | Converts a text device path node to MAC device path structure.\r | |
1624 | \r | |
1625 | @param TextDeviceNode The input Text device path node.\r | |
1626 | \r | |
1627 | @return A pointer to the newly-created MAC device path structure.\r | |
1628 | \r | |
1629 | **/\r | |
1630 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1631 | DevPathFromTextMAC (\r | |
1632 | CHAR16 *TextDeviceNode\r | |
1633 | )\r | |
1634 | {\r | |
1635 | CHAR16 *AddressStr;\r | |
1636 | CHAR16 *IfTypeStr;\r | |
1637 | UINTN Length;\r | |
1638 | MAC_ADDR_DEVICE_PATH *MACDevPath;\r | |
1639 | \r | |
1640 | AddressStr = GetNextParamStr (&TextDeviceNode);\r | |
1641 | IfTypeStr = GetNextParamStr (&TextDeviceNode);\r | |
1642 | MACDevPath = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (\r | |
1643 | MESSAGING_DEVICE_PATH,\r | |
1644 | MSG_MAC_ADDR_DP,\r | |
1645 | (UINT16) sizeof (MAC_ADDR_DEVICE_PATH)\r | |
1646 | );\r | |
1647 | \r | |
1648 | MACDevPath->IfType = (UINT8) Strtoi (IfTypeStr);\r | |
1649 | \r | |
1650 | Length = sizeof (EFI_MAC_ADDRESS);\r | |
1651 | if (MACDevPath->IfType == 0x01 || MACDevPath->IfType == 0x00) {\r | |
1652 | Length = 6;\r | |
1653 | }\r | |
1654 | \r | |
1655 | StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length);\r | |
1656 | \r | |
1657 | return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;\r | |
1658 | }\r | |
1659 | \r | |
1660 | \r | |
1661 | /**\r | |
1662 | Converts a text format to the network protocol ID.\r | |
1663 | \r | |
1664 | @param Text String of protocol field.\r | |
1665 | \r | |
1666 | @return Network protocol ID .\r | |
1667 | \r | |
1668 | **/\r | |
1669 | UINTN\r | |
1670 | NetworkProtocolFromText (\r | |
1671 | CHAR16 *Text\r | |
1672 | )\r | |
1673 | {\r | |
1674 | if (StrCmp (Text, L"UDP") == 0) {\r | |
1675 | return RFC_1700_UDP_PROTOCOL;\r | |
1676 | }\r | |
1677 | \r | |
1678 | if (StrCmp (Text, L"TCP") == 0) {\r | |
1679 | return RFC_1700_TCP_PROTOCOL;\r | |
1680 | }\r | |
1681 | \r | |
1682 | return Strtoi (Text);\r | |
1683 | }\r | |
1684 | \r | |
1685 | \r | |
1686 | /**\r | |
1687 | Converts a text device path node to IPV4 device path structure.\r | |
1688 | \r | |
1689 | @param TextDeviceNode The input Text device path node.\r | |
1690 | \r | |
1691 | @return A pointer to the newly-created IPV4 device path structure.\r | |
1692 | \r | |
1693 | **/\r | |
1694 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1695 | DevPathFromTextIPv4 (\r | |
1696 | CHAR16 *TextDeviceNode\r | |
1697 | )\r | |
1698 | {\r | |
1699 | CHAR16 *RemoteIPStr;\r | |
1700 | CHAR16 *ProtocolStr;\r | |
1701 | CHAR16 *TypeStr;\r | |
1702 | CHAR16 *LocalIPStr;\r | |
1703 | CHAR16 *GatewayIPStr;\r | |
1704 | CHAR16 *SubnetMaskStr;\r | |
1705 | IPv4_DEVICE_PATH *IPv4;\r | |
1706 | \r | |
1707 | RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r | |
1708 | ProtocolStr = GetNextParamStr (&TextDeviceNode);\r | |
1709 | TypeStr = GetNextParamStr (&TextDeviceNode);\r | |
1710 | LocalIPStr = GetNextParamStr (&TextDeviceNode);\r | |
1711 | GatewayIPStr = GetNextParamStr (&TextDeviceNode);\r | |
1712 | SubnetMaskStr = GetNextParamStr (&TextDeviceNode);\r | |
1713 | IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode (\r | |
1714 | MESSAGING_DEVICE_PATH,\r | |
1715 | MSG_IPv4_DP,\r | |
1716 | (UINT16) sizeof (IPv4_DEVICE_PATH)\r | |
1717 | );\r | |
1718 | \r | |
1719 | StrToIpv4Address (RemoteIPStr, NULL, &IPv4->RemoteIpAddress, NULL);\r | |
1720 | IPv4->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);\r | |
1721 | if (StrCmp (TypeStr, L"Static") == 0) {\r | |
1722 | IPv4->StaticIpAddress = TRUE;\r | |
1723 | } else {\r | |
1724 | IPv4->StaticIpAddress = FALSE;\r | |
1725 | }\r | |
1726 | \r | |
1727 | StrToIpv4Address (LocalIPStr, NULL, &IPv4->LocalIpAddress, NULL);\r | |
1728 | if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*SubnetMaskStr)) {\r | |
1729 | StrToIpv4Address (GatewayIPStr, NULL, &IPv4->GatewayIpAddress, NULL);\r | |
1730 | StrToIpv4Address (SubnetMaskStr, NULL, &IPv4->SubnetMask, NULL);\r | |
1731 | } else {\r | |
1732 | ZeroMem (&IPv4->GatewayIpAddress, sizeof (IPv4->GatewayIpAddress));\r | |
1733 | ZeroMem (&IPv4->SubnetMask, sizeof (IPv4->SubnetMask));\r | |
1734 | }\r | |
1735 | \r | |
1736 | IPv4->LocalPort = 0;\r | |
1737 | IPv4->RemotePort = 0;\r | |
1738 | \r | |
1739 | return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;\r | |
1740 | }\r | |
1741 | \r | |
1742 | /**\r | |
1743 | Converts a text device path node to IPV6 device path structure.\r | |
1744 | \r | |
1745 | @param TextDeviceNode The input Text device path node.\r | |
1746 | \r | |
1747 | @return A pointer to the newly-created IPV6 device path structure.\r | |
1748 | \r | |
1749 | **/\r | |
1750 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1751 | DevPathFromTextIPv6 (\r | |
1752 | CHAR16 *TextDeviceNode\r | |
1753 | )\r | |
1754 | {\r | |
1755 | CHAR16 *RemoteIPStr;\r | |
1756 | CHAR16 *ProtocolStr;\r | |
1757 | CHAR16 *TypeStr;\r | |
1758 | CHAR16 *LocalIPStr;\r | |
1759 | CHAR16 *GatewayIPStr;\r | |
1760 | CHAR16 *PrefixLengthStr;\r | |
1761 | IPv6_DEVICE_PATH *IPv6;\r | |
1762 | \r | |
1763 | RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r | |
1764 | ProtocolStr = GetNextParamStr (&TextDeviceNode);\r | |
1765 | TypeStr = GetNextParamStr (&TextDeviceNode);\r | |
1766 | LocalIPStr = GetNextParamStr (&TextDeviceNode);\r | |
1767 | PrefixLengthStr = GetNextParamStr (&TextDeviceNode);\r | |
1768 | GatewayIPStr = GetNextParamStr (&TextDeviceNode);\r | |
1769 | IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (\r | |
1770 | MESSAGING_DEVICE_PATH,\r | |
1771 | MSG_IPv6_DP,\r | |
1772 | (UINT16) sizeof (IPv6_DEVICE_PATH)\r | |
1773 | );\r | |
1774 | \r | |
1775 | StrToIpv6Address (RemoteIPStr, NULL, &IPv6->RemoteIpAddress, NULL);\r | |
1776 | IPv6->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);\r | |
1777 | if (StrCmp (TypeStr, L"Static") == 0) {\r | |
1778 | IPv6->IpAddressOrigin = 0;\r | |
1779 | } else if (StrCmp (TypeStr, L"StatelessAutoConfigure") == 0) {\r | |
1780 | IPv6->IpAddressOrigin = 1;\r | |
1781 | } else {\r | |
1782 | IPv6->IpAddressOrigin = 2;\r | |
1783 | }\r | |
1784 | \r | |
1785 | StrToIpv6Address (LocalIPStr, NULL, &IPv6->LocalIpAddress, NULL);\r | |
1786 | if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*PrefixLengthStr)) {\r | |
1787 | StrToIpv6Address (GatewayIPStr, NULL, &IPv6->GatewayIpAddress, NULL);\r | |
1788 | IPv6->PrefixLength = (UINT8) Strtoi (PrefixLengthStr);\r | |
1789 | } else {\r | |
1790 | ZeroMem (&IPv6->GatewayIpAddress, sizeof (IPv6->GatewayIpAddress));\r | |
1791 | IPv6->PrefixLength = 0;\r | |
1792 | }\r | |
1793 | \r | |
1794 | IPv6->LocalPort = 0;\r | |
1795 | IPv6->RemotePort = 0;\r | |
1796 | \r | |
1797 | return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;\r | |
1798 | }\r | |
1799 | \r | |
1800 | /**\r | |
1801 | Converts a text device path node to UART device path structure.\r | |
1802 | \r | |
1803 | @param TextDeviceNode The input Text device path node.\r | |
1804 | \r | |
1805 | @return A pointer to the newly-created UART device path structure.\r | |
1806 | \r | |
1807 | **/\r | |
1808 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1809 | DevPathFromTextUart (\r | |
1810 | CHAR16 *TextDeviceNode\r | |
1811 | )\r | |
1812 | {\r | |
1813 | CHAR16 *BaudStr;\r | |
1814 | CHAR16 *DataBitsStr;\r | |
1815 | CHAR16 *ParityStr;\r | |
1816 | CHAR16 *StopBitsStr;\r | |
1817 | UART_DEVICE_PATH *Uart;\r | |
1818 | \r | |
1819 | BaudStr = GetNextParamStr (&TextDeviceNode);\r | |
1820 | DataBitsStr = GetNextParamStr (&TextDeviceNode);\r | |
1821 | ParityStr = GetNextParamStr (&TextDeviceNode);\r | |
1822 | StopBitsStr = GetNextParamStr (&TextDeviceNode);\r | |
1823 | Uart = (UART_DEVICE_PATH *) CreateDeviceNode (\r | |
1824 | MESSAGING_DEVICE_PATH,\r | |
1825 | MSG_UART_DP,\r | |
1826 | (UINT16) sizeof (UART_DEVICE_PATH)\r | |
1827 | );\r | |
1828 | \r | |
1829 | if (StrCmp (BaudStr, L"DEFAULT") == 0) {\r | |
1830 | Uart->BaudRate = 115200;\r | |
1831 | } else {\r | |
1832 | Strtoi64 (BaudStr, &Uart->BaudRate);\r | |
1833 | }\r | |
1834 | Uart->DataBits = (UINT8) ((StrCmp (DataBitsStr, L"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr));\r | |
1835 | switch (*ParityStr) {\r | |
1836 | case L'D':\r | |
1837 | Uart->Parity = 0;\r | |
1838 | break;\r | |
1839 | \r | |
1840 | case L'N':\r | |
1841 | Uart->Parity = 1;\r | |
1842 | break;\r | |
1843 | \r | |
1844 | case L'E':\r | |
1845 | Uart->Parity = 2;\r | |
1846 | break;\r | |
1847 | \r | |
1848 | case L'O':\r | |
1849 | Uart->Parity = 3;\r | |
1850 | break;\r | |
1851 | \r | |
1852 | case L'M':\r | |
1853 | Uart->Parity = 4;\r | |
1854 | break;\r | |
1855 | \r | |
1856 | case L'S':\r | |
1857 | Uart->Parity = 5;\r | |
1858 | break;\r | |
1859 | \r | |
1860 | default:\r | |
1861 | Uart->Parity = (UINT8) Strtoi (ParityStr);\r | |
1862 | break;\r | |
1863 | }\r | |
1864 | \r | |
1865 | if (StrCmp (StopBitsStr, L"D") == 0) {\r | |
1866 | Uart->StopBits = (UINT8) 0;\r | |
1867 | } else if (StrCmp (StopBitsStr, L"1") == 0) {\r | |
1868 | Uart->StopBits = (UINT8) 1;\r | |
1869 | } else if (StrCmp (StopBitsStr, L"1.5") == 0) {\r | |
1870 | Uart->StopBits = (UINT8) 2;\r | |
1871 | } else if (StrCmp (StopBitsStr, L"2") == 0) {\r | |
1872 | Uart->StopBits = (UINT8) 3;\r | |
1873 | } else {\r | |
1874 | Uart->StopBits = (UINT8) Strtoi (StopBitsStr);\r | |
1875 | }\r | |
1876 | \r | |
1877 | return (EFI_DEVICE_PATH_PROTOCOL *) Uart;\r | |
1878 | }\r | |
1879 | \r | |
1880 | /**\r | |
1881 | Converts a text device path node to USB class device path structure.\r | |
1882 | \r | |
1883 | @param TextDeviceNode The input Text device path node.\r | |
1884 | @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.\r | |
1885 | \r | |
1886 | @return A pointer to the newly-created USB class device path structure.\r | |
1887 | \r | |
1888 | **/\r | |
1889 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1890 | ConvertFromTextUsbClass (\r | |
1891 | CHAR16 *TextDeviceNode,\r | |
1892 | USB_CLASS_TEXT *UsbClassText\r | |
1893 | )\r | |
1894 | {\r | |
1895 | CHAR16 *VIDStr;\r | |
1896 | CHAR16 *PIDStr;\r | |
1897 | CHAR16 *ClassStr;\r | |
1898 | CHAR16 *SubClassStr;\r | |
1899 | CHAR16 *ProtocolStr;\r | |
1900 | USB_CLASS_DEVICE_PATH *UsbClass;\r | |
1901 | \r | |
1902 | UsbClass = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (\r | |
1903 | MESSAGING_DEVICE_PATH,\r | |
1904 | MSG_USB_CLASS_DP,\r | |
1905 | (UINT16) sizeof (USB_CLASS_DEVICE_PATH)\r | |
1906 | );\r | |
1907 | \r | |
1908 | VIDStr = GetNextParamStr (&TextDeviceNode);\r | |
1909 | PIDStr = GetNextParamStr (&TextDeviceNode);\r | |
1910 | if (UsbClassText->ClassExist) {\r | |
1911 | ClassStr = GetNextParamStr (&TextDeviceNode);\r | |
23a62c69 FY |
1912 | if (*ClassStr == L'\0') {\r |
1913 | UsbClass->DeviceClass = 0xFF;\r | |
1914 | } else {\r | |
1915 | UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);\r | |
1916 | }\r | |
7dbc50bd YZ |
1917 | } else {\r |
1918 | UsbClass->DeviceClass = UsbClassText->Class;\r | |
1919 | }\r | |
1920 | if (UsbClassText->SubClassExist) {\r | |
1921 | SubClassStr = GetNextParamStr (&TextDeviceNode);\r | |
23a62c69 FY |
1922 | if (*SubClassStr == L'\0') {\r |
1923 | UsbClass->DeviceSubClass = 0xFF;\r | |
1924 | } else {\r | |
1925 | UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);\r | |
1926 | }\r | |
7dbc50bd YZ |
1927 | } else {\r |
1928 | UsbClass->DeviceSubClass = UsbClassText->SubClass;\r | |
1929 | }\r | |
1930 | \r | |
1931 | ProtocolStr = GetNextParamStr (&TextDeviceNode);\r | |
1932 | \r | |
23a62c69 FY |
1933 | if (*VIDStr == L'\0') {\r |
1934 | UsbClass->VendorId = 0xFFFF;\r | |
1935 | } else {\r | |
1936 | UsbClass->VendorId = (UINT16) Strtoi (VIDStr);\r | |
1937 | }\r | |
1938 | if (*PIDStr == L'\0') {\r | |
1939 | UsbClass->ProductId = 0xFFFF;\r | |
1940 | } else {\r | |
1941 | UsbClass->ProductId = (UINT16) Strtoi (PIDStr);\r | |
1942 | }\r | |
1943 | if (*ProtocolStr == L'\0') {\r | |
1944 | UsbClass->DeviceProtocol = 0xFF;\r | |
1945 | } else {\r | |
1946 | UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr);\r | |
1947 | }\r | |
7dbc50bd YZ |
1948 | \r |
1949 | return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;\r | |
1950 | }\r | |
1951 | \r | |
1952 | \r | |
1953 | /**\r | |
1954 | Converts a text device path node to USB class device path structure.\r | |
1955 | \r | |
1956 | @param TextDeviceNode The input Text device path node.\r | |
1957 | \r | |
1958 | @return A pointer to the newly-created USB class device path structure.\r | |
1959 | \r | |
1960 | **/\r | |
1961 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1962 | DevPathFromTextUsbClass (\r | |
1963 | CHAR16 *TextDeviceNode\r | |
1964 | )\r | |
1965 | {\r | |
1966 | USB_CLASS_TEXT UsbClassText;\r | |
1967 | \r | |
1968 | UsbClassText.ClassExist = TRUE;\r | |
1969 | UsbClassText.SubClassExist = TRUE;\r | |
1970 | \r | |
1971 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
1972 | }\r | |
1973 | \r | |
1974 | /**\r | |
1975 | Converts a text device path node to USB audio device path structure.\r | |
1976 | \r | |
1977 | @param TextDeviceNode The input Text device path node.\r | |
1978 | \r | |
1979 | @return A pointer to the newly-created USB audio device path structure.\r | |
1980 | \r | |
1981 | **/\r | |
1982 | EFI_DEVICE_PATH_PROTOCOL *\r | |
1983 | DevPathFromTextUsbAudio (\r | |
1984 | CHAR16 *TextDeviceNode\r | |
1985 | )\r | |
1986 | {\r | |
1987 | USB_CLASS_TEXT UsbClassText;\r | |
1988 | \r | |
1989 | UsbClassText.ClassExist = FALSE;\r | |
1990 | UsbClassText.Class = USB_CLASS_AUDIO;\r | |
1991 | UsbClassText.SubClassExist = TRUE;\r | |
1992 | \r | |
1993 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
1994 | }\r | |
1995 | \r | |
1996 | /**\r | |
1997 | Converts a text device path node to USB CDC Control device path structure.\r | |
1998 | \r | |
1999 | @param TextDeviceNode The input Text device path node.\r | |
2000 | \r | |
2001 | @return A pointer to the newly-created USB CDC Control device path structure.\r | |
2002 | \r | |
2003 | **/\r | |
2004 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2005 | DevPathFromTextUsbCDCControl (\r | |
2006 | CHAR16 *TextDeviceNode\r | |
2007 | )\r | |
2008 | {\r | |
2009 | USB_CLASS_TEXT UsbClassText;\r | |
2010 | \r | |
2011 | UsbClassText.ClassExist = FALSE;\r | |
2012 | UsbClassText.Class = USB_CLASS_CDCCONTROL;\r | |
2013 | UsbClassText.SubClassExist = TRUE;\r | |
2014 | \r | |
2015 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2016 | }\r | |
2017 | \r | |
2018 | /**\r | |
2019 | Converts a text device path node to USB HID device path structure.\r | |
2020 | \r | |
2021 | @param TextDeviceNode The input Text device path node.\r | |
2022 | \r | |
2023 | @return A pointer to the newly-created USB HID device path structure.\r | |
2024 | \r | |
2025 | **/\r | |
2026 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2027 | DevPathFromTextUsbHID (\r | |
2028 | CHAR16 *TextDeviceNode\r | |
2029 | )\r | |
2030 | {\r | |
2031 | USB_CLASS_TEXT UsbClassText;\r | |
2032 | \r | |
2033 | UsbClassText.ClassExist = FALSE;\r | |
2034 | UsbClassText.Class = USB_CLASS_HID;\r | |
2035 | UsbClassText.SubClassExist = TRUE;\r | |
2036 | \r | |
2037 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2038 | }\r | |
2039 | \r | |
2040 | /**\r | |
2041 | Converts a text device path node to USB Image device path structure.\r | |
2042 | \r | |
2043 | @param TextDeviceNode The input Text device path node.\r | |
2044 | \r | |
2045 | @return A pointer to the newly-created USB Image device path structure.\r | |
2046 | \r | |
2047 | **/\r | |
2048 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2049 | DevPathFromTextUsbImage (\r | |
2050 | CHAR16 *TextDeviceNode\r | |
2051 | )\r | |
2052 | {\r | |
2053 | USB_CLASS_TEXT UsbClassText;\r | |
2054 | \r | |
2055 | UsbClassText.ClassExist = FALSE;\r | |
2056 | UsbClassText.Class = USB_CLASS_IMAGE;\r | |
2057 | UsbClassText.SubClassExist = TRUE;\r | |
2058 | \r | |
2059 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2060 | }\r | |
2061 | \r | |
2062 | /**\r | |
2063 | Converts a text device path node to USB Print device path structure.\r | |
2064 | \r | |
2065 | @param TextDeviceNode The input Text device path node.\r | |
2066 | \r | |
2067 | @return A pointer to the newly-created USB Print device path structure.\r | |
2068 | \r | |
2069 | **/\r | |
2070 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2071 | DevPathFromTextUsbPrinter (\r | |
2072 | CHAR16 *TextDeviceNode\r | |
2073 | )\r | |
2074 | {\r | |
2075 | USB_CLASS_TEXT UsbClassText;\r | |
2076 | \r | |
2077 | UsbClassText.ClassExist = FALSE;\r | |
2078 | UsbClassText.Class = USB_CLASS_PRINTER;\r | |
2079 | UsbClassText.SubClassExist = TRUE;\r | |
2080 | \r | |
2081 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2082 | }\r | |
2083 | \r | |
2084 | /**\r | |
2085 | Converts a text device path node to USB mass storage device path structure.\r | |
2086 | \r | |
2087 | @param TextDeviceNode The input Text device path node.\r | |
2088 | \r | |
2089 | @return A pointer to the newly-created USB mass storage device path structure.\r | |
2090 | \r | |
2091 | **/\r | |
2092 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2093 | DevPathFromTextUsbMassStorage (\r | |
2094 | CHAR16 *TextDeviceNode\r | |
2095 | )\r | |
2096 | {\r | |
2097 | USB_CLASS_TEXT UsbClassText;\r | |
2098 | \r | |
2099 | UsbClassText.ClassExist = FALSE;\r | |
2100 | UsbClassText.Class = USB_CLASS_MASS_STORAGE;\r | |
2101 | UsbClassText.SubClassExist = TRUE;\r | |
2102 | \r | |
2103 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2104 | }\r | |
2105 | \r | |
2106 | /**\r | |
2107 | Converts a text device path node to USB HUB device path structure.\r | |
2108 | \r | |
2109 | @param TextDeviceNode The input Text device path node.\r | |
2110 | \r | |
2111 | @return A pointer to the newly-created USB HUB device path structure.\r | |
2112 | \r | |
2113 | **/\r | |
2114 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2115 | DevPathFromTextUsbHub (\r | |
2116 | CHAR16 *TextDeviceNode\r | |
2117 | )\r | |
2118 | {\r | |
2119 | USB_CLASS_TEXT UsbClassText;\r | |
2120 | \r | |
2121 | UsbClassText.ClassExist = FALSE;\r | |
2122 | UsbClassText.Class = USB_CLASS_HUB;\r | |
2123 | UsbClassText.SubClassExist = TRUE;\r | |
2124 | \r | |
2125 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2126 | }\r | |
2127 | \r | |
2128 | /**\r | |
2129 | Converts a text device path node to USB CDC data device path structure.\r | |
2130 | \r | |
2131 | @param TextDeviceNode The input Text device path node.\r | |
2132 | \r | |
2133 | @return A pointer to the newly-created USB CDC data device path structure.\r | |
2134 | \r | |
2135 | **/\r | |
2136 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2137 | DevPathFromTextUsbCDCData (\r | |
2138 | CHAR16 *TextDeviceNode\r | |
2139 | )\r | |
2140 | {\r | |
2141 | USB_CLASS_TEXT UsbClassText;\r | |
2142 | \r | |
2143 | UsbClassText.ClassExist = FALSE;\r | |
2144 | UsbClassText.Class = USB_CLASS_CDCDATA;\r | |
2145 | UsbClassText.SubClassExist = TRUE;\r | |
2146 | \r | |
2147 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2148 | }\r | |
2149 | \r | |
2150 | /**\r | |
2151 | Converts a text device path node to USB smart card device path structure.\r | |
2152 | \r | |
2153 | @param TextDeviceNode The input Text device path node.\r | |
2154 | \r | |
2155 | @return A pointer to the newly-created USB smart card device path structure.\r | |
2156 | \r | |
2157 | **/\r | |
2158 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2159 | DevPathFromTextUsbSmartCard (\r | |
2160 | CHAR16 *TextDeviceNode\r | |
2161 | )\r | |
2162 | {\r | |
2163 | USB_CLASS_TEXT UsbClassText;\r | |
2164 | \r | |
2165 | UsbClassText.ClassExist = FALSE;\r | |
2166 | UsbClassText.Class = USB_CLASS_SMART_CARD;\r | |
2167 | UsbClassText.SubClassExist = TRUE;\r | |
2168 | \r | |
2169 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2170 | }\r | |
2171 | \r | |
2172 | /**\r | |
2173 | Converts a text device path node to USB video device path structure.\r | |
2174 | \r | |
2175 | @param TextDeviceNode The input Text device path node.\r | |
2176 | \r | |
2177 | @return A pointer to the newly-created USB video device path structure.\r | |
2178 | \r | |
2179 | **/\r | |
2180 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2181 | DevPathFromTextUsbVideo (\r | |
2182 | CHAR16 *TextDeviceNode\r | |
2183 | )\r | |
2184 | {\r | |
2185 | USB_CLASS_TEXT UsbClassText;\r | |
2186 | \r | |
2187 | UsbClassText.ClassExist = FALSE;\r | |
2188 | UsbClassText.Class = USB_CLASS_VIDEO;\r | |
2189 | UsbClassText.SubClassExist = TRUE;\r | |
2190 | \r | |
2191 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2192 | }\r | |
2193 | \r | |
2194 | /**\r | |
2195 | Converts a text device path node to USB diagnostic device path structure.\r | |
2196 | \r | |
2197 | @param TextDeviceNode The input Text device path node.\r | |
2198 | \r | |
2199 | @return A pointer to the newly-created USB diagnostic device path structure.\r | |
2200 | \r | |
2201 | **/\r | |
2202 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2203 | DevPathFromTextUsbDiagnostic (\r | |
2204 | CHAR16 *TextDeviceNode\r | |
2205 | )\r | |
2206 | {\r | |
2207 | USB_CLASS_TEXT UsbClassText;\r | |
2208 | \r | |
2209 | UsbClassText.ClassExist = FALSE;\r | |
2210 | UsbClassText.Class = USB_CLASS_DIAGNOSTIC;\r | |
2211 | UsbClassText.SubClassExist = TRUE;\r | |
2212 | \r | |
2213 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2214 | }\r | |
2215 | \r | |
2216 | /**\r | |
2217 | Converts a text device path node to USB wireless device path structure.\r | |
2218 | \r | |
2219 | @param TextDeviceNode The input Text device path node.\r | |
2220 | \r | |
2221 | @return A pointer to the newly-created USB wireless device path structure.\r | |
2222 | \r | |
2223 | **/\r | |
2224 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2225 | DevPathFromTextUsbWireless (\r | |
2226 | CHAR16 *TextDeviceNode\r | |
2227 | )\r | |
2228 | {\r | |
2229 | USB_CLASS_TEXT UsbClassText;\r | |
2230 | \r | |
2231 | UsbClassText.ClassExist = FALSE;\r | |
2232 | UsbClassText.Class = USB_CLASS_WIRELESS;\r | |
2233 | UsbClassText.SubClassExist = TRUE;\r | |
2234 | \r | |
2235 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2236 | }\r | |
2237 | \r | |
2238 | /**\r | |
2239 | Converts a text device path node to USB device firmware update device path structure.\r | |
2240 | \r | |
2241 | @param TextDeviceNode The input Text device path node.\r | |
2242 | \r | |
2243 | @return A pointer to the newly-created USB device firmware update device path structure.\r | |
2244 | \r | |
2245 | **/\r | |
2246 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2247 | DevPathFromTextUsbDeviceFirmwareUpdate (\r | |
2248 | CHAR16 *TextDeviceNode\r | |
2249 | )\r | |
2250 | {\r | |
2251 | USB_CLASS_TEXT UsbClassText;\r | |
2252 | \r | |
2253 | UsbClassText.ClassExist = FALSE;\r | |
2254 | UsbClassText.Class = USB_CLASS_RESERVE;\r | |
2255 | UsbClassText.SubClassExist = FALSE;\r | |
2256 | UsbClassText.SubClass = USB_SUBCLASS_FW_UPDATE;\r | |
2257 | \r | |
2258 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2259 | }\r | |
2260 | \r | |
2261 | /**\r | |
2262 | Converts a text device path node to USB IRDA bridge device path structure.\r | |
2263 | \r | |
2264 | @param TextDeviceNode The input Text device path node.\r | |
2265 | \r | |
2266 | @return A pointer to the newly-created USB IRDA bridge device path structure.\r | |
2267 | \r | |
2268 | **/\r | |
2269 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2270 | DevPathFromTextUsbIrdaBridge (\r | |
2271 | CHAR16 *TextDeviceNode\r | |
2272 | )\r | |
2273 | {\r | |
2274 | USB_CLASS_TEXT UsbClassText;\r | |
2275 | \r | |
2276 | UsbClassText.ClassExist = FALSE;\r | |
2277 | UsbClassText.Class = USB_CLASS_RESERVE;\r | |
2278 | UsbClassText.SubClassExist = FALSE;\r | |
2279 | UsbClassText.SubClass = USB_SUBCLASS_IRDA_BRIDGE;\r | |
2280 | \r | |
2281 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2282 | }\r | |
2283 | \r | |
2284 | /**\r | |
2285 | Converts a text device path node to USB text and measurement device path structure.\r | |
2286 | \r | |
2287 | @param TextDeviceNode The input Text device path node.\r | |
2288 | \r | |
2289 | @return A pointer to the newly-created USB text and measurement device path structure.\r | |
2290 | \r | |
2291 | **/\r | |
2292 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2293 | DevPathFromTextUsbTestAndMeasurement (\r | |
2294 | CHAR16 *TextDeviceNode\r | |
2295 | )\r | |
2296 | {\r | |
2297 | USB_CLASS_TEXT UsbClassText;\r | |
2298 | \r | |
2299 | UsbClassText.ClassExist = FALSE;\r | |
2300 | UsbClassText.Class = USB_CLASS_RESERVE;\r | |
2301 | UsbClassText.SubClassExist = FALSE;\r | |
2302 | UsbClassText.SubClass = USB_SUBCLASS_TEST;\r | |
2303 | \r | |
2304 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2305 | }\r | |
2306 | \r | |
2307 | /**\r | |
2308 | Converts a text device path node to USB WWID device path structure.\r | |
2309 | \r | |
2310 | @param TextDeviceNode The input Text device path node.\r | |
2311 | \r | |
2312 | @return A pointer to the newly-created USB WWID device path structure.\r | |
2313 | \r | |
2314 | **/\r | |
2315 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2316 | DevPathFromTextUsbWwid (\r | |
2317 | CHAR16 *TextDeviceNode\r | |
2318 | )\r | |
2319 | {\r | |
2320 | CHAR16 *VIDStr;\r | |
2321 | CHAR16 *PIDStr;\r | |
2322 | CHAR16 *InterfaceNumStr;\r | |
2323 | CHAR16 *SerialNumberStr;\r | |
2324 | USB_WWID_DEVICE_PATH *UsbWwid;\r | |
2325 | UINTN SerialNumberStrLen;\r | |
2326 | \r | |
2327 | VIDStr = GetNextParamStr (&TextDeviceNode);\r | |
2328 | PIDStr = GetNextParamStr (&TextDeviceNode);\r | |
2329 | InterfaceNumStr = GetNextParamStr (&TextDeviceNode);\r | |
2330 | SerialNumberStr = GetNextParamStr (&TextDeviceNode);\r | |
2331 | SerialNumberStrLen = StrLen (SerialNumberStr);\r | |
2332 | if (SerialNumberStrLen >= 2 &&\r | |
2333 | SerialNumberStr[0] == L'\"' &&\r | |
2334 | SerialNumberStr[SerialNumberStrLen - 1] == L'\"'\r | |
2335 | ) {\r | |
2336 | SerialNumberStr[SerialNumberStrLen - 1] = L'\0';\r | |
2337 | SerialNumberStr++;\r | |
2338 | SerialNumberStrLen -= 2;\r | |
2339 | }\r | |
2340 | UsbWwid = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (\r | |
2341 | MESSAGING_DEVICE_PATH,\r | |
2342 | MSG_USB_WWID_DP,\r | |
2343 | (UINT16) (sizeof (USB_WWID_DEVICE_PATH) + SerialNumberStrLen * sizeof (CHAR16))\r | |
2344 | );\r | |
2345 | UsbWwid->VendorId = (UINT16) Strtoi (VIDStr);\r | |
2346 | UsbWwid->ProductId = (UINT16) Strtoi (PIDStr);\r | |
2347 | UsbWwid->InterfaceNumber = (UINT16) Strtoi (InterfaceNumStr);\r | |
2348 | \r | |
2349 | //\r | |
2350 | // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.\r | |
2351 | // Therefore, the '\0' will not be copied.\r | |
2352 | //\r | |
2353 | memcpy (\r | |
2354 | (UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH),\r | |
2355 | SerialNumberStr,\r | |
2356 | SerialNumberStrLen * sizeof (CHAR16)\r | |
2357 | );\r | |
2358 | \r | |
2359 | return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;\r | |
2360 | }\r | |
2361 | \r | |
2362 | /**\r | |
2363 | Converts a text device path node to Logic Unit device path structure.\r | |
2364 | \r | |
2365 | @param TextDeviceNode The input Text device path node.\r | |
2366 | \r | |
2367 | @return A pointer to the newly-created Logic Unit device path structure.\r | |
2368 | \r | |
2369 | **/\r | |
2370 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2371 | DevPathFromTextUnit (\r | |
2372 | CHAR16 *TextDeviceNode\r | |
2373 | )\r | |
2374 | {\r | |
2375 | CHAR16 *LunStr;\r | |
2376 | DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r | |
2377 | \r | |
2378 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
2379 | LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (\r | |
2380 | MESSAGING_DEVICE_PATH,\r | |
2381 | MSG_DEVICE_LOGICAL_UNIT_DP,\r | |
2382 | (UINT16) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)\r | |
2383 | );\r | |
2384 | \r | |
2385 | LogicalUnit->Lun = (UINT8) Strtoi (LunStr);\r | |
2386 | \r | |
2387 | return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;\r | |
2388 | }\r | |
2389 | \r | |
2390 | /**\r | |
2391 | Converts a text device path node to iSCSI device path structure.\r | |
2392 | \r | |
2393 | @param TextDeviceNode The input Text device path node.\r | |
2394 | \r | |
2395 | @return A pointer to the newly-created iSCSI device path structure.\r | |
2396 | \r | |
2397 | **/\r | |
2398 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2399 | DevPathFromTextiSCSI (\r | |
2400 | CHAR16 *TextDeviceNode\r | |
2401 | )\r | |
2402 | {\r | |
2403 | UINT16 Options;\r | |
2404 | CHAR16 *NameStr;\r | |
2405 | CHAR16 *PortalGroupStr;\r | |
2406 | CHAR16 *LunStr;\r | |
2407 | CHAR16 *HeaderDigestStr;\r | |
2408 | CHAR16 *DataDigestStr;\r | |
2409 | CHAR16 *AuthenticationStr;\r | |
2410 | CHAR16 *ProtocolStr;\r | |
2411 | CHAR8 *AsciiStr;\r | |
2412 | ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r | |
27db236a | 2413 | UINT64 Lun;\r |
7dbc50bd YZ |
2414 | \r |
2415 | NameStr = GetNextParamStr (&TextDeviceNode);\r | |
2416 | PortalGroupStr = GetNextParamStr (&TextDeviceNode);\r | |
2417 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
2418 | HeaderDigestStr = GetNextParamStr (&TextDeviceNode);\r | |
2419 | DataDigestStr = GetNextParamStr (&TextDeviceNode);\r | |
2420 | AuthenticationStr = GetNextParamStr (&TextDeviceNode);\r | |
2421 | ProtocolStr = GetNextParamStr (&TextDeviceNode);\r | |
2422 | ISCSIDevPath = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (\r | |
2423 | MESSAGING_DEVICE_PATH,\r | |
2424 | MSG_ISCSI_DP,\r | |
2425 | (UINT16) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr))\r | |
2426 | );\r | |
2427 | \r | |
2428 | AsciiStr = ISCSIDevPath->TargetName;\r | |
2429 | StrToAscii (NameStr, &AsciiStr);\r | |
2430 | \r | |
2431 | ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);\r | |
27db236a YZ |
2432 | Strtoi64 (LunStr, &Lun);\r |
2433 | WriteUnaligned64 ((UINT64 *) &ISCSIDevPath->Lun, SwapBytes64 (Lun));\r | |
7dbc50bd YZ |
2434 | \r |
2435 | Options = 0x0000;\r | |
2436 | if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {\r | |
2437 | Options |= 0x0002;\r | |
2438 | }\r | |
2439 | \r | |
2440 | if (StrCmp (DataDigestStr, L"CRC32C") == 0) {\r | |
2441 | Options |= 0x0008;\r | |
2442 | }\r | |
2443 | \r | |
2444 | if (StrCmp (AuthenticationStr, L"None") == 0) {\r | |
2445 | Options |= 0x0800;\r | |
2446 | }\r | |
2447 | \r | |
2448 | if (StrCmp (AuthenticationStr, L"CHAP_UNI") == 0) {\r | |
2449 | Options |= 0x1000;\r | |
2450 | }\r | |
2451 | \r | |
2452 | ISCSIDevPath->LoginOption = (UINT16) Options;\r | |
2453 | \r | |
c1d6749b | 2454 | if (IS_NULL (*ProtocolStr) || (StrCmp (ProtocolStr, L"TCP") == 0)) {\r |
7dbc50bd YZ |
2455 | ISCSIDevPath->NetworkProtocol = 0;\r |
2456 | } else {\r | |
2457 | //\r | |
2458 | // Undefined and reserved.\r | |
2459 | //\r | |
2460 | ISCSIDevPath->NetworkProtocol = 1;\r | |
2461 | }\r | |
2462 | \r | |
2463 | return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;\r | |
2464 | }\r | |
2465 | \r | |
2466 | /**\r | |
2467 | Converts a text device path node to VLAN device path structure.\r | |
2468 | \r | |
2469 | @param TextDeviceNode The input Text device path node.\r | |
2470 | \r | |
2471 | @return A pointer to the newly-created VLAN device path structure.\r | |
2472 | \r | |
2473 | **/\r | |
2474 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2475 | DevPathFromTextVlan (\r | |
2476 | CHAR16 *TextDeviceNode\r | |
2477 | )\r | |
2478 | {\r | |
2479 | CHAR16 *VlanStr;\r | |
2480 | VLAN_DEVICE_PATH *Vlan;\r | |
2481 | \r | |
2482 | VlanStr = GetNextParamStr (&TextDeviceNode);\r | |
2483 | Vlan = (VLAN_DEVICE_PATH *) CreateDeviceNode (\r | |
2484 | MESSAGING_DEVICE_PATH,\r | |
2485 | MSG_VLAN_DP,\r | |
2486 | (UINT16) sizeof (VLAN_DEVICE_PATH)\r | |
2487 | );\r | |
2488 | \r | |
2489 | Vlan->VlanId = (UINT16) Strtoi (VlanStr);\r | |
2490 | \r | |
2491 | return (EFI_DEVICE_PATH_PROTOCOL *) Vlan;\r | |
2492 | }\r | |
2493 | \r | |
2494 | /**\r | |
2495 | Converts a text device path node to Bluetooth device path structure.\r | |
2496 | \r | |
2497 | @param TextDeviceNode The input Text device path node.\r | |
2498 | \r | |
2499 | @return A pointer to the newly-created Bluetooth device path structure.\r | |
2500 | \r | |
2501 | **/\r | |
2502 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2503 | DevPathFromTextBluetooth (\r | |
2504 | CHAR16 *TextDeviceNode\r | |
2505 | )\r | |
2506 | {\r | |
2507 | CHAR16 *BluetoothStr;\r | |
2508 | BLUETOOTH_DEVICE_PATH *BluetoothDp;\r | |
2509 | \r | |
2510 | BluetoothStr = GetNextParamStr (&TextDeviceNode);\r | |
2511 | BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (\r | |
2512 | MESSAGING_DEVICE_PATH,\r | |
2513 | MSG_BLUETOOTH_DP,\r | |
2514 | (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)\r | |
2515 | );\r | |
2516 | StrHexToBytes (\r | |
2517 | BluetoothStr,\r | |
2518 | sizeof (BLUETOOTH_ADDRESS) * 2,\r | |
2519 | BluetoothDp->BD_ADDR.Address,\r | |
2520 | sizeof (BLUETOOTH_ADDRESS)\r | |
2521 | );\r | |
2522 | return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothDp;\r | |
2523 | }\r | |
2524 | \r | |
2525 | /**\r | |
2526 | Converts a text device path node to Wi-Fi device path structure.\r | |
2527 | \r | |
2528 | @param TextDeviceNode The input Text device path node.\r | |
2529 | \r | |
2530 | @return A pointer to the newly-created Wi-Fi device path structure.\r | |
2531 | \r | |
2532 | **/\r | |
2533 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2534 | DevPathFromTextWiFi (\r | |
2535 | CHAR16 *TextDeviceNode\r | |
2536 | )\r | |
2537 | {\r | |
2538 | CHAR16 *SSIdStr;\r | |
2539 | CHAR8 AsciiStr[33];\r | |
2540 | UINTN DataLen;\r | |
2541 | WIFI_DEVICE_PATH *WiFiDp;\r | |
2542 | \r | |
2543 | SSIdStr = GetNextParamStr (&TextDeviceNode);\r | |
2544 | WiFiDp = (WIFI_DEVICE_PATH *) CreateDeviceNode (\r | |
2545 | MESSAGING_DEVICE_PATH,\r | |
2546 | MSG_WIFI_DP,\r | |
2547 | (UINT16) sizeof (WIFI_DEVICE_PATH)\r | |
2548 | );\r | |
2549 | \r | |
2550 | if (NULL != SSIdStr) {\r | |
2551 | DataLen = StrLen (SSIdStr);\r | |
2552 | if (StrLen (SSIdStr) > 32) {\r | |
2553 | SSIdStr[32] = L'\0';\r | |
2554 | DataLen = 32;\r | |
2555 | }\r | |
2556 | \r | |
2557 | UnicodeStrToAsciiStrS (SSIdStr, AsciiStr, sizeof (AsciiStr));\r | |
2558 | memcpy (WiFiDp->SSId, AsciiStr, DataLen);\r | |
2559 | }\r | |
2560 | \r | |
2561 | return (EFI_DEVICE_PATH_PROTOCOL *) WiFiDp;\r | |
2562 | }\r | |
2563 | \r | |
f52c3ed0 YF |
2564 | /**\r |
2565 | Converts a text device path node to Bluetooth LE device path structure.\r | |
2566 | \r | |
2567 | @param TextDeviceNode The input Text device path node.\r | |
2568 | \r | |
2569 | @return A pointer to the newly-created Bluetooth LE device path structure.\r | |
2570 | \r | |
2571 | **/\r | |
2572 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2573 | DevPathFromTextBluetoothLE (\r | |
2574 | IN CHAR16 *TextDeviceNode\r | |
2575 | )\r | |
2576 | {\r | |
2577 | CHAR16 *BluetoothLeAddrStr;\r | |
2578 | CHAR16 *BluetoothLeAddrTypeStr;\r | |
2579 | BLUETOOTH_LE_DEVICE_PATH *BluetoothLeDp;\r | |
2580 | \r | |
2581 | BluetoothLeAddrStr = GetNextParamStr (&TextDeviceNode);\r | |
2582 | BluetoothLeAddrTypeStr = GetNextParamStr (&TextDeviceNode);\r | |
2583 | BluetoothLeDp = (BLUETOOTH_LE_DEVICE_PATH *) CreateDeviceNode (\r | |
2584 | MESSAGING_DEVICE_PATH,\r | |
2585 | MSG_BLUETOOTH_LE_DP,\r | |
2586 | (UINT16) sizeof (BLUETOOTH_LE_DEVICE_PATH)\r | |
2587 | );\r | |
2588 | \r | |
2589 | BluetoothLeDp->Address.Type = (UINT8) Strtoi (BluetoothLeAddrTypeStr);\r | |
2590 | StrHexToBytes (\r | |
2591 | BluetoothLeAddrStr, sizeof (BluetoothLeDp->Address.Address) * 2,\r | |
2592 | BluetoothLeDp->Address.Address, sizeof (BluetoothLeDp->Address.Address)\r | |
2593 | );\r | |
2594 | return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothLeDp;\r | |
2595 | }\r | |
2596 | \r | |
2597 | /**\r | |
2598 | Converts a text device path node to DNS device path structure.\r | |
2599 | \r | |
2600 | @param TextDeviceNode The input Text device path node.\r | |
2601 | \r | |
2602 | @return A pointer to the newly-created DNS device path structure.\r | |
2603 | \r | |
2604 | **/\r | |
2605 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2606 | DevPathFromTextDns (\r | |
2607 | IN CHAR16 *TextDeviceNode\r | |
2608 | )\r | |
2609 | {\r | |
2610 | CHAR16 *DeviceNodeStr;\r | |
2611 | CHAR16 *DeviceNodeStrPtr;\r | |
2612 | UINT32 DnsServerIpCount;\r | |
2613 | UINT16 DnsDeviceNodeLength;\r | |
2614 | DNS_DEVICE_PATH *DnsDeviceNode;\r | |
2615 | UINT32 DnsServerIpIndex;\r | |
2616 | CHAR16 *DnsServerIp;\r | |
2617 | \r | |
2618 | \r | |
2619 | //\r | |
2620 | // Count the DNS server address number.\r | |
2621 | //\r | |
2622 | DeviceNodeStr = UefiDevicePathLibStrDuplicate (TextDeviceNode);\r | |
2623 | if (DeviceNodeStr == NULL) {\r | |
2624 | return NULL;\r | |
2625 | }\r | |
2626 | \r | |
2627 | DeviceNodeStrPtr = DeviceNodeStr;\r | |
2628 | \r | |
2629 | DnsServerIpCount = 0;\r | |
2630 | while (DeviceNodeStrPtr != NULL && *DeviceNodeStrPtr != L'\0') {\r | |
2631 | GetNextParamStr (&DeviceNodeStrPtr);\r | |
2632 | DnsServerIpCount ++;\r | |
2633 | }\r | |
2634 | \r | |
2635 | free (DeviceNodeStr);\r | |
2636 | DeviceNodeStr = NULL;\r | |
2637 | \r | |
2638 | //\r | |
2639 | // One or more instances of the DNS server address in EFI_IP_ADDRESS,\r | |
2640 | // otherwise, NULL will be returned.\r | |
2641 | //\r | |
2642 | if (DnsServerIpCount == 0) {\r | |
2643 | return NULL;\r | |
2644 | }\r | |
2645 | \r | |
2646 | //\r | |
2647 | // Create the DNS DeviceNode.\r | |
2648 | //\r | |
2649 | DnsDeviceNodeLength = (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (UINT8) + DnsServerIpCount * sizeof (EFI_IP_ADDRESS));\r | |
2650 | DnsDeviceNode = (DNS_DEVICE_PATH *) CreateDeviceNode (\r | |
2651 | MESSAGING_DEVICE_PATH,\r | |
2652 | MSG_DNS_DP,\r | |
2653 | DnsDeviceNodeLength\r | |
2654 | );\r | |
2655 | if (DnsDeviceNode == NULL) {\r | |
2656 | return NULL;\r | |
2657 | }\r | |
2658 | \r | |
2659 | //\r | |
2660 | // Confirm the DNS server address is IPv4 or IPv6 type.\r | |
2661 | //\r | |
2662 | DeviceNodeStrPtr = TextDeviceNode;\r | |
2663 | while (!IS_NULL (*DeviceNodeStrPtr)) {\r | |
2664 | if (*DeviceNodeStrPtr == L'.') {\r | |
2665 | DnsDeviceNode->IsIPv6 = 0x00;\r | |
2666 | break;\r | |
2667 | }\r | |
2668 | \r | |
2669 | if (*DeviceNodeStrPtr == L':') {\r | |
2670 | DnsDeviceNode->IsIPv6 = 0x01;\r | |
2671 | break;\r | |
2672 | }\r | |
2673 | \r | |
2674 | DeviceNodeStrPtr++;\r | |
2675 | }\r | |
2676 | \r | |
2677 | for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; DnsServerIpIndex++) {\r | |
2678 | DnsServerIp = GetNextParamStr (&TextDeviceNode);\r | |
2679 | if (DnsDeviceNode->IsIPv6 == 0x00) {\r | |
2680 | StrToIpv4Address (DnsServerIp, NULL, &(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v4), NULL);\r | |
2681 | } else {\r | |
2682 | StrToIpv6Address (DnsServerIp, NULL, &(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v6), NULL);\r | |
2683 | }\r | |
2684 | }\r | |
2685 | \r | |
2686 | return (EFI_DEVICE_PATH_PROTOCOL *) DnsDeviceNode;\r | |
2687 | }\r | |
2688 | \r | |
7dbc50bd YZ |
2689 | /**\r |
2690 | Converts a text device path node to URI device path structure.\r | |
2691 | \r | |
2692 | @param TextDeviceNode The input Text device path node.\r | |
2693 | \r | |
2694 | @return A pointer to the newly-created URI device path structure.\r | |
2695 | \r | |
2696 | **/\r | |
2697 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2698 | DevPathFromTextUri (\r | |
2699 | CHAR16 *TextDeviceNode\r | |
2700 | )\r | |
2701 | {\r | |
2702 | CHAR16 *UriStr;\r | |
2703 | UINTN UriLength;\r | |
2704 | URI_DEVICE_PATH *Uri;\r | |
2705 | \r | |
2706 | UriStr = GetNextParamStr (&TextDeviceNode);\r | |
2707 | UriLength = StrnLenS (UriStr, MAX_UINT16 - sizeof (URI_DEVICE_PATH));\r | |
2708 | Uri = (URI_DEVICE_PATH *) CreateDeviceNode (\r | |
2709 | MESSAGING_DEVICE_PATH,\r | |
2710 | MSG_URI_DP,\r | |
2711 | (UINT16) (sizeof (URI_DEVICE_PATH) + UriLength)\r | |
2712 | );\r | |
2713 | \r | |
2714 | while (UriLength-- != 0) {\r | |
2715 | Uri->Uri[UriLength] = (CHAR8) UriStr[UriLength];\r | |
2716 | }\r | |
2717 | \r | |
2718 | return (EFI_DEVICE_PATH_PROTOCOL *) Uri;\r | |
2719 | }\r | |
2720 | \r | |
2721 | /**\r | |
2722 | Converts a media text device path node to media device path structure.\r | |
2723 | \r | |
2724 | @param TextDeviceNode The input Text device path node.\r | |
2725 | \r | |
2726 | @return A pointer to media device path structure.\r | |
2727 | \r | |
2728 | **/\r | |
2729 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2730 | DevPathFromTextMediaPath (\r | |
2731 | CHAR16 *TextDeviceNode\r | |
2732 | )\r | |
2733 | {\r | |
2734 | return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH, TextDeviceNode);\r | |
2735 | }\r | |
2736 | \r | |
2737 | /**\r | |
2738 | Converts a text device path node to HD device path structure.\r | |
2739 | \r | |
2740 | @param TextDeviceNode The input Text device path node.\r | |
2741 | \r | |
2742 | @return A pointer to the newly-created HD device path structure.\r | |
2743 | \r | |
2744 | **/\r | |
2745 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2746 | DevPathFromTextHD (\r | |
2747 | CHAR16 *TextDeviceNode\r | |
2748 | )\r | |
2749 | {\r | |
2750 | CHAR16 *PartitionStr;\r | |
2751 | CHAR16 *TypeStr;\r | |
2752 | CHAR16 *SignatureStr;\r | |
2753 | CHAR16 *StartStr;\r | |
2754 | CHAR16 *SizeStr;\r | |
2755 | UINT32 Signature32;\r | |
2756 | HARDDRIVE_DEVICE_PATH *Hd;\r | |
2757 | \r | |
2758 | PartitionStr = GetNextParamStr (&TextDeviceNode);\r | |
2759 | TypeStr = GetNextParamStr (&TextDeviceNode);\r | |
2760 | SignatureStr = GetNextParamStr (&TextDeviceNode);\r | |
2761 | StartStr = GetNextParamStr (&TextDeviceNode);\r | |
2762 | SizeStr = GetNextParamStr (&TextDeviceNode);\r | |
2763 | Hd = (HARDDRIVE_DEVICE_PATH *) CreateDeviceNode (\r | |
2764 | MEDIA_DEVICE_PATH,\r | |
2765 | MEDIA_HARDDRIVE_DP,\r | |
2766 | (UINT16) sizeof (HARDDRIVE_DEVICE_PATH)\r | |
2767 | );\r | |
2768 | \r | |
2769 | Hd->PartitionNumber = (UINT32) Strtoi (PartitionStr);\r | |
2770 | \r | |
2771 | ZeroMem (Hd->Signature, 16);\r | |
2772 | Hd->MBRType = (UINT8) 0;\r | |
2773 | \r | |
2774 | if (StrCmp (TypeStr, L"MBR") == 0) {\r | |
2775 | Hd->SignatureType = SIGNATURE_TYPE_MBR;\r | |
2776 | Hd->MBRType = 0x01;\r | |
2777 | \r | |
2778 | Signature32 = (UINT32) Strtoi (SignatureStr);\r | |
2779 | memcpy (Hd->Signature, &Signature32, sizeof (UINT32));\r | |
2780 | } else if (StrCmp (TypeStr, L"GPT") == 0) {\r | |
2781 | Hd->SignatureType = SIGNATURE_TYPE_GUID;\r | |
2782 | Hd->MBRType = 0x02;\r | |
2783 | \r | |
2784 | StrToGuid (SignatureStr, (EFI_GUID *) Hd->Signature);\r | |
2785 | } else {\r | |
2786 | Hd->SignatureType = (UINT8) Strtoi (TypeStr);\r | |
2787 | }\r | |
2788 | \r | |
2789 | Strtoi64 (StartStr, &Hd->PartitionStart);\r | |
2790 | Strtoi64 (SizeStr, &Hd->PartitionSize);\r | |
2791 | \r | |
2792 | return (EFI_DEVICE_PATH_PROTOCOL *) Hd;\r | |
2793 | }\r | |
2794 | \r | |
2795 | /**\r | |
2796 | Converts a text device path node to CDROM device path structure.\r | |
2797 | \r | |
2798 | @param TextDeviceNode The input Text device path node.\r | |
2799 | \r | |
2800 | @return A pointer to the newly-created CDROM device path structure.\r | |
2801 | \r | |
2802 | **/\r | |
2803 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2804 | DevPathFromTextCDROM (\r | |
2805 | CHAR16 *TextDeviceNode\r | |
2806 | )\r | |
2807 | {\r | |
2808 | CHAR16 *EntryStr;\r | |
2809 | CHAR16 *StartStr;\r | |
2810 | CHAR16 *SizeStr;\r | |
2811 | CDROM_DEVICE_PATH *CDROMDevPath;\r | |
2812 | \r | |
2813 | EntryStr = GetNextParamStr (&TextDeviceNode);\r | |
2814 | StartStr = GetNextParamStr (&TextDeviceNode);\r | |
2815 | SizeStr = GetNextParamStr (&TextDeviceNode);\r | |
2816 | CDROMDevPath = (CDROM_DEVICE_PATH *) CreateDeviceNode (\r | |
2817 | MEDIA_DEVICE_PATH,\r | |
2818 | MEDIA_CDROM_DP,\r | |
2819 | (UINT16) sizeof (CDROM_DEVICE_PATH)\r | |
2820 | );\r | |
2821 | \r | |
2822 | CDROMDevPath->BootEntry = (UINT32) Strtoi (EntryStr);\r | |
2823 | Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);\r | |
2824 | Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);\r | |
2825 | \r | |
2826 | return (EFI_DEVICE_PATH_PROTOCOL *) CDROMDevPath;\r | |
2827 | }\r | |
2828 | \r | |
2829 | /**\r | |
2830 | Converts a text device path node to Vendor-defined media device path structure.\r | |
2831 | \r | |
2832 | @param TextDeviceNode The input Text device path node.\r | |
2833 | \r | |
2834 | @return A pointer to the newly-created Vendor-defined media device path structure.\r | |
2835 | \r | |
2836 | **/\r | |
2837 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2838 | DevPathFromTextVenMedia (\r | |
2839 | CHAR16 *TextDeviceNode\r | |
2840 | )\r | |
2841 | {\r | |
2842 | return ConvertFromTextVendor (\r | |
2843 | TextDeviceNode,\r | |
2844 | MEDIA_DEVICE_PATH,\r | |
2845 | MEDIA_VENDOR_DP\r | |
2846 | );\r | |
2847 | }\r | |
2848 | \r | |
2849 | /**\r | |
2850 | Converts a text device path node to File device path structure.\r | |
2851 | \r | |
2852 | @param TextDeviceNode The input Text device path node.\r | |
2853 | \r | |
2854 | @return A pointer to the newly-created File device path structure.\r | |
2855 | \r | |
2856 | **/\r | |
2857 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2858 | DevPathFromTextFilePath (\r | |
2859 | CHAR16 *TextDeviceNode\r | |
2860 | )\r | |
2861 | {\r | |
2862 | FILEPATH_DEVICE_PATH *File;\r | |
2863 | \r | |
2864 | File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (\r | |
2865 | MEDIA_DEVICE_PATH,\r | |
2866 | MEDIA_FILEPATH_DP,\r | |
2867 | (UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2)\r | |
2868 | );\r | |
2869 | \r | |
2870 | StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);\r | |
2871 | \r | |
2872 | return (EFI_DEVICE_PATH_PROTOCOL *) File;\r | |
2873 | }\r | |
2874 | \r | |
2875 | /**\r | |
2876 | Converts a text device path node to Media protocol device path structure.\r | |
2877 | \r | |
2878 | @param TextDeviceNode The input Text device path node.\r | |
2879 | \r | |
2880 | @return A pointer to the newly-created Media protocol device path structure.\r | |
2881 | \r | |
2882 | **/\r | |
2883 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2884 | DevPathFromTextMedia (\r | |
2885 | CHAR16 *TextDeviceNode\r | |
2886 | )\r | |
2887 | {\r | |
2888 | CHAR16 *GuidStr;\r | |
2889 | MEDIA_PROTOCOL_DEVICE_PATH *Media;\r | |
2890 | \r | |
2891 | GuidStr = GetNextParamStr (&TextDeviceNode);\r | |
2892 | Media = (MEDIA_PROTOCOL_DEVICE_PATH *) CreateDeviceNode (\r | |
2893 | MEDIA_DEVICE_PATH,\r | |
2894 | MEDIA_PROTOCOL_DP,\r | |
2895 | (UINT16) sizeof (MEDIA_PROTOCOL_DEVICE_PATH)\r | |
2896 | );\r | |
2897 | \r | |
2898 | StrToGuid (GuidStr, &Media->Protocol);\r | |
2899 | \r | |
2900 | return (EFI_DEVICE_PATH_PROTOCOL *) Media;\r | |
2901 | }\r | |
2902 | \r | |
2903 | /**\r | |
2904 | Converts a text device path node to firmware volume device path structure.\r | |
2905 | \r | |
2906 | @param TextDeviceNode The input Text device path node.\r | |
2907 | \r | |
2908 | @return A pointer to the newly-created firmware volume device path structure.\r | |
2909 | \r | |
2910 | **/\r | |
2911 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2912 | DevPathFromTextFv (\r | |
2913 | CHAR16 *TextDeviceNode\r | |
2914 | )\r | |
2915 | {\r | |
2916 | CHAR16 *GuidStr;\r | |
2917 | MEDIA_FW_VOL_DEVICE_PATH *Fv;\r | |
2918 | \r | |
2919 | GuidStr = GetNextParamStr (&TextDeviceNode);\r | |
2920 | Fv = (MEDIA_FW_VOL_DEVICE_PATH *) CreateDeviceNode (\r | |
2921 | MEDIA_DEVICE_PATH,\r | |
2922 | MEDIA_PIWG_FW_VOL_DP,\r | |
2923 | (UINT16) sizeof (MEDIA_FW_VOL_DEVICE_PATH)\r | |
2924 | );\r | |
2925 | \r | |
2926 | StrToGuid (GuidStr, &Fv->FvName);\r | |
2927 | \r | |
2928 | return (EFI_DEVICE_PATH_PROTOCOL *) Fv;\r | |
2929 | }\r | |
2930 | \r | |
2931 | /**\r | |
2932 | Converts a text device path node to firmware file device path structure.\r | |
2933 | \r | |
2934 | @param TextDeviceNode The input Text device path node.\r | |
2935 | \r | |
2936 | @return A pointer to the newly-created firmware file device path structure.\r | |
2937 | \r | |
2938 | **/\r | |
2939 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2940 | DevPathFromTextFvFile (\r | |
2941 | CHAR16 *TextDeviceNode\r | |
2942 | )\r | |
2943 | {\r | |
2944 | CHAR16 *GuidStr;\r | |
2945 | MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;\r | |
2946 | \r | |
2947 | GuidStr = GetNextParamStr (&TextDeviceNode);\r | |
2948 | FvFile = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) CreateDeviceNode (\r | |
2949 | MEDIA_DEVICE_PATH,\r | |
2950 | MEDIA_PIWG_FW_FILE_DP,\r | |
2951 | (UINT16) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)\r | |
2952 | );\r | |
2953 | \r | |
2954 | StrToGuid (GuidStr, &FvFile->FvFileName);\r | |
2955 | \r | |
2956 | return (EFI_DEVICE_PATH_PROTOCOL *) FvFile;\r | |
2957 | }\r | |
2958 | \r | |
2959 | /**\r | |
2960 | Converts a text device path node to text relative offset device path structure.\r | |
2961 | \r | |
2962 | @param TextDeviceNode The input Text device path node.\r | |
2963 | \r | |
2964 | @return A pointer to the newly-created Text device path structure.\r | |
2965 | \r | |
2966 | **/\r | |
2967 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2968 | DevPathFromTextRelativeOffsetRange (\r | |
2969 | CHAR16 *TextDeviceNode\r | |
2970 | )\r | |
2971 | {\r | |
2972 | CHAR16 *StartingOffsetStr;\r | |
2973 | CHAR16 *EndingOffsetStr;\r | |
2974 | MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r | |
2975 | \r | |
2976 | StartingOffsetStr = GetNextParamStr (&TextDeviceNode);\r | |
2977 | EndingOffsetStr = GetNextParamStr (&TextDeviceNode);\r | |
2978 | Offset = (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *) CreateDeviceNode (\r | |
2979 | MEDIA_DEVICE_PATH,\r | |
2980 | MEDIA_RELATIVE_OFFSET_RANGE_DP,\r | |
2981 | (UINT16) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH)\r | |
2982 | );\r | |
2983 | \r | |
2984 | Strtoi64 (StartingOffsetStr, &Offset->StartingOffset);\r | |
2985 | Strtoi64 (EndingOffsetStr, &Offset->EndingOffset);\r | |
2986 | \r | |
2987 | return (EFI_DEVICE_PATH_PROTOCOL *) Offset;\r | |
2988 | }\r | |
2989 | \r | |
2990 | /**\r | |
2991 | Converts a text device path node to text ram disk device path structure.\r | |
2992 | \r | |
2993 | @param TextDeviceNode The input Text device path node.\r | |
2994 | \r | |
2995 | @return A pointer to the newly-created Text device path structure.\r | |
2996 | \r | |
2997 | **/\r | |
2998 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2999 | DevPathFromTextRamDisk (\r | |
3000 | CHAR16 *TextDeviceNode\r | |
3001 | )\r | |
3002 | {\r | |
3003 | CHAR16 *StartingAddrStr;\r | |
3004 | CHAR16 *EndingAddrStr;\r | |
3005 | CHAR16 *TypeGuidStr;\r | |
3006 | CHAR16 *InstanceStr;\r | |
3007 | MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;\r | |
3008 | UINT64 StartingAddr;\r | |
3009 | UINT64 EndingAddr;\r | |
3010 | \r | |
3011 | StartingAddrStr = GetNextParamStr (&TextDeviceNode);\r | |
3012 | EndingAddrStr = GetNextParamStr (&TextDeviceNode);\r | |
3013 | InstanceStr = GetNextParamStr (&TextDeviceNode);\r | |
3014 | TypeGuidStr = GetNextParamStr (&TextDeviceNode);\r | |
3015 | RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (\r | |
3016 | MEDIA_DEVICE_PATH,\r | |
3017 | MEDIA_RAM_DISK_DP,\r | |
3018 | (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)\r | |
3019 | );\r | |
3020 | \r | |
3021 | Strtoi64 (StartingAddrStr, &StartingAddr);\r | |
3022 | WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);\r | |
3023 | Strtoi64 (EndingAddrStr, &EndingAddr);\r | |
3024 | WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);\r | |
3025 | RamDisk->Instance = (UINT16) Strtoi (InstanceStr);\r | |
3026 | StrToGuid (TypeGuidStr, &RamDisk->TypeGuid);\r | |
3027 | \r | |
3028 | return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;\r | |
3029 | }\r | |
3030 | \r | |
3031 | /**\r | |
3032 | Converts a text device path node to text virtual disk device path structure.\r | |
3033 | \r | |
3034 | @param TextDeviceNode The input Text device path node.\r | |
3035 | \r | |
3036 | @return A pointer to the newly-created Text device path structure.\r | |
3037 | \r | |
3038 | **/\r | |
3039 | EFI_DEVICE_PATH_PROTOCOL *\r | |
3040 | DevPathFromTextVirtualDisk (\r | |
3041 | CHAR16 *TextDeviceNode\r | |
3042 | )\r | |
3043 | {\r | |
3044 | CHAR16 *StartingAddrStr;\r | |
3045 | CHAR16 *EndingAddrStr;\r | |
3046 | CHAR16 *InstanceStr;\r | |
3047 | MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;\r | |
3048 | UINT64 StartingAddr;\r | |
3049 | UINT64 EndingAddr;\r | |
3050 | \r | |
3051 | StartingAddrStr = GetNextParamStr (&TextDeviceNode);\r | |
3052 | EndingAddrStr = GetNextParamStr (&TextDeviceNode);\r | |
3053 | InstanceStr = GetNextParamStr (&TextDeviceNode);\r | |
3054 | \r | |
3055 | RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (\r | |
3056 | MEDIA_DEVICE_PATH,\r | |
3057 | MEDIA_RAM_DISK_DP,\r | |
3058 | (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)\r | |
3059 | );\r | |
3060 | \r | |
3061 | Strtoi64 (StartingAddrStr, &StartingAddr);\r | |
3062 | WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);\r | |
3063 | Strtoi64 (EndingAddrStr, &EndingAddr);\r | |
3064 | WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);\r | |
3065 | RamDisk->Instance = (UINT16) Strtoi (InstanceStr);\r | |
3066 | CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid);\r | |
3067 | \r | |
3068 | return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;\r | |
3069 | }\r | |
3070 | \r | |
3071 | /**\r | |
3072 | Converts a text device path node to text virtual cd device path structure.\r | |
3073 | \r | |
3074 | @param TextDeviceNode The input Text device path node.\r | |
3075 | \r | |
3076 | @return A pointer to the newly-created Text device path structure.\r | |
3077 | \r | |
3078 | **/\r | |
3079 | EFI_DEVICE_PATH_PROTOCOL *\r | |
3080 | DevPathFromTextVirtualCd (\r | |
3081 | CHAR16 *TextDeviceNode\r | |
3082 | )\r | |
3083 | {\r | |
3084 | CHAR16 *StartingAddrStr;\r | |
3085 | CHAR16 *EndingAddrStr;\r | |
3086 | CHAR16 *InstanceStr;\r | |
3087 | MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;\r | |
3088 | UINT64 StartingAddr;\r | |
3089 | UINT64 EndingAddr;\r | |
3090 | \r | |
3091 | StartingAddrStr = GetNextParamStr (&TextDeviceNode);\r | |
3092 | EndingAddrStr = GetNextParamStr (&TextDeviceNode);\r | |
3093 | InstanceStr = GetNextParamStr (&TextDeviceNode);\r | |
3094 | \r | |
3095 | RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (\r | |
3096 | MEDIA_DEVICE_PATH,\r | |
3097 | MEDIA_RAM_DISK_DP,\r | |
3098 | (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)\r | |
3099 | );\r | |
3100 | \r | |
3101 | Strtoi64 (StartingAddrStr, &StartingAddr);\r | |
3102 | WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);\r | |
3103 | Strtoi64 (EndingAddrStr, &EndingAddr);\r | |
3104 | WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);\r | |
3105 | RamDisk->Instance = (UINT16) Strtoi (InstanceStr);\r | |
3106 | CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid);\r | |
3107 | \r | |
3108 | return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;\r | |
3109 | }\r | |
3110 | \r | |
3111 | /**\r | |
3112 | Converts a text device path node to text persistent virtual disk device path structure.\r | |
3113 | \r | |
3114 | @param TextDeviceNode The input Text device path node.\r | |
3115 | \r | |
3116 | @return A pointer to the newly-created Text device path structure.\r | |
3117 | \r | |
3118 | **/\r | |
3119 | EFI_DEVICE_PATH_PROTOCOL *\r | |
3120 | DevPathFromTextPersistentVirtualDisk (\r | |
3121 | CHAR16 *TextDeviceNode\r | |
3122 | )\r | |
3123 | {\r | |
3124 | CHAR16 *StartingAddrStr;\r | |
3125 | CHAR16 *EndingAddrStr;\r | |
3126 | CHAR16 *InstanceStr;\r | |
3127 | MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;\r | |
3128 | UINT64 StartingAddr;\r | |
3129 | UINT64 EndingAddr;\r | |
3130 | \r | |
3131 | StartingAddrStr = GetNextParamStr (&TextDeviceNode);\r | |
3132 | EndingAddrStr = GetNextParamStr (&TextDeviceNode);\r | |
3133 | InstanceStr = GetNextParamStr (&TextDeviceNode);\r | |
3134 | \r | |
3135 | RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (\r | |
3136 | MEDIA_DEVICE_PATH,\r | |
3137 | MEDIA_RAM_DISK_DP,\r | |
3138 | (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)\r | |
3139 | );\r | |
3140 | \r | |
3141 | Strtoi64 (StartingAddrStr, &StartingAddr);\r | |
3142 | WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);\r | |
3143 | Strtoi64 (EndingAddrStr, &EndingAddr);\r | |
3144 | WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);\r | |
3145 | RamDisk->Instance = (UINT16) Strtoi (InstanceStr);\r | |
3146 | CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid);\r | |
3147 | \r | |
3148 | return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;\r | |
3149 | }\r | |
3150 | \r | |
3151 | /**\r | |
3152 | Converts a text device path node to text persistent virtual cd device path structure.\r | |
3153 | \r | |
3154 | @param TextDeviceNode The input Text device path node.\r | |
3155 | \r | |
3156 | @return A pointer to the newly-created Text device path structure.\r | |
3157 | \r | |
3158 | **/\r | |
3159 | EFI_DEVICE_PATH_PROTOCOL *\r | |
3160 | DevPathFromTextPersistentVirtualCd (\r | |
3161 | CHAR16 *TextDeviceNode\r | |
3162 | )\r | |
3163 | {\r | |
3164 | CHAR16 *StartingAddrStr;\r | |
3165 | CHAR16 *EndingAddrStr;\r | |
3166 | CHAR16 *InstanceStr;\r | |
3167 | MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;\r | |
3168 | UINT64 StartingAddr;\r | |
3169 | UINT64 EndingAddr;\r | |
3170 | \r | |
3171 | StartingAddrStr = GetNextParamStr (&TextDeviceNode);\r | |
3172 | EndingAddrStr = GetNextParamStr (&TextDeviceNode);\r | |
3173 | InstanceStr = GetNextParamStr (&TextDeviceNode);\r | |
3174 | \r | |
3175 | RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (\r | |
3176 | MEDIA_DEVICE_PATH,\r | |
3177 | MEDIA_RAM_DISK_DP,\r | |
3178 | (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)\r | |
3179 | );\r | |
3180 | \r | |
3181 | Strtoi64 (StartingAddrStr, &StartingAddr);\r | |
3182 | WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);\r | |
3183 | Strtoi64 (EndingAddrStr, &EndingAddr);\r | |
3184 | WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);\r | |
3185 | RamDisk->Instance = (UINT16) Strtoi (InstanceStr);\r | |
3186 | CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid);\r | |
3187 | \r | |
3188 | return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;\r | |
3189 | }\r | |
3190 | \r | |
3191 | /**\r | |
3192 | Converts a BBS text device path node to BBS device path structure.\r | |
3193 | \r | |
3194 | @param TextDeviceNode The input Text device path node.\r | |
3195 | \r | |
3196 | @return A pointer to BBS device path structure.\r | |
3197 | \r | |
3198 | **/\r | |
3199 | EFI_DEVICE_PATH_PROTOCOL *\r | |
3200 | DevPathFromTextBbsPath (\r | |
3201 | CHAR16 *TextDeviceNode\r | |
3202 | )\r | |
3203 | {\r | |
3204 | return DevPathFromTextGenericPath (BBS_DEVICE_PATH, TextDeviceNode);\r | |
3205 | }\r | |
3206 | \r | |
3207 | /**\r | |
3208 | Converts a text device path node to BIOS Boot Specification device path structure.\r | |
3209 | \r | |
3210 | @param TextDeviceNode The input Text device path node.\r | |
3211 | \r | |
3212 | @return A pointer to the newly-created BIOS Boot Specification device path structure.\r | |
3213 | \r | |
3214 | **/\r | |
3215 | EFI_DEVICE_PATH_PROTOCOL *\r | |
3216 | DevPathFromTextBBS (\r | |
3217 | CHAR16 *TextDeviceNode\r | |
3218 | )\r | |
3219 | {\r | |
3220 | CHAR16 *TypeStr;\r | |
3221 | CHAR16 *IdStr;\r | |
3222 | CHAR16 *FlagsStr;\r | |
3223 | CHAR8 *AsciiStr;\r | |
3224 | BBS_BBS_DEVICE_PATH *Bbs;\r | |
3225 | \r | |
3226 | TypeStr = GetNextParamStr (&TextDeviceNode);\r | |
3227 | IdStr = GetNextParamStr (&TextDeviceNode);\r | |
3228 | FlagsStr = GetNextParamStr (&TextDeviceNode);\r | |
3229 | Bbs = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode (\r | |
3230 | BBS_DEVICE_PATH,\r | |
3231 | BBS_BBS_DP,\r | |
3232 | (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr))\r | |
3233 | );\r | |
3234 | \r | |
3235 | if (StrCmp (TypeStr, L"Floppy") == 0) {\r | |
3236 | Bbs->DeviceType = BBS_TYPE_FLOPPY;\r | |
3237 | } else if (StrCmp (TypeStr, L"HD") == 0) {\r | |
3238 | Bbs->DeviceType = BBS_TYPE_HARDDRIVE;\r | |
3239 | } else if (StrCmp (TypeStr, L"CDROM") == 0) {\r | |
3240 | Bbs->DeviceType = BBS_TYPE_CDROM;\r | |
3241 | } else if (StrCmp (TypeStr, L"PCMCIA") == 0) {\r | |
3242 | Bbs->DeviceType = BBS_TYPE_PCMCIA;\r | |
3243 | } else if (StrCmp (TypeStr, L"USB") == 0) {\r | |
3244 | Bbs->DeviceType = BBS_TYPE_USB;\r | |
3245 | } else if (StrCmp (TypeStr, L"Network") == 0) {\r | |
3246 | Bbs->DeviceType = BBS_TYPE_EMBEDDED_NETWORK;\r | |
3247 | } else {\r | |
3248 | Bbs->DeviceType = (UINT16) Strtoi (TypeStr);\r | |
3249 | }\r | |
3250 | \r | |
3251 | AsciiStr = Bbs->String;\r | |
3252 | StrToAscii (IdStr, &AsciiStr);\r | |
3253 | \r | |
3254 | Bbs->StatusFlag = (UINT16) Strtoi (FlagsStr);\r | |
3255 | \r | |
3256 | return (EFI_DEVICE_PATH_PROTOCOL *) Bbs;\r | |
3257 | }\r | |
3258 | \r | |
3259 | /**\r | |
3260 | Converts a text device path node to SATA device path structure.\r | |
3261 | \r | |
3262 | @param TextDeviceNode The input Text device path node.\r | |
3263 | \r | |
3264 | @return A pointer to the newly-created SATA device path structure.\r | |
3265 | \r | |
3266 | **/\r | |
3267 | EFI_DEVICE_PATH_PROTOCOL *\r | |
3268 | DevPathFromTextSata (\r | |
3269 | CHAR16 *TextDeviceNode\r | |
3270 | )\r | |
3271 | {\r | |
3272 | SATA_DEVICE_PATH *Sata;\r | |
3273 | CHAR16 *Param1;\r | |
3274 | CHAR16 *Param2;\r | |
3275 | CHAR16 *Param3;\r | |
3276 | \r | |
3277 | Param1 = GetNextParamStr (&TextDeviceNode);\r | |
3278 | Param2 = GetNextParamStr (&TextDeviceNode);\r | |
3279 | Param3 = GetNextParamStr (&TextDeviceNode);\r | |
3280 | \r | |
3281 | Sata = (SATA_DEVICE_PATH *) CreateDeviceNode (\r | |
3282 | MESSAGING_DEVICE_PATH,\r | |
3283 | MSG_SATA_DP,\r | |
3284 | (UINT16) sizeof (SATA_DEVICE_PATH)\r | |
3285 | );\r | |
3286 | Sata->HBAPortNumber = (UINT16) Strtoi (Param1);\r | |
23a62c69 FY |
3287 | \r |
3288 | //\r | |
3289 | // According to UEFI spec, if PMPN is not provided, the default is 0xFFFF\r | |
3290 | //\r | |
3291 | if (*Param2 == L'\0' ) {\r | |
3292 | Sata->PortMultiplierPortNumber = 0xFFFF;\r | |
3293 | } else {\r | |
3294 | Sata->PortMultiplierPortNumber = (UINT16) Strtoi (Param2);\r | |
3295 | }\r | |
7dbc50bd YZ |
3296 | Sata->Lun = (UINT16) Strtoi (Param3);\r |
3297 | \r | |
3298 | return (EFI_DEVICE_PATH_PROTOCOL *) Sata;\r | |
3299 | }\r | |
3300 | \r | |
3301 | DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable[] = {\r | |
3302 | {L"Path", DevPathFromTextPath },\r | |
3303 | \r | |
3304 | {L"HardwarePath", DevPathFromTextHardwarePath },\r | |
3305 | {L"Pci", DevPathFromTextPci },\r | |
3306 | {L"PcCard", DevPathFromTextPcCard },\r | |
3307 | {L"MemoryMapped", DevPathFromTextMemoryMapped },\r | |
3308 | {L"VenHw", DevPathFromTextVenHw },\r | |
3309 | {L"Ctrl", DevPathFromTextCtrl },\r | |
3310 | {L"BMC", DevPathFromTextBmc },\r | |
3311 | \r | |
3312 | {L"AcpiPath", DevPathFromTextAcpiPath },\r | |
3313 | {L"Acpi", DevPathFromTextAcpi },\r | |
3314 | {L"PciRoot", DevPathFromTextPciRoot },\r | |
3315 | {L"PcieRoot", DevPathFromTextPcieRoot },\r | |
3316 | {L"Floppy", DevPathFromTextFloppy },\r | |
3317 | {L"Keyboard", DevPathFromTextKeyboard },\r | |
3318 | {L"Serial", DevPathFromTextSerial },\r | |
3319 | {L"ParallelPort", DevPathFromTextParallelPort },\r | |
3320 | {L"AcpiEx", DevPathFromTextAcpiEx },\r | |
3321 | {L"AcpiExp", DevPathFromTextAcpiExp },\r | |
3322 | {L"AcpiAdr", DevPathFromTextAcpiAdr },\r | |
3323 | \r | |
3324 | {L"Msg", DevPathFromTextMsg },\r | |
3325 | {L"Ata", DevPathFromTextAta },\r | |
3326 | {L"Scsi", DevPathFromTextScsi },\r | |
3327 | {L"Fibre", DevPathFromTextFibre },\r | |
3328 | {L"FibreEx", DevPathFromTextFibreEx },\r | |
3329 | {L"I1394", DevPathFromText1394 },\r | |
3330 | {L"USB", DevPathFromTextUsb },\r | |
3331 | {L"I2O", DevPathFromTextI2O },\r | |
3332 | {L"Infiniband", DevPathFromTextInfiniband },\r | |
3333 | {L"VenMsg", DevPathFromTextVenMsg },\r | |
3334 | {L"VenPcAnsi", DevPathFromTextVenPcAnsi },\r | |
3335 | {L"VenVt100", DevPathFromTextVenVt100 },\r | |
3336 | {L"VenVt100Plus", DevPathFromTextVenVt100Plus },\r | |
3337 | {L"VenUtf8", DevPathFromTextVenUtf8 },\r | |
3338 | {L"UartFlowCtrl", DevPathFromTextUartFlowCtrl },\r | |
3339 | {L"SAS", DevPathFromTextSAS },\r | |
3340 | {L"SasEx", DevPathFromTextSasEx },\r | |
3341 | {L"NVMe", DevPathFromTextNVMe },\r | |
3342 | {L"UFS", DevPathFromTextUfs },\r | |
3343 | {L"SD", DevPathFromTextSd },\r | |
3344 | {L"eMMC", DevPathFromTextEmmc },\r | |
3345 | {L"DebugPort", DevPathFromTextDebugPort },\r | |
3346 | {L"MAC", DevPathFromTextMAC },\r | |
3347 | {L"IPv4", DevPathFromTextIPv4 },\r | |
3348 | {L"IPv6", DevPathFromTextIPv6 },\r | |
3349 | {L"Uart", DevPathFromTextUart },\r | |
3350 | {L"UsbClass", DevPathFromTextUsbClass },\r | |
3351 | {L"UsbAudio", DevPathFromTextUsbAudio },\r | |
3352 | {L"UsbCDCControl", DevPathFromTextUsbCDCControl },\r | |
3353 | {L"UsbHID", DevPathFromTextUsbHID },\r | |
3354 | {L"UsbImage", DevPathFromTextUsbImage },\r | |
3355 | {L"UsbPrinter", DevPathFromTextUsbPrinter },\r | |
3356 | {L"UsbMassStorage", DevPathFromTextUsbMassStorage },\r | |
3357 | {L"UsbHub", DevPathFromTextUsbHub },\r | |
3358 | {L"UsbCDCData", DevPathFromTextUsbCDCData },\r | |
3359 | {L"UsbSmartCard", DevPathFromTextUsbSmartCard },\r | |
3360 | {L"UsbVideo", DevPathFromTextUsbVideo },\r | |
3361 | {L"UsbDiagnostic", DevPathFromTextUsbDiagnostic },\r | |
3362 | {L"UsbWireless", DevPathFromTextUsbWireless },\r | |
3363 | {L"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate },\r | |
3364 | {L"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge },\r | |
3365 | {L"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement },\r | |
3366 | {L"UsbWwid", DevPathFromTextUsbWwid },\r | |
3367 | {L"Unit", DevPathFromTextUnit },\r | |
3368 | {L"iSCSI", DevPathFromTextiSCSI },\r | |
3369 | {L"Vlan", DevPathFromTextVlan },\r | |
f52c3ed0 | 3370 | {L"Dns", DevPathFromTextDns },\r |
7dbc50bd YZ |
3371 | {L"Uri", DevPathFromTextUri },\r |
3372 | {L"Bluetooth", DevPathFromTextBluetooth },\r | |
3373 | {L"Wi-Fi", DevPathFromTextWiFi },\r | |
f52c3ed0 | 3374 | {L"BluetoothLE", DevPathFromTextBluetoothLE },\r |
7dbc50bd YZ |
3375 | {L"MediaPath", DevPathFromTextMediaPath },\r |
3376 | {L"HD", DevPathFromTextHD },\r | |
3377 | {L"CDROM", DevPathFromTextCDROM },\r | |
3378 | {L"VenMedia", DevPathFromTextVenMedia },\r | |
3379 | {L"Media", DevPathFromTextMedia },\r | |
3380 | {L"Fv", DevPathFromTextFv },\r | |
3381 | {L"FvFile", DevPathFromTextFvFile },\r | |
3382 | {L"Offset", DevPathFromTextRelativeOffsetRange },\r | |
3383 | {L"RamDisk", DevPathFromTextRamDisk },\r | |
3384 | {L"VirtualDisk", DevPathFromTextVirtualDisk },\r | |
3385 | {L"VirtualCD", DevPathFromTextVirtualCd },\r | |
3386 | {L"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk },\r | |
3387 | {L"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd },\r | |
3388 | \r | |
3389 | {L"BbsPath", DevPathFromTextBbsPath },\r | |
3390 | {L"BBS", DevPathFromTextBBS },\r | |
3391 | {L"Sata", DevPathFromTextSata },\r | |
3392 | {NULL, NULL}\r | |
3393 | };\r | |
3394 | \r | |
3395 | /**\r | |
3396 | Convert text to the binary representation of a device node.\r | |
3397 | \r | |
3398 | @param TextDeviceNode TextDeviceNode points to the text representation of a device\r | |
3399 | node. Conversion starts with the first character and continues\r | |
3400 | until the first non-device node character.\r | |
3401 | \r | |
3402 | @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r | |
3403 | insufficient memory or text unsupported.\r | |
3404 | \r | |
3405 | **/\r | |
3406 | EFI_DEVICE_PATH_PROTOCOL *\r | |
3407 | UefiDevicePathLibConvertTextToDeviceNode (\r | |
3408 | CONST CHAR16 *TextDeviceNode\r | |
3409 | )\r | |
3410 | {\r | |
3411 | DEVICE_PATH_FROM_TEXT FromText;\r | |
3412 | CHAR16 *ParamStr;\r | |
3413 | EFI_DEVICE_PATH_PROTOCOL *DeviceNode;\r | |
3414 | CHAR16 *DeviceNodeStr;\r | |
3415 | UINTN Index;\r | |
3416 | \r | |
3417 | if ((TextDeviceNode == NULL) || (IS_NULL (*TextDeviceNode))) {\r | |
3418 | return NULL;\r | |
3419 | }\r | |
3420 | \r | |
3421 | ParamStr = NULL;\r | |
3422 | FromText = NULL;\r | |
3423 | DeviceNodeStr = UefiDevicePathLibStrDuplicate (TextDeviceNode);\r | |
3424 | ASSERT (DeviceNodeStr != NULL);\r | |
3425 | \r | |
3426 | for (Index = 0; mUefiDevicePathLibDevPathFromTextTable[Index].Function != NULL; Index++) {\r | |
3427 | ParamStr = GetParamByNodeName (DeviceNodeStr, mUefiDevicePathLibDevPathFromTextTable[Index].DevicePathNodeText);\r | |
3428 | if (ParamStr != NULL) {\r | |
3429 | FromText = mUefiDevicePathLibDevPathFromTextTable[Index].Function;\r | |
3430 | break;\r | |
3431 | }\r | |
3432 | }\r | |
3433 | \r | |
3434 | if (FromText == NULL) {\r | |
3435 | //\r | |
3436 | // A file path\r | |
3437 | //\r | |
3438 | FromText = DevPathFromTextFilePath;\r | |
3439 | DeviceNode = FromText (DeviceNodeStr);\r | |
46cced28 HW |
3440 | //\r |
3441 | // According to above logic, if 'FromText' is NULL in the 'if' statement,\r | |
3442 | // then 'ParamStr' must be NULL as well. No memory allocation has been made\r | |
3443 | // in this case.\r | |
3444 | //\r | |
3445 | // The below check is for addressing a false positive potential memory leak\r | |
3446 | // issue raised from static analysis.\r | |
3447 | //\r | |
3448 | if (ParamStr != NULL) {\r | |
3449 | free (ParamStr);\r | |
3450 | }\r | |
7dbc50bd YZ |
3451 | } else {\r |
3452 | DeviceNode = FromText (ParamStr);\r | |
3453 | free (ParamStr);\r | |
3454 | }\r | |
3455 | \r | |
3456 | free (DeviceNodeStr);\r | |
3457 | \r | |
3458 | return DeviceNode;\r | |
3459 | }\r | |
3460 | \r | |
3461 | /**\r | |
3462 | Convert text to the binary representation of a device path.\r | |
3463 | \r | |
3464 | \r | |
3465 | @param TextDevicePath TextDevicePath points to the text representation of a device\r | |
3466 | path. Conversion starts with the first character and continues\r | |
3467 | until the first non-device node character.\r | |
3468 | \r | |
3469 | @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r | |
3470 | there was insufficient memory.\r | |
3471 | \r | |
3472 | **/\r | |
3473 | EFI_DEVICE_PATH_PROTOCOL *\r | |
3474 | UefiDevicePathLibConvertTextToDevicePath (\r | |
3475 | CONST CHAR16 *TextDevicePath\r | |
3476 | )\r | |
3477 | {\r | |
3478 | EFI_DEVICE_PATH_PROTOCOL *DeviceNode;\r | |
3479 | EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;\r | |
3480 | CHAR16 *DevicePathStr;\r | |
3481 | CHAR16 *Str;\r | |
3482 | CHAR16 *DeviceNodeStr;\r | |
3483 | BOOLEAN IsInstanceEnd;\r | |
3484 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
3485 | \r | |
3486 | if ((TextDevicePath == NULL) || (IS_NULL (*TextDevicePath))) {\r | |
3487 | return NULL;\r | |
3488 | }\r | |
3489 | \r | |
3490 | DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r | |
3491 | ASSERT (DevicePath != NULL);\r | |
3492 | SetDevicePathEndNode (DevicePath);\r | |
3493 | \r | |
3494 | DevicePathStr = UefiDevicePathLibStrDuplicate (TextDevicePath);\r | |
3495 | \r | |
3496 | Str = DevicePathStr;\r | |
3497 | while ((DeviceNodeStr = GetNextDeviceNodeStr (&Str, &IsInstanceEnd)) != NULL) {\r | |
3498 | DeviceNode = UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr);\r | |
3499 | \r | |
3500 | NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);\r | |
3501 | free (DevicePath);\r | |
3502 | free (DeviceNode);\r | |
3503 | DevicePath = NewDevicePath;\r | |
3504 | \r | |
3505 | if (IsInstanceEnd) {\r | |
3506 | DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r | |
3507 | ASSERT (DeviceNode != NULL);\r | |
3508 | SetDevicePathEndNode (DeviceNode);\r | |
3509 | DeviceNode->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;\r | |
3510 | \r | |
3511 | NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);\r | |
3512 | free (DevicePath);\r | |
3513 | free (DeviceNode);\r | |
3514 | DevicePath = NewDevicePath;\r | |
3515 | }\r | |
3516 | }\r | |
3517 | \r | |
3518 | free (DevicePathStr);\r | |
3519 | return DevicePath;\r | |
3520 | }\r |