]>
Commit | Line | Data |
---|---|---|
2cd086a6 | 1 | /** @file\r |
2 | Rewrite the BootOrder NvVar based on QEMU's "bootorder" fw_cfg file.\r | |
3 | \r | |
863986b3 | 4 | Copyright (C) 2012 - 2013, Red Hat, Inc.\r |
2cd086a6 | 5 | \r |
6 | This program and the accompanying materials are licensed and made available\r | |
7 | under the terms and conditions of the BSD License which accompanies this\r | |
8 | distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r | |
12 | WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | **/\r | |
14 | \r | |
15 | #include <Library/QemuFwCfgLib.h>\r | |
16 | #include <Library/DebugLib.h>\r | |
17 | #include <Library/MemoryAllocationLib.h>\r | |
18 | #include <Library/GenericBdsLib.h>\r | |
19 | #include <Library/UefiBootServicesTableLib.h>\r | |
20 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
21 | #include <Library/BaseLib.h>\r | |
22 | #include <Library/PrintLib.h>\r | |
863986b3 | 23 | #include <Library/DevicePathLib.h>\r |
2cd086a6 | 24 | #include <Guid/GlobalVariable.h>\r |
25 | \r | |
26 | \r | |
27 | /**\r | |
28 | OpenFirmware to UEFI device path translation output buffer size in CHAR16's.\r | |
29 | **/\r | |
30 | #define TRANSLATION_OUTPUT_SIZE 0x100\r | |
31 | \r | |
32 | \r | |
33 | /**\r | |
ec01afdb | 34 | Numbers of nodes in OpenFirmware device paths that are required and examined.\r |
2cd086a6 | 35 | **/\r |
ec01afdb | 36 | #define REQUIRED_OFW_NODES 2\r |
37 | #define EXAMINED_OFW_NODES 4\r | |
2cd086a6 | 38 | \r |
39 | \r | |
40 | /**\r | |
41 | Simple character classification routines, corresponding to POSIX class names\r | |
42 | and ASCII encoding.\r | |
43 | **/\r | |
44 | STATIC\r | |
45 | BOOLEAN\r | |
46 | IsAlnum (\r | |
47 | IN CHAR8 Chr\r | |
48 | )\r | |
49 | {\r | |
50 | return (('0' <= Chr && Chr <= '9') ||\r | |
51 | ('A' <= Chr && Chr <= 'Z') ||\r | |
52 | ('a' <= Chr && Chr <= 'z')\r | |
53 | );\r | |
54 | }\r | |
55 | \r | |
56 | \r | |
57 | STATIC\r | |
58 | BOOLEAN\r | |
59 | IsDriverNamePunct (\r | |
60 | IN CHAR8 Chr\r | |
61 | )\r | |
62 | {\r | |
63 | return (Chr == ',' || Chr == '.' || Chr == '_' ||\r | |
64 | Chr == '+' || Chr == '-'\r | |
65 | );\r | |
66 | }\r | |
67 | \r | |
68 | \r | |
69 | STATIC\r | |
70 | BOOLEAN\r | |
71 | IsPrintNotDelim (\r | |
72 | IN CHAR8 Chr\r | |
73 | )\r | |
74 | {\r | |
75 | return (32 <= Chr && Chr <= 126 &&\r | |
76 | Chr != '/' && Chr != '@' && Chr != ':');\r | |
77 | }\r | |
78 | \r | |
79 | \r | |
80 | /**\r | |
81 | Utility types and functions.\r | |
82 | **/\r | |
83 | typedef struct {\r | |
84 | CONST CHAR8 *Ptr; // not necessarily NUL-terminated\r | |
85 | UINTN Len; // number of non-NUL characters\r | |
86 | } SUBSTRING;\r | |
87 | \r | |
88 | \r | |
89 | /**\r | |
90 | \r | |
91 | Check if Substring and String have identical contents.\r | |
92 | \r | |
93 | The function relies on the restriction that a SUBSTRING cannot have embedded\r | |
94 | NULs either.\r | |
95 | \r | |
96 | @param[in] Substring The SUBSTRING input to the comparison.\r | |
97 | \r | |
98 | @param[in] String The ASCII string input to the comparison.\r | |
99 | \r | |
100 | \r | |
101 | @return Whether the inputs have identical contents.\r | |
102 | \r | |
103 | **/\r | |
104 | STATIC\r | |
105 | BOOLEAN\r | |
106 | SubstringEq (\r | |
107 | IN SUBSTRING Substring,\r | |
108 | IN CONST CHAR8 *String\r | |
109 | )\r | |
110 | {\r | |
111 | UINTN Pos;\r | |
112 | CONST CHAR8 *Chr;\r | |
113 | \r | |
114 | Pos = 0;\r | |
115 | Chr = String;\r | |
116 | \r | |
117 | while (Pos < Substring.Len && Substring.Ptr[Pos] == *Chr) {\r | |
118 | ++Pos;\r | |
119 | ++Chr;\r | |
120 | }\r | |
121 | \r | |
dccf7678 | 122 | return (BOOLEAN)(Pos == Substring.Len && *Chr == '\0');\r |
2cd086a6 | 123 | }\r |
124 | \r | |
125 | \r | |
126 | /**\r | |
127 | \r | |
128 | Parse a comma-separated list of hexadecimal integers into the elements of an\r | |
129 | UINT32 array.\r | |
130 | \r | |
131 | Whitespace, "0x" prefixes, leading or trailing commas, sequences of commas,\r | |
132 | or an empty string are not allowed; they are rejected.\r | |
133 | \r | |
134 | The function relies on ASCII encoding.\r | |
135 | \r | |
136 | @param[in] UnitAddress The substring to parse.\r | |
137 | \r | |
138 | @param[out] Result The array, allocated by the caller, to receive\r | |
139 | the parsed values. This parameter may be NULL if\r | |
140 | NumResults is zero on input.\r | |
141 | \r | |
142 | @param[in out] NumResults On input, the number of elements allocated for\r | |
143 | Result. On output, the number of elements it has\r | |
144 | taken (or would have taken) to parse the string\r | |
145 | fully.\r | |
146 | \r | |
147 | \r | |
148 | @retval RETURN_SUCCESS UnitAddress has been fully parsed.\r | |
149 | NumResults is set to the number of parsed\r | |
150 | values; the corresponding elements have\r | |
151 | been set in Result. The rest of Result's\r | |
152 | elements are unchanged.\r | |
153 | \r | |
154 | @retval RETURN_BUFFER_TOO_SMALL UnitAddress has been fully parsed.\r | |
155 | NumResults is set to the number of parsed\r | |
156 | values, but elements have been stored only\r | |
157 | up to the input value of NumResults, which\r | |
158 | is less than what has been parsed.\r | |
159 | \r | |
160 | @retval RETURN_INVALID_PARAMETER Parse error. The contents of Results is\r | |
161 | indeterminate. NumResults has not been\r | |
162 | changed.\r | |
163 | \r | |
164 | **/\r | |
165 | STATIC\r | |
166 | RETURN_STATUS\r | |
167 | ParseUnitAddressHexList (\r | |
168 | IN SUBSTRING UnitAddress,\r | |
169 | OUT UINT32 *Result,\r | |
170 | IN OUT UINTN *NumResults\r | |
171 | )\r | |
172 | {\r | |
173 | UINTN Entry; // number of entry currently being parsed\r | |
174 | UINT32 EntryVal; // value being constructed for current entry\r | |
175 | CHAR8 PrevChr; // UnitAddress character previously checked\r | |
176 | UINTN Pos; // current position within UnitAddress\r | |
177 | RETURN_STATUS Status;\r | |
178 | \r | |
179 | Entry = 0;\r | |
180 | EntryVal = 0;\r | |
181 | PrevChr = ',';\r | |
182 | \r | |
183 | for (Pos = 0; Pos < UnitAddress.Len; ++Pos) {\r | |
184 | CHAR8 Chr;\r | |
185 | INT8 Val;\r | |
186 | \r | |
187 | Chr = UnitAddress.Ptr[Pos];\r | |
188 | Val = ('a' <= Chr && Chr <= 'f') ? (Chr - 'a' + 10) :\r | |
189 | ('A' <= Chr && Chr <= 'F') ? (Chr - 'A' + 10) :\r | |
190 | ('0' <= Chr && Chr <= '9') ? (Chr - '0' ) :\r | |
191 | -1;\r | |
192 | \r | |
193 | if (Val >= 0) {\r | |
194 | if (EntryVal > 0xFFFFFFF) {\r | |
195 | return RETURN_INVALID_PARAMETER;\r | |
196 | }\r | |
197 | EntryVal = (EntryVal << 4) | Val;\r | |
198 | } else if (Chr == ',') {\r | |
199 | if (PrevChr == ',') {\r | |
200 | return RETURN_INVALID_PARAMETER;\r | |
201 | }\r | |
202 | if (Entry < *NumResults) {\r | |
203 | Result[Entry] = EntryVal;\r | |
204 | }\r | |
205 | ++Entry;\r | |
206 | EntryVal = 0;\r | |
207 | } else {\r | |
208 | return RETURN_INVALID_PARAMETER;\r | |
209 | }\r | |
210 | \r | |
211 | PrevChr = Chr;\r | |
212 | }\r | |
213 | \r | |
214 | if (PrevChr == ',') {\r | |
215 | return RETURN_INVALID_PARAMETER;\r | |
216 | }\r | |
217 | if (Entry < *NumResults) {\r | |
218 | Result[Entry] = EntryVal;\r | |
219 | Status = RETURN_SUCCESS;\r | |
220 | } else {\r | |
221 | Status = RETURN_BUFFER_TOO_SMALL;\r | |
222 | }\r | |
223 | ++Entry;\r | |
224 | \r | |
225 | *NumResults = Entry;\r | |
226 | return Status;\r | |
227 | }\r | |
228 | \r | |
229 | \r | |
230 | /**\r | |
231 | A simple array of Boot Option ID's.\r | |
232 | **/\r | |
233 | typedef struct {\r | |
234 | UINT16 *Data;\r | |
235 | UINTN Allocated;\r | |
236 | UINTN Produced;\r | |
237 | } BOOT_ORDER;\r | |
238 | \r | |
239 | \r | |
240 | /**\r | |
241 | \r | |
242 | Append BootOptionId to BootOrder, reallocating the latter if needed.\r | |
243 | \r | |
244 | @param[in out] BootOrder The structure pointing to the array and holding\r | |
245 | allocation and usage counters.\r | |
246 | \r | |
247 | @param[in] BootOptionId The value to append to the array.\r | |
248 | \r | |
249 | \r | |
250 | @retval RETURN_SUCCESS BootOptionId appended.\r | |
251 | \r | |
252 | @retval RETURN_OUT_OF_RESOURCES Memory reallocation failed.\r | |
253 | \r | |
254 | **/\r | |
255 | STATIC\r | |
256 | RETURN_STATUS\r | |
257 | BootOrderAppend (\r | |
258 | IN OUT BOOT_ORDER *BootOrder,\r | |
259 | IN UINT16 BootOptionId\r | |
260 | )\r | |
261 | {\r | |
262 | if (BootOrder->Produced == BootOrder->Allocated) {\r | |
263 | UINTN AllocatedNew;\r | |
264 | UINT16 *DataNew;\r | |
265 | \r | |
266 | ASSERT (BootOrder->Allocated > 0);\r | |
267 | AllocatedNew = BootOrder->Allocated * 2;\r | |
268 | DataNew = ReallocatePool (\r | |
269 | BootOrder->Allocated * sizeof (*BootOrder->Data),\r | |
270 | AllocatedNew * sizeof (*DataNew),\r | |
271 | BootOrder->Data\r | |
272 | );\r | |
273 | if (DataNew == NULL) {\r | |
274 | return RETURN_OUT_OF_RESOURCES;\r | |
275 | }\r | |
276 | BootOrder->Allocated = AllocatedNew;\r | |
277 | BootOrder->Data = DataNew;\r | |
278 | }\r | |
279 | \r | |
280 | BootOrder->Data[BootOrder->Produced++] = BootOptionId;\r | |
281 | return RETURN_SUCCESS;\r | |
282 | }\r | |
283 | \r | |
284 | \r | |
285 | /**\r | |
286 | OpenFirmware device path node\r | |
287 | **/\r | |
288 | typedef struct {\r | |
289 | SUBSTRING DriverName;\r | |
290 | SUBSTRING UnitAddress;\r | |
291 | SUBSTRING DeviceArguments;\r | |
292 | } OFW_NODE;\r | |
293 | \r | |
294 | \r | |
295 | /**\r | |
296 | \r | |
297 | Parse an OpenFirmware device path node into the caller-allocated OFW_NODE\r | |
298 | structure, and advance in the input string.\r | |
299 | \r | |
300 | The node format is mostly parsed after IEEE 1275-1994, 3.2.1.1 "Node names"\r | |
301 | (a leading slash is expected and not returned):\r | |
302 | \r | |
303 | /driver-name@unit-address[:device-arguments][<LF>]\r | |
304 | \r | |
305 | A single trailing <LF> character is consumed but not returned. A trailing\r | |
306 | <LF> or NUL character terminates the device path.\r | |
307 | \r | |
308 | The function relies on ASCII encoding.\r | |
309 | \r | |
310 | @param[in out] Ptr Address of the pointer pointing to the start of the\r | |
311 | node string. After successful parsing *Ptr is set to\r | |
312 | the byte immediately following the consumed\r | |
313 | characters. On error it points to the byte that\r | |
314 | caused the error. The input string is never modified.\r | |
315 | \r | |
316 | @param[out] OfwNode The members of this structure point into the input\r | |
317 | string, designating components of the node.\r | |
318 | Separators are never included. If "device-arguments"\r | |
319 | is missing, then DeviceArguments.Ptr is set to NULL.\r | |
320 | All components that are present have nonzero length.\r | |
321 | \r | |
322 | If the call doesn't succeed, the contents of this\r | |
323 | structure is indeterminate.\r | |
324 | \r | |
325 | @param[out] IsFinal In case of successul parsing, this parameter signals\r | |
326 | whether the node just parsed is the final node in the\r | |
327 | device path. The call after a final node will attempt\r | |
328 | to start parsing the next path. If the call doesn't\r | |
329 | succeed, then this parameter is not changed.\r | |
330 | \r | |
331 | \r | |
332 | @retval RETURN_SUCCESS Parsing successful.\r | |
333 | \r | |
334 | @retval RETURN_NOT_FOUND Parsing terminated. *Ptr was (and is)\r | |
335 | pointing to an empty string.\r | |
336 | \r | |
337 | @retval RETURN_INVALID_PARAMETER Parse error.\r | |
338 | \r | |
339 | **/\r | |
340 | STATIC\r | |
341 | RETURN_STATUS\r | |
342 | ParseOfwNode (\r | |
343 | IN OUT CONST CHAR8 **Ptr,\r | |
344 | OUT OFW_NODE *OfwNode,\r | |
345 | OUT BOOLEAN *IsFinal\r | |
346 | )\r | |
347 | {\r | |
348 | //\r | |
349 | // A leading slash is expected. End of string is tolerated.\r | |
350 | //\r | |
351 | switch (**Ptr) {\r | |
352 | case '\0':\r | |
353 | return RETURN_NOT_FOUND;\r | |
354 | \r | |
355 | case '/':\r | |
356 | ++*Ptr;\r | |
357 | break;\r | |
358 | \r | |
359 | default:\r | |
360 | return RETURN_INVALID_PARAMETER;\r | |
361 | }\r | |
362 | \r | |
363 | //\r | |
364 | // driver-name\r | |
365 | //\r | |
366 | OfwNode->DriverName.Ptr = *Ptr;\r | |
367 | OfwNode->DriverName.Len = 0;\r | |
368 | while (OfwNode->DriverName.Len < 32 &&\r | |
369 | (IsAlnum (**Ptr) || IsDriverNamePunct (**Ptr))\r | |
370 | ) {\r | |
371 | ++*Ptr;\r | |
372 | ++OfwNode->DriverName.Len;\r | |
373 | }\r | |
374 | \r | |
375 | if (OfwNode->DriverName.Len == 0 || OfwNode->DriverName.Len == 32) {\r | |
376 | return RETURN_INVALID_PARAMETER;\r | |
377 | }\r | |
378 | \r | |
379 | \r | |
380 | //\r | |
381 | // unit-address\r | |
382 | //\r | |
383 | if (**Ptr != '@') {\r | |
384 | return RETURN_INVALID_PARAMETER;\r | |
385 | }\r | |
386 | ++*Ptr;\r | |
387 | \r | |
388 | OfwNode->UnitAddress.Ptr = *Ptr;\r | |
389 | OfwNode->UnitAddress.Len = 0;\r | |
390 | while (IsPrintNotDelim (**Ptr)) {\r | |
391 | ++*Ptr;\r | |
392 | ++OfwNode->UnitAddress.Len;\r | |
393 | }\r | |
394 | \r | |
395 | if (OfwNode->UnitAddress.Len == 0) {\r | |
396 | return RETURN_INVALID_PARAMETER;\r | |
397 | }\r | |
398 | \r | |
399 | \r | |
400 | //\r | |
401 | // device-arguments, may be omitted\r | |
402 | //\r | |
403 | OfwNode->DeviceArguments.Len = 0;\r | |
404 | if (**Ptr == ':') {\r | |
405 | ++*Ptr;\r | |
406 | OfwNode->DeviceArguments.Ptr = *Ptr;\r | |
407 | \r | |
408 | while (IsPrintNotDelim (**Ptr)) {\r | |
409 | ++*Ptr;\r | |
410 | ++OfwNode->DeviceArguments.Len;\r | |
411 | }\r | |
412 | \r | |
413 | if (OfwNode->DeviceArguments.Len == 0) {\r | |
414 | return RETURN_INVALID_PARAMETER;\r | |
415 | }\r | |
416 | }\r | |
417 | else {\r | |
418 | OfwNode->DeviceArguments.Ptr = NULL;\r | |
419 | }\r | |
420 | \r | |
421 | switch (**Ptr) {\r | |
422 | case '\n':\r | |
423 | ++*Ptr;\r | |
424 | //\r | |
425 | // fall through\r | |
426 | //\r | |
427 | \r | |
428 | case '\0':\r | |
429 | *IsFinal = TRUE;\r | |
430 | break;\r | |
431 | \r | |
432 | case '/':\r | |
433 | *IsFinal = FALSE;\r | |
434 | break;\r | |
435 | \r | |
436 | default:\r | |
437 | return RETURN_INVALID_PARAMETER;\r | |
438 | }\r | |
439 | \r | |
440 | DEBUG ((\r | |
441 | DEBUG_VERBOSE,\r | |
442 | "%a: DriverName=\"%.*a\" UnitAddress=\"%.*a\" DeviceArguments=\"%.*a\"\n",\r | |
443 | __FUNCTION__,\r | |
444 | OfwNode->DriverName.Len, OfwNode->DriverName.Ptr,\r | |
445 | OfwNode->UnitAddress.Len, OfwNode->UnitAddress.Ptr,\r | |
446 | OfwNode->DeviceArguments.Len,\r | |
447 | OfwNode->DeviceArguments.Ptr == NULL ? "" : OfwNode->DeviceArguments.Ptr\r | |
448 | ));\r | |
449 | return RETURN_SUCCESS;\r | |
450 | }\r | |
451 | \r | |
452 | \r | |
453 | /**\r | |
454 | \r | |
455 | Translate an array of OpenFirmware device nodes to a UEFI device path\r | |
456 | fragment.\r | |
457 | \r | |
458 | @param[in] OfwNode Array of OpenFirmware device nodes to\r | |
459 | translate, constituting the beginning of an\r | |
460 | OpenFirmware device path.\r | |
461 | \r | |
462 | @param[in] NumNodes Number of elements in OfwNode.\r | |
463 | \r | |
464 | @param[out] Translated Destination array receiving the UEFI path\r | |
465 | fragment, allocated by the caller. If the\r | |
466 | return value differs from RETURN_SUCCESS, its\r | |
467 | contents is indeterminate.\r | |
468 | \r | |
469 | @param[in out] TranslatedSize On input, the number of CHAR16's in\r | |
470 | Translated. On RETURN_SUCCESS this parameter\r | |
471 | is assigned the number of non-NUL CHAR16's\r | |
472 | written to Translated. In case of other return\r | |
473 | values, TranslatedSize is indeterminate.\r | |
474 | \r | |
475 | \r | |
476 | @retval RETURN_SUCCESS Translation successful.\r | |
477 | \r | |
478 | @retval RETURN_BUFFER_TOO_SMALL The translation does not fit into the number\r | |
479 | of bytes provided.\r | |
480 | \r | |
481 | @retval RETURN_UNSUPPORTED The array of OpenFirmware device nodes can't\r | |
482 | be translated in the current implementation.\r | |
483 | \r | |
484 | **/\r | |
485 | STATIC\r | |
486 | RETURN_STATUS\r | |
487 | TranslateOfwNodes (\r | |
488 | IN CONST OFW_NODE *OfwNode,\r | |
489 | IN UINTN NumNodes,\r | |
490 | OUT CHAR16 *Translated,\r | |
491 | IN OUT UINTN *TranslatedSize\r | |
492 | )\r | |
493 | {\r | |
494 | UINT32 PciDevFun[2];\r | |
495 | UINTN NumEntries;\r | |
496 | UINTN Written;\r | |
497 | \r | |
498 | //\r | |
499 | // Get PCI device and optional PCI function. Assume a single PCI root.\r | |
500 | //\r | |
ec01afdb | 501 | if (NumNodes < REQUIRED_OFW_NODES ||\r |
2cd086a6 | 502 | !SubstringEq (OfwNode[0].DriverName, "pci")\r |
503 | ) {\r | |
504 | return RETURN_UNSUPPORTED;\r | |
505 | }\r | |
506 | PciDevFun[1] = 0;\r | |
507 | NumEntries = sizeof (PciDevFun) / sizeof (PciDevFun[0]);\r | |
508 | if (ParseUnitAddressHexList (\r | |
509 | OfwNode[1].UnitAddress,\r | |
510 | PciDevFun,\r | |
511 | &NumEntries\r | |
512 | ) != RETURN_SUCCESS\r | |
513 | ) {\r | |
514 | return RETURN_UNSUPPORTED;\r | |
515 | }\r | |
516 | \r | |
ec01afdb | 517 | if (NumNodes >= 4 &&\r |
518 | SubstringEq (OfwNode[1].DriverName, "ide") &&\r | |
2cd086a6 | 519 | SubstringEq (OfwNode[2].DriverName, "drive") &&\r |
520 | SubstringEq (OfwNode[3].DriverName, "disk")\r | |
521 | ) {\r | |
522 | //\r | |
523 | // OpenFirmware device path (IDE disk, IDE CD-ROM):\r | |
524 | //\r | |
525 | // /pci@i0cf8/ide@1,1/drive@0/disk@0\r | |
526 | // ^ ^ ^ ^ ^\r | |
527 | // | | | | master or slave\r | |
528 | // | | | primary or secondary\r | |
529 | // | PCI slot & function holding IDE controller\r | |
530 | // PCI root at system bus port, PIO\r | |
531 | //\r | |
532 | // UEFI device path:\r | |
533 | //\r | |
534 | // PciRoot(0x0)/Pci(0x1,0x1)/Ata(Primary,Master,0x0)\r | |
535 | // ^\r | |
536 | // fixed LUN\r | |
537 | //\r | |
538 | UINT32 Secondary;\r | |
539 | UINT32 Slave;\r | |
540 | \r | |
541 | NumEntries = 1;\r | |
542 | if (ParseUnitAddressHexList (\r | |
543 | OfwNode[2].UnitAddress,\r | |
544 | &Secondary,\r | |
545 | &NumEntries\r | |
546 | ) != RETURN_SUCCESS ||\r | |
547 | Secondary > 1 ||\r | |
548 | ParseUnitAddressHexList (\r | |
549 | OfwNode[3].UnitAddress,\r | |
550 | &Slave,\r | |
551 | &NumEntries // reuse after previous single-element call\r | |
552 | ) != RETURN_SUCCESS ||\r | |
553 | Slave > 1\r | |
554 | ) {\r | |
555 | return RETURN_UNSUPPORTED;\r | |
556 | }\r | |
557 | \r | |
558 | Written = UnicodeSPrintAsciiFormat (\r | |
559 | Translated,\r | |
560 | *TranslatedSize * sizeof (*Translated), // BufferSize in bytes\r | |
561 | "PciRoot(0x0)/Pci(0x%x,0x%x)/Ata(%a,%a,0x0)",\r | |
562 | PciDevFun[0],\r | |
563 | PciDevFun[1],\r | |
564 | Secondary ? "Secondary" : "Primary",\r | |
565 | Slave ? "Slave" : "Master"\r | |
566 | );\r | |
ec01afdb | 567 | } else if (NumNodes >= 4 &&\r |
568 | SubstringEq (OfwNode[1].DriverName, "isa") &&\r | |
2cd086a6 | 569 | SubstringEq (OfwNode[2].DriverName, "fdc") &&\r |
570 | SubstringEq (OfwNode[3].DriverName, "floppy")\r | |
571 | ) {\r | |
572 | //\r | |
573 | // OpenFirmware device path (floppy disk):\r | |
574 | //\r | |
575 | // /pci@i0cf8/isa@1/fdc@03f0/floppy@0\r | |
576 | // ^ ^ ^ ^\r | |
577 | // | | | A: or B:\r | |
578 | // | | ISA controller io-port (hex)\r | |
579 | // | PCI slot holding ISA controller\r | |
580 | // PCI root at system bus port, PIO\r | |
581 | //\r | |
582 | // UEFI device path:\r | |
583 | //\r | |
584 | // PciRoot(0x0)/Pci(0x1,0x0)/Floppy(0x0)\r | |
585 | // ^\r | |
586 | // ACPI UID\r | |
587 | //\r | |
588 | UINT32 AcpiUid;\r | |
589 | \r | |
590 | NumEntries = 1;\r | |
591 | if (ParseUnitAddressHexList (\r | |
592 | OfwNode[3].UnitAddress,\r | |
593 | &AcpiUid,\r | |
594 | &NumEntries\r | |
595 | ) != RETURN_SUCCESS ||\r | |
596 | AcpiUid > 1\r | |
597 | ) {\r | |
598 | return RETURN_UNSUPPORTED;\r | |
599 | }\r | |
600 | \r | |
601 | Written = UnicodeSPrintAsciiFormat (\r | |
602 | Translated,\r | |
603 | *TranslatedSize * sizeof (*Translated), // BufferSize in bytes\r | |
604 | "PciRoot(0x0)/Pci(0x%x,0x%x)/Floppy(0x%x)",\r | |
605 | PciDevFun[0],\r | |
606 | PciDevFun[1],\r | |
607 | AcpiUid\r | |
608 | );\r | |
e06a4cd1 | 609 | } else if (NumNodes >= 3 &&\r |
610 | SubstringEq (OfwNode[1].DriverName, "scsi") &&\r | |
611 | SubstringEq (OfwNode[2].DriverName, "disk")\r | |
612 | ) {\r | |
613 | //\r | |
614 | // OpenFirmware device path (virtio-blk disk):\r | |
615 | //\r | |
616 | // /pci@i0cf8/scsi@6[,3]/disk@0,0\r | |
617 | // ^ ^ ^ ^ ^\r | |
618 | // | | | fixed\r | |
619 | // | | PCI function corresponding to disk (optional)\r | |
620 | // | PCI slot holding disk\r | |
621 | // PCI root at system bus port, PIO\r | |
622 | //\r | |
623 | // UEFI device path prefix:\r | |
624 | //\r | |
625 | // PciRoot(0x0)/Pci(0x6,0x0)/HD( -- if PCI function is 0 or absent\r | |
626 | // PciRoot(0x0)/Pci(0x6,0x3)/HD( -- if PCI function is present and nonzero\r | |
627 | //\r | |
628 | Written = UnicodeSPrintAsciiFormat (\r | |
629 | Translated,\r | |
630 | *TranslatedSize * sizeof (*Translated), // BufferSize in bytes\r | |
631 | "PciRoot(0x0)/Pci(0x%x,0x%x)/HD(",\r | |
632 | PciDevFun[0],\r | |
633 | PciDevFun[1]\r | |
634 | );\r | |
d2bf9913 | 635 | } else if (NumNodes >= 4 &&\r |
636 | SubstringEq (OfwNode[1].DriverName, "scsi") &&\r | |
637 | SubstringEq (OfwNode[2].DriverName, "channel") &&\r | |
638 | SubstringEq (OfwNode[3].DriverName, "disk")\r | |
639 | ) {\r | |
640 | //\r | |
641 | // OpenFirmware device path (virtio-scsi disk):\r | |
642 | //\r | |
643 | // /pci@i0cf8/scsi@7[,3]/channel@0/disk@2,3\r | |
644 | // ^ ^ ^ ^ ^\r | |
645 | // | | | | LUN\r | |
646 | // | | | target\r | |
647 | // | | channel (unused, fixed 0)\r | |
648 | // | PCI slot[, function] holding SCSI controller\r | |
649 | // PCI root at system bus port, PIO\r | |
650 | //\r | |
651 | // UEFI device path prefix:\r | |
652 | //\r | |
653 | // PciRoot(0x0)/Pci(0x7,0x0)/Scsi(0x2,0x3)\r | |
654 | // -- if PCI function is 0 or absent\r | |
655 | // PciRoot(0x0)/Pci(0x7,0x3)/Scsi(0x2,0x3)\r | |
656 | // -- if PCI function is present and nonzero\r | |
657 | //\r | |
658 | UINT32 TargetLun[2];\r | |
659 | \r | |
660 | TargetLun[1] = 0;\r | |
661 | NumEntries = sizeof (TargetLun) / sizeof (TargetLun[0]);\r | |
662 | if (ParseUnitAddressHexList (\r | |
663 | OfwNode[3].UnitAddress,\r | |
664 | TargetLun,\r | |
665 | &NumEntries\r | |
666 | ) != RETURN_SUCCESS\r | |
667 | ) {\r | |
668 | return RETURN_UNSUPPORTED;\r | |
669 | }\r | |
670 | \r | |
671 | Written = UnicodeSPrintAsciiFormat (\r | |
672 | Translated,\r | |
673 | *TranslatedSize * sizeof (*Translated), // BufferSize in bytes\r | |
674 | "PciRoot(0x0)/Pci(0x%x,0x%x)/Scsi(0x%x,0x%x)",\r | |
675 | PciDevFun[0],\r | |
676 | PciDevFun[1],\r | |
677 | TargetLun[0],\r | |
678 | TargetLun[1]\r | |
679 | );\r | |
e7a7e480 | 680 | } else if (NumNodes >= 3 &&\r |
681 | SubstringEq (OfwNode[1].DriverName, "ethernet") &&\r | |
682 | SubstringEq (OfwNode[2].DriverName, "ethernet-phy")\r | |
683 | ) {\r | |
684 | //\r | |
685 | // OpenFirmware device path (Ethernet NIC):\r | |
686 | //\r | |
687 | // /pci@i0cf8/ethernet@3[,2]/ethernet-phy@0\r | |
688 | // ^ ^ ^\r | |
689 | // | | fixed\r | |
690 | // | PCI slot[, function] holding Ethernet card\r | |
691 | // PCI root at system bus port, PIO\r | |
692 | //\r | |
693 | // UEFI device path prefix (dependent on presence of nonzero PCI function):\r | |
694 | //\r | |
695 | // PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400E15EEF,0x1)\r | |
696 | // PciRoot(0x0)/Pci(0x3,0x2)/MAC(525400E15EEF,0x1)\r | |
697 | // ^ ^\r | |
698 | // MAC address IfType (1 == Ethernet)\r | |
699 | //\r | |
700 | // (Some UEFI NIC drivers don't set 0x1 for IfType.)\r | |
701 | //\r | |
702 | Written = UnicodeSPrintAsciiFormat (\r | |
703 | Translated,\r | |
704 | *TranslatedSize * sizeof (*Translated), // BufferSize in bytes\r | |
705 | "PciRoot(0x0)/Pci(0x%x,0x%x)/MAC",\r | |
706 | PciDevFun[0],\r | |
707 | PciDevFun[1]\r | |
708 | );\r | |
cdde6ddf | 709 | } else {\r |
710 | return RETURN_UNSUPPORTED;\r | |
711 | }\r | |
2cd086a6 | 712 | \r |
713 | //\r | |
714 | // There's no way to differentiate between "completely used up without\r | |
715 | // truncation" and "truncated", so treat the former as the latter, and return\r | |
716 | // success only for "some room left unused".\r | |
717 | //\r | |
718 | if (Written + 1 < *TranslatedSize) {\r | |
719 | *TranslatedSize = Written;\r | |
720 | return RETURN_SUCCESS;\r | |
721 | }\r | |
722 | \r | |
723 | return RETURN_BUFFER_TOO_SMALL;\r | |
724 | }\r | |
725 | \r | |
726 | \r | |
727 | /**\r | |
728 | \r | |
729 | Translate an OpenFirmware device path fragment to a UEFI device path\r | |
730 | fragment, and advance in the input string.\r | |
731 | \r | |
732 | @param[in out] Ptr Address of the pointer pointing to the start\r | |
733 | of the path string. After successful\r | |
734 | translation (RETURN_SUCCESS) or at least\r | |
735 | successful parsing (RETURN_UNSUPPORTED,\r | |
736 | RETURN_BUFFER_TOO_SMALL), *Ptr is set to the\r | |
737 | byte immediately following the consumed\r | |
738 | characters. In other error cases, it points to\r | |
739 | the byte that caused the error.\r | |
740 | \r | |
741 | @param[out] Translated Destination array receiving the UEFI path\r | |
742 | fragment, allocated by the caller. If the\r | |
743 | return value differs from RETURN_SUCCESS, its\r | |
744 | contents is indeterminate.\r | |
745 | \r | |
746 | @param[in out] TranslatedSize On input, the number of CHAR16's in\r | |
747 | Translated. On RETURN_SUCCESS this parameter\r | |
748 | is assigned the number of non-NUL CHAR16's\r | |
749 | written to Translated. In case of other return\r | |
750 | values, TranslatedSize is indeterminate.\r | |
751 | \r | |
752 | \r | |
753 | @retval RETURN_SUCCESS Translation successful.\r | |
754 | \r | |
755 | @retval RETURN_BUFFER_TOO_SMALL The OpenFirmware device path was parsed\r | |
756 | successfully, but its translation did not\r | |
757 | fit into the number of bytes provided.\r | |
758 | Further calls to this function are\r | |
759 | possible.\r | |
760 | \r | |
761 | @retval RETURN_UNSUPPORTED The OpenFirmware device path was parsed\r | |
762 | successfully, but it can't be translated in\r | |
763 | the current implementation. Further calls\r | |
764 | to this function are possible.\r | |
765 | \r | |
766 | @retval RETURN_NOT_FOUND Translation terminated, *Ptr was (and is)\r | |
767 | pointing to an empty string.\r | |
768 | \r | |
769 | @retval RETURN_INVALID_PARAMETER Parse error. This is a permanent error.\r | |
770 | \r | |
771 | **/\r | |
772 | STATIC\r | |
773 | RETURN_STATUS\r | |
774 | TranslateOfwPath (\r | |
775 | IN OUT CONST CHAR8 **Ptr,\r | |
776 | OUT CHAR16 *Translated,\r | |
777 | IN OUT UINTN *TranslatedSize\r | |
778 | )\r | |
779 | {\r | |
780 | UINTN NumNodes;\r | |
781 | RETURN_STATUS Status;\r | |
ec01afdb | 782 | OFW_NODE Node[EXAMINED_OFW_NODES];\r |
2cd086a6 | 783 | BOOLEAN IsFinal;\r |
784 | OFW_NODE Skip;\r | |
785 | \r | |
786 | NumNodes = 0;\r | |
787 | Status = ParseOfwNode (Ptr, &Node[NumNodes], &IsFinal);\r | |
788 | \r | |
789 | if (Status == RETURN_NOT_FOUND) {\r | |
790 | DEBUG ((DEBUG_VERBOSE, "%a: no more nodes\n", __FUNCTION__));\r | |
791 | return RETURN_NOT_FOUND;\r | |
792 | }\r | |
793 | \r | |
794 | while (Status == RETURN_SUCCESS && !IsFinal) {\r | |
795 | ++NumNodes;\r | |
796 | Status = ParseOfwNode (\r | |
797 | Ptr,\r | |
ec01afdb | 798 | (NumNodes < EXAMINED_OFW_NODES) ? &Node[NumNodes] : &Skip,\r |
2cd086a6 | 799 | &IsFinal\r |
800 | );\r | |
801 | }\r | |
802 | \r | |
803 | switch (Status) {\r | |
804 | case RETURN_SUCCESS:\r | |
805 | ++NumNodes;\r | |
806 | break;\r | |
807 | \r | |
808 | case RETURN_INVALID_PARAMETER:\r | |
809 | DEBUG ((DEBUG_VERBOSE, "%a: parse error\n", __FUNCTION__));\r | |
810 | return RETURN_INVALID_PARAMETER;\r | |
811 | \r | |
812 | default:\r | |
813 | ASSERT (0);\r | |
814 | }\r | |
815 | \r | |
816 | Status = TranslateOfwNodes (\r | |
817 | Node,\r | |
ec01afdb | 818 | NumNodes < EXAMINED_OFW_NODES ? NumNodes : EXAMINED_OFW_NODES,\r |
2cd086a6 | 819 | Translated,\r |
820 | TranslatedSize);\r | |
821 | switch (Status) {\r | |
822 | case RETURN_SUCCESS:\r | |
823 | DEBUG ((DEBUG_VERBOSE, "%a: success: \"%s\"\n", __FUNCTION__, Translated));\r | |
824 | break;\r | |
825 | \r | |
826 | case RETURN_BUFFER_TOO_SMALL:\r | |
827 | DEBUG ((DEBUG_VERBOSE, "%a: buffer too small\n", __FUNCTION__));\r | |
828 | break;\r | |
829 | \r | |
830 | case RETURN_UNSUPPORTED:\r | |
831 | DEBUG ((DEBUG_VERBOSE, "%a: unsupported\n", __FUNCTION__));\r | |
832 | break;\r | |
833 | \r | |
834 | default:\r | |
835 | ASSERT (0);\r | |
836 | }\r | |
837 | return Status;\r | |
838 | }\r | |
839 | \r | |
840 | \r | |
841 | /**\r | |
842 | \r | |
843 | Convert the UEFI DevicePath to full text representation with DevPathToText,\r | |
844 | then match the UEFI device path fragment in Translated against it.\r | |
845 | \r | |
846 | @param[in] Translated UEFI device path fragment, translated from\r | |
847 | OpenFirmware format, to search for.\r | |
848 | \r | |
849 | @param[in] TranslatedLength The length of Translated in CHAR16's.\r | |
850 | \r | |
851 | @param[in] DevicePath Boot option device path whose textual rendering\r | |
852 | to search in.\r | |
853 | \r | |
854 | @param[in] DevPathToText Binary-to-text conversion protocol for DevicePath.\r | |
855 | \r | |
856 | \r | |
857 | @retval TRUE If Translated was found at the beginning of DevicePath after\r | |
858 | converting the latter to text.\r | |
859 | \r | |
860 | @retval FALSE If DevicePath was NULL, or it could not be converted, or there\r | |
861 | was no match.\r | |
862 | \r | |
863 | **/\r | |
864 | STATIC\r | |
865 | BOOLEAN\r | |
866 | Match (\r | |
867 | IN CONST CHAR16 *Translated,\r | |
868 | IN UINTN TranslatedLength,\r | |
863986b3 | 869 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r |
2cd086a6 | 870 | )\r |
871 | {\r | |
872 | CHAR16 *Converted;\r | |
873 | BOOLEAN Result;\r | |
874 | \r | |
863986b3 RN |
875 | Converted = ConvertDevicePathToText (\r |
876 | DevicePath,\r | |
877 | FALSE, // DisplayOnly\r | |
878 | FALSE // AllowShortcuts\r | |
879 | );\r | |
2cd086a6 | 880 | if (Converted == NULL) {\r |
881 | return FALSE;\r | |
882 | }\r | |
883 | \r | |
884 | //\r | |
885 | // Is Translated a prefix of Converted?\r | |
886 | //\r | |
dccf7678 | 887 | Result = (BOOLEAN)(StrnCmp (Converted, Translated, TranslatedLength) == 0);\r |
2cd086a6 | 888 | DEBUG ((\r |
889 | DEBUG_VERBOSE,\r | |
890 | "%a: against \"%s\": %a\n",\r | |
891 | __FUNCTION__,\r | |
892 | Converted,\r | |
893 | Result ? "match" : "no match"\r | |
894 | ));\r | |
895 | FreePool (Converted);\r | |
896 | return Result;\r | |
897 | }\r | |
898 | \r | |
899 | \r | |
900 | /**\r | |
901 | \r | |
902 | Set the boot order based on configuration retrieved from QEMU.\r | |
903 | \r | |
904 | Attempt to retrieve the "bootorder" fw_cfg file from QEMU. Translate the\r | |
905 | OpenFirmware device paths therein to UEFI device path fragments. Match the\r | |
906 | translated fragments against BootOptionList, and rewrite the BootOrder NvVar\r | |
907 | so that it corresponds to the order described in fw_cfg.\r | |
908 | \r | |
909 | @param[in] BootOptionList A boot option list, created with\r | |
910 | BdsLibEnumerateAllBootOption ().\r | |
911 | \r | |
912 | \r | |
913 | @retval RETURN_SUCCESS BootOrder NvVar rewritten.\r | |
914 | \r | |
915 | @retval RETURN_UNSUPPORTED QEMU's fw_cfg is not supported.\r | |
916 | \r | |
917 | @retval RETURN_NOT_FOUND Empty or nonexistent "bootorder" fw_cfg\r | |
918 | file, or no match found between the\r | |
919 | "bootorder" fw_cfg file and BootOptionList.\r | |
920 | \r | |
921 | @retval RETURN_INVALID_PARAMETER Parse error in the "bootorder" fw_cfg file.\r | |
922 | \r | |
923 | @retval RETURN_OUT_OF_RESOURCES Memory allocation failed.\r | |
924 | \r | |
925 | @return Values returned by gBS->LocateProtocol ()\r | |
926 | or gRT->SetVariable ().\r | |
927 | \r | |
928 | **/\r | |
929 | RETURN_STATUS\r | |
930 | SetBootOrderFromQemu (\r | |
931 | IN CONST LIST_ENTRY *BootOptionList\r | |
932 | )\r | |
933 | {\r | |
934 | RETURN_STATUS Status;\r | |
2cd086a6 | 935 | FIRMWARE_CONFIG_ITEM FwCfgItem;\r |
936 | UINTN FwCfgSize;\r | |
937 | CHAR8 *FwCfg;\r | |
938 | CONST CHAR8 *FwCfgPtr;\r | |
939 | \r | |
940 | BOOT_ORDER BootOrder;\r | |
941 | \r | |
942 | UINTN TranslatedSize;\r | |
943 | CHAR16 Translated[TRANSLATION_OUTPUT_SIZE];\r | |
944 | \r | |
2cd086a6 | 945 | Status = QemuFwCfgFindFile ("bootorder", &FwCfgItem, &FwCfgSize);\r |
946 | if (Status != RETURN_SUCCESS) {\r | |
947 | return Status;\r | |
948 | }\r | |
949 | \r | |
950 | if (FwCfgSize == 0) {\r | |
951 | return RETURN_NOT_FOUND;\r | |
952 | }\r | |
953 | \r | |
954 | FwCfg = AllocatePool (FwCfgSize);\r | |
955 | if (FwCfg == NULL) {\r | |
956 | return RETURN_OUT_OF_RESOURCES;\r | |
957 | }\r | |
958 | \r | |
959 | QemuFwCfgSelectItem (FwCfgItem);\r | |
960 | QemuFwCfgReadBytes (FwCfgSize, FwCfg);\r | |
961 | if (FwCfg[FwCfgSize - 1] != '\0') {\r | |
962 | Status = RETURN_INVALID_PARAMETER;\r | |
963 | goto ErrorFreeFwCfg;\r | |
964 | }\r | |
965 | \r | |
966 | DEBUG ((DEBUG_VERBOSE, "%a: FwCfg:\n", __FUNCTION__));\r | |
967 | DEBUG ((DEBUG_VERBOSE, "%a\n", FwCfg));\r | |
968 | DEBUG ((DEBUG_VERBOSE, "%a: FwCfg: <end>\n", __FUNCTION__));\r | |
969 | FwCfgPtr = FwCfg;\r | |
970 | \r | |
971 | BootOrder.Produced = 0;\r | |
972 | BootOrder.Allocated = 1;\r | |
973 | BootOrder.Data = AllocatePool (\r | |
974 | BootOrder.Allocated * sizeof (*BootOrder.Data)\r | |
975 | );\r | |
976 | if (BootOrder.Data == NULL) {\r | |
977 | Status = RETURN_OUT_OF_RESOURCES;\r | |
978 | goto ErrorFreeFwCfg;\r | |
979 | }\r | |
980 | \r | |
981 | //\r | |
982 | // translate each OpenFirmware path\r | |
983 | //\r | |
984 | TranslatedSize = sizeof (Translated) / sizeof (Translated[0]);\r | |
985 | Status = TranslateOfwPath (&FwCfgPtr, Translated, &TranslatedSize);\r | |
986 | while (Status == RETURN_SUCCESS ||\r | |
987 | Status == RETURN_UNSUPPORTED ||\r | |
988 | Status == RETURN_BUFFER_TOO_SMALL) {\r | |
989 | if (Status == RETURN_SUCCESS) {\r | |
990 | CONST LIST_ENTRY *Link;\r | |
991 | \r | |
992 | //\r | |
993 | // match translated OpenFirmware path against all enumerated boot options\r | |
994 | //\r | |
995 | for (Link = BootOptionList->ForwardLink; Link != BootOptionList;\r | |
996 | Link = Link->ForwardLink) {\r | |
997 | CONST BDS_COMMON_OPTION *BootOption;\r | |
998 | \r | |
999 | BootOption = CR (\r | |
1000 | Link,\r | |
1001 | BDS_COMMON_OPTION,\r | |
1002 | Link,\r | |
1003 | BDS_LOAD_OPTION_SIGNATURE\r | |
1004 | );\r | |
1005 | if (IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE) &&\r | |
1006 | Match (\r | |
1007 | Translated,\r | |
1008 | TranslatedSize, // contains length, not size, in CHAR16's here\r | |
863986b3 | 1009 | BootOption->DevicePath\r |
2cd086a6 | 1010 | )\r |
1011 | ) {\r | |
1012 | //\r | |
1013 | // match found, store ID and continue with next OpenFirmware path\r | |
1014 | //\r | |
1015 | Status = BootOrderAppend (&BootOrder, BootOption->BootCurrent);\r | |
1016 | if (Status != RETURN_SUCCESS) {\r | |
1017 | goto ErrorFreeBootOrder;\r | |
1018 | }\r | |
1019 | break;\r | |
1020 | }\r | |
1021 | } // scanned all enumerated boot options\r | |
1022 | } // translation successful\r | |
1023 | \r | |
1024 | TranslatedSize = sizeof (Translated) / sizeof (Translated[0]);\r | |
1025 | Status = TranslateOfwPath (&FwCfgPtr, Translated, &TranslatedSize);\r | |
1026 | } // scanning of OpenFirmware paths done\r | |
1027 | \r | |
1028 | if (Status == RETURN_NOT_FOUND && BootOrder.Produced > 0) {\r | |
1029 | //\r | |
1030 | // No more OpenFirmware paths, some matches found: rewrite BootOrder NvVar.\r | |
1031 | // See Table 10 in the UEFI Spec 2.3.1 with Errata C for the required\r | |
1032 | // attributes.\r | |
1033 | //\r | |
1034 | Status = gRT->SetVariable (\r | |
1035 | L"BootOrder",\r | |
1036 | &gEfiGlobalVariableGuid,\r | |
1037 | EFI_VARIABLE_NON_VOLATILE |\r | |
1038 | EFI_VARIABLE_BOOTSERVICE_ACCESS |\r | |
1039 | EFI_VARIABLE_RUNTIME_ACCESS,\r | |
1040 | BootOrder.Produced * sizeof (*BootOrder.Data),\r | |
1041 | BootOrder.Data\r | |
1042 | );\r | |
1043 | DEBUG ((\r | |
1044 | DEBUG_INFO,\r | |
1045 | "%a: setting BootOrder: %a\n",\r | |
1046 | __FUNCTION__,\r | |
1047 | Status == EFI_SUCCESS ? "success" : "error"\r | |
1048 | ));\r | |
1049 | }\r | |
1050 | \r | |
1051 | ErrorFreeBootOrder:\r | |
1052 | FreePool (BootOrder.Data);\r | |
1053 | \r | |
1054 | ErrorFreeFwCfg:\r | |
1055 | FreePool (FwCfg);\r | |
1056 | \r | |
1057 | return Status;\r | |
1058 | }\r |