On 08/07/14 23:05, Chris Cuthbert wrote:
> This is ARM from edk2. All open source, nothing proprietary.
Ah. Yes. I recall that. Actually I have a downstream hack that is
related. I'll attach it just as illustration (the other tree patches
just increase the convenience). The point is (IIRC!) that ARM BDS does
not call BdsConnectAllDrivers() before reaching the boot menu. I guess
that's probably the issue.
In my case I wanted to auto-generate a boot option (for the boot menu)
for whatever disk partition that looked like an EFI System Partition.
The disk in question that I had was a virtio-blk disk, and the patch
didn't work initially. The reason was that at that point the disk had
not been connected yet. So, IMHO you can solve this by inserting a call
to BdsConnectAllDrivers() in a strategic point. You should probably find
that point yourself; for me it was DefineDefaultBootEntries().
(Note: I haven't tested this patch in a while, but the above was
certainly the case when I last run it.)
Laszlo
From 438c986664773cb1a97f669c9610deb1816e6fa3 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Wed, 27 Nov 2013 01:07:05 +0100
Subject: [PATCH 1/4] ArmPlatformPkg/Bds: generate ESP Image boot option if
user pref is unset
This hack is probably not upstreamable, but it should ease development:
If "PcdDefaultBootDevicePath" is set to the empty string in the platform
DSC file, then this patch will try to boot the file called "Image" from
the ESP. This should make the UEFI binary independent of the ESP's
characteristics (UUID of GPT partition, size, etc) and require disk image
files only to provide a file called "Image" in the ESP.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
ArmPlatformPkg/Bds/Bds.inf | 1 +
ArmPlatformPkg/Bds/Bds.c | 58 +++++++++++++++++++++++++++++++---------------
2 files changed, 40 insertions(+), 19 deletions(-)
diff --git a/ArmPlatformPkg/Bds/Bds.inf b/ArmPlatformPkg/Bds/Bds.inf
index a3efb6f..7391cec 100644
--- a/ArmPlatformPkg/Bds/Bds.inf
+++ b/ArmPlatformPkg/Bds/Bds.inf
@@ -53,6 +53,7 @@
gEfiEndOfDxeEventGroupGuid
gEfiFileSystemInfoGuid
gArmGlobalVariableGuid
+ gEfiPartTypeSystemPartGuid
[Protocols]
gEfiBdsArchProtocolGuid
diff --git a/ArmPlatformPkg/Bds/Bds.c b/ArmPlatformPkg/Bds/Bds.c
index b84faf9..aac1192 100644
--- a/ArmPlatformPkg/Bds/Bds.c
+++ b/ArmPlatformPkg/Bds/Bds.c
@@ -20,6 +20,7 @@
#include <Protocol/Bds.h>
#include <Guid/EventGroup.h>
+#include <Guid/Gpt.h>
#define EFI_SET_TIMER_TO_SECOND 10000000
@@ -238,30 +239,49 @@ DefineDefaultBootEntries (
Status = gRT->GetVariable (L"BootOrder", &gEfiGlobalVariableGuid, NULL, &Size, NULL);
if (Status == EFI_NOT_FOUND) {
if ((PcdGetPtr(PcdDefaultBootDevicePath) == NULL) || (StrLen ((CHAR16*)PcdGetPtr(PcdDefaultBootDevicePath)) == 0)) {
- return EFI_UNSUPPORTED;
- }
+ UINTN NrHandles;
+ EFI_HANDLE *Handles;
- Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);
- if (EFI_ERROR(Status)) {
- // You must provide an implementation of DevicePathFromTextProtocol in your firmware (eg: DevicePathDxe)
- DEBUG((EFI_D_ERROR,"Error: Bds requires DevicePathFromTextProtocol\n"));
- return Status;
- }
- BootDevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootDevicePath));
+ BdsConnectAllDrivers();
+ Status = gBS->LocateHandleBuffer (ByProtocol,
+ &gEfiPartTypeSystemPartGuid, NULL /* SearchKey */,
+ &NrHandles, &Handles);
+ if (!EFI_ERROR (Status)) {
+ ASSERT (NrHandles > 0);
+ BootDevicePath = FileDevicePath (Handles[0], L"Image");
+ if (BootDevicePath == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ }
+ FreePool (Handles);
+ }
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "failed to auto-create default boot option: %r\n",
+ Status));
+ return Status;
+ }
+ } else {
+ Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);
+ if (EFI_ERROR(Status)) {
+ // You must provide an implementation of DevicePathFromTextProtocol in your firmware (eg: DevicePathDxe)
+ DEBUG((EFI_D_ERROR,"Error: Bds requires DevicePathFromTextProtocol\n"));
+ return Status;
+ }
+ BootDevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootDevicePath));
- DEBUG_CODE_BEGIN();
- // We convert back to the text representation of the device Path to see if the initial text is correct
- EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
- CHAR16* DevicePathTxt;
+ DEBUG_CODE_BEGIN();
+ // We convert back to the text representation of the device Path to see if the initial text is correct
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
+ CHAR16* DevicePathTxt;
- Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
- ASSERT_EFI_ERROR(Status);
- DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (BootDevicePath, TRUE, TRUE);
+ Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
+ ASSERT_EFI_ERROR(Status);
+ DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (BootDevicePath, TRUE, TRUE);
- ASSERT (StrCmp ((CHAR16*)PcdGetPtr(PcdDefaultBootDevicePath), DevicePathTxt) == 0);
+ ASSERT (StrCmp ((CHAR16*)PcdGetPtr(PcdDefaultBootDevicePath), DevicePathTxt) == 0);
- FreePool (DevicePathTxt);
- DEBUG_CODE_END();
+ FreePool (DevicePathTxt);
+ DEBUG_CODE_END();
+ }
// Create the entry is the Default values are correct
if (BootDevicePath != NULL) {
--
1.8.3.1
From c034e47c3adce9da91df4274adf4f661afb79e40 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Fri, 13 Dec 2013 22:02:37 +0100
Subject: [PATCH 2/4] ArmPlatformPkg/Bds: check for other defaults too if user
pref is unset
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
ArmPlatformPkg/Bds/Bds.inf | 1 +
ArmPlatformPkg/Bds/Bds.c | 62 +++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/ArmPlatformPkg/Bds/Bds.inf b/ArmPlatformPkg/Bds/Bds.inf
index 7391cec..a1ce7be 100644
--- a/ArmPlatformPkg/Bds/Bds.inf
+++ b/ArmPlatformPkg/Bds/Bds.inf
@@ -62,6 +62,7 @@
gEfiPxeBaseCodeProtocolGuid
gEfiSimpleNetworkProtocolGuid
gEfiDevicePathToTextProtocolGuid
+ gEfiSimpleFileSystemProtocolGuid
[Pcd]
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor
diff --git a/ArmPlatformPkg/Bds/Bds.c b/ArmPlatformPkg/Bds/Bds.c
index aac1192..17e44df 100644
--- a/ArmPlatformPkg/Bds/Bds.c
+++ b/ArmPlatformPkg/Bds/Bds.c
@@ -18,6 +18,7 @@
#include <Library/PerformanceLib.h>
#include <Protocol/Bds.h>
+#include <Protocol/SimpleFileSystem.h>
#include <Guid/EventGroup.h>
#include <Guid/Gpt.h>
@@ -211,6 +212,62 @@ InitializeConsole (
return EFI_SUCCESS;
}
+STATIC
+EFI_STATUS
+FindCandidate (
+ IN EFI_HANDLE Handle,
+ OUT EFI_DEVICE_PATH **Candidate
+ )
+{
+ EFI_STATUS Status;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem;
+ EFI_FILE_PROTOCOL *RootDir;
+ CONST CHAR16 *CONST *FileName;
+ CONST CHAR16 *CONST Candidates[] = {
+ EFI_REMOVABLE_MEDIA_FILE_NAME,
+ L"\\Image",
+ L"\\EFI\\redhat\\grubaa64.efi",
+ NULL
+ };
+
+ Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid,
+ (VOID **) &FileSystem);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Status = FileSystem->OpenVolume (FileSystem, &RootDir);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (FileName = Candidates; *FileName != NULL; ++FileName) {
+ EFI_FILE_PROTOCOL *File;
+
+ Status = RootDir->Open (RootDir, &File, (CHAR16 *) *FileName,
+ EFI_FILE_MODE_READ, 0);
+ if (!EFI_ERROR (Status)) {
+ File->Close (File);
+ break;
+ }
+ }
+ if (*FileName == NULL) {
+ Status = EFI_NOT_FOUND;
+ goto CloseRoot;
+ }
+
+ *Candidate = FileDevicePath (Handle, *FileName);
+ if (*Candidate == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto CloseRoot;
+ }
+
+ DEBUG ((EFI_D_INFO, "%a: found \"%s\"\n", __FUNCTION__, *FileName));
+
+CloseRoot:
+ RootDir->Close (RootDir);
+ return Status;
+}
+
EFI_STATUS
DefineDefaultBootEntries (
VOID
@@ -248,10 +305,7 @@ DefineDefaultBootEntries (
&NrHandles, &Handles);
if (!EFI_ERROR (Status)) {
ASSERT (NrHandles > 0);
- BootDevicePath = FileDevicePath (Handles[0], L"Image");
- if (BootDevicePath == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- }
+ Status = FindCandidate (Handles[0], &BootDevicePath);
FreePool (Handles);
}
if (EFI_ERROR (Status)) {
--
1.8.3.1
From 2a36a18b8eecb72be27e0a4d1b830639bad060fe Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Sun, 10 Nov 2013 18:55:40 +0100
Subject: [PATCH 3/4] ArmPlatformPkg: Foundation: set boot type to EfiApp,
auto-detect boot path
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
.../ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc
index 012d470..cf35ac1 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc
@@ -120,11 +120,11 @@
# ARM OS Loader
#
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"root=/dev/vda2 rw console=ttyAMA0 earlyprintk=pl011,0x1c090000 maxcpus=4 debug user_debug=31 loglevel=9"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2
- gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/foundation-v8.dtb"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from first ESP"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L""
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|""
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootType|0
+ gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L""
# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();"
--
1.8.3.1
From be53ae2b975685a4a6f665e737fffe5460dc2ce7 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Thu, 9 Jan 2014 01:37:44 +0100
Subject: [PATCH 4/4] ArmPlatformPkg: FVP: set boot type to EfiApp, auto-detect
boot path
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
index 7cc4e27..ea20fcc 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
@@ -164,12 +164,11 @@
# ARM OS Loader
#
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/filesystem.cpio.gz"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0 earlyprintk=pl011,0x1c090000 debug user_debug=31 loglevel=9"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2
- gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/fdt.dtb"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from first ESP"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L""
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|""
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootType|0
+ gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L""
# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
--
1.8.3.1
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel