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