]>
Commit | Line | Data |
---|---|---|
13d40edd | 1 | /** @file\r |
2 | DevicePathFromText protocol as defined in the UEFI 2.0 specification.\r | |
95276127 | 3 | \r |
13d40edd | 4 | Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r |
5 | All rights reserved. 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 | |
95276127 | 9 | \r |
13d40edd | 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 | |
95276127 | 12 | \r |
13d40edd | 13 | **/\r |
95276127 | 14 | \r |
95276127 | 15 | #include "DevicePath.h"\r |
16 | \r | |
95276127 | 17 | \r |
572f5d8a | 18 | /**\r |
95276127 | 19 | \r |
572f5d8a | 20 | Duplicates a string.\r |
95276127 | 21 | \r |
572f5d8a | 22 | @param Src Source string.\r |
95276127 | 23 | \r |
572f5d8a | 24 | @return The duplicated string.\r |
25 | \r | |
26 | **/\r | |
27 | CHAR16 *\r | |
28 | StrDuplicate (\r | |
29 | IN CONST CHAR16 *Src\r | |
30 | )\r | |
95276127 | 31 | {\r |
572f5d8a | 32 | return AllocateCopyPool (StrSize (Src), Src);\r |
33 | }\r | |
95276127 | 34 | \r |
572f5d8a | 35 | /**\r |
95276127 | 36 | \r |
572f5d8a | 37 | Get parameter in a pair of parentheses follow the given node name.\r |
38 | For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".\r | |
95276127 | 39 | \r |
572f5d8a | 40 | @param Str Device Path Text.\r |
41 | @param NodeName Name of the node.\r | |
95276127 | 42 | \r |
572f5d8a | 43 | @return Parameter text for the node.\r |
44 | \r | |
45 | **/\r | |
95276127 | 46 | CHAR16 *\r |
47 | GetParamByNodeName (\r | |
48 | IN CHAR16 *Str,\r | |
49 | IN CHAR16 *NodeName\r | |
50 | )\r | |
95276127 | 51 | {\r |
52 | CHAR16 *ParamStr;\r | |
53 | CHAR16 *StrPointer;\r | |
54 | UINTN NodeNameLength;\r | |
55 | UINTN ParameterLength;\r | |
56 | \r | |
57 | //\r | |
58 | // Check whether the node name matchs\r | |
59 | //\r | |
60 | NodeNameLength = StrLen (NodeName);\r | |
61 | if (CompareMem (Str, NodeName, NodeNameLength * sizeof (CHAR16)) != 0) {\r | |
62 | return NULL;\r | |
63 | }\r | |
64 | \r | |
65 | ParamStr = Str + NodeNameLength;\r | |
66 | if (!IS_LEFT_PARENTH (*ParamStr)) {\r | |
67 | return NULL;\r | |
68 | }\r | |
69 | \r | |
70 | //\r | |
71 | // Skip the found '(' and find first occurrence of ')'\r | |
72 | //\r | |
73 | ParamStr++;\r | |
74 | ParameterLength = 0;\r | |
75 | StrPointer = ParamStr;\r | |
76 | while (!IS_NULL (*StrPointer)) {\r | |
77 | if (IS_RIGHT_PARENTH (*StrPointer)) {\r | |
78 | break;\r | |
79 | }\r | |
80 | StrPointer++;\r | |
81 | ParameterLength++;\r | |
82 | }\r | |
83 | if (IS_NULL (*StrPointer)) {\r | |
84 | //\r | |
85 | // ')' not found\r | |
86 | //\r | |
87 | return NULL;\r | |
88 | }\r | |
89 | \r | |
90 | ParamStr = AllocateCopyPool ((ParameterLength + 1) * sizeof (CHAR16), ParamStr);\r | |
91 | if (ParamStr == NULL) {\r | |
92 | return NULL;\r | |
93 | }\r | |
94 | //\r | |
95 | // Terminate the parameter string\r | |
96 | //\r | |
97 | ParamStr[ParameterLength] = L'\0';\r | |
98 | \r | |
99 | return ParamStr;\r | |
100 | }\r | |
101 | \r | |
572f5d8a | 102 | /**\r |
103 | Gets current sub-string from a string list, before return\r | |
104 | the list header is moved to next sub-string. The sub-string is separated\r | |
105 | by the specified character. For example, the separator is ',', the string\r | |
106 | list is "2,0,3", it returns "2", the remain list move to "0,3"\r | |
107 | \r | |
108 | @param List A string list separated by the specified separator\r | |
109 | @param Separator The separator character\r | |
110 | \r | |
111 | @return A pointer to the current sub-string\r | |
112 | \r | |
113 | **/\r | |
95276127 | 114 | CHAR16 *\r |
115 | SplitStr (\r | |
116 | IN OUT CHAR16 **List,\r | |
117 | IN CHAR16 Separator\r | |
118 | )\r | |
95276127 | 119 | {\r |
120 | CHAR16 *Str;\r | |
121 | CHAR16 *ReturnStr;\r | |
122 | \r | |
123 | Str = *List;\r | |
124 | ReturnStr = Str;\r | |
125 | \r | |
126 | if (IS_NULL (*Str)) {\r | |
127 | return ReturnStr;\r | |
128 | }\r | |
129 | \r | |
130 | //\r | |
131 | // Find first occurrence of the separator\r | |
132 | //\r | |
133 | while (!IS_NULL (*Str)) {\r | |
134 | if (*Str == Separator) {\r | |
135 | break;\r | |
136 | }\r | |
137 | Str++;\r | |
138 | }\r | |
139 | \r | |
140 | if (*Str == Separator) {\r | |
141 | //\r | |
142 | // Find a sub-string, terminate it\r | |
143 | //\r | |
144 | *Str = L'\0';\r | |
145 | Str++;\r | |
146 | }\r | |
147 | \r | |
148 | //\r | |
149 | // Move to next sub-string\r | |
150 | //\r | |
151 | *List = Str;\r | |
152 | \r | |
153 | return ReturnStr;\r | |
154 | }\r | |
155 | \r | |
572f5d8a | 156 | /**\r |
157 | Gets the next parameter string from the list.\r | |
158 | \r | |
159 | @param List A string list separated by the specified separator\r | |
160 | \r | |
161 | @return A pointer to the current sub-string\r | |
162 | \r | |
163 | **/\r | |
95276127 | 164 | CHAR16 *\r |
165 | GetNextParamStr (\r | |
166 | IN OUT CHAR16 **List\r | |
167 | )\r | |
168 | {\r | |
169 | //\r | |
170 | // The separator is comma\r | |
171 | //\r | |
172 | return SplitStr (List, L',');\r | |
173 | }\r | |
174 | \r | |
572f5d8a | 175 | /**\r |
176 | Get one device node from entire device path text.\r | |
177 | \r | |
178 | @param DevicePath On input, the current Device Path node; on output, the next device path node\r | |
179 | @param IsInstanceEnd This node is the end of a device path instance\r | |
180 | \r | |
181 | @return A device node text or NULL if no more device node available\r | |
182 | \r | |
183 | **/\r | |
95276127 | 184 | CHAR16 *\r |
185 | GetNextDeviceNodeStr (\r | |
186 | IN OUT CHAR16 **DevicePath,\r | |
187 | OUT BOOLEAN *IsInstanceEnd\r | |
188 | )\r | |
95276127 | 189 | {\r |
190 | CHAR16 *Str;\r | |
191 | CHAR16 *ReturnStr;\r | |
192 | UINTN ParenthesesStack;\r | |
193 | \r | |
194 | Str = *DevicePath;\r | |
195 | if (IS_NULL (*Str)) {\r | |
196 | return NULL;\r | |
197 | }\r | |
198 | \r | |
199 | //\r | |
200 | // Skip the leading '/', '(', ')' and ','\r | |
201 | //\r | |
202 | while (!IS_NULL (*Str)) {\r | |
203 | if (!IS_SLASH (*Str) &&\r | |
204 | !IS_COMMA (*Str) &&\r | |
205 | !IS_LEFT_PARENTH (*Str) &&\r | |
206 | !IS_RIGHT_PARENTH (*Str)) {\r | |
207 | break;\r | |
208 | }\r | |
209 | Str++;\r | |
210 | }\r | |
211 | \r | |
212 | ReturnStr = Str;\r | |
213 | \r | |
214 | //\r | |
215 | // Scan for the separator of this device node, '/' or ','\r | |
216 | //\r | |
217 | ParenthesesStack = 0;\r | |
218 | while (!IS_NULL (*Str)) {\r | |
219 | if ((IS_COMMA (*Str) || IS_SLASH (*Str)) && (ParenthesesStack == 0)) {\r | |
220 | break;\r | |
221 | }\r | |
222 | \r | |
223 | if (IS_LEFT_PARENTH (*Str)) {\r | |
224 | ParenthesesStack++;\r | |
225 | } else if (IS_RIGHT_PARENTH (*Str)) {\r | |
226 | ParenthesesStack--;\r | |
227 | }\r | |
228 | \r | |
229 | Str++;\r | |
230 | }\r | |
231 | \r | |
232 | if (ParenthesesStack != 0) {\r | |
233 | //\r | |
234 | // The '(' doesn't pair with ')', invalid device path text\r | |
235 | //\r | |
236 | return NULL;\r | |
237 | }\r | |
238 | \r | |
239 | if (IS_COMMA (*Str)) {\r | |
240 | *IsInstanceEnd = TRUE;\r | |
241 | *Str = L'\0';\r | |
242 | Str++;\r | |
243 | } else {\r | |
244 | *IsInstanceEnd = FALSE;\r | |
245 | if (!IS_NULL (*Str)) {\r | |
246 | *Str = L'\0';\r | |
247 | Str++;\r | |
248 | }\r | |
249 | }\r | |
250 | \r | |
251 | *DevicePath = Str;\r | |
252 | \r | |
253 | return ReturnStr;\r | |
254 | }\r | |
255 | \r | |
95276127 | 256 | \r |
572f5d8a | 257 | /**\r |
258 | Skip the leading white space and '0x' or '0X' of a integer string\r | |
259 | \r | |
260 | @param Str The integer string\r | |
261 | @param IsHex TRUE: Hex string, FALSE: Decimal string\r | |
262 | \r | |
263 | @return The trimmed Hex string.\r | |
264 | \r | |
265 | **/\r | |
95276127 | 266 | CHAR16 *\r |
267 | TrimHexStr (\r | |
cf40f28a | 268 | IN CHAR16 *Str,\r |
269 | OUT BOOLEAN *IsHex\r | |
95276127 | 270 | )\r |
95276127 | 271 | {\r |
cf40f28a | 272 | *IsHex = FALSE;\r |
273 | \r | |
95276127 | 274 | //\r |
275 | // skip preceeding white space\r | |
276 | //\r | |
572f5d8a | 277 | while ((*Str != 0) && *Str == ' ') {\r |
95276127 | 278 | Str += 1;\r |
279 | }\r | |
280 | //\r | |
281 | // skip preceeding zeros\r | |
282 | //\r | |
572f5d8a | 283 | while ((*Str != 0) && *Str == '0') {\r |
95276127 | 284 | Str += 1;\r |
285 | }\r | |
286 | //\r | |
287 | // skip preceeding character 'x' or 'X'\r | |
288 | //\r | |
572f5d8a | 289 | if ((*Str != 0) && (*Str == 'x' || *Str == 'X')) {\r |
95276127 | 290 | Str += 1;\r |
cf40f28a | 291 | *IsHex = TRUE;\r |
95276127 | 292 | }\r |
293 | \r | |
294 | return Str;\r | |
295 | }\r | |
296 | \r | |
572f5d8a | 297 | /**\r |
95276127 | 298 | \r |
572f5d8a | 299 | Convert hex string to uint.\r |
95276127 | 300 | \r |
572f5d8a | 301 | @param Str The hex string\r |
95276127 | 302 | \r |
572f5d8a | 303 | @return A UINTN value represented by Str\r |
95276127 | 304 | \r |
572f5d8a | 305 | **/\r |
306 | UINTN\r | |
307 | Xtoi (\r | |
308 | IN CHAR16 *Str\r | |
309 | )\r | |
95276127 | 310 | {\r |
311 | UINTN Rvalue;\r | |
312 | UINTN Length;\r | |
313 | \r | |
314 | ASSERT (Str != NULL);\r | |
315 | \r | |
316 | //\r | |
317 | // convert hex digits\r | |
318 | //\r | |
319 | Rvalue = 0;\r | |
320 | Length = sizeof (UINTN);\r | |
cf40f28a | 321 | HexStringToBuf ((UINT8 *) &Rvalue, &Length, Str, NULL);\r |
95276127 | 322 | \r |
323 | return Rvalue;\r | |
324 | }\r | |
325 | \r | |
572f5d8a | 326 | /**\r |
95276127 | 327 | \r |
328 | Convert hex string to 64 bit data.\r | |
329 | \r | |
572f5d8a | 330 | @param Str The hex string\r |
331 | @param Data A pointer to the UINT64 value represented by Str\r | |
95276127 | 332 | \r |
572f5d8a | 333 | **/\r |
334 | VOID\r | |
335 | Xtoi64 (\r | |
336 | IN CHAR16 *Str,\r | |
337 | OUT UINT64 *Data\r | |
338 | )\r | |
95276127 | 339 | {\r |
340 | UINTN Length;\r | |
341 | \r | |
342 | *Data = 0;\r | |
343 | Length = sizeof (UINT64);\r | |
cf40f28a | 344 | HexStringToBuf ((UINT8 *) Data, &Length, Str, NULL);\r |
95276127 | 345 | }\r |
346 | \r | |
572f5d8a | 347 | /**\r |
95276127 | 348 | \r |
572f5d8a | 349 | Convert decimal string to uint.\r |
95276127 | 350 | \r |
572f5d8a | 351 | @param Str The decimal string\r |
95276127 | 352 | \r |
572f5d8a | 353 | @return A UINTN value represented by Str\r |
95276127 | 354 | \r |
572f5d8a | 355 | **/\r |
356 | UINTN\r | |
357 | Dtoi (\r | |
358 | IN CHAR16 *Str\r | |
359 | )\r | |
95276127 | 360 | {\r |
361 | UINTN Rvalue;\r | |
362 | CHAR16 Char;\r | |
363 | UINTN High;\r | |
364 | UINTN Low;\r | |
365 | \r | |
572f5d8a | 366 | ASSERT (Str != NULL);\r |
95276127 | 367 | \r |
368 | High = (UINTN) -1 / 10;\r | |
369 | Low = (UINTN) -1 % 10;\r | |
370 | //\r | |
371 | // skip preceeding white space\r | |
372 | //\r | |
572f5d8a | 373 | while ((*Str != 0) && *Str == ' ') {\r |
374 | Str += 1;\r | |
95276127 | 375 | }\r |
376 | //\r | |
377 | // convert digits\r | |
378 | //\r | |
379 | Rvalue = 0;\r | |
572f5d8a | 380 | Char = *(Str++);\r |
381 | while (Char != 0) {\r | |
95276127 | 382 | if (Char >= '0' && Char <= '9') {\r |
383 | if ((Rvalue > High || Rvalue == High) && (Char - '0' > (INTN) Low)) {\r | |
384 | return (UINTN) -1;\r | |
385 | }\r | |
386 | \r | |
387 | Rvalue = (Rvalue * 10) + Char - '0';\r | |
388 | } else {\r | |
389 | break;\r | |
390 | }\r | |
391 | \r | |
572f5d8a | 392 | Char = *(Str++);\r |
95276127 | 393 | }\r |
394 | \r | |
395 | return Rvalue;\r | |
396 | }\r | |
397 | \r | |
572f5d8a | 398 | /**\r |
399 | \r | |
400 | Convert decimal string to uint.\r | |
401 | \r | |
402 | @param Str The decimal string\r | |
403 | @param Data A pointer to the UINT64 value represented by Str\r | |
404 | \r | |
405 | **/\r | |
cf40f28a | 406 | VOID\r |
407 | Dtoi64 (\r | |
572f5d8a | 408 | IN CHAR16 *Str,\r |
cf40f28a | 409 | OUT UINT64 *Data\r |
410 | )\r | |
cf40f28a | 411 | {\r |
412 | UINT64 Rvalue;\r | |
413 | CHAR16 Char;\r | |
414 | UINT64 High;\r | |
415 | UINT64 Low;\r | |
416 | \r | |
572f5d8a | 417 | ASSERT (Str != NULL);\r |
cf40f28a | 418 | ASSERT (Data != NULL);\r |
419 | \r | |
420 | //\r | |
421 | // skip preceeding white space\r | |
422 | //\r | |
572f5d8a | 423 | while ((*Str != 0) && *Str == ' ') {\r |
424 | Str += 1;\r | |
cf40f28a | 425 | }\r |
426 | //\r | |
427 | // convert digits\r | |
428 | //\r | |
429 | Rvalue = 0;\r | |
572f5d8a | 430 | Char = *(Str++);\r |
431 | while (Char != 0) {\r | |
cf40f28a | 432 | if (Char >= '0' && Char <= '9') {\r |
433 | High = LShiftU64 (Rvalue, 3);\r | |
434 | Low = LShiftU64 (Rvalue, 1);\r | |
435 | Rvalue = High + Low + Char - '0';\r | |
436 | } else {\r | |
437 | break;\r | |
438 | }\r | |
439 | \r | |
572f5d8a | 440 | Char = *(Str++);\r |
cf40f28a | 441 | }\r |
442 | \r | |
443 | *Data = Rvalue;\r | |
444 | }\r | |
445 | \r | |
572f5d8a | 446 | /**\r |
cf40f28a | 447 | \r |
448 | Convert integer string to uint.\r | |
449 | \r | |
572f5d8a | 450 | @param Str The integer string. If leading with "0x" or "0X", it's heximal.\r |
cf40f28a | 451 | \r |
572f5d8a | 452 | @return A UINTN value represented by Str\r |
cf40f28a | 453 | \r |
572f5d8a | 454 | **/\r |
455 | UINTN\r | |
456 | Strtoi (\r | |
457 | IN CHAR16 *Str\r | |
458 | )\r | |
cf40f28a | 459 | {\r |
460 | BOOLEAN IsHex;\r | |
461 | \r | |
462 | Str = TrimHexStr (Str, &IsHex);\r | |
463 | \r | |
464 | if (IsHex) {\r | |
465 | return Xtoi (Str);\r | |
466 | } else {\r | |
467 | return Dtoi (Str);\r | |
468 | }\r | |
469 | }\r | |
470 | \r | |
572f5d8a | 471 | /**\r |
cf40f28a | 472 | \r |
473 | Convert integer string to 64 bit data.\r | |
474 | \r | |
572f5d8a | 475 | @param Str The integer string. If leading with "0x" or "0X", it's heximal.\r |
476 | @param Data A pointer to the UINT64 value represented by Str\r | |
cf40f28a | 477 | \r |
572f5d8a | 478 | **/\r |
479 | VOID\r | |
480 | Strtoi64 (\r | |
481 | IN CHAR16 *Str,\r | |
482 | OUT UINT64 *Data\r | |
483 | )\r | |
cf40f28a | 484 | {\r |
485 | BOOLEAN IsHex;\r | |
486 | \r | |
487 | Str = TrimHexStr (Str, &IsHex);\r | |
488 | \r | |
489 | if (IsHex) {\r | |
490 | Xtoi64 (Str, Data);\r | |
491 | } else {\r | |
492 | Dtoi64 (Str, Data);\r | |
493 | }\r | |
494 | }\r | |
495 | \r | |
572f5d8a | 496 | /**\r |
497 | Converts a list of string to a specified buffer.\r | |
498 | \r | |
499 | @param Buf The output buffer that contains the string.\r | |
500 | @param BufferLength The length of the buffer\r | |
501 | @param Str The input string that contains the hex number\r | |
502 | \r | |
503 | @retval EFI_SUCCESS The string was successfully converted to the buffer.\r | |
504 | \r | |
505 | **/\r | |
506 | EFI_STATUS\r | |
95276127 | 507 | StrToBuf (\r |
508 | OUT UINT8 *Buf,\r | |
509 | IN UINTN BufferLength,\r | |
510 | IN CHAR16 *Str\r | |
511 | )\r | |
512 | {\r | |
513 | UINTN Index;\r | |
514 | UINTN StrLength;\r | |
515 | UINT8 Digit;\r | |
516 | UINT8 Byte;\r | |
517 | \r | |
6ee5bbdd | 518 | Digit = 0;\r |
519 | \r | |
95276127 | 520 | //\r |
521 | // Two hex char make up one byte\r | |
522 | //\r | |
523 | StrLength = BufferLength * sizeof (CHAR16);\r | |
524 | \r | |
525 | for(Index = 0; Index < StrLength; Index++, Str++) {\r | |
526 | \r | |
527 | IsHexDigit (&Digit, *Str);\r | |
528 | \r | |
529 | //\r | |
530 | // For odd charaters, write the upper nibble for each buffer byte,\r | |
531 | // and for even characters, the lower nibble.\r | |
532 | //\r | |
533 | if ((Index & 1) == 0) {\r | |
534 | Byte = (UINT8) (Digit << 4);\r | |
535 | } else {\r | |
536 | Byte = Buf[Index / 2];\r | |
537 | Byte &= 0xF0;\r | |
538 | Byte = (UINT8) (Byte | Digit);\r | |
539 | }\r | |
540 | \r | |
541 | Buf[Index / 2] = Byte;\r | |
542 | }\r | |
543 | \r | |
544 | return EFI_SUCCESS;\r | |
545 | }\r | |
546 | \r | |
572f5d8a | 547 | /**\r |
548 | Converts a string to GUID value.\r | |
549 | \r | |
550 | @param Str The registry format GUID string that contains the GUID value.\r | |
551 | @param Guid A pointer to the converted GUID value.\r | |
552 | \r | |
553 | @retval EFI_SUCCESS The GUID string was successfully converted to the GUID value.\r | |
554 | @retval EFI_UNSUPPORTED The input string is not in registry format.\r | |
555 | @return others Some error occurred when converting part of GUID value.\r | |
556 | \r | |
557 | **/\r | |
95276127 | 558 | EFI_STATUS\r |
559 | StrToGuid (\r | |
560 | IN CHAR16 *Str,\r | |
561 | OUT EFI_GUID *Guid\r | |
562 | )\r | |
563 | {\r | |
564 | UINTN BufferLength;\r | |
565 | UINTN ConvertedStrLen;\r | |
566 | EFI_STATUS Status;\r | |
567 | \r | |
568 | BufferLength = sizeof (Guid->Data1);\r | |
569 | Status = HexStringToBuf ((UINT8 *) &Guid->Data1, &BufferLength, Str, &ConvertedStrLen);\r | |
570 | if (EFI_ERROR (Status)) {\r | |
571 | return Status;\r | |
572 | }\r | |
573 | Str += ConvertedStrLen;\r | |
574 | if (IS_HYPHEN (*Str)) {\r | |
572f5d8a | 575 | Str++;\r |
95276127 | 576 | } else {\r |
577 | return EFI_UNSUPPORTED;\r | |
578 | }\r | |
579 | \r | |
580 | BufferLength = sizeof (Guid->Data2);\r | |
581 | Status = HexStringToBuf ((UINT8 *) &Guid->Data2, &BufferLength, Str, &ConvertedStrLen);\r | |
582 | if (EFI_ERROR (Status)) {\r | |
583 | return Status;\r | |
584 | }\r | |
585 | Str += ConvertedStrLen;\r | |
586 | if (IS_HYPHEN (*Str)) {\r | |
587 | Str++;\r | |
588 | } else {\r | |
589 | return EFI_UNSUPPORTED;\r | |
590 | }\r | |
591 | \r | |
592 | BufferLength = sizeof (Guid->Data3);\r | |
593 | Status = HexStringToBuf ((UINT8 *) &Guid->Data3, &BufferLength, Str, &ConvertedStrLen);\r | |
594 | if (EFI_ERROR (Status)) {\r | |
595 | return Status;\r | |
596 | }\r | |
597 | Str += ConvertedStrLen;\r | |
598 | if (IS_HYPHEN (*Str)) {\r | |
599 | Str++;\r | |
600 | } else {\r | |
601 | return EFI_UNSUPPORTED;\r | |
602 | }\r | |
603 | \r | |
604 | StrToBuf (&Guid->Data4[0], 2, Str);\r | |
605 | //\r | |
606 | // Skip 2 byte hex chars\r | |
607 | //\r | |
608 | Str += 2 * 2;\r | |
609 | \r | |
610 | if (IS_HYPHEN (*Str)) {\r | |
611 | Str++;\r | |
612 | } else {\r | |
613 | return EFI_UNSUPPORTED;\r | |
614 | }\r | |
615 | StrToBuf (&Guid->Data4[2], 6, Str);\r | |
616 | \r | |
617 | return EFI_SUCCESS;\r | |
618 | }\r | |
619 | \r | |
572f5d8a | 620 | /**\r |
621 | Converts a string to IPv4 address\r | |
622 | \r | |
623 | @param Str A string representation of IPv4 address.\r | |
624 | @param IPv4Addr A pointer to the converted IPv4 address.\r | |
625 | \r | |
626 | **/\r | |
95276127 | 627 | VOID\r |
628 | StrToIPv4Addr (\r | |
629 | IN OUT CHAR16 **Str,\r | |
630 | OUT EFI_IPv4_ADDRESS *IPv4Addr\r | |
631 | )\r | |
632 | {\r | |
633 | UINTN Index;\r | |
634 | \r | |
635 | for (Index = 0; Index < 4; Index++) {\r | |
cf40f28a | 636 | IPv4Addr->Addr[Index] = (UINT8) Dtoi (SplitStr (Str, L'.'));\r |
95276127 | 637 | }\r |
638 | }\r | |
639 | \r | |
572f5d8a | 640 | /**\r |
641 | Converts a string to IPv4 address\r | |
642 | \r | |
643 | @param Str A string representation of IPv6 address.\r | |
644 | @param IPv6Addr A pointer to the converted IPv6 address.\r | |
645 | \r | |
646 | **/\r | |
95276127 | 647 | VOID\r |
648 | StrToIPv6Addr (\r | |
649 | IN OUT CHAR16 **Str,\r | |
650 | OUT EFI_IPv6_ADDRESS *IPv6Addr\r | |
651 | )\r | |
652 | {\r | |
653 | UINTN Index;\r | |
654 | UINT16 Data;\r | |
655 | \r | |
656 | for (Index = 0; Index < 8; Index++) {\r | |
657 | Data = (UINT16) Xtoi (SplitStr (Str, L':'));\r | |
658 | IPv6Addr->Addr[Index * 2] = (UINT8) (Data >> 8);\r | |
659 | IPv6Addr->Addr[Index * 2 + 1] = (UINT8) (Data & 0xff);\r | |
660 | }\r | |
661 | }\r | |
662 | \r | |
572f5d8a | 663 | /**\r |
664 | Converts a Unicode string to ASCII string.\r | |
665 | \r | |
666 | @param Str The equiventant Unicode string\r | |
667 | @param AsciiStr On input, it points to destination ASCII string buffer; on output, it points\r | |
668 | to the next ASCII string next to it\r | |
669 | \r | |
670 | **/\r | |
95276127 | 671 | VOID\r |
672 | StrToAscii (\r | |
673 | IN CHAR16 *Str,\r | |
674 | IN OUT CHAR8 **AsciiStr\r | |
675 | )\r | |
676 | {\r | |
677 | CHAR8 *Dest;\r | |
678 | \r | |
679 | Dest = *AsciiStr;\r | |
680 | while (!IS_NULL (*Str)) {\r | |
681 | *(Dest++) = (CHAR8) *(Str++);\r | |
682 | }\r | |
683 | *Dest = 0;\r | |
684 | \r | |
685 | //\r | |
686 | // Return the string next to it\r | |
687 | //\r | |
688 | *AsciiStr = Dest + 1;\r | |
689 | }\r | |
690 | \r | |
572f5d8a | 691 | /**\r |
692 | Converts a text device path node to Hardware PCI device path structure.\r | |
693 | \r | |
694 | @param TextDeviceNode The input Text device path node.\r | |
695 | \r | |
696 | @return A pointer to Hardware PCI device path structure.\r | |
697 | \r | |
698 | **/\r | |
95276127 | 699 | EFI_DEVICE_PATH_PROTOCOL *\r |
700 | DevPathFromTextPci (\r | |
701 | IN CHAR16 *TextDeviceNode\r | |
702 | )\r | |
703 | {\r | |
704 | CHAR16 *FunctionStr;\r | |
705 | CHAR16 *DeviceStr;\r | |
706 | PCI_DEVICE_PATH *Pci;\r | |
707 | \r | |
95276127 | 708 | DeviceStr = GetNextParamStr (&TextDeviceNode);\r |
cf40f28a | 709 | FunctionStr = GetNextParamStr (&TextDeviceNode);\r |
95276127 | 710 | Pci = (PCI_DEVICE_PATH *) CreateDeviceNode (\r |
711 | HARDWARE_DEVICE_PATH,\r | |
712 | HW_PCI_DP,\r | |
713 | sizeof (PCI_DEVICE_PATH)\r | |
714 | );\r | |
715 | \r | |
cf40f28a | 716 | Pci->Function = (UINT8) Strtoi (FunctionStr);\r |
717 | Pci->Device = (UINT8) Strtoi (DeviceStr);\r | |
95276127 | 718 | \r |
719 | return (EFI_DEVICE_PATH_PROTOCOL *) Pci;\r | |
720 | }\r | |
721 | \r | |
572f5d8a | 722 | /**\r |
723 | Converts a text device path node to Hardware PC card device path structure.\r | |
724 | \r | |
725 | @param TextDeviceNode The input Text device path node.\r | |
726 | \r | |
727 | @return A pointer to Hardware PC card device path structure.\r | |
728 | \r | |
729 | **/\r | |
95276127 | 730 | EFI_DEVICE_PATH_PROTOCOL *\r |
731 | DevPathFromTextPcCard (\r | |
732 | IN CHAR16 *TextDeviceNode\r | |
733 | )\r | |
734 | {\r | |
735 | CHAR16 *FunctionNumberStr;\r | |
736 | PCCARD_DEVICE_PATH *Pccard;\r | |
737 | \r | |
738 | FunctionNumberStr = GetNextParamStr (&TextDeviceNode);\r | |
739 | Pccard = (PCCARD_DEVICE_PATH *) CreateDeviceNode (\r | |
740 | HARDWARE_DEVICE_PATH,\r | |
741 | HW_PCCARD_DP,\r | |
742 | sizeof (PCCARD_DEVICE_PATH)\r | |
743 | );\r | |
744 | \r | |
cf40f28a | 745 | Pccard->FunctionNumber = (UINT8) Strtoi (FunctionNumberStr);\r |
95276127 | 746 | \r |
747 | return (EFI_DEVICE_PATH_PROTOCOL *) Pccard;\r | |
748 | }\r | |
749 | \r | |
572f5d8a | 750 | /**\r |
751 | Converts a text device path node to Hardware memory map device path structure.\r | |
752 | \r | |
753 | @param TextDeviceNode The input Text device path node.\r | |
754 | \r | |
755 | @return A pointer to Hardware memory map device path structure.\r | |
756 | \r | |
757 | **/\r | |
95276127 | 758 | EFI_DEVICE_PATH_PROTOCOL *\r |
759 | DevPathFromTextMemoryMapped (\r | |
760 | IN CHAR16 *TextDeviceNode\r | |
761 | )\r | |
762 | {\r | |
cf40f28a | 763 | CHAR16 *MemoryTypeStr;\r |
95276127 | 764 | CHAR16 *StartingAddressStr;\r |
765 | CHAR16 *EndingAddressStr;\r | |
766 | MEMMAP_DEVICE_PATH *MemMap;\r | |
767 | \r | |
cf40f28a | 768 | MemoryTypeStr = GetNextParamStr (&TextDeviceNode);\r |
95276127 | 769 | StartingAddressStr = GetNextParamStr (&TextDeviceNode);\r |
770 | EndingAddressStr = GetNextParamStr (&TextDeviceNode);\r | |
771 | MemMap = (MEMMAP_DEVICE_PATH *) CreateDeviceNode (\r | |
772 | HARDWARE_DEVICE_PATH,\r | |
773 | HW_MEMMAP_DP,\r | |
774 | sizeof (MEMMAP_DEVICE_PATH)\r | |
775 | );\r | |
776 | \r | |
cf40f28a | 777 | MemMap->MemoryType = (UINT32) Strtoi (MemoryTypeStr);\r |
778 | Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);\r | |
779 | Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);\r | |
95276127 | 780 | \r |
781 | return (EFI_DEVICE_PATH_PROTOCOL *) MemMap;\r | |
782 | }\r | |
783 | \r | |
572f5d8a | 784 | /**\r |
785 | Converts a text device path node to Vendor device path structure based on the input Type\r | |
786 | and SubType.\r | |
787 | \r | |
788 | @param TextDeviceNode The input Text device path node.\r | |
789 | @param Type The type of device path node.\r | |
790 | @param SubType The subtype of device path node.\r | |
791 | \r | |
792 | @return A pointer to the newly-created Vendor device path structure.\r | |
793 | \r | |
794 | **/\r | |
95276127 | 795 | EFI_DEVICE_PATH_PROTOCOL *\r |
796 | ConvertFromTextVendor (\r | |
797 | IN CHAR16 *TextDeviceNode,\r | |
798 | IN UINT8 Type,\r | |
799 | IN UINT8 SubType\r | |
800 | )\r | |
801 | {\r | |
802 | CHAR16 *GuidStr;\r | |
803 | CHAR16 *DataStr;\r | |
804 | UINTN Length;\r | |
805 | VENDOR_DEVICE_PATH *Vendor;\r | |
806 | \r | |
807 | GuidStr = GetNextParamStr (&TextDeviceNode);\r | |
808 | \r | |
809 | DataStr = GetNextParamStr (&TextDeviceNode);\r | |
810 | Length = StrLen (DataStr);\r | |
811 | //\r | |
812 | // Two hex characters make up 1 buffer byte\r | |
813 | //\r | |
814 | Length = (Length + 1) / 2;\r | |
815 | \r | |
816 | Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r | |
817 | Type,\r | |
818 | SubType,\r | |
d074a8e1 | 819 | (UINT16) (sizeof (VENDOR_DEVICE_PATH) + Length)\r |
95276127 | 820 | );\r |
821 | \r | |
822 | StrToGuid (GuidStr, &Vendor->Guid);\r | |
823 | StrToBuf (((UINT8 *) Vendor) + sizeof (VENDOR_DEVICE_PATH), Length, DataStr);\r | |
824 | \r | |
825 | return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r | |
826 | }\r | |
827 | \r | |
572f5d8a | 828 | /**\r |
829 | Converts a text device path node to Vendor Hardware device path structure.\r | |
830 | \r | |
831 | @param TextDeviceNode The input Text device path node.\r | |
832 | \r | |
833 | @return A pointer to the newly-created Vendor Hardware device path structure.\r | |
834 | \r | |
835 | **/\r | |
95276127 | 836 | EFI_DEVICE_PATH_PROTOCOL *\r |
837 | DevPathFromTextVenHw (\r | |
838 | IN CHAR16 *TextDeviceNode\r | |
839 | )\r | |
840 | {\r | |
841 | return ConvertFromTextVendor (\r | |
842 | TextDeviceNode,\r | |
843 | HARDWARE_DEVICE_PATH,\r | |
844 | HW_VENDOR_DP\r | |
845 | );\r | |
846 | }\r | |
847 | \r | |
572f5d8a | 848 | /**\r |
849 | Converts a text device path node to Hardware Controller device path structure.\r | |
850 | \r | |
851 | @param TextDeviceNode The input Text device path node.\r | |
852 | \r | |
853 | @return A pointer to the newly-created Hardware Controller device path structure.\r | |
854 | \r | |
855 | **/\r | |
95276127 | 856 | EFI_DEVICE_PATH_PROTOCOL *\r |
857 | DevPathFromTextCtrl (\r | |
858 | IN CHAR16 *TextDeviceNode\r | |
859 | )\r | |
860 | {\r | |
861 | CHAR16 *ControllerStr;\r | |
862 | CONTROLLER_DEVICE_PATH *Controller;\r | |
863 | \r | |
864 | ControllerStr = GetNextParamStr (&TextDeviceNode);\r | |
865 | Controller = (CONTROLLER_DEVICE_PATH *) CreateDeviceNode (\r | |
866 | HARDWARE_DEVICE_PATH,\r | |
867 | HW_CONTROLLER_DP,\r | |
868 | sizeof (CONTROLLER_DEVICE_PATH)\r | |
869 | );\r | |
cf40f28a | 870 | Controller->ControllerNumber = (UINT32) Strtoi (ControllerStr);\r |
95276127 | 871 | \r |
872 | return (EFI_DEVICE_PATH_PROTOCOL *) Controller;\r | |
873 | }\r | |
874 | \r | |
572f5d8a | 875 | /**\r |
876 | Converts a string to EisaId.\r | |
877 | \r | |
878 | @param Text The input string.\r | |
879 | @param EisaId A pointer to the output EisaId.\r | |
880 | \r | |
881 | **/\r | |
cf40f28a | 882 | VOID\r |
883 | EisaIdFromText (\r | |
884 | IN CHAR16 *Text,\r | |
885 | OUT UINT32 *EisaId\r | |
886 | )\r | |
887 | {\r | |
888 | UINTN PnpId;\r | |
889 | \r | |
890 | PnpId = Xtoi (Text + 3);\r | |
572f5d8a | 891 | *EisaId = (((Text[0] - '@') & 0x1f) << 10) +\r |
892 | (((Text[1] - '@') & 0x1f) << 5) +\r | |
cf40f28a | 893 | ((Text[2] - '@') & 0x1f) +\r |
894 | (UINT32) (PnpId << 16);\r | |
895 | }\r | |
896 | \r | |
572f5d8a | 897 | /**\r |
898 | Converts a text device path node to ACPI HID device path structure.\r | |
899 | \r | |
900 | @param TextDeviceNode The input Text device path node.\r | |
901 | \r | |
902 | @return A pointer to the newly-created ACPI HID device path structure.\r | |
903 | \r | |
904 | **/\r | |
95276127 | 905 | EFI_DEVICE_PATH_PROTOCOL *\r |
906 | DevPathFromTextAcpi (\r | |
907 | IN CHAR16 *TextDeviceNode\r | |
908 | )\r | |
909 | {\r | |
910 | CHAR16 *HIDStr;\r | |
911 | CHAR16 *UIDStr;\r | |
912 | ACPI_HID_DEVICE_PATH *Acpi;\r | |
913 | \r | |
914 | HIDStr = GetNextParamStr (&TextDeviceNode);\r | |
915 | UIDStr = GetNextParamStr (&TextDeviceNode);\r | |
916 | Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r | |
917 | ACPI_DEVICE_PATH,\r | |
918 | ACPI_DP,\r | |
919 | sizeof (ACPI_HID_DEVICE_PATH)\r | |
920 | );\r | |
921 | \r | |
cf40f28a | 922 | EisaIdFromText (HIDStr, &Acpi->HID);\r |
923 | Acpi->UID = (UINT32) Strtoi (UIDStr);\r | |
95276127 | 924 | \r |
925 | return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r | |
926 | }\r | |
927 | \r | |
572f5d8a | 928 | /**\r |
929 | Converts a text device path node to ACPI HID device path structure.\r | |
930 | \r | |
931 | @param TextDeviceNode The input Text device path node.\r | |
932 | @param PnPId The input plug and play identification.\r | |
933 | \r | |
934 | @return A pointer to the newly-created ACPI HID device path structure.\r | |
935 | \r | |
936 | **/\r | |
95276127 | 937 | EFI_DEVICE_PATH_PROTOCOL *\r |
938 | ConvertFromTextAcpi (\r | |
939 | IN CHAR16 *TextDeviceNode,\r | |
cf40f28a | 940 | IN UINT32 PnPId\r |
95276127 | 941 | )\r |
942 | {\r | |
943 | CHAR16 *UIDStr;\r | |
944 | ACPI_HID_DEVICE_PATH *Acpi;\r | |
945 | \r | |
946 | UIDStr = GetNextParamStr (&TextDeviceNode);\r | |
947 | Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r | |
948 | ACPI_DEVICE_PATH,\r | |
949 | ACPI_DP,\r | |
950 | sizeof (ACPI_HID_DEVICE_PATH)\r | |
951 | );\r | |
952 | \r | |
cf40f28a | 953 | Acpi->HID = EFI_PNP_ID (PnPId);\r |
954 | Acpi->UID = (UINT32) Strtoi (UIDStr);\r | |
95276127 | 955 | \r |
956 | return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r | |
957 | }\r | |
958 | \r | |
572f5d8a | 959 | /**\r |
960 | Converts a text device path node to PCI root device path structure.\r | |
961 | \r | |
962 | @param TextDeviceNode The input Text device path node.\r | |
963 | \r | |
964 | @return A pointer to the newly-created PCI root device path structure.\r | |
965 | \r | |
966 | **/\r | |
95276127 | 967 | EFI_DEVICE_PATH_PROTOCOL *\r |
968 | DevPathFromTextPciRoot (\r | |
969 | IN CHAR16 *TextDeviceNode\r | |
970 | )\r | |
971 | {\r | |
cf40f28a | 972 | return ConvertFromTextAcpi (TextDeviceNode, 0x0a03);\r |
95276127 | 973 | }\r |
974 | \r | |
572f5d8a | 975 | /**\r |
976 | Converts a text device path node to Floppy device path structure.\r | |
977 | \r | |
978 | @param TextDeviceNode The input Text device path node.\r | |
979 | \r | |
980 | @return A pointer to the newly-created Floppy device path structure.\r | |
981 | \r | |
982 | **/\r | |
95276127 | 983 | EFI_DEVICE_PATH_PROTOCOL *\r |
984 | DevPathFromTextFloppy (\r | |
985 | IN CHAR16 *TextDeviceNode\r | |
986 | )\r | |
987 | {\r | |
cf40f28a | 988 | return ConvertFromTextAcpi (TextDeviceNode, 0x0604);\r |
95276127 | 989 | }\r |
990 | \r | |
572f5d8a | 991 | /**\r |
992 | Converts a text device path node to Keyboard device path structure.\r | |
993 | \r | |
994 | @param TextDeviceNode The input Text device path node.\r | |
995 | \r | |
996 | @return A pointer to the newly-created Keyboard device path structure.\r | |
997 | \r | |
998 | **/\r | |
95276127 | 999 | EFI_DEVICE_PATH_PROTOCOL *\r |
1000 | DevPathFromTextKeyboard (\r | |
1001 | IN CHAR16 *TextDeviceNode\r | |
1002 | )\r | |
1003 | {\r | |
cf40f28a | 1004 | return ConvertFromTextAcpi (TextDeviceNode, 0x0301);\r |
95276127 | 1005 | }\r |
1006 | \r | |
572f5d8a | 1007 | /**\r |
1008 | Converts a text device path node to Serial device path structure.\r | |
1009 | \r | |
1010 | @param TextDeviceNode The input Text device path node.\r | |
1011 | \r | |
1012 | @return A pointer to the newly-created Serial device path structure.\r | |
1013 | \r | |
1014 | **/\r | |
95276127 | 1015 | EFI_DEVICE_PATH_PROTOCOL *\r |
1016 | DevPathFromTextSerial (\r | |
1017 | IN CHAR16 *TextDeviceNode\r | |
1018 | )\r | |
1019 | {\r | |
cf40f28a | 1020 | return ConvertFromTextAcpi (TextDeviceNode, 0x0501);\r |
95276127 | 1021 | }\r |
1022 | \r | |
572f5d8a | 1023 | /**\r |
1024 | Converts a text device path node to Parallel Port device path structure.\r | |
1025 | \r | |
1026 | @param TextDeviceNode The input Text device path node.\r | |
1027 | \r | |
1028 | @return A pointer to the newly-created Parallel Port device path structure.\r | |
1029 | \r | |
1030 | **/\r | |
95276127 | 1031 | EFI_DEVICE_PATH_PROTOCOL *\r |
1032 | DevPathFromTextParallelPort (\r | |
1033 | IN CHAR16 *TextDeviceNode\r | |
1034 | )\r | |
1035 | {\r | |
cf40f28a | 1036 | return ConvertFromTextAcpi (TextDeviceNode, 0x0401);\r |
95276127 | 1037 | }\r |
1038 | \r | |
572f5d8a | 1039 | /**\r |
1040 | Converts a text device path node to ACPI extention device path structure.\r | |
1041 | \r | |
1042 | @param TextDeviceNode The input Text device path node.\r | |
1043 | \r | |
1044 | @return A pointer to the newly-created ACPI extention device path structure.\r | |
1045 | \r | |
1046 | **/\r | |
95276127 | 1047 | EFI_DEVICE_PATH_PROTOCOL *\r |
1048 | DevPathFromTextAcpiEx (\r | |
1049 | IN CHAR16 *TextDeviceNode\r | |
1050 | )\r | |
1051 | {\r | |
cf40f28a | 1052 | CHAR16 *HIDStr;\r |
1053 | CHAR16 *CIDStr;\r | |
1054 | CHAR16 *UIDStr;\r | |
1055 | CHAR16 *HIDSTRStr;\r | |
1056 | CHAR16 *CIDSTRStr;\r | |
1057 | CHAR16 *UIDSTRStr;\r | |
1058 | CHAR8 *AsciiStr;\r | |
1059 | UINT16 Length;\r | |
1060 | ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;\r | |
95276127 | 1061 | \r |
1062 | HIDStr = GetNextParamStr (&TextDeviceNode);\r | |
1063 | CIDStr = GetNextParamStr (&TextDeviceNode);\r | |
1064 | UIDStr = GetNextParamStr (&TextDeviceNode);\r | |
1065 | HIDSTRStr = GetNextParamStr (&TextDeviceNode);\r | |
1066 | CIDSTRStr = GetNextParamStr (&TextDeviceNode);\r | |
1067 | UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r | |
1068 | \r | |
1069 | Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (HIDSTRStr) + 1);\r | |
1070 | Length = (UINT16) (Length + StrLen (UIDSTRStr) + 1);\r | |
1071 | Length = (UINT16) (Length + StrLen (CIDSTRStr) + 1);\r | |
cf40f28a | 1072 | AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r |
1073 | ACPI_DEVICE_PATH,\r | |
1074 | ACPI_EXTENDED_DP,\r | |
1075 | Length\r | |
1076 | );\r | |
95276127 | 1077 | \r |
cf40f28a | 1078 | EisaIdFromText (HIDStr, &AcpiEx->HID);\r |
1079 | EisaIdFromText (CIDStr, &AcpiEx->CID);\r | |
1080 | AcpiEx->UID = (UINT32) Strtoi (UIDStr);\r | |
95276127 | 1081 | \r |
cf40f28a | 1082 | AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r |
95276127 | 1083 | StrToAscii (HIDSTRStr, &AsciiStr);\r |
1084 | StrToAscii (UIDSTRStr, &AsciiStr);\r | |
1085 | StrToAscii (CIDSTRStr, &AsciiStr);\r | |
cf40f28a | 1086 | \r |
1087 | return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r | |
95276127 | 1088 | }\r |
1089 | \r | |
572f5d8a | 1090 | /**\r |
1091 | Converts a text device path node to ACPI extention device path structure.\r | |
1092 | \r | |
1093 | @param TextDeviceNode The input Text device path node.\r | |
1094 | \r | |
1095 | @return A pointer to the newly-created ACPI extention device path structure.\r | |
1096 | \r | |
1097 | **/\r | |
95276127 | 1098 | EFI_DEVICE_PATH_PROTOCOL *\r |
1099 | DevPathFromTextAcpiExp (\r | |
1100 | IN CHAR16 *TextDeviceNode\r | |
1101 | )\r | |
1102 | {\r | |
cf40f28a | 1103 | CHAR16 *HIDStr;\r |
1104 | CHAR16 *CIDStr;\r | |
1105 | CHAR16 *UIDSTRStr;\r | |
1106 | CHAR8 *AsciiStr;\r | |
1107 | UINT16 Length;\r | |
1108 | ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;\r | |
95276127 | 1109 | \r |
1110 | HIDStr = GetNextParamStr (&TextDeviceNode);\r | |
1111 | CIDStr = GetNextParamStr (&TextDeviceNode);\r | |
1112 | UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r | |
d074a8e1 | 1113 | Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (UIDSTRStr) + 3);\r |
cf40f28a | 1114 | AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r |
1115 | ACPI_DEVICE_PATH,\r | |
1116 | ACPI_EXTENDED_DP,\r | |
1117 | Length\r | |
1118 | );\r | |
95276127 | 1119 | \r |
cf40f28a | 1120 | EisaIdFromText (HIDStr, &AcpiEx->HID);\r |
1121 | EisaIdFromText (CIDStr, &AcpiEx->CID);\r | |
1122 | AcpiEx->UID = 0;\r | |
95276127 | 1123 | \r |
cf40f28a | 1124 | AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r |
95276127 | 1125 | //\r |
1126 | // HID string is NULL\r | |
1127 | //\r | |
cf40f28a | 1128 | *AsciiStr = '\0';\r |
95276127 | 1129 | //\r |
1130 | // Convert UID string\r | |
1131 | //\r | |
1132 | AsciiStr++;\r | |
1133 | StrToAscii (UIDSTRStr, &AsciiStr);\r | |
1134 | //\r | |
1135 | // CID string is NULL\r | |
1136 | //\r | |
cf40f28a | 1137 | *AsciiStr = '\0';\r |
95276127 | 1138 | \r |
cf40f28a | 1139 | return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r |
95276127 | 1140 | }\r |
1141 | \r | |
572f5d8a | 1142 | /**\r |
1143 | Converts a text device path node to Parallel Port device path structure.\r | |
1144 | \r | |
1145 | @param TextDeviceNode The input Text device path node.\r | |
1146 | \r | |
1147 | @return A pointer to the newly-created Parallel Port device path structure.\r | |
1148 | \r | |
1149 | **/\r | |
95276127 | 1150 | EFI_DEVICE_PATH_PROTOCOL *\r |
1151 | DevPathFromTextAta (\r | |
1152 | IN CHAR16 *TextDeviceNode\r | |
1153 | )\r | |
1154 | {\r | |
1155 | CHAR16 *PrimarySecondaryStr;\r | |
1156 | CHAR16 *SlaveMasterStr;\r | |
1157 | CHAR16 *LunStr;\r | |
1158 | ATAPI_DEVICE_PATH *Atapi;\r | |
1159 | \r | |
1160 | Atapi = (ATAPI_DEVICE_PATH *) CreateDeviceNode (\r | |
1161 | MESSAGING_DEVICE_PATH,\r | |
1162 | MSG_ATAPI_DP,\r | |
1163 | sizeof (ATAPI_DEVICE_PATH)\r | |
1164 | );\r | |
1165 | \r | |
1166 | PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);\r | |
1167 | SlaveMasterStr = GetNextParamStr (&TextDeviceNode);\r | |
1168 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
1169 | \r | |
1170 | Atapi->PrimarySecondary = (UINT8) ((StrCmp (PrimarySecondaryStr, L"Primary") == 0) ? 0 : 1);\r | |
1171 | Atapi->SlaveMaster = (UINT8) ((StrCmp (SlaveMasterStr, L"Master") == 0) ? 0 : 1);\r | |
cf40f28a | 1172 | Atapi->Lun = (UINT16) Strtoi (LunStr);\r |
95276127 | 1173 | \r |
1174 | return (EFI_DEVICE_PATH_PROTOCOL *) Atapi;\r | |
1175 | }\r | |
1176 | \r | |
572f5d8a | 1177 | /**\r |
1178 | Converts a text device path node to SCSI device path structure.\r | |
1179 | \r | |
1180 | @param TextDeviceNode The input Text device path node.\r | |
1181 | \r | |
1182 | @return A pointer to the newly-created SCSI device path structure.\r | |
1183 | \r | |
1184 | **/\r | |
95276127 | 1185 | EFI_DEVICE_PATH_PROTOCOL *\r |
1186 | DevPathFromTextScsi (\r | |
1187 | IN CHAR16 *TextDeviceNode\r | |
1188 | )\r | |
1189 | {\r | |
1190 | CHAR16 *PunStr;\r | |
1191 | CHAR16 *LunStr;\r | |
1192 | SCSI_DEVICE_PATH *Scsi;\r | |
1193 | \r | |
1194 | PunStr = GetNextParamStr (&TextDeviceNode);\r | |
1195 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
1196 | Scsi = (SCSI_DEVICE_PATH *) CreateDeviceNode (\r | |
1197 | MESSAGING_DEVICE_PATH,\r | |
1198 | MSG_SCSI_DP,\r | |
1199 | sizeof (SCSI_DEVICE_PATH)\r | |
1200 | );\r | |
1201 | \r | |
cf40f28a | 1202 | Scsi->Pun = (UINT16) Strtoi (PunStr);\r |
1203 | Scsi->Lun = (UINT16) Strtoi (LunStr);\r | |
95276127 | 1204 | \r |
1205 | return (EFI_DEVICE_PATH_PROTOCOL *) Scsi;\r | |
1206 | }\r | |
1207 | \r | |
572f5d8a | 1208 | /**\r |
1209 | Converts a text device path node to Fibre device path structure.\r | |
1210 | \r | |
1211 | @param TextDeviceNode The input Text device path node.\r | |
1212 | \r | |
1213 | @return A pointer to the newly-created Fibre device path structure.\r | |
1214 | \r | |
1215 | **/\r | |
95276127 | 1216 | EFI_DEVICE_PATH_PROTOCOL *\r |
1217 | DevPathFromTextFibre (\r | |
1218 | IN CHAR16 *TextDeviceNode\r | |
1219 | )\r | |
1220 | {\r | |
1221 | CHAR16 *WWNStr;\r | |
1222 | CHAR16 *LunStr;\r | |
1223 | FIBRECHANNEL_DEVICE_PATH *Fibre;\r | |
1224 | \r | |
1225 | WWNStr = GetNextParamStr (&TextDeviceNode);\r | |
1226 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
1227 | Fibre = (FIBRECHANNEL_DEVICE_PATH *) CreateDeviceNode (\r | |
1228 | MESSAGING_DEVICE_PATH,\r | |
1229 | MSG_FIBRECHANNEL_DP,\r | |
1230 | sizeof (FIBRECHANNEL_DEVICE_PATH)\r | |
1231 | );\r | |
1232 | \r | |
1233 | Fibre->Reserved = 0;\r | |
cf40f28a | 1234 | Strtoi64 (WWNStr, &Fibre->WWN);\r |
1235 | Strtoi64 (LunStr, &Fibre->Lun);\r | |
95276127 | 1236 | \r |
1237 | return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;\r | |
1238 | }\r | |
1239 | \r | |
572f5d8a | 1240 | /**\r |
1241 | Converts a text device path node to 1394 device path structure.\r | |
1242 | \r | |
1243 | @param TextDeviceNode The input Text device path node.\r | |
1244 | \r | |
1245 | @return A pointer to the newly-created 1394 device path structure.\r | |
1246 | \r | |
1247 | **/\r | |
95276127 | 1248 | EFI_DEVICE_PATH_PROTOCOL *\r |
1249 | DevPathFromText1394 (\r | |
1250 | IN CHAR16 *TextDeviceNode\r | |
1251 | )\r | |
1252 | {\r | |
1253 | CHAR16 *GuidStr;\r | |
572f5d8a | 1254 | F1394_DEVICE_PATH *F1394DevPath;\r |
95276127 | 1255 | \r |
1256 | GuidStr = GetNextParamStr (&TextDeviceNode);\r | |
572f5d8a | 1257 | F1394DevPath = (F1394_DEVICE_PATH *) CreateDeviceNode (\r |
1258 | MESSAGING_DEVICE_PATH,\r | |
1259 | MSG_1394_DP,\r | |
1260 | sizeof (F1394_DEVICE_PATH)\r | |
1261 | );\r | |
95276127 | 1262 | \r |
572f5d8a | 1263 | F1394DevPath->Reserved = 0;\r |
1264 | Xtoi64 (GuidStr, &F1394DevPath->Guid);\r | |
95276127 | 1265 | \r |
572f5d8a | 1266 | return (EFI_DEVICE_PATH_PROTOCOL *) F1394DevPath;\r |
95276127 | 1267 | }\r |
1268 | \r | |
572f5d8a | 1269 | /**\r |
1270 | Converts a text device path node to USB device path structure.\r | |
1271 | \r | |
1272 | @param TextDeviceNode The input Text device path node.\r | |
1273 | \r | |
1274 | @return A pointer to the newly-created USB device path structure.\r | |
1275 | \r | |
1276 | **/\r | |
95276127 | 1277 | EFI_DEVICE_PATH_PROTOCOL *\r |
1278 | DevPathFromTextUsb (\r | |
1279 | IN CHAR16 *TextDeviceNode\r | |
1280 | )\r | |
1281 | {\r | |
1282 | CHAR16 *PortStr;\r | |
1283 | CHAR16 *InterfaceStr;\r | |
1284 | USB_DEVICE_PATH *Usb;\r | |
1285 | \r | |
1286 | PortStr = GetNextParamStr (&TextDeviceNode);\r | |
1287 | InterfaceStr = GetNextParamStr (&TextDeviceNode);\r | |
1288 | Usb = (USB_DEVICE_PATH *) CreateDeviceNode (\r | |
1289 | MESSAGING_DEVICE_PATH,\r | |
1290 | MSG_USB_DP,\r | |
1291 | sizeof (USB_DEVICE_PATH)\r | |
1292 | );\r | |
1293 | \r | |
cf40f28a | 1294 | Usb->ParentPortNumber = (UINT8) Strtoi (PortStr);\r |
1295 | Usb->InterfaceNumber = (UINT8) Strtoi (InterfaceStr);\r | |
95276127 | 1296 | \r |
1297 | return (EFI_DEVICE_PATH_PROTOCOL *) Usb;\r | |
1298 | }\r | |
1299 | \r | |
572f5d8a | 1300 | /**\r |
1301 | Converts a text device path node to I20 device path structure.\r | |
1302 | \r | |
1303 | @param TextDeviceNode The input Text device path node.\r | |
1304 | \r | |
1305 | @return A pointer to the newly-created I20 device path structure.\r | |
1306 | \r | |
1307 | **/\r | |
95276127 | 1308 | EFI_DEVICE_PATH_PROTOCOL *\r |
1309 | DevPathFromTextI2O (\r | |
1310 | IN CHAR16 *TextDeviceNode\r | |
1311 | )\r | |
1312 | {\r | |
1313 | CHAR16 *TIDStr;\r | |
572f5d8a | 1314 | I2O_DEVICE_PATH *I2ODevPath;\r |
95276127 | 1315 | \r |
572f5d8a | 1316 | TIDStr = GetNextParamStr (&TextDeviceNode);\r |
1317 | I2ODevPath = (I2O_DEVICE_PATH *) CreateDeviceNode (\r | |
95276127 | 1318 | MESSAGING_DEVICE_PATH,\r |
1319 | MSG_I2O_DP,\r | |
1320 | sizeof (I2O_DEVICE_PATH)\r | |
1321 | );\r | |
1322 | \r | |
572f5d8a | 1323 | I2ODevPath->Tid = (UINT32) Strtoi (TIDStr);\r |
95276127 | 1324 | \r |
572f5d8a | 1325 | return (EFI_DEVICE_PATH_PROTOCOL *) I2ODevPath;\r |
95276127 | 1326 | }\r |
1327 | \r | |
572f5d8a | 1328 | /**\r |
1329 | Converts a text device path node to Infini Band device path structure.\r | |
1330 | \r | |
1331 | @param TextDeviceNode The input Text device path node.\r | |
1332 | \r | |
1333 | @return A pointer to the newly-created Infini Band device path structure.\r | |
1334 | \r | |
1335 | **/\r | |
95276127 | 1336 | EFI_DEVICE_PATH_PROTOCOL *\r |
1337 | DevPathFromTextInfiniband (\r | |
1338 | IN CHAR16 *TextDeviceNode\r | |
1339 | )\r | |
1340 | {\r | |
1341 | CHAR16 *FlagsStr;\r | |
1342 | CHAR16 *GuidStr;\r | |
1343 | CHAR16 *SidStr;\r | |
1344 | CHAR16 *TidStr;\r | |
1345 | CHAR16 *DidStr;\r | |
1346 | EFI_GUID PortGid;\r | |
1347 | INFINIBAND_DEVICE_PATH *InfiniBand;\r | |
1348 | \r | |
1349 | FlagsStr = GetNextParamStr (&TextDeviceNode);\r | |
1350 | GuidStr = GetNextParamStr (&TextDeviceNode);\r | |
1351 | SidStr = GetNextParamStr (&TextDeviceNode);\r | |
1352 | TidStr = GetNextParamStr (&TextDeviceNode);\r | |
1353 | DidStr = GetNextParamStr (&TextDeviceNode);\r | |
1354 | InfiniBand = (INFINIBAND_DEVICE_PATH *) CreateDeviceNode (\r | |
1355 | MESSAGING_DEVICE_PATH,\r | |
1356 | MSG_INFINIBAND_DP,\r | |
1357 | sizeof (INFINIBAND_DEVICE_PATH)\r | |
1358 | );\r | |
1359 | \r | |
cf40f28a | 1360 | InfiniBand->ResourceFlags = (UINT32) Strtoi (FlagsStr);\r |
95276127 | 1361 | StrToGuid (GuidStr, &PortGid);\r |
1362 | CopyMem (InfiniBand->PortGid, &PortGid, sizeof (EFI_GUID));\r | |
cf40f28a | 1363 | Strtoi64 (SidStr, &InfiniBand->ServiceId);\r |
1364 | Strtoi64 (TidStr, &InfiniBand->TargetPortId);\r | |
1365 | Strtoi64 (DidStr, &InfiniBand->DeviceId);\r | |
95276127 | 1366 | \r |
1367 | return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand;\r | |
1368 | }\r | |
1369 | \r | |
572f5d8a | 1370 | /**\r |
1371 | Converts a text device path node to Vendor-Defined Messaging device path structure.\r | |
1372 | \r | |
1373 | @param TextDeviceNode The input Text device path node.\r | |
1374 | \r | |
1375 | @return A pointer to the newly-created Vendor-Defined Messaging device path structure.\r | |
1376 | \r | |
1377 | **/\r | |
95276127 | 1378 | EFI_DEVICE_PATH_PROTOCOL *\r |
1379 | DevPathFromTextVenMsg (\r | |
1380 | IN CHAR16 *TextDeviceNode\r | |
1381 | )\r | |
1382 | {\r | |
1383 | return ConvertFromTextVendor (\r | |
1384 | TextDeviceNode,\r | |
1385 | MESSAGING_DEVICE_PATH,\r | |
1386 | MSG_VENDOR_DP\r | |
1387 | );\r | |
1388 | }\r | |
1389 | \r | |
572f5d8a | 1390 | /**\r |
1391 | Converts a text device path node to Vendor defined PC-ANSI device path structure.\r | |
1392 | \r | |
1393 | @param TextDeviceNode The input Text device path node.\r | |
1394 | \r | |
1395 | @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.\r | |
1396 | \r | |
1397 | **/\r | |
95276127 | 1398 | EFI_DEVICE_PATH_PROTOCOL *\r |
1399 | DevPathFromTextVenPcAnsi (\r | |
1400 | IN CHAR16 *TextDeviceNode\r | |
1401 | )\r | |
1402 | {\r | |
1403 | VENDOR_DEVICE_PATH *Vendor;\r | |
1404 | \r | |
1405 | Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r | |
1406 | MESSAGING_DEVICE_PATH,\r | |
1407 | MSG_VENDOR_DP,\r | |
1408 | sizeof (VENDOR_DEVICE_PATH));\r | |
1409 | CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);\r | |
1410 | \r | |
1411 | return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r | |
1412 | }\r | |
1413 | \r | |
572f5d8a | 1414 | /**\r |
1415 | Converts a text device path node to Vendor defined VT100 device path structure.\r | |
1416 | \r | |
1417 | @param TextDeviceNode The input Text device path node.\r | |
1418 | \r | |
1419 | @return A pointer to the newly-created Vendor defined VT100 device path structure.\r | |
1420 | \r | |
1421 | **/\r | |
95276127 | 1422 | EFI_DEVICE_PATH_PROTOCOL *\r |
1423 | DevPathFromTextVenVt100 (\r | |
1424 | IN CHAR16 *TextDeviceNode\r | |
1425 | )\r | |
1426 | {\r | |
1427 | VENDOR_DEVICE_PATH *Vendor;\r | |
1428 | \r | |
1429 | Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r | |
1430 | MESSAGING_DEVICE_PATH,\r | |
1431 | MSG_VENDOR_DP,\r | |
1432 | sizeof (VENDOR_DEVICE_PATH));\r | |
1433 | CopyGuid (&Vendor->Guid, &gEfiVT100Guid);\r | |
1434 | \r | |
1435 | return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r | |
1436 | }\r | |
1437 | \r | |
572f5d8a | 1438 | /**\r |
1439 | Converts a text device path node to Vendor defined VT100 Plus device path structure.\r | |
1440 | \r | |
1441 | @param TextDeviceNode The input Text device path node.\r | |
1442 | \r | |
1443 | @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.\r | |
1444 | \r | |
1445 | **/\r | |
95276127 | 1446 | EFI_DEVICE_PATH_PROTOCOL *\r |
1447 | DevPathFromTextVenVt100Plus (\r | |
1448 | IN CHAR16 *TextDeviceNode\r | |
1449 | )\r | |
1450 | {\r | |
1451 | VENDOR_DEVICE_PATH *Vendor;\r | |
1452 | \r | |
1453 | Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r | |
1454 | MESSAGING_DEVICE_PATH,\r | |
1455 | MSG_VENDOR_DP,\r | |
1456 | sizeof (VENDOR_DEVICE_PATH));\r | |
1457 | CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);\r | |
1458 | \r | |
1459 | return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r | |
1460 | }\r | |
1461 | \r | |
572f5d8a | 1462 | /**\r |
1463 | Converts a text device path node to Vendor defined UTF8 device path structure.\r | |
1464 | \r | |
1465 | @param TextDeviceNode The input Text device path node.\r | |
1466 | \r | |
1467 | @return A pointer to the newly-created Vendor defined UTF8 device path structure.\r | |
1468 | \r | |
1469 | **/\r | |
95276127 | 1470 | EFI_DEVICE_PATH_PROTOCOL *\r |
1471 | DevPathFromTextVenUtf8 (\r | |
1472 | IN CHAR16 *TextDeviceNode\r | |
1473 | )\r | |
1474 | {\r | |
1475 | VENDOR_DEVICE_PATH *Vendor;\r | |
1476 | \r | |
1477 | Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r | |
1478 | MESSAGING_DEVICE_PATH,\r | |
1479 | MSG_VENDOR_DP,\r | |
1480 | sizeof (VENDOR_DEVICE_PATH));\r | |
1481 | CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);\r | |
1482 | \r | |
1483 | return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r | |
1484 | }\r | |
1485 | \r | |
572f5d8a | 1486 | /**\r |
1487 | Converts a text device path node to UART Flow Control device path structure.\r | |
1488 | \r | |
1489 | @param TextDeviceNode The input Text device path node.\r | |
1490 | \r | |
1491 | @return A pointer to the newly-created UART Flow Control device path structure.\r | |
1492 | \r | |
1493 | **/\r | |
95276127 | 1494 | EFI_DEVICE_PATH_PROTOCOL *\r |
1495 | DevPathFromTextUartFlowCtrl (\r | |
1496 | IN CHAR16 *TextDeviceNode\r | |
1497 | )\r | |
1498 | {\r | |
1499 | CHAR16 *ValueStr;\r | |
1500 | UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;\r | |
1501 | \r | |
1502 | ValueStr = GetNextParamStr (&TextDeviceNode);\r | |
1503 | UartFlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) CreateDeviceNode (\r | |
1504 | MESSAGING_DEVICE_PATH,\r | |
1505 | MSG_VENDOR_DP,\r | |
1506 | sizeof (UART_FLOW_CONTROL_DEVICE_PATH)\r | |
1507 | );\r | |
1508 | \r | |
1509 | CopyGuid (&UartFlowControl->Guid, &mEfiDevicePathMessagingUartFlowControlGuid);\r | |
1510 | if (StrCmp (ValueStr, L"XonXoff") == 0) {\r | |
1511 | UartFlowControl->FlowControlMap = 2;\r | |
1512 | } else if (StrCmp (ValueStr, L"Hardware") == 0) {\r | |
1513 | UartFlowControl->FlowControlMap = 1;\r | |
1514 | } else {\r | |
1515 | UartFlowControl->FlowControlMap = 0;\r | |
1516 | }\r | |
1517 | \r | |
1518 | return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl;\r | |
1519 | }\r | |
1520 | \r | |
572f5d8a | 1521 | /**\r |
1522 | Converts a text device path node to Serial Attached SCSI device path structure.\r | |
1523 | \r | |
1524 | @param TextDeviceNode The input Text device path node.\r | |
1525 | \r | |
1526 | @return A pointer to the newly-created Serial Attached SCSI device path structure.\r | |
1527 | \r | |
1528 | **/\r | |
95276127 | 1529 | EFI_DEVICE_PATH_PROTOCOL *\r |
1530 | DevPathFromTextSAS (\r | |
1531 | IN CHAR16 *TextDeviceNode\r | |
1532 | )\r | |
1533 | {\r | |
1534 | CHAR16 *AddressStr;\r | |
1535 | CHAR16 *LunStr;\r | |
1536 | CHAR16 *RTPStr;\r | |
1537 | CHAR16 *SASSATAStr;\r | |
1538 | CHAR16 *LocationStr;\r | |
1539 | CHAR16 *ConnectStr;\r | |
1540 | CHAR16 *DriveBayStr;\r | |
1541 | CHAR16 *ReservedStr;\r | |
1542 | UINT16 Info;\r | |
1543 | SAS_DEVICE_PATH *Sas;\r | |
1544 | \r | |
1545 | AddressStr = GetNextParamStr (&TextDeviceNode);\r | |
1546 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
1547 | RTPStr = GetNextParamStr (&TextDeviceNode);\r | |
1548 | SASSATAStr = GetNextParamStr (&TextDeviceNode);\r | |
1549 | LocationStr = GetNextParamStr (&TextDeviceNode);\r | |
1550 | ConnectStr = GetNextParamStr (&TextDeviceNode);\r | |
1551 | DriveBayStr = GetNextParamStr (&TextDeviceNode);\r | |
1552 | ReservedStr = GetNextParamStr (&TextDeviceNode);\r | |
1553 | Info = 0x0000;\r | |
1554 | Sas = (SAS_DEVICE_PATH *) CreateDeviceNode (\r | |
1555 | MESSAGING_DEVICE_PATH,\r | |
1556 | MSG_VENDOR_DP,\r | |
1557 | sizeof (SAS_DEVICE_PATH)\r | |
1558 | );\r | |
1559 | \r | |
1560 | CopyGuid (&Sas->Guid, &mEfiDevicePathMessagingSASGuid);\r | |
cf40f28a | 1561 | Strtoi64 (AddressStr, &Sas->SasAddress);\r |
1562 | Strtoi64 (LunStr, &Sas->Lun);\r | |
1563 | Sas->RelativeTargetPort = (UINT16) Strtoi (RTPStr);\r | |
1564 | if (StrCmp (SASSATAStr, L"NoTopology") != 0) {\r | |
95276127 | 1565 | if (StrCmp (DriveBayStr, L"0") == 0) {\r |
1566 | Info |= 0x0001;\r | |
1567 | } else {\r | |
1568 | Info |= 0x0002;\r | |
cf40f28a | 1569 | Info = (UINT16) (Info | (Strtoi (DriveBayStr) << 8));\r |
95276127 | 1570 | }\r |
1571 | \r | |
1572 | if (StrCmp (SASSATAStr, L"SATA") == 0) {\r | |
1573 | Info |= 0x0010;\r | |
1574 | }\r | |
1575 | \r | |
1576 | if (StrCmp (LocationStr, L"External") == 0) {\r | |
1577 | Info |= 0x0020;\r | |
1578 | }\r | |
1579 | \r | |
1580 | if (StrCmp (ConnectStr, L"Expanded") == 0) {\r | |
1581 | Info |= 0x0040;\r | |
1582 | }\r | |
1583 | }\r | |
1584 | \r | |
1585 | Sas->DeviceTopology = Info;\r | |
cf40f28a | 1586 | Sas->Reserved = (UINT32) Strtoi (ReservedStr);\r |
95276127 | 1587 | \r |
1588 | return (EFI_DEVICE_PATH_PROTOCOL *) Sas;\r | |
1589 | }\r | |
1590 | \r | |
572f5d8a | 1591 | /**\r |
1592 | Converts a text device path node to Debug Port device path structure.\r | |
1593 | \r | |
1594 | @param TextDeviceNode The input Text device path node.\r | |
1595 | \r | |
1596 | @return A pointer to the newly-created Debug Port device path structure.\r | |
1597 | \r | |
1598 | **/\r | |
95276127 | 1599 | EFI_DEVICE_PATH_PROTOCOL *\r |
1600 | DevPathFromTextDebugPort (\r | |
1601 | IN CHAR16 *TextDeviceNode\r | |
1602 | )\r | |
1603 | {\r | |
1604 | VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend;\r | |
1605 | \r | |
1606 | Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (\r | |
1607 | MESSAGING_DEVICE_PATH,\r | |
1608 | MSG_VENDOR_DP,\r | |
1609 | sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH)\r | |
1610 | );\r | |
1611 | \r | |
1612 | CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);\r | |
1613 | \r | |
1614 | return (EFI_DEVICE_PATH_PROTOCOL *) Vend;\r | |
1615 | }\r | |
1616 | \r | |
572f5d8a | 1617 | /**\r |
1618 | Converts a text device path node to MAC device path structure.\r | |
1619 | \r | |
1620 | @param TextDeviceNode The input Text device path node.\r | |
1621 | \r | |
1622 | @return A pointer to the newly-created MAC device path structure.\r | |
1623 | \r | |
1624 | **/\r | |
95276127 | 1625 | EFI_DEVICE_PATH_PROTOCOL *\r |
1626 | DevPathFromTextMAC (\r | |
1627 | IN CHAR16 *TextDeviceNode\r | |
1628 | )\r | |
1629 | {\r | |
1630 | CHAR16 *AddressStr;\r | |
1631 | CHAR16 *IfTypeStr;\r | |
1632 | UINTN Length;\r | |
572f5d8a | 1633 | MAC_ADDR_DEVICE_PATH *MACDevPath;\r |
95276127 | 1634 | \r |
1635 | AddressStr = GetNextParamStr (&TextDeviceNode);\r | |
1636 | IfTypeStr = GetNextParamStr (&TextDeviceNode);\r | |
572f5d8a | 1637 | MACDevPath = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (\r |
95276127 | 1638 | MESSAGING_DEVICE_PATH,\r |
1639 | MSG_MAC_ADDR_DP,\r | |
1640 | sizeof (MAC_ADDR_DEVICE_PATH)\r | |
1641 | );\r | |
1642 | \r | |
572f5d8a | 1643 | MACDevPath->IfType = (UINT8) Strtoi (IfTypeStr);\r |
95276127 | 1644 | \r |
1645 | Length = sizeof (EFI_MAC_ADDRESS);\r | |
572f5d8a | 1646 | StrToBuf (&MACDevPath->MacAddress.Addr[0], Length, AddressStr);\r |
95276127 | 1647 | \r |
572f5d8a | 1648 | return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;\r |
95276127 | 1649 | }\r |
1650 | \r | |
572f5d8a | 1651 | /**\r |
1652 | Converts a text device path node to IPV4 device path structure.\r | |
1653 | \r | |
1654 | @param TextDeviceNode The input Text device path node.\r | |
1655 | \r | |
1656 | @return A pointer to the newly-created IPV4 device path structure.\r | |
1657 | \r | |
1658 | **/\r | |
95276127 | 1659 | EFI_DEVICE_PATH_PROTOCOL *\r |
1660 | DevPathFromTextIPv4 (\r | |
1661 | IN CHAR16 *TextDeviceNode\r | |
1662 | )\r | |
1663 | {\r | |
1664 | CHAR16 *RemoteIPStr;\r | |
1665 | CHAR16 *ProtocolStr;\r | |
1666 | CHAR16 *TypeStr;\r | |
1667 | CHAR16 *LocalIPStr;\r | |
1668 | IPv4_DEVICE_PATH *IPv4;\r | |
1669 | \r | |
1670 | RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r | |
1671 | ProtocolStr = GetNextParamStr (&TextDeviceNode);\r | |
1672 | TypeStr = GetNextParamStr (&TextDeviceNode);\r | |
1673 | LocalIPStr = GetNextParamStr (&TextDeviceNode);\r | |
1674 | IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode (\r | |
1675 | MESSAGING_DEVICE_PATH,\r | |
1676 | MSG_IPv4_DP,\r | |
1677 | sizeof (IPv4_DEVICE_PATH)\r | |
1678 | );\r | |
1679 | \r | |
1680 | StrToIPv4Addr (&RemoteIPStr, &IPv4->RemoteIpAddress);\r | |
1681 | IPv4->Protocol = (UINT16) ((StrCmp (ProtocolStr, L"UDP") == 0) ? 0 : 1);\r | |
1682 | if (StrCmp (TypeStr, L"Static") == 0) {\r | |
1683 | IPv4->StaticIpAddress = TRUE;\r | |
1684 | } else {\r | |
1685 | IPv4->StaticIpAddress = FALSE;\r | |
1686 | }\r | |
1687 | \r | |
1688 | StrToIPv4Addr (&LocalIPStr, &IPv4->LocalIpAddress);\r | |
1689 | \r | |
cf40f28a | 1690 | IPv4->LocalPort = 0;\r |
1691 | IPv4->RemotePort = 0;\r | |
95276127 | 1692 | \r |
1693 | return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;\r | |
1694 | }\r | |
1695 | \r | |
572f5d8a | 1696 | /**\r |
1697 | Converts a text device path node to IPV6 device path structure.\r | |
1698 | \r | |
1699 | @param TextDeviceNode The input Text device path node.\r | |
1700 | \r | |
1701 | @return A pointer to the newly-created IPV6 device path structure.\r | |
1702 | \r | |
1703 | **/\r | |
95276127 | 1704 | EFI_DEVICE_PATH_PROTOCOL *\r |
1705 | DevPathFromTextIPv6 (\r | |
1706 | IN CHAR16 *TextDeviceNode\r | |
1707 | )\r | |
1708 | {\r | |
1709 | CHAR16 *RemoteIPStr;\r | |
1710 | CHAR16 *ProtocolStr;\r | |
1711 | CHAR16 *TypeStr;\r | |
1712 | CHAR16 *LocalIPStr;\r | |
1713 | IPv6_DEVICE_PATH *IPv6;\r | |
1714 | \r | |
1715 | RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r | |
1716 | ProtocolStr = GetNextParamStr (&TextDeviceNode);\r | |
1717 | TypeStr = GetNextParamStr (&TextDeviceNode);\r | |
1718 | LocalIPStr = GetNextParamStr (&TextDeviceNode);\r | |
1719 | IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (\r | |
1720 | MESSAGING_DEVICE_PATH,\r | |
1721 | MSG_IPv6_DP,\r | |
1722 | sizeof (IPv6_DEVICE_PATH)\r | |
1723 | );\r | |
1724 | \r | |
1725 | StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress);\r | |
1726 | IPv6->Protocol = (UINT16) ((StrCmp (ProtocolStr, L"UDP") == 0) ? 0 : 1);\r | |
1727 | if (StrCmp (TypeStr, L"Static") == 0) {\r | |
1728 | IPv6->StaticIpAddress = TRUE;\r | |
1729 | } else {\r | |
1730 | IPv6->StaticIpAddress = FALSE;\r | |
1731 | }\r | |
1732 | \r | |
1733 | StrToIPv6Addr (&LocalIPStr, &IPv6->LocalIpAddress);\r | |
1734 | \r | |
1735 | IPv6->LocalPort = 0;\r | |
1736 | IPv6->RemotePort = 0;\r | |
1737 | \r | |
1738 | return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;\r | |
1739 | }\r | |
1740 | \r | |
572f5d8a | 1741 | /**\r |
1742 | Converts a text device path node to UART device path structure.\r | |
1743 | \r | |
1744 | @param TextDeviceNode The input Text device path node.\r | |
1745 | \r | |
1746 | @return A pointer to the newly-created UART device path structure.\r | |
1747 | \r | |
1748 | **/\r | |
95276127 | 1749 | EFI_DEVICE_PATH_PROTOCOL *\r |
1750 | DevPathFromTextUart (\r | |
1751 | IN CHAR16 *TextDeviceNode\r | |
1752 | )\r | |
1753 | {\r | |
1754 | CHAR16 *BaudStr;\r | |
1755 | CHAR16 *DataBitsStr;\r | |
1756 | CHAR16 *ParityStr;\r | |
1757 | CHAR16 *StopBitsStr;\r | |
1758 | UART_DEVICE_PATH *Uart;\r | |
1759 | \r | |
1760 | BaudStr = GetNextParamStr (&TextDeviceNode);\r | |
1761 | DataBitsStr = GetNextParamStr (&TextDeviceNode);\r | |
1762 | ParityStr = GetNextParamStr (&TextDeviceNode);\r | |
1763 | StopBitsStr = GetNextParamStr (&TextDeviceNode);\r | |
1764 | Uart = (UART_DEVICE_PATH *) CreateDeviceNode (\r | |
1765 | MESSAGING_DEVICE_PATH,\r | |
1766 | MSG_UART_DP,\r | |
1767 | sizeof (UART_DEVICE_PATH)\r | |
1768 | );\r | |
1769 | \r | |
cf40f28a | 1770 | Uart->BaudRate = (StrCmp (BaudStr, L"DEFAULT") == 0) ? 115200 : Dtoi (BaudStr);\r |
1771 | Uart->DataBits = (UINT8) ((StrCmp (DataBitsStr, L"DEFAULT") == 0) ? 8 : Dtoi (DataBitsStr));\r | |
95276127 | 1772 | switch (*ParityStr) {\r |
1773 | case L'D':\r | |
1774 | Uart->Parity = 0;\r | |
1775 | break;\r | |
1776 | \r | |
1777 | case L'N':\r | |
1778 | Uart->Parity = 1;\r | |
1779 | break;\r | |
1780 | \r | |
1781 | case L'E':\r | |
1782 | Uart->Parity = 2;\r | |
1783 | break;\r | |
1784 | \r | |
1785 | case L'O':\r | |
1786 | Uart->Parity = 3;\r | |
1787 | break;\r | |
1788 | \r | |
1789 | case L'M':\r | |
1790 | Uart->Parity = 4;\r | |
1791 | break;\r | |
1792 | \r | |
1793 | case L'S':\r | |
1794 | Uart->Parity = 5;\r | |
1795 | \r | |
1796 | default:\r | |
1797 | Uart->Parity = 0xff;\r | |
1798 | }\r | |
1799 | \r | |
1800 | if (StrCmp (StopBitsStr, L"D") == 0) {\r | |
1801 | Uart->StopBits = (UINT8) 0;\r | |
1802 | } else if (StrCmp (StopBitsStr, L"1") == 0) {\r | |
1803 | Uart->StopBits = (UINT8) 1;\r | |
1804 | } else if (StrCmp (StopBitsStr, L"1.5") == 0) {\r | |
1805 | Uart->StopBits = (UINT8) 2;\r | |
1806 | } else if (StrCmp (StopBitsStr, L"2") == 0) {\r | |
1807 | Uart->StopBits = (UINT8) 3;\r | |
1808 | } else {\r | |
1809 | Uart->StopBits = 0xff;\r | |
1810 | }\r | |
1811 | \r | |
1812 | return (EFI_DEVICE_PATH_PROTOCOL *) Uart;\r | |
1813 | }\r | |
1814 | \r | |
572f5d8a | 1815 | /**\r |
1816 | Converts a text device path node to USB class device path structure.\r | |
1817 | \r | |
1818 | @param TextDeviceNode The input Text device path node.\r | |
1819 | @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.\r | |
1820 | \r | |
1821 | @return A pointer to the newly-created USB class device path structure.\r | |
1822 | \r | |
1823 | **/\r | |
95276127 | 1824 | EFI_DEVICE_PATH_PROTOCOL *\r |
1825 | ConvertFromTextUsbClass (\r | |
1826 | IN CHAR16 *TextDeviceNode,\r | |
1827 | IN USB_CLASS_TEXT *UsbClassText\r | |
1828 | )\r | |
1829 | {\r | |
1830 | CHAR16 *VIDStr;\r | |
1831 | CHAR16 *PIDStr;\r | |
1832 | CHAR16 *ClassStr;\r | |
1833 | CHAR16 *SubClassStr;\r | |
1834 | CHAR16 *ProtocolStr;\r | |
1835 | USB_CLASS_DEVICE_PATH *UsbClass;\r | |
1836 | \r | |
1837 | UsbClass = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (\r | |
1838 | MESSAGING_DEVICE_PATH,\r | |
1839 | MSG_USB_CLASS_DP,\r | |
1840 | sizeof (USB_CLASS_DEVICE_PATH)\r | |
1841 | );\r | |
1842 | \r | |
1843 | VIDStr = GetNextParamStr (&TextDeviceNode);\r | |
1844 | PIDStr = GetNextParamStr (&TextDeviceNode);\r | |
1845 | if (UsbClassText->ClassExist) {\r | |
1846 | ClassStr = GetNextParamStr (&TextDeviceNode);\r | |
cf40f28a | 1847 | UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);\r |
95276127 | 1848 | } else {\r |
1849 | UsbClass->DeviceClass = UsbClassText->Class;\r | |
1850 | }\r | |
1851 | if (UsbClassText->SubClassExist) {\r | |
1852 | SubClassStr = GetNextParamStr (&TextDeviceNode);\r | |
cf40f28a | 1853 | UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);\r |
95276127 | 1854 | } else {\r |
1855 | UsbClass->DeviceSubClass = UsbClassText->SubClass;\r | |
572f5d8a | 1856 | }\r |
95276127 | 1857 | \r |
1858 | ProtocolStr = GetNextParamStr (&TextDeviceNode);\r | |
1859 | \r | |
cf40f28a | 1860 | UsbClass->VendorId = (UINT16) Strtoi (VIDStr);\r |
1861 | UsbClass->ProductId = (UINT16) Strtoi (PIDStr);\r | |
1862 | UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr);\r | |
95276127 | 1863 | \r |
1864 | return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;\r | |
1865 | }\r | |
1866 | \r | |
1867 | \r | |
572f5d8a | 1868 | /**\r |
1869 | Converts a text device path node to USB class device path structure.\r | |
1870 | \r | |
1871 | @param TextDeviceNode The input Text device path node.\r | |
1872 | \r | |
1873 | @return A pointer to the newly-created USB class device path structure.\r | |
1874 | \r | |
1875 | **/\r | |
95276127 | 1876 | EFI_DEVICE_PATH_PROTOCOL *\r |
1877 | DevPathFromTextUsbClass (\r | |
1878 | IN CHAR16 *TextDeviceNode\r | |
1879 | )\r | |
1880 | {\r | |
1881 | USB_CLASS_TEXT UsbClassText;\r | |
1882 | \r | |
1883 | UsbClassText.ClassExist = TRUE;\r | |
1884 | UsbClassText.SubClassExist = TRUE;\r | |
1885 | \r | |
1886 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
1887 | }\r | |
1888 | \r | |
572f5d8a | 1889 | /**\r |
1890 | Converts a text device path node to USB audio device path structure.\r | |
1891 | \r | |
1892 | @param TextDeviceNode The input Text device path node.\r | |
1893 | \r | |
1894 | @return A pointer to the newly-created USB audio device path structure.\r | |
1895 | \r | |
1896 | **/\r | |
95276127 | 1897 | EFI_DEVICE_PATH_PROTOCOL *\r |
1898 | DevPathFromTextUsbAudio (\r | |
1899 | IN CHAR16 *TextDeviceNode\r | |
1900 | )\r | |
1901 | {\r | |
1902 | USB_CLASS_TEXT UsbClassText;\r | |
1903 | \r | |
1904 | UsbClassText.ClassExist = FALSE;\r | |
1905 | UsbClassText.Class = USB_CLASS_AUDIO;\r | |
1906 | UsbClassText.SubClassExist = TRUE;\r | |
1907 | \r | |
1908 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
1909 | }\r | |
1910 | \r | |
572f5d8a | 1911 | /**\r |
1912 | Converts a text device path node to USB CDC Control device path structure.\r | |
1913 | \r | |
1914 | @param TextDeviceNode The input Text device path node.\r | |
1915 | \r | |
1916 | @return A pointer to the newly-created USB CDC Control device path structure.\r | |
1917 | \r | |
1918 | **/\r | |
95276127 | 1919 | EFI_DEVICE_PATH_PROTOCOL *\r |
1920 | DevPathFromTextUsbCDCControl (\r | |
1921 | IN CHAR16 *TextDeviceNode\r | |
1922 | )\r | |
1923 | {\r | |
1924 | USB_CLASS_TEXT UsbClassText;\r | |
1925 | \r | |
1926 | UsbClassText.ClassExist = FALSE;\r | |
1927 | UsbClassText.Class = USB_CLASS_CDCCONTROL;\r | |
1928 | UsbClassText.SubClassExist = TRUE;\r | |
1929 | \r | |
1930 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
1931 | }\r | |
1932 | \r | |
572f5d8a | 1933 | /**\r |
1934 | Converts a text device path node to USB HID device path structure.\r | |
1935 | \r | |
1936 | @param TextDeviceNode The input Text device path node.\r | |
1937 | \r | |
1938 | @return A pointer to the newly-created USB HID device path structure.\r | |
1939 | \r | |
1940 | **/\r | |
95276127 | 1941 | EFI_DEVICE_PATH_PROTOCOL *\r |
1942 | DevPathFromTextUsbHID (\r | |
1943 | IN CHAR16 *TextDeviceNode\r | |
1944 | )\r | |
1945 | {\r | |
1946 | USB_CLASS_TEXT UsbClassText;\r | |
1947 | \r | |
1948 | UsbClassText.ClassExist = FALSE;\r | |
1949 | UsbClassText.Class = USB_CLASS_HID;\r | |
1950 | UsbClassText.SubClassExist = TRUE;\r | |
1951 | \r | |
1952 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
1953 | }\r | |
1954 | \r | |
572f5d8a | 1955 | /**\r |
1956 | Converts a text device path node to USB Image device path structure.\r | |
1957 | \r | |
1958 | @param TextDeviceNode The input Text device path node.\r | |
1959 | \r | |
1960 | @return A pointer to the newly-created USB Image device path structure.\r | |
1961 | \r | |
1962 | **/\r | |
95276127 | 1963 | EFI_DEVICE_PATH_PROTOCOL *\r |
1964 | DevPathFromTextUsbImage (\r | |
1965 | IN CHAR16 *TextDeviceNode\r | |
1966 | )\r | |
1967 | {\r | |
1968 | USB_CLASS_TEXT UsbClassText;\r | |
1969 | \r | |
1970 | UsbClassText.ClassExist = FALSE;\r | |
1971 | UsbClassText.Class = USB_CLASS_IMAGE;\r | |
1972 | UsbClassText.SubClassExist = TRUE;\r | |
1973 | \r | |
1974 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
1975 | }\r | |
1976 | \r | |
572f5d8a | 1977 | /**\r |
1978 | Converts a text device path node to USB Print device path structure.\r | |
1979 | \r | |
1980 | @param TextDeviceNode The input Text device path node.\r | |
1981 | \r | |
1982 | @return A pointer to the newly-created USB Print device path structure.\r | |
1983 | \r | |
1984 | **/\r | |
95276127 | 1985 | EFI_DEVICE_PATH_PROTOCOL *\r |
1986 | DevPathFromTextUsbPrinter (\r | |
1987 | IN CHAR16 *TextDeviceNode\r | |
1988 | )\r | |
1989 | {\r | |
1990 | USB_CLASS_TEXT UsbClassText;\r | |
1991 | \r | |
1992 | UsbClassText.ClassExist = FALSE;\r | |
1993 | UsbClassText.Class = USB_CLASS_PRINTER;\r | |
1994 | UsbClassText.SubClassExist = TRUE;\r | |
1995 | \r | |
1996 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
1997 | }\r | |
1998 | \r | |
572f5d8a | 1999 | /**\r |
2000 | Converts a text device path node to USB mass storage device path structure.\r | |
2001 | \r | |
2002 | @param TextDeviceNode The input Text device path node.\r | |
2003 | \r | |
2004 | @return A pointer to the newly-created USB mass storage device path structure.\r | |
2005 | \r | |
2006 | **/\r | |
95276127 | 2007 | EFI_DEVICE_PATH_PROTOCOL *\r |
2008 | DevPathFromTextUsbMassStorage (\r | |
2009 | IN CHAR16 *TextDeviceNode\r | |
2010 | )\r | |
2011 | {\r | |
2012 | USB_CLASS_TEXT UsbClassText;\r | |
2013 | \r | |
2014 | UsbClassText.ClassExist = FALSE;\r | |
2015 | UsbClassText.Class = USB_CLASS_MASS_STORAGE;\r | |
2016 | UsbClassText.SubClassExist = TRUE;\r | |
2017 | \r | |
2018 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2019 | }\r | |
2020 | \r | |
572f5d8a | 2021 | /**\r |
2022 | Converts a text device path node to USB HUB device path structure.\r | |
2023 | \r | |
2024 | @param TextDeviceNode The input Text device path node.\r | |
2025 | \r | |
2026 | @return A pointer to the newly-created USB HUB device path structure.\r | |
2027 | \r | |
2028 | **/\r | |
95276127 | 2029 | EFI_DEVICE_PATH_PROTOCOL *\r |
2030 | DevPathFromTextUsbHub (\r | |
2031 | IN CHAR16 *TextDeviceNode\r | |
2032 | )\r | |
2033 | {\r | |
2034 | USB_CLASS_TEXT UsbClassText;\r | |
2035 | \r | |
2036 | UsbClassText.ClassExist = FALSE;\r | |
2037 | UsbClassText.Class = USB_CLASS_HUB;\r | |
2038 | UsbClassText.SubClassExist = TRUE;\r | |
2039 | \r | |
2040 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2041 | }\r | |
2042 | \r | |
572f5d8a | 2043 | /**\r |
2044 | Converts a text device path node to USB CDC data device path structure.\r | |
2045 | \r | |
2046 | @param TextDeviceNode The input Text device path node.\r | |
2047 | \r | |
2048 | @return A pointer to the newly-created USB CDC data device path structure.\r | |
2049 | \r | |
2050 | **/\r | |
95276127 | 2051 | EFI_DEVICE_PATH_PROTOCOL *\r |
2052 | DevPathFromTextUsbCDCData (\r | |
2053 | IN CHAR16 *TextDeviceNode\r | |
2054 | )\r | |
2055 | {\r | |
2056 | USB_CLASS_TEXT UsbClassText;\r | |
2057 | \r | |
2058 | UsbClassText.ClassExist = FALSE;\r | |
2059 | UsbClassText.Class = USB_CLASS_CDCDATA;\r | |
2060 | UsbClassText.SubClassExist = TRUE;\r | |
2061 | \r | |
2062 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2063 | }\r | |
2064 | \r | |
572f5d8a | 2065 | /**\r |
2066 | Converts a text device path node to USB smart card device path structure.\r | |
2067 | \r | |
2068 | @param TextDeviceNode The input Text device path node.\r | |
2069 | \r | |
2070 | @return A pointer to the newly-created USB smart card device path structure.\r | |
2071 | \r | |
2072 | **/\r | |
95276127 | 2073 | EFI_DEVICE_PATH_PROTOCOL *\r |
2074 | DevPathFromTextUsbSmartCard (\r | |
2075 | IN CHAR16 *TextDeviceNode\r | |
2076 | )\r | |
2077 | {\r | |
2078 | USB_CLASS_TEXT UsbClassText;\r | |
2079 | \r | |
2080 | UsbClassText.ClassExist = FALSE;\r | |
2081 | UsbClassText.Class = USB_CLASS_SMART_CARD;\r | |
2082 | UsbClassText.SubClassExist = TRUE;\r | |
2083 | \r | |
2084 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2085 | }\r | |
2086 | \r | |
572f5d8a | 2087 | /**\r |
2088 | Converts a text device path node to USB video device path structure.\r | |
2089 | \r | |
2090 | @param TextDeviceNode The input Text device path node.\r | |
2091 | \r | |
2092 | @return A pointer to the newly-created USB video device path structure.\r | |
2093 | \r | |
2094 | **/\r | |
95276127 | 2095 | EFI_DEVICE_PATH_PROTOCOL *\r |
2096 | DevPathFromTextUsbVideo (\r | |
2097 | IN CHAR16 *TextDeviceNode\r | |
2098 | )\r | |
2099 | {\r | |
2100 | USB_CLASS_TEXT UsbClassText;\r | |
2101 | \r | |
2102 | UsbClassText.ClassExist = FALSE;\r | |
2103 | UsbClassText.Class = USB_CLASS_VIDEO;\r | |
2104 | UsbClassText.SubClassExist = TRUE;\r | |
2105 | \r | |
2106 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2107 | }\r | |
2108 | \r | |
572f5d8a | 2109 | /**\r |
2110 | Converts a text device path node to USB diagnostic device path structure.\r | |
2111 | \r | |
2112 | @param TextDeviceNode The input Text device path node.\r | |
2113 | \r | |
2114 | @return A pointer to the newly-created USB diagnostic device path structure.\r | |
2115 | \r | |
2116 | **/\r | |
95276127 | 2117 | EFI_DEVICE_PATH_PROTOCOL *\r |
2118 | DevPathFromTextUsbDiagnostic (\r | |
2119 | IN CHAR16 *TextDeviceNode\r | |
2120 | )\r | |
2121 | {\r | |
2122 | USB_CLASS_TEXT UsbClassText;\r | |
2123 | \r | |
2124 | UsbClassText.ClassExist = FALSE;\r | |
2125 | UsbClassText.Class = USB_CLASS_DIAGNOSTIC;\r | |
2126 | UsbClassText.SubClassExist = TRUE;\r | |
2127 | \r | |
2128 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2129 | }\r | |
2130 | \r | |
572f5d8a | 2131 | /**\r |
2132 | Converts a text device path node to USB wireless device path structure.\r | |
2133 | \r | |
2134 | @param TextDeviceNode The input Text device path node.\r | |
2135 | \r | |
2136 | @return A pointer to the newly-created USB wireless device path structure.\r | |
2137 | \r | |
2138 | **/\r | |
95276127 | 2139 | EFI_DEVICE_PATH_PROTOCOL *\r |
2140 | DevPathFromTextUsbWireless (\r | |
2141 | IN CHAR16 *TextDeviceNode\r | |
2142 | )\r | |
2143 | {\r | |
2144 | USB_CLASS_TEXT UsbClassText;\r | |
2145 | \r | |
2146 | UsbClassText.ClassExist = FALSE;\r | |
2147 | UsbClassText.Class = USB_CLASS_WIRELESS;\r | |
2148 | UsbClassText.SubClassExist = TRUE;\r | |
2149 | \r | |
2150 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2151 | }\r | |
2152 | \r | |
572f5d8a | 2153 | /**\r |
2154 | Converts a text device path node to USB device firmware update device path structure.\r | |
2155 | \r | |
2156 | @param TextDeviceNode The input Text device path node.\r | |
2157 | \r | |
2158 | @return A pointer to the newly-created USB device firmware update device path structure.\r | |
2159 | \r | |
2160 | **/\r | |
95276127 | 2161 | EFI_DEVICE_PATH_PROTOCOL *\r |
2162 | DevPathFromTextUsbDeviceFirmwareUpdate (\r | |
2163 | IN CHAR16 *TextDeviceNode\r | |
2164 | )\r | |
2165 | {\r | |
2166 | USB_CLASS_TEXT UsbClassText;\r | |
2167 | \r | |
2168 | UsbClassText.ClassExist = FALSE;\r | |
2169 | UsbClassText.Class = USB_CLASS_RESERVE;\r | |
2170 | UsbClassText.SubClassExist = FALSE;\r | |
2171 | UsbClassText.SubClass = USB_SUBCLASS_FW_UPDATE;\r | |
2172 | \r | |
2173 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2174 | }\r | |
2175 | \r | |
572f5d8a | 2176 | /**\r |
2177 | Converts a text device path node to USB IRDA bridge device path structure.\r | |
2178 | \r | |
2179 | @param TextDeviceNode The input Text device path node.\r | |
2180 | \r | |
2181 | @return A pointer to the newly-created USB IRDA bridge device path structure.\r | |
2182 | \r | |
2183 | **/\r | |
95276127 | 2184 | EFI_DEVICE_PATH_PROTOCOL *\r |
2185 | DevPathFromTextUsbIrdaBridge (\r | |
2186 | IN CHAR16 *TextDeviceNode\r | |
2187 | )\r | |
2188 | {\r | |
2189 | USB_CLASS_TEXT UsbClassText;\r | |
2190 | \r | |
2191 | UsbClassText.ClassExist = FALSE;\r | |
2192 | UsbClassText.Class = USB_CLASS_RESERVE;\r | |
2193 | UsbClassText.SubClassExist = FALSE;\r | |
2194 | UsbClassText.SubClass = USB_SUBCLASS_IRDA_BRIDGE;\r | |
2195 | \r | |
2196 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2197 | }\r | |
2198 | \r | |
572f5d8a | 2199 | /**\r |
2200 | Converts a text device path node to USB text and measurement device path structure.\r | |
2201 | \r | |
2202 | @param TextDeviceNode The input Text device path node.\r | |
2203 | \r | |
2204 | @return A pointer to the newly-created USB text and measurement device path structure.\r | |
2205 | \r | |
2206 | **/\r | |
95276127 | 2207 | EFI_DEVICE_PATH_PROTOCOL *\r |
2208 | DevPathFromTextUsbTestAndMeasurement (\r | |
2209 | IN CHAR16 *TextDeviceNode\r | |
2210 | )\r | |
2211 | {\r | |
2212 | USB_CLASS_TEXT UsbClassText;\r | |
2213 | \r | |
2214 | UsbClassText.ClassExist = FALSE;\r | |
2215 | UsbClassText.Class = USB_CLASS_RESERVE;\r | |
2216 | UsbClassText.SubClassExist = FALSE;\r | |
2217 | UsbClassText.SubClass = USB_SUBCLASS_TEST;\r | |
2218 | \r | |
2219 | return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r | |
2220 | }\r | |
2221 | \r | |
572f5d8a | 2222 | /**\r |
2223 | Converts a text device path node to USB WWID 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 WWID device path structure.\r | |
2228 | \r | |
2229 | **/\r | |
95276127 | 2230 | EFI_DEVICE_PATH_PROTOCOL *\r |
2231 | DevPathFromTextUsbWwid (\r | |
2232 | IN CHAR16 *TextDeviceNode\r | |
2233 | )\r | |
2234 | {\r | |
2235 | CHAR16 *VIDStr;\r | |
2236 | CHAR16 *PIDStr;\r | |
2237 | CHAR16 *InterfaceNumStr;\r | |
cf40f28a | 2238 | CHAR16 *SerialNumberStr;\r |
95276127 | 2239 | USB_WWID_DEVICE_PATH *UsbWwid;\r |
2240 | \r | |
2241 | VIDStr = GetNextParamStr (&TextDeviceNode);\r | |
2242 | PIDStr = GetNextParamStr (&TextDeviceNode);\r | |
2243 | InterfaceNumStr = GetNextParamStr (&TextDeviceNode);\r | |
cf40f28a | 2244 | SerialNumberStr = GetNextParamStr (&TextDeviceNode);\r |
95276127 | 2245 | UsbWwid = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (\r |
2246 | MESSAGING_DEVICE_PATH,\r | |
2247 | MSG_USB_WWID_DP,\r | |
cf40f28a | 2248 | (UINT16) (sizeof (USB_WWID_DEVICE_PATH) + StrSize (SerialNumberStr))\r |
95276127 | 2249 | );\r |
2250 | \r | |
cf40f28a | 2251 | UsbWwid->VendorId = (UINT16) Strtoi (VIDStr);\r |
2252 | UsbWwid->ProductId = (UINT16) Strtoi (PIDStr);\r | |
2253 | UsbWwid->InterfaceNumber = (UINT16) Strtoi (InterfaceNumStr);\r | |
2254 | StrCpy ((CHAR16 *) ((UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH)), SerialNumberStr);\r | |
95276127 | 2255 | \r |
2256 | return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;\r | |
2257 | }\r | |
2258 | \r | |
572f5d8a | 2259 | /**\r |
2260 | Converts a text device path node to Logic Unit device path structure.\r | |
2261 | \r | |
2262 | @param TextDeviceNode The input Text device path node.\r | |
2263 | \r | |
2264 | @return A pointer to the newly-created Logic Unit device path structure.\r | |
2265 | \r | |
2266 | **/\r | |
95276127 | 2267 | EFI_DEVICE_PATH_PROTOCOL *\r |
2268 | DevPathFromTextUnit (\r | |
2269 | IN CHAR16 *TextDeviceNode\r | |
2270 | )\r | |
2271 | {\r | |
2272 | CHAR16 *LunStr;\r | |
2273 | DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r | |
2274 | \r | |
2275 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
2276 | LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (\r | |
2277 | MESSAGING_DEVICE_PATH,\r | |
2278 | MSG_DEVICE_LOGICAL_UNIT_DP,\r | |
cf40f28a | 2279 | (UINT16) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)\r |
95276127 | 2280 | );\r |
2281 | \r | |
cf40f28a | 2282 | LogicalUnit->Lun = (UINT8) Strtoi (LunStr);\r |
95276127 | 2283 | \r |
2284 | return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;\r | |
2285 | }\r | |
2286 | \r | |
572f5d8a | 2287 | /**\r |
2288 | Converts a text device path node to iSCSI device path structure.\r | |
2289 | \r | |
2290 | @param TextDeviceNode The input Text device path node.\r | |
2291 | \r | |
2292 | @return A pointer to the newly-created iSCSI device path structure.\r | |
2293 | \r | |
2294 | **/\r | |
95276127 | 2295 | EFI_DEVICE_PATH_PROTOCOL *\r |
2296 | DevPathFromTextiSCSI (\r | |
2297 | IN CHAR16 *TextDeviceNode\r | |
2298 | )\r | |
2299 | {\r | |
2300 | UINT16 Options;\r | |
2301 | CHAR16 *NameStr;\r | |
2302 | CHAR16 *PortalGroupStr;\r | |
2303 | CHAR16 *LunStr;\r | |
2304 | CHAR16 *HeaderDigestStr;\r | |
2305 | CHAR16 *DataDigestStr;\r | |
2306 | CHAR16 *AuthenticationStr;\r | |
2307 | CHAR16 *ProtocolStr;\r | |
cf40f28a | 2308 | CHAR8 *AsciiStr;\r |
572f5d8a | 2309 | ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r |
95276127 | 2310 | \r |
2311 | NameStr = GetNextParamStr (&TextDeviceNode);\r | |
2312 | PortalGroupStr = GetNextParamStr (&TextDeviceNode);\r | |
2313 | LunStr = GetNextParamStr (&TextDeviceNode);\r | |
2314 | HeaderDigestStr = GetNextParamStr (&TextDeviceNode);\r | |
2315 | DataDigestStr = GetNextParamStr (&TextDeviceNode);\r | |
2316 | AuthenticationStr = GetNextParamStr (&TextDeviceNode);\r | |
2317 | ProtocolStr = GetNextParamStr (&TextDeviceNode);\r | |
572f5d8a | 2318 | ISCSIDevPath = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (\r |
95276127 | 2319 | MESSAGING_DEVICE_PATH,\r |
2320 | MSG_ISCSI_DP,\r | |
047c6449 | 2321 | (UINT16) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr))\r |
95276127 | 2322 | );\r |
2323 | \r | |
572f5d8a | 2324 | AsciiStr = ISCSIDevPath->iSCSITargetName;\r |
cf40f28a | 2325 | StrToAscii (NameStr, &AsciiStr);\r |
2326 | \r | |
572f5d8a | 2327 | ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);\r |
2328 | Strtoi64 (LunStr, &ISCSIDevPath->Lun);\r | |
95276127 | 2329 | \r |
2330 | Options = 0x0000;\r | |
2331 | if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {\r | |
2332 | Options |= 0x0002;\r | |
2333 | }\r | |
2334 | \r | |
2335 | if (StrCmp (DataDigestStr, L"CRC32C") == 0) {\r | |
2336 | Options |= 0x0008;\r | |
2337 | }\r | |
2338 | \r | |
2339 | if (StrCmp (AuthenticationStr, L"None") == 0) {\r | |
2340 | Options |= 0x0800;\r | |
2341 | }\r | |
2342 | \r | |
2343 | if (StrCmp (AuthenticationStr, L"CHAP_UNI") == 0) {\r | |
2344 | Options |= 0x1000;\r | |
2345 | }\r | |
2346 | \r | |
572f5d8a | 2347 | ISCSIDevPath->LoginOption = (UINT16) Options;\r |
95276127 | 2348 | \r |
572f5d8a | 2349 | ISCSIDevPath->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP");\r |
95276127 | 2350 | \r |
572f5d8a | 2351 | return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;\r |
95276127 | 2352 | }\r |
2353 | \r | |
572f5d8a | 2354 | /**\r |
2355 | Converts a text device path node to HD device path structure.\r | |
2356 | \r | |
2357 | @param TextDeviceNode The input Text device path node.\r | |
2358 | \r | |
2359 | @return A pointer to the newly-created HD device path structure.\r | |
2360 | \r | |
2361 | **/\r | |
95276127 | 2362 | EFI_DEVICE_PATH_PROTOCOL *\r |
2363 | DevPathFromTextHD (\r | |
2364 | IN CHAR16 *TextDeviceNode\r | |
2365 | )\r | |
2366 | {\r | |
2367 | CHAR16 *PartitionStr;\r | |
2368 | CHAR16 *TypeStr;\r | |
2369 | CHAR16 *SignatureStr;\r | |
2370 | CHAR16 *StartStr;\r | |
2371 | CHAR16 *SizeStr;\r | |
2372 | UINT32 Signature32;\r | |
2373 | EFI_GUID SignatureGuid;\r | |
2374 | HARDDRIVE_DEVICE_PATH *Hd;\r | |
2375 | \r | |
2376 | PartitionStr = GetNextParamStr (&TextDeviceNode);\r | |
2377 | TypeStr = GetNextParamStr (&TextDeviceNode);\r | |
2378 | SignatureStr = GetNextParamStr (&TextDeviceNode);\r | |
2379 | StartStr = GetNextParamStr (&TextDeviceNode);\r | |
2380 | SizeStr = GetNextParamStr (&TextDeviceNode);\r | |
2381 | Hd = (HARDDRIVE_DEVICE_PATH *) CreateDeviceNode (\r | |
2382 | MEDIA_DEVICE_PATH,\r | |
2383 | MEDIA_HARDDRIVE_DP,\r | |
2384 | sizeof (HARDDRIVE_DEVICE_PATH)\r | |
2385 | );\r | |
2386 | \r | |
cf40f28a | 2387 | Hd->PartitionNumber = (UINT32) Dtoi (PartitionStr);\r |
95276127 | 2388 | \r |
2389 | ZeroMem (Hd->Signature, 16);\r | |
2390 | Hd->MBRType = (UINT8) 0;\r | |
2391 | \r | |
cf40f28a | 2392 | if (StrCmp (TypeStr, L"MBR") == 0) {\r |
95276127 | 2393 | Hd->SignatureType = SIGNATURE_TYPE_MBR;\r |
2394 | Hd->MBRType = 0x01;\r | |
2395 | \r | |
cf40f28a | 2396 | Signature32 = (UINT32) Strtoi (SignatureStr);\r |
95276127 | 2397 | CopyMem (Hd->Signature, &Signature32, sizeof (UINT32));\r |
cf40f28a | 2398 | } else if (StrCmp (TypeStr, L"GPT") == 0) {\r |
95276127 | 2399 | Hd->SignatureType = SIGNATURE_TYPE_GUID;\r |
2400 | Hd->MBRType = 0x02;\r | |
2401 | \r | |
2402 | StrToGuid (SignatureStr, &SignatureGuid);\r | |
2403 | CopyMem (Hd->Signature, &SignatureGuid, sizeof (EFI_GUID));\r | |
2404 | } else {\r | |
cf40f28a | 2405 | Hd->SignatureType = (UINT8) Strtoi (TypeStr);\r |
95276127 | 2406 | }\r |
2407 | \r | |
cf40f28a | 2408 | Strtoi64 (StartStr, &Hd->PartitionStart);\r |
2409 | Strtoi64 (SizeStr, &Hd->PartitionSize);\r | |
95276127 | 2410 | \r |
2411 | return (EFI_DEVICE_PATH_PROTOCOL *) Hd;\r | |
2412 | }\r | |
2413 | \r | |
572f5d8a | 2414 | /**\r |
2415 | Converts a text device path node to CDROM device path structure.\r | |
2416 | \r | |
2417 | @param TextDeviceNode The input Text device path node.\r | |
2418 | \r | |
2419 | @return A pointer to the newly-created CDROM device path structure.\r | |
2420 | \r | |
2421 | **/\r | |
95276127 | 2422 | EFI_DEVICE_PATH_PROTOCOL *\r |
2423 | DevPathFromTextCDROM (\r | |
2424 | IN CHAR16 *TextDeviceNode\r | |
2425 | )\r | |
2426 | {\r | |
2427 | CHAR16 *EntryStr;\r | |
2428 | CHAR16 *StartStr;\r | |
2429 | CHAR16 *SizeStr;\r | |
572f5d8a | 2430 | CDROM_DEVICE_PATH *CDROMDevPath;\r |
95276127 | 2431 | \r |
2432 | EntryStr = GetNextParamStr (&TextDeviceNode);\r | |
2433 | StartStr = GetNextParamStr (&TextDeviceNode);\r | |
2434 | SizeStr = GetNextParamStr (&TextDeviceNode);\r | |
572f5d8a | 2435 | CDROMDevPath = (CDROM_DEVICE_PATH *) CreateDeviceNode (\r |
95276127 | 2436 | MEDIA_DEVICE_PATH,\r |
2437 | MEDIA_CDROM_DP,\r | |
2438 | sizeof (CDROM_DEVICE_PATH)\r | |
2439 | );\r | |
2440 | \r | |
572f5d8a | 2441 | CDROMDevPath->BootEntry = (UINT32) Strtoi (EntryStr);\r |
2442 | Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);\r | |
2443 | Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);\r | |
95276127 | 2444 | \r |
572f5d8a | 2445 | return (EFI_DEVICE_PATH_PROTOCOL *) CDROMDevPath;\r |
95276127 | 2446 | }\r |
2447 | \r | |
572f5d8a | 2448 | /**\r |
2449 | Converts a text device path node to Vendor-defined media device path structure.\r | |
2450 | \r | |
2451 | @param TextDeviceNode The input Text device path node.\r | |
2452 | \r | |
2453 | @return A pointer to the newly-created Vendor-defined media device path structure.\r | |
2454 | \r | |
2455 | **/\r | |
95276127 | 2456 | EFI_DEVICE_PATH_PROTOCOL *\r |
2457 | DevPathFromTextVenMEDIA (\r | |
2458 | IN CHAR16 *TextDeviceNode\r | |
2459 | )\r | |
2460 | {\r | |
2461 | return ConvertFromTextVendor (\r | |
2462 | TextDeviceNode,\r | |
2463 | MEDIA_DEVICE_PATH,\r | |
2464 | MEDIA_VENDOR_DP\r | |
2465 | );\r | |
2466 | }\r | |
2467 | \r | |
572f5d8a | 2468 | /**\r |
2469 | Converts a text device path node to File device path structure.\r | |
2470 | \r | |
2471 | @param TextDeviceNode The input Text device path node.\r | |
2472 | \r | |
2473 | @return A pointer to the newly-created File device path structure.\r | |
2474 | \r | |
2475 | **/\r | |
95276127 | 2476 | EFI_DEVICE_PATH_PROTOCOL *\r |
2477 | DevPathFromTextFilePath (\r | |
2478 | IN CHAR16 *TextDeviceNode\r | |
2479 | )\r | |
2480 | {\r | |
2481 | FILEPATH_DEVICE_PATH *File;\r | |
2482 | \r | |
2483 | File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (\r | |
2484 | MEDIA_DEVICE_PATH,\r | |
2485 | MEDIA_FILEPATH_DP,\r | |
d074a8e1 | 2486 | (UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2)\r |
95276127 | 2487 | );\r |
2488 | \r | |
2489 | StrCpy (File->PathName, TextDeviceNode);\r | |
2490 | \r | |
2491 | return (EFI_DEVICE_PATH_PROTOCOL *) File;\r | |
2492 | }\r | |
2493 | \r | |
572f5d8a | 2494 | /**\r |
2495 | Converts a text device path node to Media protocol device path structure.\r | |
2496 | \r | |
2497 | @param TextDeviceNode The input Text device path node.\r | |
2498 | \r | |
2499 | @return A pointer to the newly-created Media protocol device path structure.\r | |
2500 | \r | |
2501 | **/\r | |
95276127 | 2502 | EFI_DEVICE_PATH_PROTOCOL *\r |
2503 | DevPathFromTextMedia (\r | |
2504 | IN CHAR16 *TextDeviceNode\r | |
2505 | )\r | |
2506 | {\r | |
2507 | CHAR16 *GuidStr;\r | |
2508 | MEDIA_PROTOCOL_DEVICE_PATH *Media;\r | |
2509 | \r | |
2510 | GuidStr = GetNextParamStr (&TextDeviceNode);\r | |
2511 | Media = (MEDIA_PROTOCOL_DEVICE_PATH *) CreateDeviceNode (\r | |
2512 | MEDIA_DEVICE_PATH,\r | |
2513 | MEDIA_PROTOCOL_DP,\r | |
2514 | sizeof (MEDIA_PROTOCOL_DEVICE_PATH)\r | |
2515 | );\r | |
2516 | \r | |
2517 | StrToGuid (GuidStr, &Media->Protocol);\r | |
2518 | \r | |
2519 | return (EFI_DEVICE_PATH_PROTOCOL *) Media;\r | |
2520 | }\r | |
2521 | \r | |
572f5d8a | 2522 | /**\r |
2523 | Converts a text device path node to firmware volume device path structure.\r | |
2524 | \r | |
2525 | @param TextDeviceNode The input Text device path node.\r | |
2526 | \r | |
2527 | @return A pointer to the newly-created firmware volume device path structure.\r | |
2528 | \r | |
2529 | **/\r | |
cf40f28a | 2530 | EFI_DEVICE_PATH_PROTOCOL *\r |
2531 | DevPathFromTextFv (\r | |
2532 | IN CHAR16 *TextDeviceNode\r | |
2533 | )\r | |
2534 | {\r | |
2535 | CHAR16 *GuidStr;\r | |
2536 | MEDIA_FW_VOL_DEVICE_PATH *Fv;\r | |
2537 | \r | |
2538 | GuidStr = GetNextParamStr (&TextDeviceNode);\r | |
2539 | Fv = (MEDIA_FW_VOL_DEVICE_PATH *) CreateDeviceNode (\r | |
2540 | MEDIA_DEVICE_PATH,\r | |
2541 | MEDIA_PIWG_FW_VOL_DP,\r | |
2542 | sizeof (MEDIA_FW_VOL_DEVICE_PATH)\r | |
2543 | );\r | |
2544 | \r | |
2545 | StrToGuid (GuidStr, &Fv->FvName);\r | |
2546 | \r | |
2547 | return (EFI_DEVICE_PATH_PROTOCOL *) Fv;\r | |
2548 | }\r | |
2549 | \r | |
572f5d8a | 2550 | /**\r |
2551 | Converts a text device path node to firmware file device path structure.\r | |
2552 | \r | |
2553 | @param TextDeviceNode The input Text device path node.\r | |
2554 | \r | |
2555 | @return A pointer to the newly-created firmware file device path structure.\r | |
2556 | \r | |
2557 | **/\r | |
cf40f28a | 2558 | EFI_DEVICE_PATH_PROTOCOL *\r |
2559 | DevPathFromTextFvFile (\r | |
2560 | IN CHAR16 *TextDeviceNode\r | |
2561 | )\r | |
2562 | {\r | |
2563 | CHAR16 *GuidStr;\r | |
2564 | MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;\r | |
2565 | \r | |
2566 | GuidStr = GetNextParamStr (&TextDeviceNode);\r | |
2567 | FvFile = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) CreateDeviceNode (\r | |
2568 | MEDIA_DEVICE_PATH,\r | |
2569 | MEDIA_PIWG_FW_FILE_DP,\r | |
2570 | sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)\r | |
2571 | );\r | |
2572 | \r | |
2573 | StrToGuid (GuidStr, &FvFile->FvFileName);\r | |
2574 | \r | |
2575 | return (EFI_DEVICE_PATH_PROTOCOL *) FvFile;\r | |
2576 | }\r | |
2577 | \r | |
572f5d8a | 2578 | /**\r |
2579 | Converts a text device path node to BIOS Boot Specification device path structure.\r | |
2580 | \r | |
2581 | @param TextDeviceNode The input Text device path node.\r | |
2582 | \r | |
2583 | @return A pointer to the newly-created BIOS Boot Specificationa device path structure.\r | |
2584 | \r | |
2585 | **/\r | |
95276127 | 2586 | EFI_DEVICE_PATH_PROTOCOL *\r |
2587 | DevPathFromTextBBS (\r | |
2588 | IN CHAR16 *TextDeviceNode\r | |
2589 | )\r | |
2590 | {\r | |
2591 | CHAR16 *TypeStr;\r | |
2592 | CHAR16 *IdStr;\r | |
2593 | CHAR16 *FlagsStr;\r | |
cf40f28a | 2594 | CHAR8 *AsciiStr;\r |
95276127 | 2595 | BBS_BBS_DEVICE_PATH *Bbs;\r |
2596 | \r | |
2597 | TypeStr = GetNextParamStr (&TextDeviceNode);\r | |
2598 | IdStr = GetNextParamStr (&TextDeviceNode);\r | |
2599 | FlagsStr = GetNextParamStr (&TextDeviceNode);\r | |
2600 | Bbs = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode (\r | |
2601 | BBS_DEVICE_PATH,\r | |
2602 | BBS_BBS_DP,\r | |
d074a8e1 | 2603 | (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr))\r |
95276127 | 2604 | );\r |
2605 | \r | |
2606 | if (StrCmp (TypeStr, L"Floppy") == 0) {\r | |
2607 | Bbs->DeviceType = BBS_TYPE_FLOPPY;\r | |
2608 | } else if (StrCmp (TypeStr, L"HD") == 0) {\r | |
2609 | Bbs->DeviceType = BBS_TYPE_HARDDRIVE;\r | |
2610 | } else if (StrCmp (TypeStr, L"CDROM") == 0) {\r | |
2611 | Bbs->DeviceType = BBS_TYPE_CDROM;\r | |
2612 | } else if (StrCmp (TypeStr, L"PCMCIA") == 0) {\r | |
2613 | Bbs->DeviceType = BBS_TYPE_PCMCIA;\r | |
2614 | } else if (StrCmp (TypeStr, L"USB") == 0) {\r | |
2615 | Bbs->DeviceType = BBS_TYPE_USB;\r | |
2616 | } else if (StrCmp (TypeStr, L"Network") == 0) {\r | |
2617 | Bbs->DeviceType = BBS_TYPE_EMBEDDED_NETWORK;\r | |
2618 | } else {\r | |
cf40f28a | 2619 | Bbs->DeviceType = (UINT16) Strtoi (TypeStr);\r |
95276127 | 2620 | }\r |
2621 | \r | |
cf40f28a | 2622 | AsciiStr = Bbs->String;\r |
2623 | StrToAscii (IdStr, &AsciiStr);\r | |
95276127 | 2624 | \r |
cf40f28a | 2625 | Bbs->StatusFlag = (UINT16) Strtoi (FlagsStr);\r |
95276127 | 2626 | \r |
2627 | return (EFI_DEVICE_PATH_PROTOCOL *) Bbs;\r | |
2628 | }\r | |
2629 | \r | |
572f5d8a | 2630 | /**\r |
2631 | Converts a text device path node to SATA device path structure.\r | |
2632 | \r | |
2633 | @param TextDeviceNode The input Text device path node.\r | |
2634 | \r | |
2635 | @return A pointer to the newly-created SATA device path structure.\r | |
2636 | \r | |
2637 | **/\r | |
cf40f28a | 2638 | EFI_DEVICE_PATH_PROTOCOL *\r |
2639 | DevPathFromTextSata (\r | |
2640 | IN CHAR16 *TextDeviceNode\r | |
2641 | )\r | |
2642 | {\r | |
2643 | SATA_DEVICE_PATH *Sata;\r | |
2644 | CHAR16 *Param1;\r | |
2645 | CHAR16 *Param2;\r | |
2646 | CHAR16 *Param3;\r | |
2647 | \r | |
2648 | //\r | |
2649 | // The PMPN is optional.\r | |
2650 | //\r | |
2651 | Param1 = GetNextParamStr (&TextDeviceNode);\r | |
2652 | Param2 = GetNextParamStr (&TextDeviceNode);\r | |
2653 | Param3 = NULL;\r | |
2654 | if (!IS_NULL (TextDeviceNode)) {\r | |
2655 | Param3 = GetNextParamStr (&TextDeviceNode);\r | |
2656 | }\r | |
2657 | \r | |
2658 | Sata = (SATA_DEVICE_PATH *) CreateDeviceNode (\r | |
2659 | MESSAGING_DEVICE_PATH,\r | |
2660 | MSG_SATA_DP,\r | |
2661 | sizeof (SATA_DEVICE_PATH)\r | |
2662 | );\r | |
93e3992d | 2663 | Sata->HBAPortNumber = (UINT16) Xtoi (Param1);\r |
cf40f28a | 2664 | if (Param3 != NULL) {\r |
93e3992d | 2665 | Sata->PortMultiplierPortNumber = (UINT16) Xtoi (Param2);\r |
cf40f28a | 2666 | Param2 = Param3;\r |
2667 | } else {\r | |
93e3992d | 2668 | Sata->PortMultiplierPortNumber = 0;\r |
cf40f28a | 2669 | }\r |
93e3992d | 2670 | Sata->Lun = (UINT16) Xtoi (Param2);\r |
cf40f28a | 2671 | \r |
2672 | return (EFI_DEVICE_PATH_PROTOCOL *) Sata;\r | |
2673 | }\r | |
2674 | \r | |
95276127 | 2675 | GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[] = {\r |
2676 | {L"Pci", DevPathFromTextPci},\r | |
2677 | {L"PcCard", DevPathFromTextPcCard},\r | |
2678 | {L"MemoryMapped", DevPathFromTextMemoryMapped},\r | |
2679 | {L"VenHw", DevPathFromTextVenHw},\r | |
2680 | {L"Ctrl", DevPathFromTextCtrl},\r | |
2681 | {L"Acpi", DevPathFromTextAcpi},\r | |
2682 | {L"PciRoot", DevPathFromTextPciRoot},\r | |
2683 | {L"Floppy", DevPathFromTextFloppy},\r | |
2684 | {L"Keyboard", DevPathFromTextKeyboard},\r | |
2685 | {L"Serial", DevPathFromTextSerial},\r | |
2686 | {L"ParallelPort", DevPathFromTextParallelPort},\r | |
2687 | {L"AcpiEx", DevPathFromTextAcpiEx},\r | |
2688 | {L"AcpiExp", DevPathFromTextAcpiExp},\r | |
2689 | {L"Ata", DevPathFromTextAta},\r | |
2690 | {L"Scsi", DevPathFromTextScsi},\r | |
2691 | {L"Fibre", DevPathFromTextFibre},\r | |
2692 | {L"I1394", DevPathFromText1394},\r | |
2693 | {L"USB", DevPathFromTextUsb},\r | |
2694 | {L"I2O", DevPathFromTextI2O},\r | |
2695 | {L"Infiniband", DevPathFromTextInfiniband},\r | |
2696 | {L"VenMsg", DevPathFromTextVenMsg},\r | |
2697 | {L"VenPcAnsi", DevPathFromTextVenPcAnsi},\r | |
2698 | {L"VenVt100", DevPathFromTextVenVt100},\r | |
2699 | {L"VenVt100Plus", DevPathFromTextVenVt100Plus},\r | |
2700 | {L"VenUtf8", DevPathFromTextVenUtf8},\r | |
2701 | {L"UartFlowCtrl", DevPathFromTextUartFlowCtrl},\r | |
2702 | {L"SAS", DevPathFromTextSAS},\r | |
2703 | {L"DebugPort", DevPathFromTextDebugPort},\r | |
2704 | {L"MAC", DevPathFromTextMAC},\r | |
2705 | {L"IPv4", DevPathFromTextIPv4},\r | |
2706 | {L"IPv6", DevPathFromTextIPv6},\r | |
2707 | {L"Uart", DevPathFromTextUart},\r | |
2708 | {L"UsbClass", DevPathFromTextUsbClass},\r | |
2709 | {L"UsbAudio", DevPathFromTextUsbAudio},\r | |
2710 | {L"UsbCDCControl", DevPathFromTextUsbCDCControl},\r | |
2711 | {L"UsbHID", DevPathFromTextUsbHID},\r | |
2712 | {L"UsbImage", DevPathFromTextUsbImage},\r | |
2713 | {L"UsbPrinter", DevPathFromTextUsbPrinter},\r | |
2714 | {L"UsbMassStorage", DevPathFromTextUsbMassStorage},\r | |
2715 | {L"UsbHub", DevPathFromTextUsbHub},\r | |
2716 | {L"UsbCDCData", DevPathFromTextUsbCDCData},\r | |
2717 | {L"UsbSmartCard", DevPathFromTextUsbSmartCard},\r | |
2718 | {L"UsbVideo", DevPathFromTextUsbVideo},\r | |
2719 | {L"UsbDiagnostic", DevPathFromTextUsbDiagnostic},\r | |
2720 | {L"UsbWireless", DevPathFromTextUsbWireless},\r | |
2721 | {L"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate},\r | |
2722 | {L"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge},\r | |
2723 | {L"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement},\r | |
2724 | {L"UsbWwid", DevPathFromTextUsbWwid},\r | |
2725 | {L"Unit", DevPathFromTextUnit},\r | |
2726 | {L"iSCSI", DevPathFromTextiSCSI},\r | |
2727 | {L"HD", DevPathFromTextHD},\r | |
2728 | {L"CDROM", DevPathFromTextCDROM},\r | |
2729 | {L"VenMEDIA", DevPathFromTextVenMEDIA},\r | |
2730 | {L"Media", DevPathFromTextMedia},\r | |
cf40f28a | 2731 | {L"Fv", DevPathFromTextFv},\r |
2732 | {L"FvFile", DevPathFromTextFvFile},\r | |
95276127 | 2733 | {L"BBS", DevPathFromTextBBS},\r |
cf40f28a | 2734 | {L"Sata", DevPathFromTextSata},\r |
95276127 | 2735 | {NULL, NULL}\r |
2736 | };\r | |
2737 | \r | |
572f5d8a | 2738 | /**\r |
2739 | Convert text to the binary representation of a device node.\r | |
95276127 | 2740 | \r |
572f5d8a | 2741 | @param TextDeviceNode TextDeviceNode points to the text representation of a device\r |
95276127 | 2742 | node. Conversion starts with the first character and continues\r |
2743 | until the first non-device node character.\r | |
2744 | \r | |
572f5d8a | 2745 | @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r |
2746 | insufficient memory or text unsupported.\r | |
95276127 | 2747 | \r |
572f5d8a | 2748 | **/\r |
2749 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2750 | EFIAPI\r | |
2751 | ConvertTextToDeviceNode (\r | |
2752 | IN CONST CHAR16 *TextDeviceNode\r | |
2753 | )\r | |
95276127 | 2754 | {\r |
572f5d8a | 2755 | DUMP_NODE DumpNode;\r |
95276127 | 2756 | CHAR16 *ParamStr;\r |
2757 | EFI_DEVICE_PATH_PROTOCOL *DeviceNode;\r | |
2758 | CHAR16 *DeviceNodeStr;\r | |
2759 | UINTN Index;\r | |
2760 | \r | |
2761 | if ((TextDeviceNode == NULL) || (IS_NULL (*TextDeviceNode))) {\r | |
2762 | return NULL;\r | |
2763 | }\r | |
2764 | \r | |
2765 | ParamStr = NULL;\r | |
2766 | DumpNode = NULL;\r | |
2767 | DeviceNodeStr = StrDuplicate (TextDeviceNode);\r | |
2768 | \r | |
2769 | for (Index = 0; DevPathFromTextTable[Index].Function; Index++) {\r | |
2770 | ParamStr = GetParamByNodeName (DeviceNodeStr, DevPathFromTextTable[Index].DevicePathNodeText);\r | |
2771 | if (ParamStr != NULL) {\r | |
2772 | DumpNode = DevPathFromTextTable[Index].Function;\r | |
2773 | break;\r | |
2774 | }\r | |
2775 | }\r | |
2776 | \r | |
2777 | if (DumpNode == NULL) {\r | |
2778 | //\r | |
2779 | // A file path\r | |
2780 | //\r | |
2781 | DumpNode = DevPathFromTextFilePath;\r | |
2782 | DeviceNode = DumpNode (DeviceNodeStr);\r | |
2783 | } else {\r | |
2784 | DeviceNode = DumpNode (ParamStr);\r | |
2785 | FreePool (ParamStr);\r | |
2786 | }\r | |
2787 | \r | |
2788 | FreePool (DeviceNodeStr);\r | |
2789 | \r | |
2790 | return DeviceNode;\r | |
2791 | }\r | |
2792 | \r | |
572f5d8a | 2793 | /**\r |
2794 | Convert text to the binary representation of a device path.\r | |
95276127 | 2795 | \r |
95276127 | 2796 | \r |
572f5d8a | 2797 | @param TextDevicePath TextDevicePath points to the text representation of a device\r |
95276127 | 2798 | path. Conversion starts with the first character and continues\r |
2799 | until the first non-device node character.\r | |
2800 | \r | |
572f5d8a | 2801 | @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r |
2802 | there was insufficient memory.\r | |
95276127 | 2803 | \r |
572f5d8a | 2804 | **/\r |
2805 | EFI_DEVICE_PATH_PROTOCOL *\r | |
2806 | EFIAPI\r | |
2807 | ConvertTextToDevicePath (\r | |
2808 | IN CONST CHAR16 *TextDevicePath\r | |
2809 | )\r | |
95276127 | 2810 | {\r |
572f5d8a | 2811 | DUMP_NODE DumpNode;\r |
95276127 | 2812 | CHAR16 *ParamStr;\r |
2813 | EFI_DEVICE_PATH_PROTOCOL *DeviceNode;\r | |
2814 | UINTN Index;\r | |
2815 | EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;\r | |
2816 | CHAR16 *DevicePathStr;\r | |
2817 | CHAR16 *Str;\r | |
2818 | CHAR16 *DeviceNodeStr;\r | |
2819 | UINT8 IsInstanceEnd;\r | |
2820 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
2821 | \r | |
2822 | if ((TextDevicePath == NULL) || (IS_NULL (*TextDevicePath))) {\r | |
2823 | return NULL;\r | |
2824 | }\r | |
2825 | \r | |
2826 | DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r | |
2827 | SetDevicePathEndNode (DevicePath);\r | |
2828 | \r | |
2829 | ParamStr = NULL;\r | |
2830 | DeviceNodeStr = NULL;\r | |
2831 | DevicePathStr = StrDuplicate (TextDevicePath);\r | |
2832 | \r | |
2833 | Str = DevicePathStr;\r | |
2834 | while ((DeviceNodeStr = GetNextDeviceNodeStr (&Str, &IsInstanceEnd)) != NULL) {\r | |
2835 | DumpNode = NULL;\r | |
2836 | for (Index = 0; DevPathFromTextTable[Index].Function; Index++) {\r | |
2837 | ParamStr = GetParamByNodeName (DeviceNodeStr, DevPathFromTextTable[Index].DevicePathNodeText);\r | |
2838 | if (ParamStr != NULL) {\r | |
2839 | DumpNode = DevPathFromTextTable[Index].Function;\r | |
2840 | break;\r | |
2841 | }\r | |
2842 | }\r | |
2843 | \r | |
2844 | if (DumpNode == NULL) {\r | |
2845 | //\r | |
2846 | // A file path\r | |
2847 | //\r | |
2848 | DumpNode = DevPathFromTextFilePath;\r | |
2849 | DeviceNode = DumpNode (DeviceNodeStr);\r | |
2850 | } else {\r | |
2851 | DeviceNode = DumpNode (ParamStr);\r | |
2852 | FreePool (ParamStr);\r | |
2853 | }\r | |
2854 | \r | |
2855 | NewDevicePath = AppendDeviceNodeProtocolInterface (DevicePath, DeviceNode);\r | |
2856 | FreePool (DevicePath);\r | |
2857 | FreePool (DeviceNode);\r | |
2858 | DevicePath = NewDevicePath;\r | |
2859 | \r | |
572f5d8a | 2860 | if (IsInstanceEnd != 0) {\r |
95276127 | 2861 | DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r |
572f5d8a | 2862 | SET_DEVICE_PATH_INSTANCE_END_NODE (DeviceNode);\r |
95276127 | 2863 | \r |
2864 | NewDevicePath = AppendDeviceNodeProtocolInterface (DevicePath, DeviceNode);\r | |
2865 | FreePool (DevicePath);\r | |
2866 | FreePool (DeviceNode);\r | |
2867 | DevicePath = NewDevicePath;\r | |
2868 | }\r | |
2869 | }\r | |
2870 | \r | |
2871 | FreePool (DevicePathStr);\r | |
2872 | return DevicePath;\r | |
2873 | }\r |