diff options
author | Ryan Harkin <ryan.harkin@linaro.org> | 2015-07-28 12:53:36 +0100 |
---|---|---|
committer | Ryan Harkin <ryan.harkin@linaro.org> | 2015-07-28 18:56:04 +0100 |
commit | ea31f8eb0ca0500212fc577c17b4a48e6d2656af (patch) | |
tree | 636987dfacd3b9ec9ad85b3a375b5c492fc6038b | |
parent | a2327c2ea41832c450184111712132ddb8307e04 (diff) |
ArmPkg: BdsLib: replace fixed pcds with constantsarmlt-20151026-001armlt-20150825armlt-15.10armlt-15.09armlt-15.0820150803-00115.1015.0915.08
BdsLib was using fixed PCDs where constants could easily perform that
same function.
This patch is based off an older Tiancore. A version based of the tip
of tree was posted to linaro-uefi for review:
https://lists.linaro.org/pipermail/linaro-uefi/2015-July/001019.html
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
-rw-r--r-- | ArmPkg/ArmPkg.dec | 19 | ||||
-rw-r--r-- | ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c | 8 | ||||
-rw-r--r-- | ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c | 2 | ||||
-rw-r--r-- | ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c | 20 | ||||
-rw-r--r-- | ArmPkg/Library/BdsLib/BdsLib.inf | 7 | ||||
-rw-r--r-- | ArmPkg/Library/BdsLib/BdsLinuxFdt.c | 14 | ||||
-rw-r--r-- | ArmPkg/Library/BdsLib/BdsLinuxLoader.h | 32 |
7 files changed, 49 insertions, 53 deletions
diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index ede7f881b8..4efc03d397 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -116,8 +116,6 @@ # BdsLib
#
gArmTokenSpaceGuid.PcdArmMachineType|0|UINT32|0x0000001E
- # The compressed Linux kernel is expected to be under 128MB from the beginning of the System Memory
- gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset|0x08000000|UINT32|0x0000001F
# Maximum file size for TFTP servers that do not support 'tsize' extension
gArmTokenSpaceGuid.PcdMaxTftpFileSize|0x01000000|UINT32|0x00000000
@@ -153,16 +151,6 @@ # By default we do not do a transition to non-secure mode
gArmTokenSpaceGuid.PcdArmNonSecModeTransition|0x0|UINT32|0x0000003E
- # The Linux ATAGs are expected to be under 0x4000 (16KB) from the beginning of the System Memory
- gArmTokenSpaceGuid.PcdArmLinuxAtagMaxOffset|0x4000|UINT32|0x00000020
-
- # If the fixed FDT address is not available, then it should be loaded below the kernel.
- # The recommendation from the Linux kernel is to have the FDT below 16KB.
- # (see the kernel doc: Documentation/arm/Booting)
- gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset|0x08400000|UINT32|0x00000023
- # The FDT blob must be loaded at a 64bit aligned address.
- gArmTokenSpaceGuid.PcdArmLinuxFdtAlignment|0x8|UINT32|0x00000026
-
# Non Secure Access Control Register
# - BIT15 : NSASEDIS - Disable Non-secure Advanced SIMD functionality
# - BIT14 : NSD32DIS - Disable Non-secure use of D16-D31
@@ -201,13 +189,6 @@ # Other modes include using SP0 or switching to Aarch32, but these are
# not currently supported.
gArmTokenSpaceGuid.PcdArmNonSecModeTransition|0x3c9|UINT32|0x0000003E
- # If the fixed FDT address is not available, then it should be loaded above the kernel.
- # The recommendation from the AArch64 Linux kernel is to have the FDT below 512MB.
- # (see the kernel doc: Documentation/arm64/booting.txt)
- gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset|0x20000000|UINT32|0x00000023
- # The FDT blob must be loaded at a 2MB aligned address.
- gArmTokenSpaceGuid.PcdArmLinuxFdtAlignment|0x00200000|UINT32|0x00000026
-
#
# These PCDs are also defined as 'PcdsDynamic' or 'PcdsPatchableInModule' to be
diff --git a/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c b/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c index a5f0c6fb00..d12a26e121 100644 --- a/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c +++ b/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c @@ -228,12 +228,12 @@ BdsBootLinuxFdt ( //
// Try to put the kernel at the start of RAM so as to give it access to all memory.
- // If that fails fall back to try loading it within LINUX_KERNEL_MAX_OFFSET of memory start.
+ // If that fails fall back to try loading it within LINUX_KERNEL_MAX_ADDR of memory start.
LinuxImage = PcdGet64 (PcdSystemMemoryBase) + 0x80000;
Status = BdsLoadImage (LinuxKernelDevicePath, AllocateAddress, &LinuxImage, &LinuxImageSize);
if (EFI_ERROR(Status)) {
// Try again but give the loader more freedom of where to put the image.
- LinuxImage = LINUX_KERNEL_MAX_OFFSET;
+ LinuxImage = LINUX_KERNEL_MAX_ADDR;
Status = BdsLoadImage (LinuxKernelDevicePath, AllocateMaxAddress, &LinuxImage, &LinuxImageSize);
if (EFI_ERROR(Status)) {
Print (L"ERROR: Did not find Linux kernel (%r).\n", Status);
@@ -247,7 +247,7 @@ BdsBootLinuxFdt ( }
if (InitrdDevicePath) {
- InitrdImageBase = LINUX_KERNEL_MAX_OFFSET;
+ InitrdImageBase = LINUX_INITRD_MAX_ADDR;
Status = BdsLoadImage (InitrdDevicePath, AllocateMaxAddress, &InitrdImageBase, &InitrdImageBaseSize);
if (Status == EFI_OUT_OF_RESOURCES) {
Status = BdsLoadImage (InitrdDevicePath, AllocateAnyPages, &InitrdImageBase, &InitrdImageBaseSize);
@@ -270,7 +270,7 @@ BdsBootLinuxFdt ( // Load the FDT binary from a device path.
// The FDT will be reloaded later to a more appropriate location for the Linux kernel.
- FdtBlobBase = LINUX_KERNEL_MAX_OFFSET;
+ FdtBlobBase = LINUX_KERNEL_MAX_ADDR;
Status = BdsLoadImage (FdtDevicePath, AllocateMaxAddress, &FdtBlobBase, &FdtBlobSize);
if (EFI_ERROR(Status)) {
Print (L"ERROR: Did not find Device Tree blob (%r).\n", Status);
diff --git a/ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c b/ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c index 33c27988ad..72c034b59c 100644 --- a/ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c +++ b/ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c @@ -128,7 +128,7 @@ PrepareAtagList ( EFI_PHYSICAL_ADDRESS AtagStartAddress;
BDS_SYSTEM_MEMORY_RESOURCE *Resource;
- AtagStartAddress = LINUX_ATAG_MAX_OFFSET;
+ AtagStartAddress = LINUX_ATAG_MAX_ADDR;
Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData, EFI_SIZE_TO_PAGES(ATAG_MAX_SIZE), &AtagStartAddress);
if (EFI_ERROR(Status)) {
DEBUG ((EFI_D_WARN, "Warning: Failed to allocate Atag at 0x%lX (%r). The Atag will be allocated somewhere else in System Memory.\n", AtagStartAddress, Status));
diff --git a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c b/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c index ebfcf40827..2c74772837 100644 --- a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c +++ b/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c @@ -74,18 +74,18 @@ StartLinux ( // physical memory.
//Note: There is no requirement on the alignment
if (MachineType != ARM_FDT_MACHINE_TYPE) {
- if (((UINTN)KernelParamsAddress > LINUX_ATAG_MAX_OFFSET) && (KernelParamsSize < PcdGet32(PcdArmLinuxAtagMaxOffset))) {
- KernelParamsAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CopyMem (ALIGN32_BELOW(LINUX_ATAG_MAX_OFFSET - KernelParamsSize), (VOID*)(UINTN)KernelParamsAddress, KernelParamsSize);
+ if (((UINTN)KernelParamsAddress > LINUX_ATAG_MAX_ADDR) && (KernelParamsSize < LINUX_ATAG_MAX_OFFSET)) {
+ KernelParamsAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CopyMem (ALIGN32_BELOW(LINUX_ATAG_MAX_ADDR - KernelParamsSize), (VOID*)(UINTN)KernelParamsAddress, KernelParamsSize);
}
} else {
- if (((UINTN)KernelParamsAddress > LINUX_FDT_MAX_OFFSET) && (KernelParamsSize < PcdGet32(PcdArmLinuxFdtMaxOffset))) {
- KernelParamsAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CopyMem (ALIGN32_BELOW(LINUX_FDT_MAX_OFFSET - KernelParamsSize), (VOID*)(UINTN)KernelParamsAddress, KernelParamsSize);
+ if (((UINTN)KernelParamsAddress > LINUX_FDT_MAX_ADDR) && (KernelParamsSize < LINUX_FDT_MAX_OFFSET)) {
+ KernelParamsAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CopyMem (ALIGN32_BELOW(LINUX_FDT_MAX_ADDR - KernelParamsSize), (VOID*)(UINTN)KernelParamsAddress, KernelParamsSize);
}
}
- if ((UINTN)LinuxImage > LINUX_KERNEL_MAX_OFFSET) {
+ if ((UINTN)LinuxImage > LINUX_KERNEL_MAX_ADDR) {
//Note: There is no requirement on the alignment
- LinuxKernel = (LINUX_KERNEL)CopyMem (ALIGN32_BELOW(LINUX_KERNEL_MAX_OFFSET - LinuxImageSize), (VOID*)(UINTN)LinuxImage, LinuxImageSize);
+ LinuxKernel = (LINUX_KERNEL)CopyMem (ALIGN32_BELOW(LINUX_KERNEL_MAX_ADDR - LinuxImageSize), (VOID*)(UINTN)LinuxImage, LinuxImageSize);
} else {
LinuxKernel = (LINUX_KERNEL)(UINTN)LinuxImage;
}
@@ -174,7 +174,7 @@ BdsBootLinuxAtag ( PERF_START (NULL, "BDS", NULL, 0);
// Load the Linux kernel from a device path
- LinuxImage = LINUX_KERNEL_MAX_OFFSET;
+ LinuxImage = LINUX_KERNEL_MAX_ADDR;
Status = BdsLoadImage (LinuxKernelDevicePath, AllocateMaxAddress, &LinuxImage, &LinuxImageSize);
if (EFI_ERROR(Status)) {
Print (L"ERROR: Did not find Linux kernel.\n");
@@ -183,7 +183,7 @@ BdsBootLinuxAtag ( if (InitrdDevicePath) {
// Load the initrd near to the Linux kernel
- InitrdImageBase = LINUX_FDT_MAX_OFFSET;
+ InitrdImageBase = LINUX_INITRD_MAX_ADDR;
Status = BdsLoadImage (InitrdDevicePath, AllocateMaxAddress, &InitrdImageBase, &InitrdImageBaseSize);
if (Status == EFI_OUT_OF_RESOURCES) {
Status = BdsLoadImage (InitrdDevicePath, AllocateAnyPages, &InitrdImageBase, &InitrdImageBaseSize);
@@ -261,7 +261,7 @@ BdsBootLinuxFdt ( PERF_START (NULL, "BDS", NULL, 0);
// Load the Linux kernel from a device path
- LinuxImage = LINUX_KERNEL_MAX_OFFSET;
+ LinuxImage = LINUX_KERNEL_MAX_ADDR;
Status = BdsLoadImage (LinuxKernelDevicePath, AllocateMaxAddress, &LinuxImage, &LinuxImageSize);
if (EFI_ERROR(Status)) {
Print (L"ERROR: Did not find Linux kernel.\n");
@@ -269,7 +269,7 @@ BdsBootLinuxFdt ( }
if (InitrdDevicePath) {
- InitrdImageBase = LINUX_FDT_MAX_OFFSET;
+ InitrdImageBase = LINUX_INITRD_MAX_ADDR;
Status = BdsLoadImage (InitrdDevicePath, AllocateMaxAddress, &InitrdImageBase, &InitrdImageBaseSize);
if (Status == EFI_OUT_OF_RESOURCES) {
Status = BdsLoadImage (InitrdDevicePath, AllocateAnyPages, &InitrdImageBase, &InitrdImageBaseSize);
diff --git a/ArmPkg/Library/BdsLib/BdsLib.inf b/ArmPkg/Library/BdsLib/BdsLib.inf index ecf6de52d0..0d4f04970d 100644 --- a/ArmPkg/Library/BdsLib/BdsLib.inf +++ b/ArmPkg/Library/BdsLib/BdsLib.inf @@ -91,15 +91,8 @@ [FixedPcd]
gArmTokenSpaceGuid.PcdArmMachineType
- gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset
- gArmTokenSpaceGuid.PcdArmLinuxFdtAlignment
- gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset
-
gArmTokenSpaceGuid.PcdMaxTftpFileSize
-[FixedPcd.ARM]
- gArmTokenSpaceGuid.PcdArmLinuxAtagMaxOffset
-
[Pcd.AARCH64]
gArmTokenSpaceGuid.PcdGicDistributorBase
gArmTokenSpaceGuid.PcdGicSgiIntId
diff --git a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c index e3795527f2..3baf162d47 100644 --- a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c +++ b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c @@ -231,20 +231,16 @@ RelocateFdt ( {
EFI_STATUS Status;
INTN Error;
- UINT64 FdtAlignment;
*RelocatedFdtSize = OriginalFdtSize + FDT_ADDITIONAL_ENTRIES_SIZE;
// If FDT load address needs to be aligned, allocate more space.
- FdtAlignment = PcdGet32 (PcdArmLinuxFdtAlignment);
- if (FdtAlignment != 0) {
- *RelocatedFdtSize += FdtAlignment;
- }
+ *RelocatedFdtSize += LINUX_FDT_ALIGNMENT;
// Try below a watermark address.
Status = EFI_NOT_FOUND;
- if (PcdGet32 (PcdArmLinuxFdtMaxOffset) != 0) {
- *RelocatedFdt = LINUX_FDT_MAX_OFFSET;
+ if (LINUX_FDT_MAX_OFFSET != 0) {
+ *RelocatedFdt = LINUX_FDT_MAX_ADDR;
Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData,
EFI_SIZE_TO_PAGES (*RelocatedFdtSize), RelocatedFdt);
if (EFI_ERROR (Status)) {
@@ -265,8 +261,8 @@ RelocateFdt ( }
*RelocatedFdtAlloc = *RelocatedFdt;
- if (FdtAlignment != 0) {
- *RelocatedFdt = ALIGN (*RelocatedFdt, FdtAlignment);
+ if (LINUX_FDT_ALIGNMENT != 0) {
+ *RelocatedFdt = ALIGN (*RelocatedFdt, LINUX_FDT_ALIGNMENT);
}
// Load the Original FDT tree into the new region
diff --git a/ArmPkg/Library/BdsLib/BdsLinuxLoader.h b/ArmPkg/Library/BdsLib/BdsLinuxLoader.h index b78f606129..e8f5590ea6 100644 --- a/ArmPkg/Library/BdsLib/BdsLinuxLoader.h +++ b/ArmPkg/Library/BdsLib/BdsLinuxLoader.h @@ -16,9 +16,35 @@ #define __BDSLINUXLOADER_H
#define LINUX_UIMAGE_SIGNATURE 0x56190527
-#define LINUX_KERNEL_MAX_OFFSET (PcdGet64 (PcdSystemMemoryBase) + PcdGet32(PcdArmLinuxKernelMaxOffset))
-#define LINUX_ATAG_MAX_OFFSET (PcdGet64 (PcdSystemMemoryBase) + PcdGet32(PcdArmLinuxAtagMaxOffset))
-#define LINUX_FDT_MAX_OFFSET (PcdGet64 (PcdSystemMemoryBase) + PcdGet32(PcdArmLinuxFdtMaxOffset))
+
+#if defined (MDE_CPU_ARM)
+ // On ARM, the kernel recommendations say that the kernel should live before
+ // the 128MiB (0x08000000) boundary.
+ #define LINUX_KERNEL_MAX_OFFSET 0x08000000
+
+ // ATAGS data should be in the first 16KB
+ #define LINUX_ATAG_MAX_OFFSET 0x00004000
+
+ // The device tree and initrd should live after the 128MiB boundary.
+ #define LINUX_FDT_MAX_OFFSET 0x08400000
+ #define LINUX_INITRD_MAX_OFFSET 0x08400000
+ #define LINUX_FDT_ALIGNMENT 0x00000008
+#elif defined (MDE_CPU_AARCH64)
+ #define LINUX_KERNEL_MAX_OFFSET 0x08000000
+
+ // arm64 Kernels prior to v4.2 required the device tree to reside in the
+ // first 512MB of memory
+ #define LINUX_FDT_MAX_OFFSET 0x20000000
+ #define LINUX_INITRD_MAX_OFFSET 0x20000000
+
+ // Recommendations are to align the FDT to 2MiB
+ #define LINUX_FDT_ALIGNMENT 0x00200000
+#endif
+
+#define LINUX_KERNEL_MAX_ADDR (PcdGet64 (PcdSystemMemoryBase) + LINUX_KERNEL_MAX_OFFSET)
+#define LINUX_ATAG_MAX_ADDR (PcdGet64 (PcdSystemMemoryBase) + LINUX_ATAG_MAX_OFFSET)
+#define LINUX_FDT_MAX_ADDR (PcdGet64 (PcdSystemMemoryBase) + LINUX_FDT_MAX_OFFSET)
+#define LINUX_INITRD_MAX_ADDR (PcdGet64 (PcdSystemMemoryBase) + LINUX_INITRD_MAX_OFFSET)
// Additional size that could be used for FDT entries added by the UEFI OS Loader
// Estimation based on: EDID (300bytes) + bootargs (200bytes) + initrd region (20bytes)
|