Skip to content

Commit a56080d

Browse files
committed
FdtPlatform: Expand search for overrides
- Scan all supported file systems (FAT, ext4) on the selected boot device, rather than just the one containing the OS loader. - Also look for base DTB overrides in `\dtb` and `\dtb\rockchip`. Fedora images conveniently have a symlink to the current kernel DTBs in the latter path, on the second ext4 boot partition. - Add config options to allow specifying custom relative paths for the base DTB override and overlays. Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
1 parent 2310656 commit a56080d

File tree

9 files changed

+436
-108
lines changed

9 files changed

+436
-108
lines changed

edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/FdtPlatformDxe/FdtPlatformDxe.c

Lines changed: 296 additions & 101 deletions
Large diffs are not rendered by default.

edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
[LibraryClasses]
3030
BaseLib
3131
DebugLib
32+
DevicePathLib
3233
PrintLib
3334
DxeServicesLib
3435
MemoryAllocationLib
@@ -54,6 +55,8 @@
5455
gRK3588TokenSpaceGuid.PcdFdtForceGop
5556
gRK3588TokenSpaceGuid.PcdFdtSupportOverrides
5657
gRK3588TokenSpaceGuid.PcdFdtOverrideFixup
58+
gRK3588TokenSpaceGuid.PcdFdtOverrideBasePath
59+
gRK3588TokenSpaceGuid.PcdFdtOverrideOverlayPath
5760
gRK3588TokenSpaceGuid.PcdComboPhy0Mode
5861
gRK3588TokenSpaceGuid.PcdComboPhy1Mode
5962
gRK3588TokenSpaceGuid.PcdComboPhy2Mode

edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/ConfigTable.c

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
**/
99

