Skip to content
Permalink
Browse files
RPi: allow selecting DT-only mode
Today the Pies can be booted in a way where only ACPI is exposed,
or both ACPI and DT are exposed.

This adds one more mode - DT only, no ACPI. The target audience
is developers. When both are exposed, it's up to the OS to decide
which gets used, and that choice can differ between OSes,

Note: this does _not_ change defaults. Pi 3 still defaults to
ACPI + DT, while Pi 4 still defaults to ACPI only.

We don't really want to remove DT + ACPI mode - it is the default
on Pi 3, and removing it is bound to just annoy users - WoA and
NetBSD (voa UEFI) on Pi 3 only work with ACPI, while everything
else (Linux, FreeBSD) only work with DT. I'd make an analogy of
MPS and ACPI being exposed for the longest time ever together on
PCs.

Testing: OpenBSD on Pi 4 with DT-only and ACPI-only boots.

Signed-off-by: Andrei Warkentin <andrey.warkentin@gmail.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
  • Loading branch information
andreiw authored and Ard Biesheuvel committed May 11, 2020
1 parent e52345a commit d492639638eee331ac3389e6cf53ea266c3c84b3
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 29 deletions.
@@ -155,11 +155,11 @@ SetupVariables (
}

Size = sizeof (UINT32);
Status = gRT->GetVariable (L"OptDeviceTree",
Status = gRT->GetVariable (L"SystemTableMode",
&gConfigDxeFormSetGuid,
NULL, &Size, &Var32);
if (EFI_ERROR (Status)) {
PcdSet32 (PcdOptDeviceTree, PcdGet32 (PcdOptDeviceTree));
PcdSet32 (PcdSystemTableMode, PcdGet32 (PcdSystemTableMode));
}

Size = sizeof (UINT32);
@@ -488,8 +488,11 @@ ConfigInitialize (
DEBUG ((DEBUG_ERROR, "Couldn't install ConfigDxe configuration pages: %r\n", Status));
}

Status = LocateAndInstallAcpiFromFv (&mAcpiTableFile);
ASSERT_EFI_ERROR (Status);
if (PcdGet32 (PcdSystemTableMode) == SYSTEM_TABLE_MODE_ACPI ||
PcdGet32 (PcdSystemTableMode) == SYSTEM_TABLE_MODE_BOTH) {
Status = LocateAndInstallAcpiFromFv (&mAcpiTableFile);
ASSERT_EFI_ERROR (Status);
}

return EFI_SUCCESS;
}
@@ -77,7 +77,7 @@
gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit
gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes
gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot
gRaspberryPiTokenSpaceGuid.PcdOptDeviceTree
gRaspberryPiTokenSpaceGuid.PcdSystemTableMode
gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB
gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB

@@ -41,10 +41,11 @@
#string STR_ADVANCED_3GB_OFF #language en-US "Disabled"
#string STR_ADVANCED_3GB_ON #language en-US "Enabled"

#string STR_ADVANCED_DT_PROMPT #language en-US "Device Tree"
#string STR_ADVANCED_DT_HELP #language en-US "Disable this option to force OSes such as GNU/Linux to use ACPI"
#string STR_ADVANCED_DT_OFF #language en-US "Disabled (Force ACPI)"
#string STR_ADVANCED_DT_ON #language en-US "Enabled"
#string STR_ADVANCED_SYSTAB_PROMPT #language en-US "System Table Selection"
#string STR_ADVANCED_SYSTAB_HELP #language en-US "ACPI/DT choice for specific OSes"
#string STR_ADVANCED_SYSTAB_ACPI #language en-US "ACPI"
#string STR_ADVANCED_SYSTAB_BOTH #language en-US "ACPI + Devicetree"
#string STR_ADVANCED_SYSTAB_DT #language en-US "Devicetree"

