]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Bds/BootMenu.c
Add generic HPET Timer DXE Driver and support libraries
[mirror_edk2.git] / ArmPlatformPkg / Bds / BootMenu.c
CommitLineData
ea46ebbe 1/** @file\r
2*\r
3* Copyright (c) 2011, ARM Limited. All rights reserved.\r
4*\r
5* This program and the accompanying materials\r
6* are licensed and made available under the terms and conditions of the BSD License\r
7* which accompanies this distribution. The full text of the license may be found at\r
8* http://opensource.org/licenses/bsd-license.php\r
9*\r
10* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12*\r
13**/\r
14\r
15#include "BdsInternal.h"\r
16\r
17extern EFI_HANDLE mImageHandle;\r
18extern BDS_LOAD_OPTION_SUPPORT *BdsLoadOptionSupportList;\r
19\r
20EFI_STATUS\r
656416bc 21SelectBootDevice (\r
22 OUT BDS_SUPPORTED_DEVICE** SupportedBootDevice\r
ea46ebbe 23 )\r
24{\r
656416bc 25 EFI_STATUS Status;\r
ea46ebbe 26 LIST_ENTRY SupportedDeviceList;\r
27 UINTN SupportedDeviceCount;\r
ea46ebbe 28 LIST_ENTRY* Entry;\r
29 UINTN SupportedDeviceSelected;\r
ea46ebbe 30 UINTN Index;\r
ea46ebbe 31\r
32 //\r
33 // List the Boot Devices supported\r
34 //\r
35\r
36 // Start all the drivers first\r
37 BdsConnectAllDrivers ();\r
38\r
39 // List the supported devices\r
40 Status = BootDeviceListSupportedInit (&SupportedDeviceList);\r
41 ASSERT_EFI_ERROR(Status);\r
42\r
43 SupportedDeviceCount = 0;\r
44 for (Entry = GetFirstNode (&SupportedDeviceList);\r
45 !IsNull (&SupportedDeviceList,Entry);\r
46 Entry = GetNextNode (&SupportedDeviceList,Entry)\r
47 )\r
48 {\r
656416bc 49 *SupportedBootDevice = SUPPORTED_BOOT_DEVICE_FROM_LINK(Entry);\r
50 Print(L"[%d] %s\n",SupportedDeviceCount+1,(*SupportedBootDevice)->Description);\r
ea46ebbe 51\r
52 DEBUG_CODE_BEGIN();\r
53 CHAR16* DevicePathTxt;\r
54 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;\r
55\r
56 Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);\r
57 ASSERT_EFI_ERROR(Status);\r
656416bc 58 DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText((*SupportedBootDevice)->DevicePathProtocol,TRUE,TRUE);\r
ea46ebbe 59\r
60 Print(L"\t- %s\n",DevicePathTxt);\r
61\r
62 FreePool(DevicePathTxt);\r
63 DEBUG_CODE_END();\r
64\r
65 SupportedDeviceCount++;\r
66 }\r
67\r
68 if (SupportedDeviceCount == 0) {\r
69 Print(L"There is no supported device.\n");\r
70 Status = EFI_ABORTED;\r
71 goto EXIT;\r
72 }\r
73\r
74 //\r
75 // Select the Boot Device\r
76 //\r
77 SupportedDeviceSelected = 0;\r
78 while (SupportedDeviceSelected == 0) {\r
79 Print(L"Select the Boot Device: ");\r
80 Status = GetHIInputInteger (&SupportedDeviceSelected);\r
81 if (EFI_ERROR(Status)) {\r
82 Status = EFI_ABORTED;\r
83 goto EXIT;\r
84 } else if ((SupportedDeviceSelected == 0) || (SupportedDeviceSelected > SupportedDeviceCount)) {\r
85 Print(L"Invalid input (max %d)\n",SupportedDeviceSelected);\r
86 SupportedDeviceSelected = 0;\r
87 }\r
88 }\r
89\r
90 //\r
91 // Get the Device Path for the selected boot device\r
92 //\r
93 Index = 1;\r
94 for (Entry = GetFirstNode (&SupportedDeviceList);\r
95 !IsNull (&SupportedDeviceList,Entry);\r
96 Entry = GetNextNode (&SupportedDeviceList,Entry)\r
97 )\r
98 {\r
99 if (Index == SupportedDeviceSelected) {\r
656416bc 100 *SupportedBootDevice = SUPPORTED_BOOT_DEVICE_FROM_LINK(Entry);\r
ea46ebbe 101 break;\r
102 }\r
103 Index++;\r
104 }\r
656416bc 105 \r
106EXIT:\r
107 BootDeviceListSupportedFree (&SupportedDeviceList, *SupportedBootDevice);\r
108 return Status;\r
109}\r
110\r
111EFI_STATUS\r
112BootMenuAddBootOption (\r
113 IN LIST_ENTRY *BootOptionsList\r
114 )\r
115{\r
116 EFI_STATUS Status;\r
117 BDS_SUPPORTED_DEVICE* SupportedBootDevice;\r
118 BDS_LOADER_ARGUMENTS BootArguments;\r
119 CHAR8 AsciiBootDescription[BOOT_DEVICE_DESCRIPTION_MAX];\r
120 CHAR16 *BootDescription;\r
121 UINT32 Attributes;\r
122 BDS_LOADER_TYPE BootType;\r
123 BDS_LOAD_OPTION *BdsLoadOption;\r
124 EFI_DEVICE_PATH *DevicePath;\r
125 EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;\r
126 EFI_DEVICE_PATH_PROTOCOL *InitrdPathNode;\r
127\r
128 Attributes = 0;\r
129 SupportedBootDevice = NULL;\r
130\r
131 // List the Boot Devices supported\r
132 Status = SelectBootDevice(&SupportedBootDevice);\r
133 if (EFI_ERROR(Status)) {\r
134 Status = EFI_ABORTED;\r
135 goto EXIT;\r
136 }\r
ea46ebbe 137\r
138 // Create the specific device path node\r
656416bc 139 Print(L"File path of the EFI Application or the kernel: ");\r
ea46ebbe 140 Status = SupportedBootDevice->Support->CreateDevicePathNode (SupportedBootDevice, &DevicePathNode, &BootType, &Attributes);\r
141 if (EFI_ERROR(Status)) {\r
142 Status = EFI_ABORTED;\r
143 goto EXIT;\r
144 }\r
145 // Append the Device Path node to the select device path\r
146 DevicePath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode);\r
147\r
656416bc 148 if (BootType == BDS_LOADER_KERNEL_LINUX_ATAG) {\r
149 // Create the specific device path node\r
150 Print(L"File path of the initrd: ");\r
151 Status = SupportedBootDevice->Support->CreateDevicePathNode (SupportedBootDevice, &InitrdPathNode, NULL, NULL);\r
152 if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd\r
153 Status = EFI_ABORTED;\r
154 goto EXIT;\r
155 }\r
156\r
157 if (InitrdPathNode != NULL) {\r
158 // Append the Device Path node to the select device path\r
159 BootArguments.LinuxAtagArguments.InitrdPathList = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode);\r
160 } else {\r
161 BootArguments.LinuxAtagArguments.InitrdPathList = NULL;\r
162 }\r
163\r
164 Print(L"Arguments to pass to the binary: ");\r
165 Status = GetHIInputAscii (BootArguments.LinuxAtagArguments.CmdLine,BOOT_DEVICE_OPTION_MAX);\r
166 if (EFI_ERROR(Status)) {\r
167 Status = EFI_ABORTED;\r
168 goto FREE_DEVICE_PATH;\r
169 }\r
170 BootArguments.LinuxAtagArguments.CmdLine[BOOT_DEVICE_OPTION_MAX]= '\0';\r
ea46ebbe 171 }\r
172\r
173 Print(L"Description for this new Entry: ");\r
174 Status = GetHIInputAscii (AsciiBootDescription,BOOT_DEVICE_DESCRIPTION_MAX);\r
175 if (EFI_ERROR(Status)) {\r
176 Status = EFI_ABORTED;\r
177 goto FREE_DEVICE_PATH;\r
178 }\r
179\r
180 // Convert Ascii into Unicode\r
181 BootDescription = (CHAR16*)AllocatePool(AsciiStrSize(AsciiBootDescription) * sizeof(CHAR16));\r
182 AsciiStrToUnicodeStr (AsciiBootDescription, BootDescription);\r
183\r
184 // Create new entry\r
656416bc 185 Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, &BootArguments, &BdsLoadOption);\r
ea46ebbe 186 if (!EFI_ERROR(Status)) {\r
187 InsertTailList (BootOptionsList,&BdsLoadOption->Link);\r
188 }\r
189\r
190 FreePool (BootDescription);\r
191\r
192FREE_DEVICE_PATH:\r
193 FreePool (DevicePath);\r
194\r
656416bc 195 \r
ea46ebbe 196EXIT:\r
656416bc 197 if (Status == EFI_ABORTED) {\r
198 Print(L"\n");\r
199 }\r
200 FreePool(SupportedBootDevice);\r
ea46ebbe 201 return Status;\r
202}\r
203\r
204STATIC\r
205EFI_STATUS\r
206BootMenuSelectBootOption (\r
207 IN LIST_ENTRY *BootOptionsList,\r
208 IN CONST CHAR16* InputStatement,\r
209 OUT BDS_LOAD_OPTION **BdsLoadOption\r
210 )\r
211{\r
212 EFI_STATUS Status;\r
213 LIST_ENTRY* Entry;\r
214 BDS_LOAD_OPTION *BootOption;\r
215 UINTN BootOptionSelected;\r
216 UINTN BootOptionCount;\r
217 UINTN Index;\r
218\r
219 // Display the list of supported boot devices\r
220 BootOptionCount = 1;\r
221 for (Entry = GetFirstNode (BootOptionsList);\r
222 !IsNull (BootOptionsList,Entry);\r
223 Entry = GetNextNode (BootOptionsList,Entry)\r
224 )\r
225 {\r
226 BootOption = LOAD_OPTION_FROM_LINK(Entry);\r
227 Print(L"[%d] %s\n",BootOptionCount,BootOption->Description);\r
228\r
229 DEBUG_CODE_BEGIN();\r
230 CHAR16* DevicePathTxt;\r
231 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;\r
232\r
233 Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);\r
234 ASSERT_EFI_ERROR(Status);\r
235 DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BootOption->FilePathList,TRUE,TRUE);\r
236\r
237 Print(L"\t- %s\n",DevicePathTxt);\r
656416bc 238 if ((BDS_LOADER_TYPE)ReadUnaligned32(&BootOption->OptionalData->LoaderType) == BDS_LOADER_KERNEL_LINUX_ATAG) {\r
239 Print(L"\t- Arguments: %a\n",BootOption->OptionalData->Arguments.LinuxAtagArguments.CmdLine);\r
ea46ebbe 240 }\r
241\r
242 FreePool(DevicePathTxt);\r
243 DEBUG_CODE_END();\r
244\r
245 BootOptionCount++;\r
246 }\r
247\r
248 // Get the index of the boot device to delete\r
249 BootOptionSelected = 0;\r
250 while (BootOptionSelected == 0) {\r
251 Print(InputStatement);\r
252 Status = GetHIInputInteger (&BootOptionSelected);\r
253 if (EFI_ERROR(Status)) {\r
254 return Status;\r
255 } else if ((BootOptionSelected == 0) || (BootOptionSelected >= BootOptionCount)) {\r
656416bc 256 Print(L"Invalid input (max %d)\n",BootOptionCount-1);\r
ea46ebbe 257 BootOptionSelected = 0;\r
258 }\r
259 }\r
260\r
261 // Get the structure of the Boot device to delete\r
262 Index = 1;\r
263 for (Entry = GetFirstNode (BootOptionsList);\r
264 !IsNull (BootOptionsList,Entry);\r
265 Entry = GetNextNode (BootOptionsList,Entry)\r
266 )\r
267 {\r
268 if (Index == BootOptionSelected) {\r
269 *BdsLoadOption = LOAD_OPTION_FROM_LINK(Entry);\r
270 break;\r
271 }\r
272 Index++;\r
273 }\r
274\r
275 return EFI_SUCCESS;\r
276}\r
277\r
278EFI_STATUS\r
279BootMenuRemoveBootOption (\r
280 IN LIST_ENTRY *BootOptionsList\r
281 )\r
282{\r
283 EFI_STATUS Status;\r
284 BDS_LOAD_OPTION *BootOption;\r
285\r
286 Status = BootMenuSelectBootOption (BootOptionsList,L"Delete entry: ",&BootOption);\r
287 if (EFI_ERROR(Status)) {\r
288 return Status;\r
289 }\r
290\r
291 // Delete the BDS Load option structures\r
292 BootOptionDelete (BootOption);\r
293\r
294 return EFI_SUCCESS;\r
295}\r
296\r
297EFI_STATUS\r
298BootMenuUpdateBootOption (\r
299 IN LIST_ENTRY *BootOptionsList\r
300 )\r
301{\r
656416bc 302 EFI_STATUS Status;\r
303 BDS_LOAD_OPTION *BootOption;\r
304 BDS_LOAD_OPTION_SUPPORT *DeviceSupport;\r
305 BDS_LOADER_ARGUMENTS BootArguments;\r
306 CHAR8 AsciiBootDescription[BOOT_DEVICE_DESCRIPTION_MAX];\r
307 CHAR16 *BootDescription;\r
308 EFI_DEVICE_PATH* DevicePath;\r
309 BDS_LOADER_TYPE BootType;\r
ea46ebbe 310\r
311 Status = BootMenuSelectBootOption (BootOptionsList,L"Update entry: ",&BootOption);\r
312 if (EFI_ERROR(Status)) {\r
313 return Status;\r
314 }\r
315\r
316 // Get the device support for this Boot Option\r
317 Status = BootDeviceGetDeviceSupport (BootOption,&DeviceSupport);\r
318 if (EFI_ERROR(Status)) {\r
319 Print(L"Impossible to retrieve the supported device for the update\n");\r
320 return EFI_UNSUPPORTED;\r
321 }\r
322\r
656416bc 323 Print(L"File path of the EFI Application or the kernel: ");\r
324 Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, &DevicePath, NULL, NULL);\r
ea46ebbe 325 if (EFI_ERROR(Status)) {\r
326 Status = EFI_ABORTED;\r
327 goto EXIT;\r
328 }\r
329\r
656416bc 330 BootType = (BDS_LOADER_TYPE)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->LoaderType));\r
331\r
332 // TODO: Allow adding an initrd to a boot entry without one\r
333 if (BootType == BDS_LOADER_KERNEL_LINUX_ATAG) {\r
334 if (ReadUnaligned16(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathListLength) > 0\r
335 && (EFI_DEVICE_PATH_PROTOCOL *)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList)) != NULL) {\r
336\r
337 Print(L"File path of the initrd: ");\r
338 Status = DeviceSupport->UpdateDevicePathNode (\r
339 (EFI_DEVICE_PATH_PROTOCOL *)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList)),\r
340 &BootArguments.LinuxAtagArguments.InitrdPathList,\r
341 NULL,\r
342 NULL);\r
343 if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {// EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd\r
344 Status = EFI_ABORTED;\r
345 goto EXIT;\r
346 }\r
347 } else {\r
348 BootArguments.LinuxAtagArguments.InitrdPathList = NULL;\r
349 BootArguments.LinuxAtagArguments.InitrdPathListLength = 0;\r
350 }\r
351\r
352 Print(L"Arguments to pass to the binary: ");\r
353 if (ReadUnaligned32((CONST UINT32*)&BootOption->OptionalData->Arguments.LinuxAtagArguments.CmdLine)) {\r
354 AsciiStrnCpy(BootArguments.LinuxAtagArguments.CmdLine,\r
355 BootOption->OptionalData->Arguments.LinuxAtagArguments.CmdLine,\r
356 BOOT_DEVICE_OPTION_MAX+1);\r
357 } else {\r
358 BootArguments.LinuxAtagArguments.CmdLine[0] = '\0';\r
359 }\r
360 Status = EditHIInputAscii (BootArguments.LinuxAtagArguments.CmdLine, BOOT_DEVICE_OPTION_MAX);\r
361 if (EFI_ERROR(Status)) {\r
362 Status = EFI_ABORTED;\r
363 goto FREE_DEVICE_PATH;\r
364 }\r
ea46ebbe 365 }\r
366\r
367 Print(L"Description for this new Entry: ");\r
656416bc 368 UnicodeStrToAsciiStr (BootOption->Description, AsciiBootDescription);\r
369 Status = EditHIInputAscii (AsciiBootDescription, BOOT_DEVICE_DESCRIPTION_MAX);\r
ea46ebbe 370 if (EFI_ERROR(Status)) {\r
371 Status = EFI_ABORTED;\r
372 goto FREE_DEVICE_PATH;\r
373 }\r
374\r
375 // Convert Ascii into Unicode\r
376 BootDescription = (CHAR16*)AllocatePool(AsciiStrSize(AsciiBootDescription) * sizeof(CHAR16));\r
377 AsciiStrToUnicodeStr (AsciiBootDescription, BootDescription);\r
378\r
379 // Update the entry\r
656416bc 380 Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, BootType, &BootArguments);\r
ea46ebbe 381\r
382 FreePool (BootDescription);\r
383\r
384FREE_DEVICE_PATH:\r
385 FreePool (DevicePath);\r
386\r
387EXIT:\r
326d1df9 388 if (Status == EFI_ABORTED) {\r
389 Print(L"\n");\r
390 }\r
ea46ebbe 391 return Status;\r
392}\r
393\r
394struct BOOT_MANAGER_ENTRY {\r
395 CONST CHAR16* Description;\r
396 EFI_STATUS (*Callback) (IN LIST_ENTRY *BootOptionsList);\r
397} BootManagerEntries[] = {\r
398 { L"Add Boot Device Entry", BootMenuAddBootOption },\r
399 { L"Update Boot Device Entry", BootMenuUpdateBootOption },\r
400 { L"Remove Boot Device Entry", BootMenuRemoveBootOption },\r
401};\r
402\r
403EFI_STATUS\r
404BootMenuManager (\r
405 IN LIST_ENTRY *BootOptionsList\r
406 )\r
407{\r
408 UINTN Index;\r
409 UINTN OptionSelected;\r
410 UINTN BootManagerEntryCount;\r
411 EFI_STATUS Status;\r
412\r
413 BootManagerEntryCount = sizeof(BootManagerEntries) / sizeof(struct BOOT_MANAGER_ENTRY);\r
414\r
415 while (TRUE) {\r
416 // Display Boot Manager menu\r
417 for (Index = 0; Index < BootManagerEntryCount; Index++) {\r
418 Print(L"[%d] %s\n",Index+1,BootManagerEntries[Index]);\r
419 }\r
420 Print(L"[%d] Return to main menu\n",Index+1);\r
421\r
422 // Select which entry to call\r
423 Print(L"Choice: ");\r
424 Status = GetHIInputInteger (&OptionSelected);\r
425 if (EFI_ERROR(Status) || (OptionSelected == (BootManagerEntryCount+1))) {\r
326d1df9 426 if (EFI_ERROR(Status)) {\r
427 Print(L"\n");\r
428 }\r
ea46ebbe 429 return EFI_SUCCESS;\r
430 } else if ((OptionSelected > 0) && (OptionSelected <= BootManagerEntryCount)) {\r
431 Status = BootManagerEntries[OptionSelected-1].Callback (BootOptionsList);\r
432 }\r
433 }\r
434\r
435 return EFI_SUCCESS;\r
436}\r
437\r
438EFI_STATUS\r
439BootEBL (\r
440 IN LIST_ENTRY *BootOptionsList\r
441 )\r
442{\r
443 EFI_STATUS Status;\r
444\r
445 // Start EFI Shell\r
446 Status = BdsLoadApplication(mImageHandle, L"Ebl");\r
447 if (Status == EFI_NOT_FOUND) {\r
448 Print (L"Error: EFI Application not found.\n");\r
449 } else if (EFI_ERROR(Status)) {\r
450 Print (L"Error: Status Code: 0x%X\n",(UINT32)Status);\r
451 }\r
452\r
453 return Status;\r
454}\r
455\r
456struct BOOT_MAIN_ENTRY {\r
457 CONST CHAR16* Description;\r
458 EFI_STATUS (*Callback) (IN LIST_ENTRY *BootOptionsList);\r
459} BootMainEntries[] = {\r
460 { L"EBL", BootEBL },\r
461 { L"Boot Manager", BootMenuManager },\r
462};\r
463\r
464\r
465EFI_STATUS\r
466BootMenuMain (\r
467 VOID\r
468 )\r
469{\r
470 LIST_ENTRY BootOptionsList;\r
471 UINTN OptionCount;\r
472 UINTN BootOptionCount;\r
473 EFI_STATUS Status;\r
474 LIST_ENTRY *Entry;\r
475 BDS_LOAD_OPTION *BootOption;\r
476 UINTN BootOptionSelected;\r
477 UINTN Index;\r
478 UINTN BootMainEntryCount;\r
479\r
e862cd50 480 BootOption = NULL;\r
ea46ebbe 481 BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY);\r
a6caee65 482\r
ea46ebbe 483 // Get Boot#### list\r
484 BootOptionList (&BootOptionsList);\r
485\r
486 while (TRUE) {\r
487 OptionCount = 1;\r
488\r
489 // Display the Boot options\r
490 for (Entry = GetFirstNode (&BootOptionsList);\r
491 !IsNull (&BootOptionsList,Entry);\r
492 Entry = GetNextNode (&BootOptionsList,Entry)\r
493 )\r
494 {\r
495 BootOption = LOAD_OPTION_FROM_LINK(Entry);\r
496\r
497 Print(L"[%d] %s\n",OptionCount,BootOption->Description);\r
498\r
499 DEBUG_CODE_BEGIN();\r
500 CHAR16* DevicePathTxt;\r
501 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;\r
502\r
503 Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);\r
aa95e2f7 504 if (EFI_ERROR(Status)) {\r
505 // You must provide an implementation of DevicePathToTextProtocol in your firmware (eg: DevicePathDxe)\r
506 DEBUG((EFI_D_ERROR,"Error: Bds requires DevicePathToTextProtocol\n"));\r
507 return Status;\r
508 }\r
ea46ebbe 509 DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BootOption->FilePathList,TRUE,TRUE);\r
510\r
511 Print(L"\t- %s\n",DevicePathTxt);\r
656416bc 512 if (ReadUnaligned32(&BootOption->OptionalData->LoaderType) == BDS_LOADER_KERNEL_LINUX_ATAG) {\r
513 if (ReadUnaligned16(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathListLength) > 0\r
514 && (EFI_DEVICE_PATH_PROTOCOL *)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList)) != NULL) {\r
515 DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL *)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList)),TRUE,TRUE);\r
516 Print(L"\t- Initrd: %s\n", DevicePathTxt);\r
ea46ebbe 517 }\r
656416bc 518 \r
519 Print(L"\t- Arguments: %a\n", BootOption->OptionalData->Arguments.LinuxAtagArguments.CmdLine);\r
ea46ebbe 520 }\r
521\r
656416bc 522 Print(L"\t- LoaderType: %d\n", ReadUnaligned32 (&BootOption->OptionalData->LoaderType));\r
523\r
ea46ebbe 524 FreePool(DevicePathTxt);\r
525 DEBUG_CODE_END();\r
526\r
527 OptionCount++;\r
528 }\r
529 BootOptionCount = OptionCount-1;\r
530\r
531 // Display the hardcoded Boot entries\r
532 for (Index = 0; Index < BootMainEntryCount; Index++) {\r
533 Print(L"[%d] %s\n",OptionCount,BootMainEntries[Index]);\r
534 OptionCount++;\r
535 }\r
536\r
537 // Request the boot entry from the user\r
538 BootOptionSelected = 0;\r
539 while (BootOptionSelected == 0) {\r
540 Print(L"Start: ");\r
541 Status = GetHIInputInteger (&BootOptionSelected);\r
542 if (EFI_ERROR(Status) || (BootOptionSelected == 0) || (BootOptionSelected > OptionCount)) {\r
543 Print(L"Invalid input (max %d)\n",(OptionCount-1));\r
544 BootOptionSelected = 0;\r
545 }\r
546 }\r
547\r
548 // Start the selected entry\r
549 if (BootOptionSelected > BootOptionCount) {\r
550 // Start the hardcoded entry\r
551 Status = BootMainEntries[BootOptionSelected - BootOptionCount - 1].Callback (&BootOptionsList);\r
552 } else {\r
553 // Find the selected entry from the Boot#### list\r
554 Index = 1;\r
555 for (Entry = GetFirstNode (&BootOptionsList);\r
556 !IsNull (&BootOptionsList,Entry);\r
557 Entry = GetNextNode (&BootOptionsList,Entry)\r
558 )\r
559 {\r
560 if (Index == BootOptionSelected) {\r
561 BootOption = LOAD_OPTION_FROM_LINK(Entry);\r
562 break;\r
563 }\r
564 Index++;\r
565 }\r
566\r
567 Status = BootOptionStart (BootOption);\r
568 }\r
569 }\r
570\r
571 return Status;\r
572}\r