10+
#include <Library/BaseMemoryLib.h>
1011
#include <Library/DebugLib.h>
1112
#include <Library/RockchipPlatformLib.h>
1213
#include <Library/UefiRuntimeServicesTableLib.h>
@@ -49,12 +50,13 @@ SetupConfigTableVariables (
4950
VOID
5051
)
5152
{
52-
UINTN Size;
53-
UINT32 Var32;
54-
UINT8 Var8;
55-
EFI_STATUS Status;
56-
UINTN Index;
57-
UINT32 FirstFdtCompatModeSupported;
53+
UINTN Size;
54+
UINT32 Var32;
55+
UINT8 Var8;
56+
EFI_STATUS Status;
57+
UINTN Index;
58+
UINT32 FirstFdtCompatModeSupported;
59+
FDT_OVERRIDE_PATH_VARSTORE_DATA FdtOverridePath;
5860

5961
Size = sizeof (UINT32);
6062
Status = gRT->GetVariable (
@@ -160,4 +162,44 @@ SetupConfigTableVariables (
160162
Status = PcdSet8S (PcdFdtOverrideFixup, FixedPcdGet8 (PcdFdtOverrideFixupDefault));
161163
ASSERT_EFI_ERROR (Status);
162164
}
165+
166+
Size = sizeof (FDT_OVERRIDE_PATH_VARSTORE_DATA);
167+
Status = gRT->GetVariable (
168+
L"FdtOverrideBasePath",
169+
&gRK3588DxeFormSetGuid,
170+
NULL,
171+
&Size,
172+
&FdtOverridePath
173+
);
174+
if (EFI_ERROR (Status) || (FdtOverridePath.Path[0] == L' ')) {
175+
if (FixedPcdGetSize (PcdFdtOverrideBasePathDefault) <= Size) {
176+
Status = PcdSetPtrS (PcdFdtOverrideBasePath, &Size, FixedPcdGetPtr (PcdFdtOverrideBasePathDefault));
177+
} else {
178+
ASSERT (FALSE);
179+
ZeroMem (&FdtOverridePath, Size);
180+
Status = PcdSetPtrS (PcdFdtOverrideBasePath, &Size, &FdtOverridePath);
181+
}
182+
183+
ASSERT_EFI_ERROR (Status);
184+
}
185+
186+
Size = sizeof (FDT_OVERRIDE_PATH_VARSTORE_DATA);
187+
Status = gRT->GetVariable (
188+
L"FdtOverrideOverlayPath",
189+
&gRK3588DxeFormSetGuid,
190+
NULL,
191+
&Size,
192+
&FdtOverridePath
193+
);
194+
if (EFI_ERROR (Status) || (FdtOverridePath.Path[0] == L' ')) {
195+
if (FixedPcdGetSize (PcdFdtOverrideOverlayPathDefault) <= Size) {
196+
Status = PcdSetPtrS (PcdFdtOverrideOverlayPath, &Size, FixedPcdGetPtr (PcdFdtOverrideOverlayPathDefault));
197+
} else {
198+
ASSERT (FALSE);
199+
ZeroMem (&FdtOverridePath, Size);
200+
Status = PcdSetPtrS (PcdFdtOverrideOverlayPath, &Size, &FdtOverridePath);
201+
}
202+
203+
ASSERT_EFI_ERROR (Status);
204+
}
163205
}

edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588Dxe.inf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@
110110
gRK3588TokenSpaceGuid.PcdFdtSupportOverrides
111111
gRK3588TokenSpaceGuid.PcdFdtOverrideFixupDefault
112112
gRK3588TokenSpaceGuid.PcdFdtOverrideFixup
113+
gRK3588TokenSpaceGuid.PcdFdtOverrideBasePathDefault
114+
gRK3588TokenSpaceGuid.PcdFdtOverrideBasePath
115+
gRK3588TokenSpaceGuid.PcdFdtOverrideOverlayPathDefault
116+
gRK3588TokenSpaceGuid.PcdFdtOverrideOverlayPath
113117

114118
gRK3588TokenSpaceGuid.PcdHasOnBoardFanOutput
115119
gRK3588TokenSpaceGuid.PcdCoolingFanState

edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588DxeHii.uni

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,38 @@
263263
#string STR_FDT_SUPPORT_OVERRIDES_PROMPT #language en-US "Support DTB override & overlays"
264264
#string STR_FDT_SUPPORT_OVERRIDES_HELP #language en-US "Enable or disable support for overriding the firmware-provided DTB and installing overlays.\n\nCheck firmware documentation for more details."
265265

266-
#string STR_FDT_OVERRIDE_FIXUP_PROMPT #language en-US "Fix-up DTB override"
266+
#string STR_FDT_OVERRIDE_SUBTITLE #language en-US "DTB Override"
267+
268+
#string STR_FDT_OVERRIDE_FIXUP_PROMPT #language en-US "Firmware Fix-ups"
267269
#string STR_FDT_OVERRIDE_FIXUP_HELP #language en-US "Enable or disable firmware fix-ups for the DTB override."
268270

271+
#string STR_FDT_OVERRIDE_BASE_PATH_PROMPT #language en-US "Preferred Base DTB Path"
272+
#string STR_FDT_OVERRIDE_BASE_PATH_HELP #language en-US "Enter the preferred file or directory path for the base DTB override, relative to the file system root.\n\n"
273+
"Once a boot device is selected, the firmware will scan all the supported file systems on it (FAT, ext4) and try to load the specified override.\n\n"
274+
"- If a directory path is specified, the platform FDT file name will be appended to it (<PLATFORM-DT-NAME>).\n"
275+
"- If a file path is specified, it will be used as is.\n"
276+
"- If no override exists, the firmware-provided DTB will be used instead.\n\n"
277+
"Examples:\n"
278+
" \\dtbs\n"
279+
" \\dtbs\\my-board.dtb\n\n"
280+
"Default alternative paths:\n"
281+
" \\dtb\n"
282+
" \\dtb\\base\n"
283+
" \\dtb\\rockchip\n\n"
284+
"To reset this option to the default value, set it to a space character, save and reboot."
285+
286+
#string STR_FDT_OVERRIDE_OVERLAY_PATH_PROMPT #language en-US "Preferred Overlays Path"
287+
#string STR_FDT_OVERRIDE_OVERLAY_PATH_HELP #language en-US "Enter the preferred directory path for the DTB overlays, relative to the file system root.\n\n"
288+
"Once a boot device is selected, the firmware will scan all the supported file systems on it (FAT, ext4) and try to load all overlays in the specified directory.\n\n"
289+
"- If the installation of an overlay fails, all other overlays will be discarded.\n\n"
290+
"Examples:\n"
291+
" \\my-overlays\n"
292+
" \\dtbs\\overlays\n\n"
293+
"Default alternative paths:\n"
294+
" \\dtb\\overlays\n"
295+
" \\dtb\\overlays\\<PLATFORM-DT-NAME>\n\n"
296+
"To reset this option to the default value, set it to a space character, save and reboot."
297+
269298
/*
270299
* Cooling fan configuration
271300
*/

edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588DxeHii.vfr

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@ formset
218218
name = FdtOverrideFixup,
219219
guid = RK3588DXE_FORMSET_GUID;
220220

221+
efivarstore FDT_OVERRIDE_PATH_VARSTORE_DATA,
222+
attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
223+
name = FdtOverrideBasePath,
224+
guid = RK3588DXE_FORMSET_GUID;
225+
226+
efivarstore FDT_OVERRIDE_PATH_VARSTORE_DATA,
227+
attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
228+
name = FdtOverrideOverlayPath,
229+
guid = RK3588DXE_FORMSET_GUID;
230+
221231
efivarstore COOLING_FAN_STATE_VARSTORE_DATA,
222232
attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
223233
name = CoolingFanState,
@@ -859,6 +869,9 @@ formset
859869
endoneof;
860870

861871
suppressif ideqval FdtSupportOverrides.State == 0;
872+
subtitle text = STRING_TOKEN(STR_NULL_STRING);
873+
subtitle text = STRING_TOKEN(STR_FDT_OVERRIDE_SUBTITLE);
874+
862875
oneof varid = FdtOverrideFixup,
863876
prompt = STRING_TOKEN(STR_FDT_OVERRIDE_FIXUP_PROMPT),
864877
help = STRING_TOKEN(STR_FDT_OVERRIDE_FIXUP_HELP),
@@ -867,6 +880,24 @@ formset
867880
option text = STRING_TOKEN(STR_DISABLED), value = FALSE, flags = 0;
868881
option text = STRING_TOKEN(STR_ENABLED), value = TRUE, flags = 0;
869882
endoneof;
883+
884+
subtitle text = STRING_TOKEN(STR_NULL_STRING);
885+
886+
string varid = FdtOverrideBasePath.Path,
887+
prompt = STRING_TOKEN(STR_FDT_OVERRIDE_BASE_PATH_PROMPT),
888+
help = STRING_TOKEN(STR_FDT_OVERRIDE_BASE_PATH_HELP),
889+
flags = INTERACTIVE | RESET_REQUIRED,
890+
minsize = 0,
891+
maxsize = FDT_OVERRIDE_PATH_MAX_LEN,
892+
endstring;
893+
894+
string varid = FdtOverrideOverlayPath.Path,
895+
prompt = STRING_TOKEN(STR_FDT_OVERRIDE_OVERLAY_PATH_PROMPT),
896+
help = STRING_TOKEN(STR_FDT_OVERRIDE_OVERLAY_PATH_HELP),
897+
flags = INTERACTIVE | RESET_REQUIRED,
898+
minsize = 0,
899+
maxsize = FDT_OVERRIDE_PATH_MAX_LEN,
900+
endstring;
870901
endif;
871902
endif;
872903
endform;

edk2-rockchip/Silicon/Rockchip/RK3588/Include/VarStoreData.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ typedef struct {
8989
UINT8 State;
9090
} FDT_SUPPORT_OVERRIDES_VARSTORE_DATA;
9191

92+
#define FDT_OVERRIDE_PATH_MAX_LEN 254
93+
#define FDT_OVERRIDE_PATH_MAX_SIZE 255
94+
typedef struct {
95+
CHAR16 Path[FDT_OVERRIDE_PATH_MAX_SIZE];
96+
} FDT_OVERRIDE_PATH_VARSTORE_DATA;
97+
9298
#define COOLING_FAN_STATE_DISABLED 0
9399
#define COOLING_FAN_STATE_ENABLED 1
94100
typedef struct {

edk2-rockchip/Silicon/Rockchip/RK3588/RK3588.dec

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
gRK3588TokenSpaceGuid.PcdFdtForceGopDefault|0|UINT8|0x00010352
5353
gRK3588TokenSpaceGuid.PcdFdtSupportOverridesDefault|0|UINT8|0x00010353
5454
gRK3588TokenSpaceGuid.PcdFdtOverrideFixupDefault|0|UINT8|0x00010354
55+
gRK3588TokenSpaceGuid.PcdFdtOverrideBasePathDefault|L""|VOID*|0x00010355
56+
gRK3588TokenSpaceGuid.PcdFdtOverrideOverlayPathDefault|L""|VOID*|0x00010356
5557

5658
gRK3588TokenSpaceGuid.PcdHasOnBoardFanOutput|FALSE|BOOLEAN|0x10401
5759

@@ -122,6 +124,18 @@
122124
gRK3588TokenSpaceGuid.PcdFdtForceGop|0|UINT8|0x00000352
123125
gRK3588TokenSpaceGuid.PcdFdtSupportOverrides|0|UINT8|0x00000353
124126
gRK3588TokenSpaceGuid.PcdFdtOverrideFixup|0|UINT8|0x00000354
127+
gRK3588TokenSpaceGuid.PcdFdtOverrideBasePath|{ 0x0 }|FDT_OVERRIDE_PATH_VARSTORE_DATA|0x00000355 {
128+
<Packages>
129+
Silicon/Rockchip/RK3588/RK3588.dec
130+
<HeaderFiles>
131+
VarStoreData.h
132+
}
133+
gRK3588TokenSpaceGuid.PcdFdtOverrideOverlayPath|{ 0x0 }|FDT_OVERRIDE_PATH_VARSTORE_DATA|0x00000356 {
134+
<Packages>
135+
Silicon/Rockchip/RK3588/RK3588.dec
136+
<HeaderFiles>
137+
VarStoreData.h
138+
}
125139

126140
gRK3588TokenSpaceGuid.PcdCoolingFanState|0|UINT32|0x00000401
127141
gRK3588TokenSpaceGuid.PcdCoolingFanSpeed|0|UINT32|0x00000402

edk2-rockchip/Silicon/Rockchip/RK3588/RK3588Base.dsc.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@
287287
gRK3588TokenSpaceGuid.PcdFdtForceGopDefault|FALSE
288288
gRK3588TokenSpaceGuid.PcdFdtSupportOverridesDefault|FALSE
289289
gRK3588TokenSpaceGuid.PcdFdtOverrideFixupDefault|TRUE
290+
gRK3588TokenSpaceGuid.PcdFdtOverrideBasePathDefault|L""
291+
gRK3588TokenSpaceGuid.PcdFdtOverrideOverlayPathDefault|L""
290292

291293
#
292294
# Display support flags and default values
@@ -375,6 +377,8 @@
375377
gRK3588TokenSpaceGuid.PcdFdtForceGop|L"FdtForceGop"|gRK3588DxeFormSetGuid|0x0|gRK3588TokenSpaceGuid.PcdFdtForceGopDefault
376378
gRK3588TokenSpaceGuid.PcdFdtSupportOverrides|L"FdtSupportOverrides"|gRK3588DxeFormSetGuid|0x0|gRK3588TokenSpaceGuid.PcdFdtSupportOverridesDefault
377379
gRK3588TokenSpaceGuid.PcdFdtOverrideFixup|L"FdtOverrideFixup"|gRK3588DxeFormSetGuid|0x0|gRK3588TokenSpaceGuid.PcdFdtOverrideFixupDefault
380+
gRK3588TokenSpaceGuid.PcdFdtOverrideBasePath|L"FdtOverrideBasePath"|gRK3588DxeFormSetGuid|0x0|{ 0x0 }
381+
gRK3588TokenSpaceGuid.PcdFdtOverrideOverlayPath|L"FdtOverrideOverlayPath"|gRK3588DxeFormSetGuid|0x0|{ 0x0 }
378382

379383
#
380384
# Cooling Fan

0 commit comments

Comments
 (0)