/*
* MMC/SD configuration.
@@ -44,9 +44,9 @@ formset
name = RamLimitTo3GB,
guid = CONFIGDXE_FORM_SET_GUID;

efivarstore ADVANCED_DEVICE_TREE_VARSTORE_DATA,
efivarstore SYSTEM_TABLE_MODE_VARSTORE_DATA,
attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
name = OptDeviceTree,
name = SystemTableMode,
guid = CONFIGDXE_FORM_SET_GUID;

efivarstore MMC_SD_VARSTORE_DATA,
@@ -164,12 +164,13 @@ formset
endoneof;
endif;

oneof varid = OptDeviceTree.Enabled,
prompt = STRING_TOKEN(STR_ADVANCED_DT_PROMPT),
help = STRING_TOKEN(STR_ADVANCED_DT_HELP),
oneof varid = SystemTableMode.Mode,
prompt = STRING_TOKEN(STR_ADVANCED_SYSTAB_PROMPT),
help = STRING_TOKEN(STR_ADVANCED_SYSTAB_HELP),
flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
option text = STRING_TOKEN(STR_ADVANCED_DT_OFF), value = 0, flags = 0;
option text = STRING_TOKEN(STR_ADVANCED_DT_ON), value = 1, flags = DEFAULT;
option text = STRING_TOKEN(STR_ADVANCED_SYSTAB_ACPI), value = SYSTEM_TABLE_MODE_ACPI, flags = 0;
option text = STRING_TOKEN(STR_ADVANCED_SYSTAB_BOTH), value = SYSTEM_TABLE_MODE_BOTH, flags = DEFAULT;
option text = STRING_TOKEN(STR_ADVANCED_SYSTAB_DT), value = SYSTEM_TABLE_MODE_DT, flags = DEFAULT;
endoneof;
endform;

@@ -355,7 +355,8 @@ FdtDxeInitialize (
UINTN FdtSize;
VOID *FdtImage = NULL;

if (PcdGet32 (PcdOptDeviceTree) == 0) {
if (PcdGet32 (PcdSystemTableMode) != SYSTEM_TABLE_MODE_BOTH &&
PcdGet32 (PcdSystemTableMode) != SYSTEM_TABLE_MODE_DT) {
DEBUG ((DEBUG_INFO, "Device Tree disabled per user configuration\n"));
return EFI_SUCCESS;
}
@@ -46,4 +46,4 @@
gRaspberryPiTokenSpaceGuid.PcdFdtBaseAddress

[Pcd]
gRaspberryPiTokenSpaceGuid.PcdOptDeviceTree
gRaspberryPiTokenSpaceGuid.PcdSystemTableMode
@@ -76,12 +76,11 @@ typedef struct {
} ADVANCED_RAM_LIMIT_TO_3GB_VARSTORE_DATA;

typedef struct {
/*
* 0 - Do not provide a Device Tree to the OS
* 1 - Provide a Device Tree to the OS
*/
UINT32 Enabled;
} ADVANCED_DEVICE_TREE_VARSTORE_DATA;
#define SYSTEM_TABLE_MODE_ACPI 0
#define SYSTEM_TABLE_MODE_BOTH 1
#define SYSTEM_TABLE_MODE_DT 2
UINT32 Mode;
} SYSTEM_TABLE_MODE_VARSTORE_DATA;

typedef struct {
/*
@@ -484,9 +484,13 @@
gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB|L"RamLimitTo3GB"|gConfigDxeFormSetGuid|0x0|0

#
# Device Tree
# Device Tree and ACPI selection.
#
gRaspberryPiTokenSpaceGuid.PcdOptDeviceTree|L"OptDeviceTree"|gConfigDxeFormSetGuid|0x0|1
# 0 - SYSTEM_TABLE_MODE_ACPI
# 1 - SYSTEM_TABLE_MODE_BOTH (default)
# 2 - SYSTEM_TABLE_MODE_DT
#
gRaspberryPiTokenSpaceGuid.PcdSystemTableMode|L"SystemTableMode"|gConfigDxeFormSetGuid|0x0|1

#
# Common UEFI ones.
@@ -496,9 +496,13 @@
gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB|L"RamLimitTo3GB"|gConfigDxeFormSetGuid|0x0|1

#
# Device Tree
# Device Tree and ACPI selection.
#
gRaspberryPiTokenSpaceGuid.PcdOptDeviceTree|L"OptDeviceTree"|gConfigDxeFormSetGuid|0x0|0
# 0 - SYSTEM_TABLE_MODE_ACPI (default)
# 1 - SYSTEM_TABLE_MODE_BOTH
# 2 - SYSTEM_TABLE_MODE_DT
#
gRaspberryPiTokenSpaceGuid.PcdSystemTableMode|L"SystemTableMode"|gConfigDxeFormSetGuid|0x0|0

#
# Common UEFI ones.
@@ -65,6 +65,6 @@
gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|0|UINT32|0x00000016
gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes|0x3F|UINT8|0x00000017
gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot|0|UINT32|0x00000018
gRaspberryPiTokenSpaceGuid.PcdOptDeviceTree|1|UINT32|0x0000001B
gRaspberryPiTokenSpaceGuid.PcdSystemTableMode|1|UINT32|0x0000001B
gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB|0|UINT32|0x00000019
gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB|0|UINT32|0x0000001A

0 comments on commit d492639

Please sign in to comment.