X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=inline;f=ArmPlatformPkg%2FBds%2FBootMenu.c;h=543958bf17a794f4c161a945ee436a8e8db98b02;hb=1ddb209e0e7d57d13483a52db2e0f9483b150b68;hp=b18a58bd8c77a3869b8e5b6fcf0a464cdc4fc7d1;hpb=656416bc2ee1409492343cde3f27ce717e90fdf7;p=mirror_edk2.git diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c index b18a58bd8c..543958bf17 100644 --- a/ArmPlatformPkg/Bds/BootMenu.c +++ b/ArmPlatformPkg/Bds/BootMenu.c @@ -53,9 +53,9 @@ SelectBootDevice ( CHAR16* DevicePathTxt; EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol; - Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol); + Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol); ASSERT_EFI_ERROR(Status); - DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText((*SupportedBootDevice)->DevicePathProtocol,TRUE,TRUE); + DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText ((*SupportedBootDevice)->DevicePathProtocol,TRUE,TRUE); Print(L"\t- %s\n",DevicePathTxt); @@ -82,7 +82,7 @@ SelectBootDevice ( Status = EFI_ABORTED; goto EXIT; } else if ((SupportedDeviceSelected == 0) || (SupportedDeviceSelected > SupportedDeviceCount)) { - Print(L"Invalid input (max %d)\n",SupportedDeviceSelected); + Print(L"Invalid input (max %d)\n",SupportedDeviceCount); SupportedDeviceSelected = 0; } } @@ -113,23 +113,26 @@ BootMenuAddBootOption ( IN LIST_ENTRY *BootOptionsList ) { - EFI_STATUS Status; - BDS_SUPPORTED_DEVICE* SupportedBootDevice; - BDS_LOADER_ARGUMENTS BootArguments; - CHAR8 AsciiBootDescription[BOOT_DEVICE_DESCRIPTION_MAX]; - CHAR16 *BootDescription; - UINT32 Attributes; - BDS_LOADER_TYPE BootType; - BDS_LOAD_OPTION *BdsLoadOption; - EFI_DEVICE_PATH *DevicePath; - EFI_DEVICE_PATH_PROTOCOL *DevicePathNode; - EFI_DEVICE_PATH_PROTOCOL *InitrdPathNode; + EFI_STATUS Status; + BDS_SUPPORTED_DEVICE* SupportedBootDevice; + ARM_BDS_LOADER_ARGUMENTS* BootArguments; + CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX]; + CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX]; + UINT32 Attributes; + ARM_BDS_LOADER_TYPE BootType; + BDS_LOAD_OPTION_ENTRY *BdsLoadOptionEntry; + EFI_DEVICE_PATH *DevicePath; + EFI_DEVICE_PATH_PROTOCOL *DevicePathNode; + EFI_DEVICE_PATH_PROTOCOL *InitrdPathNode; + EFI_DEVICE_PATH_PROTOCOL *InitrdPath; + UINTN CmdLineSize; + UINTN InitrdSize; Attributes = 0; SupportedBootDevice = NULL; // List the Boot Devices supported - Status = SelectBootDevice(&SupportedBootDevice); + Status = SelectBootDevice (&SupportedBootDevice); if (EFI_ERROR(Status)) { Status = EFI_ABORTED; goto EXIT; @@ -145,7 +148,7 @@ BootMenuAddBootOption ( // Append the Device Path node to the select device path DevicePath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode); - if (BootType == BDS_LOADER_KERNEL_LINUX_ATAG) { + if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) { // Create the specific device path node Print(L"File path of the initrd: "); Status = SupportedBootDevice->Support->CreateDevicePathNode (SupportedBootDevice, &InitrdPathNode, NULL, NULL); @@ -156,39 +159,45 @@ BootMenuAddBootOption ( if (InitrdPathNode != NULL) { // Append the Device Path node to the select device path - BootArguments.LinuxAtagArguments.InitrdPathList = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode); + InitrdPath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode); } else { - BootArguments.LinuxAtagArguments.InitrdPathList = NULL; + InitrdPath = NULL; } Print(L"Arguments to pass to the binary: "); - Status = GetHIInputAscii (BootArguments.LinuxAtagArguments.CmdLine,BOOT_DEVICE_OPTION_MAX); + Status = GetHIInputAscii (CmdLine,BOOT_DEVICE_OPTION_MAX); if (EFI_ERROR(Status)) { Status = EFI_ABORTED; goto FREE_DEVICE_PATH; } - BootArguments.LinuxAtagArguments.CmdLine[BOOT_DEVICE_OPTION_MAX]= '\0'; + + CmdLineSize = AsciiStrSize (CmdLine); + InitrdSize = GetDevicePathSize (InitrdPath); + + BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize); + + BootArguments->LinuxArguments.CmdLineSize = CmdLineSize; + BootArguments->LinuxArguments.InitrdSize = InitrdSize; + CopyMem ((VOID*)(&BootArguments->LinuxArguments + 1), CmdLine, CmdLineSize); + CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize); + } else { + BootArguments = NULL; } Print(L"Description for this new Entry: "); - Status = GetHIInputAscii (AsciiBootDescription,BOOT_DEVICE_DESCRIPTION_MAX); + Status = GetHIInputStr (BootDescription, BOOT_DEVICE_DESCRIPTION_MAX); if (EFI_ERROR(Status)) { Status = EFI_ABORTED; goto FREE_DEVICE_PATH; } - // Convert Ascii into Unicode - BootDescription = (CHAR16*)AllocatePool(AsciiStrSize(AsciiBootDescription) * sizeof(CHAR16)); - AsciiStrToUnicodeStr (AsciiBootDescription, BootDescription); - // Create new entry - Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, &BootArguments, &BdsLoadOption); + BdsLoadOptionEntry = (BDS_LOAD_OPTION_ENTRY*)AllocatePool (sizeof(BDS_LOAD_OPTION_ENTRY)); + Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, BootArguments, &BdsLoadOptionEntry->BdsLoadOption); if (!EFI_ERROR(Status)) { - InsertTailList (BootOptionsList,&BdsLoadOption->Link); + InsertTailList (BootOptionsList, &BdsLoadOptionEntry->Link); } - FreePool (BootDescription); - FREE_DEVICE_PATH: FreePool (DevicePath); @@ -204,39 +213,49 @@ EXIT: STATIC EFI_STATUS BootMenuSelectBootOption ( - IN LIST_ENTRY *BootOptionsList, - IN CONST CHAR16* InputStatement, - OUT BDS_LOAD_OPTION **BdsLoadOption + IN LIST_ENTRY* BootOptionsList, + IN CONST CHAR16* InputStatement, + IN BOOLEAN OnlyArmBdsBootEntry, + OUT BDS_LOAD_OPTION_ENTRY** BdsLoadOptionEntry ) { - EFI_STATUS Status; - LIST_ENTRY* Entry; - BDS_LOAD_OPTION *BootOption; - UINTN BootOptionSelected; - UINTN BootOptionCount; - UINTN Index; + EFI_STATUS Status; + LIST_ENTRY* Entry; + BDS_LOAD_OPTION* BdsLoadOption; + UINTN BootOptionSelected; + UINTN BootOptionCount; + UINTN Index; // Display the list of supported boot devices - BootOptionCount = 1; + BootOptionCount = 0; for (Entry = GetFirstNode (BootOptionsList); !IsNull (BootOptionsList,Entry); - Entry = GetNextNode (BootOptionsList,Entry) + Entry = GetNextNode (BootOptionsList, Entry) ) { - BootOption = LOAD_OPTION_FROM_LINK(Entry); - Print(L"[%d] %s\n",BootOptionCount,BootOption->Description); + BdsLoadOption = LOAD_OPTION_FROM_LINK(Entry); + + if (OnlyArmBdsBootEntry && !IS_ARM_BDS_BOOTENTRY (BdsLoadOption)) { + continue; + } + + Print (L"[%d] %s\n", (BootOptionCount + 1), BdsLoadOption->Description); DEBUG_CODE_BEGIN(); CHAR16* DevicePathTxt; EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol; + ARM_BDS_LOADER_TYPE LoaderType; + ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData; Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol); ASSERT_EFI_ERROR(Status); - DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BootOption->FilePathList,TRUE,TRUE); + DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BdsLoadOption->FilePathList,TRUE,TRUE); Print(L"\t- %s\n",DevicePathTxt); - if ((BDS_LOADER_TYPE)ReadUnaligned32(&BootOption->OptionalData->LoaderType) == BDS_LOADER_KERNEL_LINUX_ATAG) { - Print(L"\t- Arguments: %a\n",BootOption->OptionalData->Arguments.LinuxAtagArguments.CmdLine); + OptionalData = BdsLoadOption->OptionalData; + LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType); + if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT)) { + Print (L"\t- Arguments: %a\n",&OptionalData->Arguments.LinuxArguments + 1); } FreePool(DevicePathTxt); @@ -245,6 +264,19 @@ BootMenuSelectBootOption ( BootOptionCount++; } + // Check if a valid boot option(s) is found + if (BootOptionCount == 0) { + if (StrCmp (InputStatement, DELETE_BOOT_ENTRY) == 0) { + Print (L"Nothing to remove!\n"); + }else if (StrCmp (InputStatement, UPDATE_BOOT_ENTRY) == 0) { + Print (L"Couldn't find valid boot entries\n"); + } else{ + Print (L"No supported Boot Entry.\n"); + } + + return EFI_NOT_FOUND; + } + // Get the index of the boot device to delete BootOptionSelected = 0; while (BootOptionSelected == 0) { @@ -252,8 +284,8 @@ BootMenuSelectBootOption ( Status = GetHIInputInteger (&BootOptionSelected); if (EFI_ERROR(Status)) { return Status; - } else if ((BootOptionSelected == 0) || (BootOptionSelected >= BootOptionCount)) { - Print(L"Invalid input (max %d)\n",BootOptionCount-1); + } else if ((BootOptionSelected == 0) || (BootOptionSelected > BootOptionCount)) { + Print(L"Invalid input (max %d)\n",BootOptionCount); BootOptionSelected = 0; } } @@ -261,12 +293,12 @@ BootMenuSelectBootOption ( // Get the structure of the Boot device to delete Index = 1; for (Entry = GetFirstNode (BootOptionsList); - !IsNull (BootOptionsList,Entry); + !IsNull (BootOptionsList, Entry); Entry = GetNextNode (BootOptionsList,Entry) ) { if (Index == BootOptionSelected) { - *BdsLoadOption = LOAD_OPTION_FROM_LINK(Entry); + *BdsLoadOptionEntry = LOAD_OPTION_ENTRY_FROM_LINK(Entry); break; } Index++; @@ -280,16 +312,22 @@ BootMenuRemoveBootOption ( IN LIST_ENTRY *BootOptionsList ) { - EFI_STATUS Status; - BDS_LOAD_OPTION *BootOption; + EFI_STATUS Status; + BDS_LOAD_OPTION_ENTRY* BootOptionEntry; - Status = BootMenuSelectBootOption (BootOptionsList,L"Delete entry: ",&BootOption); + Status = BootMenuSelectBootOption (BootOptionsList, DELETE_BOOT_ENTRY, FALSE, &BootOptionEntry); if (EFI_ERROR(Status)) { return Status; } + // If the Boot Option was attached to a list remove it + if (!IsListEmpty (&BootOptionEntry->Link)) { + // Remove the entry from the list + RemoveEntryList (&BootOptionEntry->Link); + } + // Delete the BDS Load option structures - BootOptionDelete (BootOption); + BootOptionDelete (BootOptionEntry->BdsLoadOption); return EFI_SUCCESS; } @@ -299,24 +337,31 @@ BootMenuUpdateBootOption ( IN LIST_ENTRY *BootOptionsList ) { - EFI_STATUS Status; - BDS_LOAD_OPTION *BootOption; - BDS_LOAD_OPTION_SUPPORT *DeviceSupport; - BDS_LOADER_ARGUMENTS BootArguments; - CHAR8 AsciiBootDescription[BOOT_DEVICE_DESCRIPTION_MAX]; - CHAR16 *BootDescription; - EFI_DEVICE_PATH* DevicePath; - BDS_LOADER_TYPE BootType; - - Status = BootMenuSelectBootOption (BootOptionsList,L"Update entry: ",&BootOption); + EFI_STATUS Status; + BDS_LOAD_OPTION_ENTRY *BootOptionEntry; + BDS_LOAD_OPTION *BootOption; + BDS_LOAD_OPTION_SUPPORT* DeviceSupport; + ARM_BDS_LOADER_ARGUMENTS* BootArguments; + CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX]; + CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX]; + EFI_DEVICE_PATH* DevicePath; + ARM_BDS_LOADER_TYPE BootType; + ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData; + ARM_BDS_LINUX_ARGUMENTS* LinuxArguments; + EFI_DEVICE_PATH* InitrdPathList; + UINTN InitrdSize; + UINTN CmdLineSize; + + Status = BootMenuSelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, TRUE, &BootOptionEntry); if (EFI_ERROR(Status)) { return Status; } + BootOption = BootOptionEntry->BdsLoadOption; // Get the device support for this Boot Option - Status = BootDeviceGetDeviceSupport (BootOption,&DeviceSupport); + Status = BootDeviceGetDeviceSupport (BootOption, &DeviceSupport); if (EFI_ERROR(Status)) { - Print(L"Impossible to retrieve the supported device for the update\n"); + Print(L"Not possible to retrieve the supported device for the update\n"); return EFI_UNSUPPORTED; } @@ -327,59 +372,59 @@ BootMenuUpdateBootOption ( goto EXIT; } - BootType = (BDS_LOADER_TYPE)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->LoaderType)); + OptionalData = BootOption->OptionalData; + BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&OptionalData->Header.LoaderType)); // TODO: Allow adding an initrd to a boot entry without one - if (BootType == BDS_LOADER_KERNEL_LINUX_ATAG) { - if (ReadUnaligned16(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathListLength) > 0 - && (EFI_DEVICE_PATH_PROTOCOL *)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList)) != NULL) { + if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) { + LinuxArguments = &OptionalData->Arguments.LinuxArguments; + CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize); + + InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize); + if (InitrdSize > 0) { Print(L"File path of the initrd: "); - Status = DeviceSupport->UpdateDevicePathNode ( - (EFI_DEVICE_PATH_PROTOCOL *)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList)), - &BootArguments.LinuxAtagArguments.InitrdPathList, - NULL, - NULL); + Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((LinuxArguments + 1) + CmdLineSize), &InitrdPathList, NULL, NULL); if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {// EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd Status = EFI_ABORTED; goto EXIT; } - } else { - BootArguments.LinuxAtagArguments.InitrdPathList = NULL; - BootArguments.LinuxAtagArguments.InitrdPathListLength = 0; + InitrdSize = GetDevicePathSize (InitrdPathList); } - Print(L"Arguments to pass to the binary: "); - if (ReadUnaligned32((CONST UINT32*)&BootOption->OptionalData->Arguments.LinuxAtagArguments.CmdLine)) { - AsciiStrnCpy(BootArguments.LinuxAtagArguments.CmdLine, - BootOption->OptionalData->Arguments.LinuxAtagArguments.CmdLine, - BOOT_DEVICE_OPTION_MAX+1); + Print(L"Arguments to pass to the binary: "); + if (CmdLineSize > 0) { + AsciiStrnCpy(CmdLine, (CONST CHAR8*)(LinuxArguments + 1), CmdLineSize); } else { - BootArguments.LinuxAtagArguments.CmdLine[0] = '\0'; + CmdLine[0] = '\0'; } - Status = EditHIInputAscii (BootArguments.LinuxAtagArguments.CmdLine, BOOT_DEVICE_OPTION_MAX); + Status = EditHIInputAscii (CmdLine, BOOT_DEVICE_OPTION_MAX); if (EFI_ERROR(Status)) { Status = EFI_ABORTED; goto FREE_DEVICE_PATH; } + + CmdLineSize = AsciiStrSize (CmdLine); + + BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool(sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize); + BootArguments->LinuxArguments.CmdLineSize = CmdLineSize; + BootArguments->LinuxArguments.InitrdSize = InitrdSize; + CopyMem (&BootArguments->LinuxArguments + 1, CmdLine, CmdLineSize); + CopyMem ((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLine, InitrdPathList, InitrdSize); + } else { + BootArguments = NULL; } Print(L"Description for this new Entry: "); - UnicodeStrToAsciiStr (BootOption->Description, AsciiBootDescription); - Status = EditHIInputAscii (AsciiBootDescription, BOOT_DEVICE_DESCRIPTION_MAX); + StrnCpy (BootDescription, BootOption->Description, BOOT_DEVICE_DESCRIPTION_MAX); + Status = EditHIInputStr (BootDescription, BOOT_DEVICE_DESCRIPTION_MAX); if (EFI_ERROR(Status)) { Status = EFI_ABORTED; goto FREE_DEVICE_PATH; } - // Convert Ascii into Unicode - BootDescription = (CHAR16*)AllocatePool(AsciiStrSize(AsciiBootDescription) * sizeof(CHAR16)); - AsciiStrToUnicodeStr (AsciiBootDescription, BootDescription); - // Update the entry - Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, BootType, &BootArguments); - - FreePool (BootDescription); + Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, BootType, BootArguments); FREE_DEVICE_PATH: FreePool (DevicePath); @@ -428,11 +473,10 @@ BootMenuManager ( } return EFI_SUCCESS; } else if ((OptionSelected > 0) && (OptionSelected <= BootManagerEntryCount)) { - Status = BootManagerEntries[OptionSelected-1].Callback (BootOptionsList); + BootManagerEntries[OptionSelected-1].Callback (BootOptionsList); } } - - return EFI_SUCCESS; + // Should never go here } EFI_STATUS @@ -443,7 +487,7 @@ BootEBL ( EFI_STATUS Status; // Start EFI Shell - Status = BdsLoadApplication(mImageHandle, L"Ebl"); + Status = BdsLoadApplication (mImageHandle, L"Ebl", 0, NULL); if (Status == EFI_NOT_FOUND) { Print (L"Error: EFI Application not found.\n"); } else if (EFI_ERROR(Status)) { @@ -467,23 +511,23 @@ BootMenuMain ( VOID ) { - LIST_ENTRY BootOptionsList; - UINTN OptionCount; - UINTN BootOptionCount; - EFI_STATUS Status; - LIST_ENTRY *Entry; - BDS_LOAD_OPTION *BootOption; - UINTN BootOptionSelected; - UINTN Index; - UINTN BootMainEntryCount; + LIST_ENTRY BootOptionsList; + UINTN OptionCount; + UINTN BootOptionCount; + EFI_STATUS Status; + LIST_ENTRY* Entry; + BDS_LOAD_OPTION* BootOption; + UINTN BootOptionSelected; + UINTN Index; + UINTN BootMainEntryCount; BootOption = NULL; BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY); - // Get Boot#### list - BootOptionList (&BootOptionsList); - while (TRUE) { + // Get Boot#### list + BootOptionList (&BootOptionsList); + OptionCount = 1; // Display the Boot options @@ -494,33 +538,40 @@ BootMenuMain ( { BootOption = LOAD_OPTION_FROM_LINK(Entry); - Print(L"[%d] %s\n",OptionCount,BootOption->Description); + Print(L"[%d] %s\n", OptionCount, BootOption->Description); DEBUG_CODE_BEGIN(); CHAR16* DevicePathTxt; EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol; + ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData; + UINTN CmdLineSize; + ARM_BDS_LOADER_TYPE LoaderType; - Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol); + Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol); if (EFI_ERROR(Status)) { // You must provide an implementation of DevicePathToTextProtocol in your firmware (eg: DevicePathDxe) DEBUG((EFI_D_ERROR,"Error: Bds requires DevicePathToTextProtocol\n")); return Status; } - DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BootOption->FilePathList,TRUE,TRUE); + DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (BootOption->FilePathList, TRUE, TRUE); Print(L"\t- %s\n",DevicePathTxt); - if (ReadUnaligned32(&BootOption->OptionalData->LoaderType) == BDS_LOADER_KERNEL_LINUX_ATAG) { - if (ReadUnaligned16(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathListLength) > 0 - && (EFI_DEVICE_PATH_PROTOCOL *)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList)) != NULL) { - DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL *)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList)),TRUE,TRUE); - Print(L"\t- Initrd: %s\n", DevicePathTxt); + + // If it is a supported BootEntry then print its details + if (IS_ARM_BDS_BOOTENTRY (BootOption)) { + OptionalData = BootOption->OptionalData; + LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType); + if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT)) { + if (ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.InitrdSize) > 0) { + CmdLineSize = ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.CmdLineSize); + DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText ( + GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(&OptionalData->Arguments.LinuxArguments + 1) + CmdLineSize)), TRUE, TRUE); + Print(L"\t- Initrd: %s\n", DevicePathTxt); + } + Print(L"\t- Arguments: %a\n", (&OptionalData->Arguments.LinuxArguments + 1)); } - - Print(L"\t- Arguments: %a\n", BootOption->OptionalData->Arguments.LinuxAtagArguments.CmdLine); + Print(L"\t- LoaderType: %d\n", LoaderType); } - - Print(L"\t- LoaderType: %d\n", ReadUnaligned32 (&BootOption->OptionalData->LoaderType)); - FreePool(DevicePathTxt); DEBUG_CODE_END(); @@ -567,6 +618,5 @@ BootMenuMain ( Status = BootOptionStart (BootOption); } } - - return Status; + // Should never go here }