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