[edk2-platforms] [PATCH V1] PurleyOpenBoardPkg : Support for LINUX Boot


manickavasakam karpagavinayagam
 

Support for LINUX Boot
To enable/disable feature, PcdLinuxBootEnable can be used
1. Follow directions on http://osresearch.net/Building/ to compile the heads kernel and initrd for qemu-system_x86_64
2. Copy the following built files
(1) initrd.cpio.xz to LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
(2) bzimage to LinuxBootPkg/LinuxBinaries/linux.efi
---
.../BoardTiogaPass/CoreDxeInclude.dsc | 5 +-
.../BoardTiogaPass/CoreUefiBootInclude.fdf | 5 +-
.../BoardTiogaPass/OpenBoardPkg.dsc | 7 +
.../BoardTiogaPass/OpenBoardPkg.fdf | 57 ++-
.../BoardTiogaPass/PlatformPkgConfig.dsc | 7 +
.../LinuxBinaries/LinuxKernel.inf | 9 +
.../LinuxBootPkg/LinuxBinaries/initrd.cpio.xz | Bin 0 -> 16 bytes
.../LinuxBootPkg/LinuxBinaries/linux.efi | Bin 0 -> 16 bytes
.../LinuxBootPkg/LinuxBoot.c | 422 ++++++++++++++++++
.../LinuxBootPkg/LinuxBoot.h | 193 ++++++++
.../LinuxBootPkg/LinuxBoot.inf | 46 ++
.../LinuxBootPkg/LinuxBootNull.c | 43 ++
.../LinuxBootPkg/LinuxBootNull.inf | 31 ++
.../Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec | 2 +
.../DxePlatformBootManagerLib/BdsPlatform.c | 9 +
.../DxePlatformBootManagerLib.inf | 2 +
Platform/Intel/Readme.md | 42 ++
17 files changed, 872 insertions(+), 8 deletions(-)
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/LinuxKernel.inf
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/linux.efi
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.c
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.h
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.inf
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.c
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.inf

diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
index b0660d72dd..a17015704b 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
@@ -83,6 +83,7 @@
$(PLATFORM_BOARD_PACKAGE)/Override/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
#TiogaPass Override END

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
@@ -97,10 +98,11 @@
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
FatPkg/EnhancedFatDxe/Fat.inf
-
+!endif
#MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

@@ -124,6 +126,7 @@
<LibraryClasses>
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
}
+!endif

!if gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly == FALSE
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclude.fdf b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclude.fdf
index 141ce5dda3..6cd8ba6626 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclude.fdf
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclude.fdf
@@ -47,6 +47,7 @@ INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
INF $(PLATFORM_BOARD_PACKAGE)/Override/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
#TiogaPass Override END

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
@@ -62,10 +63,12 @@ INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
INF FatPkg/EnhancedFatDxe/Fat.inf
+!endif

#INF MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

@@ -79,4 +82,4 @@ INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf

INF MdeModulePkg/Application/UiApp/UiApp.inf
INF MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
-
+!endif
diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
index e4c8e7fbf1..06ed3f610e 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
@@ -104,6 +104,13 @@
################################################################################

[LibraryClasses.common]
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+ LinuxBootLib|$(PLATFORM_BOARD_PACKAGE)/LinuxBootPkg/LinuxBoot.inf
+ LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
+!else
+ LinuxBootLib|$(PLATFORM_BOARD_PACKAGE)/LinuxBootPkg/LinuxBootNull.inf
+!endif
+
!if gPlatformTokenSpaceGuid.PcdFastBoot == FALSE
PlatformBootManagerLib|$(PLATFORM_PACKAGE)/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
!else
diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
index 43cd8d94e1..adbf28a936 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
@@ -19,6 +19,38 @@
# Also all values will have a PCD assigned so that they can be used in the system, and
# the FlashMap edit tool can be used to change the values here, without effecting the code.
# This requires all code to only use the PCD tokens to recover the values.
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset = 0x00000000 # Flash addr (0xFF840000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize = 0x00300000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset = 0x00300000 # Flash addr (0xFF8A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset = 0x00400000 # Flash addr (0xFF910000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset = 0x00500000 # Flash addr (0xFFE00000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset = 0x00600000 # Flash addr (0xFF9A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize = 0x00600000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset = 0x00C00000 # Flash addr (0xFF800000)
+SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize = 0x0007C000 #
+
+!else
+
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset = 0x00000000 # Flash addr (0xFF840000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize = 0x00500000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset = 0x00500000 # Flash addr (0xFF8A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset = 0x00600000 # Flash addr (0xFF910000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset = 0x00700000 # Flash addr (0xFFE00000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize = 0x00200000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset = 0x00900000 # Flash addr (0xFF9A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize = 0x00300000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset = 0x00C00000 # Flash addr (0xFF800000)
+SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize = 0x0007C000 #
+
+!endif
+

[FD.Platform]
BaseAddress = 0xFF000000 | gEfiPchTokenSpaceGuid.PcdFlashAreaBaseAddress
@@ -27,27 +59,27 @@ ErasePolarity = 1
BlockSize = 0x10000
NumBlocks = 0x100

-0x00000000|0x00500000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize
FV = FvAdvanced

-0x00500000|0x00100000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize
FV = FvSecurity

-0x00600000|0x00100000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize
FV = FvOsBoot

-0x00700000|0x00200000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize
FV = FvLateSiliconCompressed

-0x00900000|0x00300000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize
FV = FvUefiBoot

-0x00C00000|0x0007C000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
#NV_VARIABLE_STORE
DATA = {
@@ -303,6 +335,19 @@ FILE DRIVER = db90bb7e-e4ba-4f07-96d6-b7076713bd2c {

INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+
+FILE DRIVER = 81339b04-fa8c-4be0-9ca7-916fc5319eb5 {
+ SECTION DXE_DEPEX_EXP = {FALSE}
+ SECTION PE32 = $(PLATFORM_BOARD_PACKAGE)/LinuxBootPkg/LinuxBinaries/linux.efi
+}
+
+FILE FREEFORM = 16b60e5d-f1c5-42f0-9b34-08C81C430473 {
+ SECTION RAW = $(PLATFORM_BOARD_PACKAGE)/LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
+}
+
+!endif
+

[FV.FvUefiBoot]
FvAlignment = 16
diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.dsc b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.dsc
index 36a29c8d68..ff27252233 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.dsc
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.dsc
@@ -51,7 +51,14 @@

gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable|TRUE

+ gPlatformTokenSpaceGuid.PcdLinuxBootEnable|FALSE
+
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+ gPlatformTokenSpaceGuid.PcdFastBoot|TRUE
+!else
gPlatformTokenSpaceGuid.PcdFastBoot|FALSE
+!endif
+
!if gPlatformTokenSpaceGuid.PcdFastBoot == TRUE
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable|FALSE
gPlatformTokenSpaceGuid.PcdUpdateConsoleInBds|FALSE
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/LinuxKernel.inf b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/LinuxKernel.inf
new file mode 100644
index 0000000000..a249027d22
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/LinuxKernel.inf
@@ -0,0 +1,9 @@
+[Defines]
+ INF_VERSION = 1.27
+ BASE_NAME = LinuxKernel
+ FILE_GUID = 81339b04-fa8c-4be0-9ca7-916fc5319eb5
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+
+[Binaries.common.AARCH64]
+ PE32|linux.efi|*
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/initrd.cpio.xz b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
new file mode 100644
index 0000000000000000000000000000000000000000..01d633b27e8ea9b17084fc911d0c8cc43a4170a9
GIT binary patch
literal 16
KcmZQzKm`B*5C8!H

literal 0
HcmV?d00001

diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/linux.efi b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/linux.efi
new file mode 100644
index 0000000000000000000000000000000000000000..01d633b27e8ea9b17084fc911d0c8cc43a4170a9
GIT binary patch
literal 16
KcmZQzKm`B*5C8!H

literal 0
HcmV?d00001

diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.c b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.c
new file mode 100644
index 0000000000..eec05824d6
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.c
@@ -0,0 +1,422 @@
+/** @file
+
+Copyright (c) 2021, American Megatrends International LLC. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/**
+ *
+ * This library will load the Linux kernel and initrd from the BIOS and launch it.
+ *
+ */
+
+//---------------------------------------------------------------------------
+
+#include <PiDxe.h>
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Guid/DxeServices.h>
+#include <Library/DxeServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Protocol/FirmwareVolume2.h>
+#include <Protocol/LoadedImage.h>
+#include <Guid/MemoryTypeInformation.h>
+#include <Pi/PiDxeCis.h>
+#include <Pi/PiHob.h>
+#include <Library/PcdLib.h>
+#include <Library/DxeServicesLib.h>
+#include "LinuxBoot.h"
+
+//16b60e5d-f1c5-42f0-9b34-08C81C430473
+#define LINUX_BOOT_INITRD_GUID \
+ { \
+ 0x16b60e5d, 0xf1c5, 0x42f0, {0x9b, 0x34, 0x08, 0xc8, 0x1c, 0x43, 0x04, 0x73} \
+ }
+
+#define LINUX_BOOT_KERNEL_GUID \
+ { \
+ 0x81339b04, 0xfa8c, 0x4be0, {0x9c, 0xa7, 0x91, 0x6f, 0xc5, 0x31, 0x9e, 0xb5} \
+ }
+
+
+EFI_STATUS
+EFIAPI
+LoadLinuxCheckKernelSetup (
+ IN VOID *KernelSetup,
+ IN UINTN KernelSetupSize
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateKernelSetupPages (
+ IN UINTN Pages
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinuxInitializeKernelSetup (
+ IN VOID *KernelSetup
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateKernelPages (
+ IN VOID *KernelSetup,
+ IN UINTN Pages
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinuxSetCommandLine (
+ IN OUT VOID *KernelSetup,
+ IN CHAR8 *CommandLine
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinux (
+ IN VOID *Kernel,
+ IN OUT VOID *KernelSetup
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateInitrdPages (
+ IN VOID *KernelSetup,
+ IN UINTN Pages
+ );
+
+EFI_GUID gLinuxBootInitrdFileGuid = LINUX_BOOT_INITRD_GUID;
+
+EFI_GUID gLinuxBootKernelFileGuid = LINUX_BOOT_KERNEL_GUID;
+
+//---------------------------------------------------------------------------
+
+/**
+ Dump some hexadecimal data to the screen.
+
+ @note Function taken from ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c in EDKII
+
+ @param[in] Indent How many spaces to indent the output.
+ @param[in] Offset The offset of the printing.
+ @param[in] DataSize The size in bytes of UserData.
+ @param[in] UserData The data to print out.
+**/
+static
+VOID
+DumpHex (
+ IN UINTN Indent,
+ IN UINTN Offset,
+ IN UINTN DataSize,
+ IN VOID *UserData
+ )
+{
+ UINT8 *Data;
+ CHAR8 Val[50];
+ CHAR8 Str[20];
+ UINT8 TempByte;
+ UINTN Size;
+ UINTN Index;
+ CHAR8 Hex[] = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
+ };
+
+ DEBUG((DEBUG_INFO, "%*a 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n", Indent, ""));
+ DEBUG((DEBUG_INFO, "%*a ------------------------------------------------\n", Indent, ""));
+
+ Data = UserData;
+ while (DataSize != 0) {
+ Size = 16;
+ if (Size > DataSize) {
+ Size = DataSize;
+ }
+
+ for (Index = 0; Index < Size; Index += 1) {
+ TempByte = Data[Index];
+ Val[Index * 3 + 0] = Hex[TempByte >> 4];
+ Val[Index * 3 + 1] = Hex[TempByte & 0xF];
+ Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' ');
+ Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
+ }
+
+ Val[Index * 3] = 0;
+ Str[Index] = 0;
+ DEBUG((DEBUG_INFO, "%*a%08X: %-48a %a\n", Indent, "", Offset, Val, Str));
+
+ Data += Size;
+ Offset += Size;
+ DataSize -= Size;
+ }
+}
+
+
+/**
+ * This function completes a minimal amount of the necessary BDS functions to prepare
+ * for booting the kernel.
+ *
+ * @param None
+ *
+ * @retval EFI_SUCCESS Successfully completed remaining tasks
+ * @return EFI_ERROR Could not complete BDS tasks
+ */
+EFI_STATUS
+CompleteBdsTasks (
+ VOID
+)
+{
+
+ return EFI_SUCCESS;
+}
+
+/**
+ * This function will load and launch the Linux kernel from a BIOS FV.
+ *
+ * @note This function is not intended to return. Any exiting from this function indicates
+ * a problem loading or launching the kernel.
+ *
+ * @param None
+ *
+ * @return EFI_ERROR Any error code
+ */
+EFI_STATUS
+LoadAndLaunchKernel (
+ VOID
+)
+{
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage = NULL;
+ EFI_STATUS Status;
+ EFI_HANDLE KernelHandle = NULL;
+ VOID *KernelBuffer = NULL;
+ VOID *KernelFfsBuffer = NULL;
+ UINTN KernelFfsSize = 0;
+ VOID *InitrdData = NULL;
+ VOID *InitrdBuffer = NULL;
+ UINTN InitrdSize = 0;
+ struct boot_params *BootParams = NULL;
+ struct boot_params *HandoverParams = NULL;
+ UINT32 StartOffset = 0;
+ UINT32 KernelLength = 0;
+ UINT8 *Temp;
+ UINT8 CmdLine[] = " ";
+
+ DEBUG((DEBUG_INFO, "LoadAndLaunchKernel Entry\n"));
+
+ ///
+ /// Kernel load and preparation
+ ///
+ DEBUG((DEBUG_INFO, "Preparing the kernel...\n"));
+
+ // Retrieve the kernel from the firmware volume
+ Status = GetSectionFromAnyFv(
+ &gLinuxBootKernelFileGuid,
+ EFI_SECTION_PE32,
+ 0,
+ &KernelFfsBuffer,
+ &KernelFfsSize
+ );
+
+ DEBUG((DEBUG_INFO, "Status %r\n",Status));
+ DEBUG((DEBUG_INFO, "KernelFfsBuffer %x\n",KernelFfsBuffer));
+ DEBUG((DEBUG_INFO, "KernelFfsSize %x\n",KernelFfsSize));
+
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not retrieve kernel; %r.\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Loaded kernel to buffer at 0x%p with size 0x%X.\n", KernelFfsBuffer, KernelFfsSize));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes:\n", MIN(KernelFfsSize, 0x100)));
+
+ DumpHex(2, 0, MIN(0x100, KernelFfsSize), KernelFfsBuffer);
+
+ // Create a LoadImage protocol for the kernel
+ Status = gBS->LoadImage(TRUE, gImageHandle, NULL, KernelFfsBuffer, KernelFfsSize, &KernelHandle);
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not create LoadImage for kernel %r\n", Status));
+ goto FatalError;
+ }
+
+ // Get the new LoadedImage protocol to retrieve information about the kernel
+ Status = gBS->HandleProtocol(KernelHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not get kernel LoadedImage protocol; %r\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Kernel LoadedImage information:\n"));
+ DEBUG((DEBUG_INFO, " ImageBase = 0x%p\n", LoadedImage->ImageBase));
+ DEBUG((DEBUG_INFO, " ImageSize = 0x%p\n", LoadedImage->ImageSize));
+
+ // Verify the kernel boot parameters from the LoadedImage and allocate an initalization buffer once verified
+ BootParams = (struct boot_params*) LoadedImage->ImageBase;
+
+ Status = LoadLinuxCheckKernelSetup((VOID *) BootParams, sizeof(struct boot_params));
+ if (EFI_ERROR (Status)) {
+ DEBUG((DEBUG_ERROR, "LoadLinuxCheckKernelSetup failed; %r.\n", Status));
+ goto FatalError;
+ }
+
+ HandoverParams = LoadLinuxAllocateKernelSetupPages(EFI_SIZE_TO_PAGES(KERNEL_SETUP_SIZE));
+ if (HandoverParams == NULL) {
+ DEBUG((DEBUG_ERROR, "Could not allocate memory for kernel handover parameters.\n"));
+ goto FatalError;
+ }
+ DEBUG((DEBUG_INFO, "Handover parameters allocated at 0x%p\n", HandoverParams));
+
+ gBS->CopyMem(&HandoverParams->hdr, &BootParams->hdr, sizeof(struct setup_header));
+
+ Status = LoadLinuxInitializeKernelSetup(HandoverParams);
+ if (EFI_ERROR (Status)) {
+ DEBUG((DEBUG_ERROR, "Unable to initialize the handover parameters; %r.\n", Status));
+ goto FatalError;
+ }
+
+ // Allocate space for the kernel and copy it into the new buffer
+ KernelBuffer = LoadLinuxAllocateKernelPages(HandoverParams, EFI_SIZE_TO_PAGES(HandoverParams->hdr.init_size));
+ if (KernelBuffer == NULL) {
+ DEBUG((DEBUG_ERROR, "Unable to allocate memory for kernel.\n"));
+ goto FatalError;
+ }
+
+ StartOffset = (HandoverParams->hdr.setup_secs + 1) * 512;
+ KernelLength = (UINT32) (KernelFfsSize - StartOffset);
+ Temp = (UINT8 *) LoadedImage->ImageBase;
+
+ DEBUG((DEBUG_INFO, "Kernel starts at offset 0x%X with length 0x%X\n", StartOffset, KernelLength));
+
+ gBS->CopyMem(KernelBuffer, (Temp + StartOffset), KernelLength);
+ DEBUG((DEBUG_INFO, "First 0x%X bytes of new kernel buffer contents:\n", MIN(0x100, KernelLength)));
+
+ DumpHex(2, 0, MIN(0x100, KernelLength), KernelBuffer);
+
+ // Prepare the command line
+ Status = LoadLinuxSetCommandLine(HandoverParams, (UINT8 *) &CmdLine);
+ if (EFI_ERROR (Status)) {
+ DEBUG((EFI_D_INFO, "Unable to set linux command line; %r.\n", Status));
+ goto FatalError;
+ }
+
+ HandoverParams->hdr.code32_start = (UINT32)(UINTN) KernelBuffer;
+ HandoverParams->hdr.loader_id = 0x21;
+
+ DEBUG((DEBUG_INFO, "Kernel loaded.\n"));
+
+#if 1
+//#if defined(INTEGRATED_INITRAM_FS) && (INTEGRATED_INITRAM_FS ==0)
+ ///
+ /// Initrd load and preparation
+ ///
+ DEBUG((DEBUG_INFO, "Preparing the initrd...\n"));
+
+ // Retrieve the initrd from the firmware volume
+ Status = GetSectionFromAnyFv(
+ &gLinuxBootInitrdFileGuid,
+ EFI_SECTION_RAW,
+ 0,
+ &InitrdBuffer,
+ &InitrdSize
+ );
+
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not retrieve initrd; %r.\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Loaded initrd to buffer at 0x%p with size 0x%X.\n", InitrdBuffer, InitrdSize));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes:\n", MIN(0x100, InitrdSize)));
+ DumpHex(2, 0, MIN(0x100, InitrdSize), InitrdBuffer);
+
+ // Allocate the initrd for the kernel and copy it in
+ InitrdData = LoadLinuxAllocateInitrdPages(HandoverParams, EFI_SIZE_TO_PAGES(InitrdSize));
+ if (InitrdData == NULL) {
+ DEBUG((DEBUG_ERROR, "Unable to allocate memory for initrd.\n"));
+ goto FatalError;
+ }
+
+ gBS->CopyMem(InitrdData, InitrdBuffer, InitrdSize);
+
+ HandoverParams->hdr.ramdisk_start = (UINT32)(UINTN) InitrdData;
+ HandoverParams->hdr.ramdisk_len = (UINT32) InitrdSize;
+
+ DEBUG((DEBUG_INFO, "Initrd loaded.\n"));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes of initrd buffer:\n", MIN(0x100, InitrdSize)));
+ DumpHex(2, 0, MIN(0x100, InitrdSize), InitrdData);
+
+ // General cleanup before launching the kernel
+ gBS->FreePool(InitrdBuffer);
+ InitrdBuffer = NULL;
+#endif
+
+ gBS->UnloadImage(KernelHandle);
+ gBS->FreePool(KernelFfsBuffer);
+ KernelFfsBuffer = NULL;
+
+ DEBUG((DEBUG_ERROR, "Launching the kernel\n"));
+
+
+ //
+ // Signal the EFI_EVENT_GROUP_READY_TO_BOOT event.
+ //
+ EfiSignalEventReadyToBoot();
+
+
+ // Launch the kernel
+ Status = LoadLinux(KernelBuffer, HandoverParams);
+
+ ///
+ /// LoadLinux should never return if the kernel boots. Anything past here is an error scenario
+ ///
+ DEBUG((DEBUG_ERROR, "ERROR: LoadLinux has returned with status; %r.\n", Status));
+
+FatalError:
+ // Free everything
+ if (InitrdData != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS) InitrdData, EFI_SIZE_TO_PAGES(InitrdSize));
+ if (KernelBuffer != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS) KernelBuffer, EFI_SIZE_TO_PAGES(HandoverParams->hdr.init_size));
+ if (HandoverParams != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS) HandoverParams, EFI_SIZE_TO_PAGES(KERNEL_SETUP_SIZE));
+ if (InitrdBuffer != NULL) gBS->FreePool(InitrdBuffer);
+ if (KernelHandle != NULL) gBS->UnloadImage(KernelHandle);
+ if (KernelFfsBuffer != NULL) gBS->FreePool(KernelFfsBuffer);
+
+ return EFI_NOT_FOUND;
+}
+
+/**
+ * This is the main function for this feature. This will handle finding and launching
+ * the Linux kernel.
+ *
+ * @note In general, this function will never return to BDS. The LINUXBOOT_ALLOW_RETURN_TO_BDS
+ * token will allow you to return to BDS if the kernel fails to launch for some reason.
+ *
+ * @param None
+ *
+ * @retval None
+ */
+
+EFI_STATUS
+LinuxBootStart (
+ VOID
+ )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ // Finish BDS and then try to launch the kernel
+ //Status = CompleteBdsTasks();
+
+ if (!EFI_ERROR(Status)) {
+ LoadAndLaunchKernel();
+ }
+
+ DEBUG((DEBUG_ERROR, "-----------------------------------\n"));
+ DEBUG((DEBUG_ERROR, " ERROR: Kernel failed to launch.\n"));
+ DEBUG((DEBUG_ERROR, "-----------------------------------\n"));
+ return Status;
+}
+
+//---------------------------------------------------------------------------
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.h b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.h
new file mode 100644
index 0000000000..479fb8cbfd
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.h
@@ -0,0 +1,193 @@
+/** @file
+
+Copyright (c) 2021, American Megatrends International LLC. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/**
+ *
+ * Header for library definitions and prototypes.
+ *
+ */
+
+#ifndef __LINUX_BOOT_PRIVATE__H__
+#define __LINUX_BOOT_PRIVATE__H__
+#ifdef __cplusplus
+extern "C" {
+#endif // #ifdef __cplusplus
+
+//---------------------------------------------------------------------------
+
+//#include <Token.h>
+
+#define BOOTSIG 0x1FE
+#define SETUP_HDR 0x53726448 /* 0x53726448 == "HdrS" */
+
+#define E820_RAM 1
+#define E820_RESERVED 2
+#define E820_ACPI 3
+#define E820_NVS 4
+#define E820_UNUSABLE 5
+
+#pragma pack(1)
+
+struct setup_header {
+ UINT8 setup_secs; /* Sectors for setup code */
+ UINT16 root_flags;
+ UINT32 sys_size;
+ UINT16 ram_size;
+ UINT16 video_mode;
+ UINT16 root_dev;
+ UINT16 signature; /* Boot signature */
+ UINT16 jump;
+ UINT32 header;
+ UINT16 version;
+ UINT16 su_switch;
+ UINT16 setup_seg;
+ UINT16 start_sys;
+ UINT16 kernel_ver;
+ UINT8 loader_id;
+ UINT8 load_flags;
+ UINT16 movesize;
+ UINT32 code32_start; /* Start of code loaded high */
+ UINT32 ramdisk_start; /* Start of initial ramdisk */
+ UINT32 ramdisk_len; /* Length of initial ramdisk */
+ UINT32 bootsect_kludge;
+ UINT16 heap_end;
+ UINT8 ext_loader_ver; /* Extended boot loader version */
+ UINT8 ext_loader_type; /* Extended boot loader ID */
+ UINT32 cmd_line_ptr; /* 32-bit pointer to the kernel command line */
+ UINT32 ramdisk_max; /* Highest legal initrd address */
+ UINT32 kernel_alignment; /* Physical addr alignment required for kernel */
+ UINT8 relocatable_kernel; /* Whether kernel is relocatable or not */
+ UINT8 min_alignment;
+ UINT16 xloadflags;
+ UINT32 cmdline_size;
+ UINT32 hardware_subarch;
+ UINT64 hardware_subarch_data;
+ UINT32 payload_offset;
+ UINT32 payload_length;
+ UINT64 setup_data;
+ UINT64 pref_address;
+ UINT32 init_size;
+ UINT32 handover_offset;
+};
+
+struct efi_info {
+ UINT32 efi_loader_signature;
+ UINT32 efi_systab;
+ UINT32 efi_memdesc_size;
+ UINT32 efi_memdesc_version;
+ UINT32 efi_memmap;
+ UINT32 efi_memmap_size;
+ UINT32 efi_systab_hi;
+ UINT32 efi_memmap_hi;
+};
+
+struct e820_entry {
+ UINT64 addr; /* start of memory segment */
+ UINT64 size; /* size of memory segment */
+ UINT32 type; /* type of memory segment */
+};
+
+struct screen_info {
+ UINT8 orig_x; /* 0x00 */
+ UINT8 orig_y; /* 0x01 */
+ UINT16 ext_mem_k; /* 0x02 */
+ UINT16 orig_video_page; /* 0x04 */
+ UINT8 orig_video_mode; /* 0x06 */
+ UINT8 orig_video_cols; /* 0x07 */
+ UINT8 flags; /* 0x08 */
+ UINT8 unused2; /* 0x09 */
+ UINT16 orig_video_ega_bx;/* 0x0a */
+ UINT16 unused3; /* 0x0c */
+ UINT8 orig_video_lines; /* 0x0e */
+ UINT8 orig_video_isVGA; /* 0x0f */
+ UINT16 orig_video_points;/* 0x10 */
+
+ /* VESA graphic mode -- linear frame buffer */
+ UINT16 lfb_width; /* 0x12 */
+ UINT16 lfb_height; /* 0x14 */
+ UINT16 lfb_depth; /* 0x16 */
+ UINT32 lfb_base; /* 0x18 */
+ UINT32 lfb_size; /* 0x1c */
+ UINT16 cl_magic, cl_offset; /* 0x20 */
+ UINT16 lfb_linelength; /* 0x24 */
+ UINT8 red_size; /* 0x26 */
+ UINT8 red_pos; /* 0x27 */
+ UINT8 green_size; /* 0x28 */
+ UINT8 green_pos; /* 0x29 */
+ UINT8 blue_size; /* 0x2a */
+ UINT8 blue_pos; /* 0x2b */
+ UINT8 rsvd_size; /* 0x2c */
+ UINT8 rsvd_pos; /* 0x2d */
+ UINT16 vesapm_seg; /* 0x2e */
+ UINT16 vesapm_off; /* 0x30 */
+ UINT16 pages; /* 0x32 */
+ UINT16 vesa_attributes; /* 0x34 */
+ UINT32 capabilities; /* 0x36 */
+ UINT8 _reserved[6]; /* 0x3a */
+};
+
+struct boot_params {
+ struct screen_info screen_info;
+ UINT8 apm_bios_info[0x14];
+ UINT8 _pad2[4];
+ UINT64 tboot_addr;
+ UINT8 ist_info[0x10];
+ UINT8 _pad3[16];
+ UINT8 hd0_info[16];
+ UINT8 hd1_info[16];
+ UINT8 sys_desc_table[0x10];
+ UINT8 olpc_ofw_header[0x10];
+ UINT8 _pad4[128];
+ UINT8 edid_info[0x80];
+ struct efi_info efi_info;
+ UINT32 alt_mem_k;
+ UINT32 scratch;
+ UINT8 e820_entries;
+ UINT8 eddbuf_entries;
+ UINT8 edd_mbr_sig_buf_entries;
+ UINT8 _pad6[6];
+ struct setup_header hdr;
+ UINT8 _pad7[0x290-0x1f1-sizeof(struct setup_header)];
+ UINT32 edd_mbr_sig_buffer[16];
+ struct e820_entry e820_map[128];
+ UINT8 _pad8[48];
+ UINT8 eddbuf[0x1ec];
+ UINT8 _pad9[276];
+};
+#pragma pack ()
+
+//---------------------------------------------------------------------------
+
+#ifndef MIN
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#endif // #ifndef MIN
+
+#define KERNEL_SETUP_SIZE 16384
+
+//---------------------------------------------------------------------------
+
+///
+/// Function prototypes from Bds module
+///
+VOID ConnectEverything();
+VOID RecoverTheMemoryAbove4Gb();
+VOID SignalAllDriversConnectedEvent();
+VOID SignalProtocolEvent(IN EFI_GUID *ProtocolGuid);
+
+#if LINUXBOOT_SIGNAL_EXITPMAUTH == 1
+VOID SignalExitPmAuthProtocolEvent(VOID);
+#endif // #if LINUXBOOT_SIGNAL_EXITPMAUTH == 1
+
+typedef VOID (BDS_CONTROL_FLOW_FUNCTION)();
+
+//---------------------------------------------------------------------------
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif // #ifdef __cplusplus
+#endif // #ifndef __LINUX_BOOT_PRIVATE__H__
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.inf b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.inf
new file mode 100644
index 0000000000..62e09a75c8
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.inf
@@ -0,0 +1,46 @@
+## @file
+#
+# Copyright (c) 2021, American Megatrends International LLC. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+##
+#
+# This library links with the Bds module to launch the Linux kernel.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ VERSION_STRING = 1.0
+ BASE_NAME = LinuxBoot
+ FILE_GUID = 74a41ddc-fac5-4787-afad-d81ee30a8b63 # {0x74a41ddc, 0xfac5, 0x4787, {0xaf, 0xad, 0xd8, 0x1e, 0xe3, 0x0a, 0x8b, 0x63}}
+ MODULE_TYPE = DXE_DRIVER
+ LIBRARY_CLASS = LinuxBootLib|DXE_DRIVER
+[Sources]
+ LinuxBoot.c
+ LinuxBoot.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ DxeServicesLib
+ BaseMemoryLib
+ DebugLib
+ UefiRuntimeServicesTableLib
+ UefiBootServicesTableLib
+ UefiLib
+ LoadLinuxLib
+
+[Guids]
+
+[Protocols]
+ gEfiLoadedImageProtocolGuid
+
+[Pcd]
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.c b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.c
new file mode 100644
index 0000000000..fa6ea117f4
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.c
@@ -0,0 +1,43 @@
+/** @file
+
+Copyright (c) 2021, American Megatrends International LLC. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/**
+ *
+ * This library will load the Linux kernel and initrd from the BIOS and launch it.
+ *
+ */
+
+//---------------------------------------------------------------------------
+
+#include <PiDxe.h>
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+
+/**
+ * This is the main function for this feature. This will handle finding and launching
+ * the Linux kernel.
+ *
+ * @note In general, this function will never return to BDS. The LINUXBOOT_ALLOW_RETURN_TO_BDS
+ * token will allow you to return to BDS if the kernel fails to launch for some reason.
+ *
+ * @param None
+ *
+ * @retval None
+ */
+
+EFI_STATUS
+LinuxBootStart (
+ VOID
+ )
+{
+
+ return EFI_SUCCESS;
+}
+
+//---------------------------------------------------------------------------
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.inf b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.inf
new file mode 100644
index 0000000000..3ed53c6ba0
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.inf
@@ -0,0 +1,31 @@
+## @file
+#
+# Copyright (c) 2021, American Megatrends International LLC. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+##
+#
+# This library links with the Bds module to launch the Linux kernel.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ VERSION_STRING = 1.0
+ BASE_NAME = LinuxBoot
+ FILE_GUID = 0551B6D3-0594-4B02-AF42-5A9C7515CEC8
+ MODULE_TYPE = DXE_DRIVER
+ LIBRARY_CLASS = LinuxBootLib|DXE_DRIVER
+[Sources]
+ LinuxBootNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ DxeServicesLib
\ No newline at end of file
diff --git a/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec b/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
index 4dcec5430b..0c1ab318b8 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
+++ b/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
@@ -49,6 +49,8 @@

gPlatformTokenSpaceGuid.PcdUpdateConsoleInBds|TRUE|BOOLEAN|0x30000035

+ gPlatformTokenSpaceGuid.PcdLinuxBootEnable|FALSE|BOOLEAN|0x30000036
+
[PcdsDynamicEx]
gPlatformTokenSpaceGuid.PcdDfxAdvDebugJumper|FALSE|BOOLEAN|0x6000001D

diff --git a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
index b3b8ceba6f..bd0509ab10 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
+++ b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
@@ -2,6 +2,7 @@
This file include all platform action which can be customized by IBV/OEM.

Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2021, American Megatrends International LLC.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -31,6 +32,12 @@ BOOLEAN gPPRequireUIConfirm;

extern UINTN mBootMenuOptionNumber;

+EFI_STATUS
+LinuxBootStart (
+ VOID
+ );
+
+
GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath = {
{
{
@@ -1268,6 +1275,8 @@ PlatformBootManagerAfterConsole (
LocalBootMode = gBootMode;
DEBUG ((DEBUG_INFO, "Current local bootmode - %x\n", LocalBootMode));

+ LinuxBootStart();
+
//
// Go the different platform policy with different boot mode
// Notes: this part code can be change with the table policy
diff --git a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
index 5790743565..21ac65257c 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
+++ b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
@@ -2,6 +2,7 @@
# Component name for module DxePlatformBootManagerLib
#
# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2021, American Megatrends International LLC.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -40,6 +41,7 @@
PerformanceLib
TimerLib
Tcg2PhysicalPresenceLib
+ LinuxBootLib

[Packages]
MdePkg/MdePkg.dec
diff --git a/Platform/Intel/Readme.md b/Platform/Intel/Readme.md
index 06c5f32b1e..a34784ccb8 100644
--- a/Platform/Intel/Readme.md
+++ b/Platform/Intel/Readme.md
@@ -87,6 +87,11 @@ A UEFI firmware implementation using MinPlatformPkg is constructed using the fol
----------------------------------------|--------------------------------------------|------------------------------|--------------------|
| Mt. Olympus | Purley | PurleyOpenBoardPkg | BoardMtOlympus |

+| Machine Name | Supported Chipsets | BoardPkg | Board Name |
+----------------------------------------|--------------------------------------------|------------------------------|--------------------|
+| TiogaPass | Purley | PurleyOpenBoardPkg | BoardTiogaPass |
+
+
#### Simics

| Machine Name | Supported Chipsets | BoardPkg | Board Name |
@@ -250,6 +255,12 @@ return back to the minimum platform caller.
| | | | build settings, environment variables.
| | | |---build_board.py: Optional board-specific pre-build,
| | | build, post-build and clean functions.
+ | | |------PurleyOpenBoardPkg
+ | | | |------BoardTiogaPass
+ | | | |---build_config.cfg: BoardTiogaPass specific
+ | | | | build settings, environment variables.
+ | | | |---build_board.py: Optional board-specific pre-build,
+ | | | build, post-build and clean functions.
| | |
| | |------SimicsOpenBoardPkg
| | | |------BoardX58Ich10
@@ -292,6 +303,18 @@ For PurleyOpenBoardPkg
"bld cache-consume" Consume a cache of binary files from the specified directory, BINARY_CACHE_PATH is empty,
used "BinCache" as default path.

+For PurleyOpenBoardPkg (TiogaPass)
+1. Open command window, go to the workspace directory, e.g. c:\Edk2Workspace.
+2. Type "cd edk2-platforms\Platform\Intel\PurleyOpenBoardPkg\BoardTiogaPass".
+3. Type "GitEdk2MinBoardTiogaPass.bat" to setup GIT environment.
+4. Type "bld" to build Purley BoardTiogaPass board UEFI firmware image, "bld release" for release build, "bld clean" to
+ remove intermediate files."bld cache-produce" Generate a cache of binary files in the specified directory,
+ "bld cache-consume" Consume a cache of binary files from the specified directory, BINARY_CACHE_PATH is empty,
+ used "BinCache" as default path.
+5. Final BIOS image will be Build\PurleyOpenBoardPkg\BoardTiagoPass\DEBUG_VS2015x86\FV\PLATFORM.fd or
+ Build\PurleyOpenBoardPkg\BoardTiagoPass\RELEASE_VS2015x86\FV\PLATFORM.fd, depending on bld batch script input.
+6. This BIOS image needs to be merged with SPS FW
+
### **Known limitations**

**KabylakeOpenBoardPkg**
@@ -307,6 +330,25 @@ For PurleyOpenBoardPkg
2. This firmware project does not build with the GCC compiler.
3. The validated version of iASL compiler that can build MinPurley is 20180629. Older versions may generate ACPI build errors.

+**PurleyOpenBoardPkg Tioga Pass **
+1. This firmware project has only been tested on the Tioga Pass hardware.
+2. This firmware project build has only been tested using the Microsoft Visual Studio 2015 build tools.
+3. This firmware project does not build with the GCC compiler.
+4. The validated version of iASL compiler that can build MinPurley is 20180629. Older versions may generate ACPI build errors.
+5. Installed and booted to UEFI Windows 2016 on M.2 NVME slot
+6. Installed and booted to UEFI Windows 2019 on M.2 NVME slot and with SATA HDD.
+7. Installed and booted to UEFI RHEL 7.3 on SATA HDD
+8. Installed and booted to Ubuntu 18.04 on M.2 NVME slot.
+9. Verified Mellanox card detection during POST and OS
+10. LINUX Boot Support (PcdLinuxBootEnable needs to be enabled)
+
+1. Follow directions on http://osresearch.net/Building/ to compile the heads kernel and initrd for qemu-system_x86_64
+2. Copy the following built files
+(1) initrd.cpio.xz to LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
+(2) bzimage to LinuxBootPkg/LinuxBinaries/linux.efi
+
+
+
**SimicsOpenBoardPkg**
1. This firmware project has only been tested booting to Microsoft Windows 10 x64 and Ubuntu 17.10 with AHCI mode.

--
2.25.0.windows.1


Please consider the environment before printing this email.

The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


Nate DeSimone
 

From: Manickavasakam Karpagavinayagam <manickavasakamk@ami.com>

Support for LINUX Boot
To enable/disable feature, PcdLinuxBootEnable can be used
1. Follow directions on http://osresearch.net/Building/ to compile the heads kernel and initrd for qemu-system_x86_64
2. Copy the following built files
(1) initrd.cpio.xz to LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
(2) bzimage to LinuxBootPkg/LinuxBinaries/linux.efi

Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Felix Polyudov <Felixp@ami.com>
Cc: Harikrishna Doppalapudi <harikrishnad@ami.com>
Cc: Manish Jha <manishj@ami.com>
Cc: Zachary Bobroff <zacharyb@ami.com>
Cc: Manickavasakam Karpagavinayagam <manickavasakamk@ami.com>
---
.../BoardTiogaPass/CoreDxeInclude.dsc | 5 +-
.../BoardTiogaPass/CoreUefiBootInclude.fdf | 5 +-
.../BoardTiogaPass/OpenBoardPkg.dsc | 7 +
.../BoardTiogaPass/OpenBoardPkg.fdf | 57 ++-
.../BoardTiogaPass/PlatformPkgConfig.dsc | 7 +
.../LinuxBinaries/LinuxKernel.inf | 9 +
.../LinuxBootPkg/LinuxBinaries/initrd.cpio.xz | Bin 0 -> 16 bytes
.../LinuxBootPkg/LinuxBinaries/linux.efi | Bin 0 -> 16 bytes
.../LinuxBootPkg/LinuxBoot.c | 422 ++++++++++++++++++
.../LinuxBootPkg/LinuxBoot.h | 193 ++++++++
.../LinuxBootPkg/LinuxBoot.inf | 46 ++
.../LinuxBootPkg/LinuxBootNull.c | 43 ++
.../LinuxBootPkg/LinuxBootNull.inf | 31 ++
.../Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec | 2 +
.../DxePlatformBootManagerLib/BdsPlatform.c | 9 +
.../DxePlatformBootManagerLib.inf | 2 +
Platform/Intel/Readme.md | 42 ++
17 files changed, 872 insertions(+), 8 deletions(-)
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/LinuxKernel.inf
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/linux.efi
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.c
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.h
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.inf
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.c
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.inf

diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
index b0660d72dd..a17015704b 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
@@ -83,6 +83,7 @@
$(PLATFORM_BOARD_PACKAGE)/Override/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
#TiogaPass Override END

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
@@ -97,10 +98,11 @@
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
FatPkg/EnhancedFatDxe/Fat.inf
-
+!endif
#MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

@@ -124,6 +126,7 @@
<LibraryClasses>
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
}
+!endif

!if gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly == FALSE
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclude.fdf b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclude.fdf
index 141ce5dda3..6cd8ba6626 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclude.fdf
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclude.fdf
@@ -47,6 +47,7 @@ INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
INF $(PLATFORM_BOARD_PACKAGE)/Override/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
#TiogaPass Override END

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
@@ -62,10 +63,12 @@ INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
INF FatPkg/EnhancedFatDxe/Fat.inf
+!endif

#INF MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

@@ -79,4 +82,4 @@ INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf

INF MdeModulePkg/Application/UiApp/UiApp.inf
INF MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
-
+!endif
diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
index e4c8e7fbf1..06ed3f610e 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
@@ -104,6 +104,13 @@
################################################################################

[LibraryClasses.common]
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+ LinuxBootLib|$(PLATFORM_BOARD_PACKAGE)/LinuxBootPkg/LinuxBoot.inf
+ LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
+!else
+ LinuxBootLib|$(PLATFORM_BOARD_PACKAGE)/LinuxBootPkg/LinuxBootNull.inf
+!endif
+
!if gPlatformTokenSpaceGuid.PcdFastBoot == FALSE
PlatformBootManagerLib|$(PLATFORM_PACKAGE)/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
!else
diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
index 43cd8d94e1..adbf28a936 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
@@ -19,6 +19,38 @@
# Also all values will have a PCD assigned so that they can be used in the system, and
# the FlashMap edit tool can be used to change the values here, without effecting the code.
# This requires all code to only use the PCD tokens to recover the values.
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset = 0x00000000 # Flash addr (0xFF840000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize = 0x00300000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset = 0x00300000 # Flash addr (0xFF8A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset = 0x00400000 # Flash addr (0xFF910000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset = 0x00500000 # Flash addr (0xFFE00000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset = 0x00600000 # Flash addr (0xFF9A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize = 0x00600000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset = 0x00C00000 # Flash addr (0xFF800000)
+SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize = 0x0007C000 #
+
+!else
+
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset = 0x00000000 # Flash addr (0xFF840000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize = 0x00500000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset = 0x00500000 # Flash addr (0xFF8A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset = 0x00600000 # Flash addr (0xFF910000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset = 0x00700000 # Flash addr (0xFFE00000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize = 0x00200000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset = 0x00900000 # Flash addr (0xFF9A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize = 0x00300000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset = 0x00C00000 # Flash addr (0xFF800000)
+SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize = 0x0007C000 #
+
+!endif
+

[FD.Platform]
BaseAddress = 0xFF000000 | gEfiPchTokenSpaceGuid.PcdFlashAreaBaseAddress
@@ -27,27 +59,27 @@ ErasePolarity = 1
BlockSize = 0x10000
NumBlocks = 0x100

-0x00000000|0x00500000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize
FV = FvAdvanced

-0x00500000|0x00100000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize
FV = FvSecurity

-0x00600000|0x00100000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize
FV = FvOsBoot

-0x00700000|0x00200000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize
FV = FvLateSiliconCompressed

-0x00900000|0x00300000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize
FV = FvUefiBoot

-0x00C00000|0x0007C000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
#NV_VARIABLE_STORE
DATA = {
@@ -303,6 +335,19 @@ FILE DRIVER = db90bb7e-e4ba-4f07-96d6-b7076713bd2c {

INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+
+FILE DRIVER = 81339b04-fa8c-4be0-9ca7-916fc5319eb5 {
+ SECTION DXE_DEPEX_EXP = {FALSE}
+ SECTION PE32 = $(PLATFORM_BOARD_PACKAGE)/LinuxBootPkg/LinuxBinaries/linux.efi
+}
+
+FILE FREEFORM = 16b60e5d-f1c5-42f0-9b34-08C81C430473 {
+ SECTION RAW = $(PLATFORM_BOARD_PACKAGE)/LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
+}
+
+!endif
+

[FV.FvUefiBoot]
FvAlignment = 16
diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.dsc b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.dsc
index 36a29c8d68..ff27252233 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.dsc
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.dsc
@@ -51,7 +51,14 @@

gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable|TRUE

+ gPlatformTokenSpaceGuid.PcdLinuxBootEnable|FALSE
+
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+ gPlatformTokenSpaceGuid.PcdFastBoot|TRUE
+!else
gPlatformTokenSpaceGuid.PcdFastBoot|FALSE
+!endif
+
!if gPlatformTokenSpaceGuid.PcdFastBoot == TRUE
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable|FALSE
gPlatformTokenSpaceGuid.PcdUpdateConsoleInBds|FALSE
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/LinuxKernel.inf b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/LinuxKernel.inf
new file mode 100644
index 0000000000..a249027d22
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/LinuxKernel.inf
@@ -0,0 +1,9 @@
+[Defines]
+ INF_VERSION = 1.27
+ BASE_NAME = LinuxKernel
+ FILE_GUID = 81339b04-fa8c-4be0-9ca7-916fc5319eb5
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+
+[Binaries.common.AARCH64]
+ PE32|linux.efi|*
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/initrd.cpio.xz b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
new file mode 100644
index 0000000000000000000000000000000000000000..01d633b27e8ea9b17084fc911d0c8cc43a4170a9
GIT binary patch
literal 16
KcmZQzKm`B*5C8!H

literal 0
HcmV?d00001

diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/linux.efi b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/linux.efi
new file mode 100644
index 0000000000000000000000000000000000000000..01d633b27e8ea9b17084fc911d0c8cc43a4170a9
GIT binary patch
literal 16
KcmZQzKm`B*5C8!H

literal 0
HcmV?d00001

diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.c b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.c
new file mode 100644
index 0000000000..eec05824d6
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.c
@@ -0,0 +1,422 @@
+/** @file
+
+Copyright (c) 2021, American Megatrends International LLC. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/**
+ *
+ * This library will load the Linux kernel and initrd from the BIOS and launch it.
+ *
+ */
+
+//---------------------------------------------------------------------------
+
+#include <PiDxe.h>
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Guid/DxeServices.h>
+#include <Library/DxeServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Protocol/FirmwareVolume2.h>
+#include <Protocol/LoadedImage.h>
+#include <Guid/MemoryTypeInformation.h>
+#include <Pi/PiDxeCis.h>
+#include <Pi/PiHob.h>
+#include <Library/PcdLib.h>
+#include <Library/DxeServicesLib.h>
+#include "LinuxBoot.h"
+
+//16b60e5d-f1c5-42f0-9b34-08C81C430473
+#define LINUX_BOOT_INITRD_GUID \
+ { \
+ 0x16b60e5d, 0xf1c5, 0x42f0, {0x9b, 0x34, 0x08, 0xc8, 0x1c, 0x43, 0x04, 0x73} \
+ }
+
+#define LINUX_BOOT_KERNEL_GUID \
+ { \
+ 0x81339b04, 0xfa8c, 0x4be0, {0x9c, 0xa7, 0x91, 0x6f, 0xc5, 0x31, 0x9e, 0xb5} \
+ }
+
+
+EFI_STATUS
+EFIAPI
+LoadLinuxCheckKernelSetup (
+ IN VOID *KernelSetup,
+ IN UINTN KernelSetupSize
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateKernelSetupPages (
+ IN UINTN Pages
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinuxInitializeKernelSetup (
+ IN VOID *KernelSetup
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateKernelPages (
+ IN VOID *KernelSetup,
+ IN UINTN Pages
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinuxSetCommandLine (
+ IN OUT VOID *KernelSetup,
+ IN CHAR8 *CommandLine
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinux (
+ IN VOID *Kernel,
+ IN OUT VOID *KernelSetup
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateInitrdPages (
+ IN VOID *KernelSetup,
+ IN UINTN Pages
+ );
+
+EFI_GUID gLinuxBootInitrdFileGuid = LINUX_BOOT_INITRD_GUID;
+
+EFI_GUID gLinuxBootKernelFileGuid = LINUX_BOOT_KERNEL_GUID;
+
+//---------------------------------------------------------------------------
+
+/**
+ Dump some hexadecimal data to the screen.
+
+ @note Function taken from ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c in EDKII
+
+ @param[in] Indent How many spaces to indent the output.
+ @param[in] Offset The offset of the printing.
+ @param[in] DataSize The size in bytes of UserData.
+ @param[in] UserData The data to print out.
+**/
+static
+VOID
+DumpHex (
+ IN UINTN Indent,
+ IN UINTN Offset,
+ IN UINTN DataSize,
+ IN VOID *UserData
+ )
+{
+ UINT8 *Data;
+ CHAR8 Val[50];
+ CHAR8 Str[20];
+ UINT8 TempByte;
+ UINTN Size;
+ UINTN Index;
+ CHAR8 Hex[] = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
+ };
+
+ DEBUG((DEBUG_INFO, "%*a 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n", Indent, ""));
+ DEBUG((DEBUG_INFO, "%*a ------------------------------------------------\n", Indent, ""));
+
+ Data = UserData;
+ while (DataSize != 0) {
+ Size = 16;
+ if (Size > DataSize) {
+ Size = DataSize;
+ }
+
+ for (Index = 0; Index < Size; Index += 1) {
+ TempByte = Data[Index];
+ Val[Index * 3 + 0] = Hex[TempByte >> 4];
+ Val[Index * 3 + 1] = Hex[TempByte & 0xF];
+ Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' ');
+ Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
+ }
+
+ Val[Index * 3] = 0;
+ Str[Index] = 0;
+ DEBUG((DEBUG_INFO, "%*a%08X: %-48a %a\n", Indent, "", Offset, Val, Str));
+
+ Data += Size;
+ Offset += Size;
+ DataSize -= Size;
+ }
+}
+
+
+/**
+ * This function completes a minimal amount of the necessary BDS functions to prepare
+ * for booting the kernel.
+ *
+ * @param None
+ *
+ * @retval EFI_SUCCESS Successfully completed remaining tasks
+ * @return EFI_ERROR Could not complete BDS tasks
+ */
+EFI_STATUS
+CompleteBdsTasks (
+ VOID
+)
+{
+
+ return EFI_SUCCESS;
+}
+
+/**
+ * This function will load and launch the Linux kernel from a BIOS FV.
+ *
+ * @note This function is not intended to return. Any exiting from this function indicates
+ * a problem loading or launching the kernel.
+ *
+ * @param None
+ *
+ * @return EFI_ERROR Any error code
+ */
+EFI_STATUS
+LoadAndLaunchKernel (
+ VOID
+)
+{
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage = NULL;
+ EFI_STATUS Status;
+ EFI_HANDLE KernelHandle = NULL;
+ VOID *KernelBuffer = NULL;
+ VOID *KernelFfsBuffer = NULL;
+ UINTN KernelFfsSize = 0;
+ VOID *InitrdData = NULL;
+ VOID *InitrdBuffer = NULL;
+ UINTN InitrdSize = 0;
+ struct boot_params *BootParams = NULL;
+ struct boot_params *HandoverParams = NULL;
+ UINT32 StartOffset = 0;
+ UINT32 KernelLength = 0;
+ UINT8 *Temp;
+ UINT8 CmdLine[] = " ";
+
+ DEBUG((DEBUG_INFO, "LoadAndLaunchKernel Entry\n"));
+
+ ///
+ /// Kernel load and preparation
+ ///
+ DEBUG((DEBUG_INFO, "Preparing the kernel...\n"));
+
+ // Retrieve the kernel from the firmware volume
+ Status = GetSectionFromAnyFv(
+ &gLinuxBootKernelFileGuid,
+ EFI_SECTION_PE32,
+ 0,
+ &KernelFfsBuffer,
+ &KernelFfsSize
+ );
+
+ DEBUG((DEBUG_INFO, "Status %r\n",Status));
+ DEBUG((DEBUG_INFO, "KernelFfsBuffer %x\n",KernelFfsBuffer));
+ DEBUG((DEBUG_INFO, "KernelFfsSize %x\n",KernelFfsSize));
+
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not retrieve kernel; %r.\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Loaded kernel to buffer at 0x%p with size 0x%X.\n", KernelFfsBuffer, KernelFfsSize));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes:\n", MIN(KernelFfsSize, 0x100)));
+
+ DumpHex(2, 0, MIN(0x100, KernelFfsSize), KernelFfsBuffer);
+
+ // Create a LoadImage protocol for the kernel
+ Status = gBS->LoadImage(TRUE, gImageHandle, NULL, KernelFfsBuffer, KernelFfsSize, &KernelHandle);
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not create LoadImage for kernel %r\n", Status));
+ goto FatalError;
+ }
+
+ // Get the new LoadedImage protocol to retrieve information about the kernel
+ Status = gBS->HandleProtocol(KernelHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not get kernel LoadedImage protocol; %r\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Kernel LoadedImage information:\n"));
+ DEBUG((DEBUG_INFO, " ImageBase = 0x%p\n", LoadedImage->ImageBase));
+ DEBUG((DEBUG_INFO, " ImageSize = 0x%p\n", LoadedImage->ImageSize));
+
+ // Verify the kernel boot parameters from the LoadedImage and allocate an initalization buffer once verified
+ BootParams = (struct boot_params*) LoadedImage->ImageBase;
+
+ Status = LoadLinuxCheckKernelSetup((VOID *) BootParams, sizeof(struct boot_params));
+ if (EFI_ERROR (Status)) {
+ DEBUG((DEBUG_ERROR, "LoadLinuxCheckKernelSetup failed; %r.\n", Status));
+ goto FatalError;
+ }
+
+ HandoverParams = LoadLinuxAllocateKernelSetupPages(EFI_SIZE_TO_PAGES(KERNEL_SETUP_SIZE));
+ if (HandoverParams == NULL) {
+ DEBUG((DEBUG_ERROR, "Could not allocate memory for kernel handover parameters.\n"));
+ goto FatalError;
+ }
+ DEBUG((DEBUG_INFO, "Handover parameters allocated at 0x%p\n", HandoverParams));
+
+ gBS->CopyMem(&HandoverParams->hdr, &BootParams->hdr, sizeof(struct setup_header));
+
+ Status = LoadLinuxInitializeKernelSetup(HandoverParams);
+ if (EFI_ERROR (Status)) {
+ DEBUG((DEBUG_ERROR, "Unable to initialize the handover parameters; %r.\n", Status));
+ goto FatalError;
+ }
+
+ // Allocate space for the kernel and copy it into the new buffer
+ KernelBuffer = LoadLinuxAllocateKernelPages(HandoverParams, EFI_SIZE_TO_PAGES(HandoverParams->hdr.init_size));
+ if (KernelBuffer == NULL) {
+ DEBUG((DEBUG_ERROR, "Unable to allocate memory for kernel.\n"));
+ goto FatalError;
+ }
+
+ StartOffset = (HandoverParams->hdr.setup_secs + 1) * 512;
+ KernelLength = (UINT32) (KernelFfsSize - StartOffset);
+ Temp = (UINT8 *) LoadedImage->ImageBase;
+
+ DEBUG((DEBUG_INFO, "Kernel starts at offset 0x%X with length 0x%X\n", StartOffset, KernelLength));
+
+ gBS->CopyMem(KernelBuffer, (Temp + StartOffset), KernelLength);
+ DEBUG((DEBUG_INFO, "First 0x%X bytes of new kernel buffer contents:\n", MIN(0x100, KernelLength)));
+
+ DumpHex(2, 0, MIN(0x100, KernelLength), KernelBuffer);
+
+ // Prepare the command line
+ Status = LoadLinuxSetCommandLine(HandoverParams, (UINT8 *) &CmdLine);
+ if (EFI_ERROR (Status)) {
+ DEBUG((EFI_D_INFO, "Unable to set linux command line; %r.\n", Status));
+ goto FatalError;
+ }
+
+ HandoverParams->hdr.code32_start = (UINT32)(UINTN) KernelBuffer;
+ HandoverParams->hdr.loader_id = 0x21;
+
+ DEBUG((DEBUG_INFO, "Kernel loaded.\n"));
+
+#if 1
+//#if defined(INTEGRATED_INITRAM_FS) && (INTEGRATED_INITRAM_FS ==0)
+ ///
+ /// Initrd load and preparation
+ ///
+ DEBUG((DEBUG_INFO, "Preparing the initrd...\n"));
+
+ // Retrieve the initrd from the firmware volume
+ Status = GetSectionFromAnyFv(
+ &gLinuxBootInitrdFileGuid,
+ EFI_SECTION_RAW,
+ 0,
+ &InitrdBuffer,
+ &InitrdSize
+ );
+
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not retrieve initrd; %r.\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Loaded initrd to buffer at 0x%p with size 0x%X.\n", InitrdBuffer, InitrdSize));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes:\n", MIN(0x100, InitrdSize)));
+ DumpHex(2, 0, MIN(0x100, InitrdSize), InitrdBuffer);
+
+ // Allocate the initrd for the kernel and copy it in
+ InitrdData = LoadLinuxAllocateInitrdPages(HandoverParams, EFI_SIZE_TO_PAGES(InitrdSize));
+ if (InitrdData == NULL) {
+ DEBUG((DEBUG_ERROR, "Unable to allocate memory for initrd.\n"));
+ goto FatalError;
+ }
+
+ gBS->CopyMem(InitrdData, InitrdBuffer, InitrdSize);
+
+ HandoverParams->hdr.ramdisk_start = (UINT32)(UINTN) InitrdData;
+ HandoverParams->hdr.ramdisk_len = (UINT32) InitrdSize;
+
+ DEBUG((DEBUG_INFO, "Initrd loaded.\n"));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes of initrd buffer:\n", MIN(0x100, InitrdSize)));
+ DumpHex(2, 0, MIN(0x100, InitrdSize), InitrdData);
+
+ // General cleanup before launching the kernel
+ gBS->FreePool(InitrdBuffer);
+ InitrdBuffer = NULL;
+#endif
+
+ gBS->UnloadImage(KernelHandle);
+ gBS->FreePool(KernelFfsBuffer);
+ KernelFfsBuffer = NULL;
+
+ DEBUG((DEBUG_ERROR, "Launching the kernel\n"));
+
+
+ //
+ // Signal the EFI_EVENT_GROUP_READY_TO_BOOT event.
+ //
+ EfiSignalEventReadyToBoot();
+
+
+ // Launch the kernel
+ Status = LoadLinux(KernelBuffer, HandoverParams);
+
+ ///
+ /// LoadLinux should never return if the kernel boots. Anything past here is an error scenario
+ ///
+ DEBUG((DEBUG_ERROR, "ERROR: LoadLinux has returned with status; %r.\n", Status));
+
+FatalError:
+ // Free everything
+ if (InitrdData != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS) InitrdData, EFI_SIZE_TO_PAGES(InitrdSize));
+ if (KernelBuffer != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS) KernelBuffer, EFI_SIZE_TO_PAGES(HandoverParams->hdr.init_size));
+ if (HandoverParams != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS) HandoverParams, EFI_SIZE_TO_PAGES(KERNEL_SETUP_SIZE));
+ if (InitrdBuffer != NULL) gBS->FreePool(InitrdBuffer);
+ if (KernelHandle != NULL) gBS->UnloadImage(KernelHandle);
+ if (KernelFfsBuffer != NULL) gBS->FreePool(KernelFfsBuffer);
+
+ return EFI_NOT_FOUND;
+}
+
+/**
+ * This is the main function for this feature. This will handle finding and launching
+ * the Linux kernel.
+ *
+ * @note In general, this function will never return to BDS. The LINUXBOOT_ALLOW_RETURN_TO_BDS
+ * token will allow you to return to BDS if the kernel fails to launch for some reason.
+ *
+ * @param None
+ *
+ * @retval None
+ */
+
+EFI_STATUS
+LinuxBootStart (
+ VOID
+ )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ // Finish BDS and then try to launch the kernel
+ //Status = CompleteBdsTasks();
+
+ if (!EFI_ERROR(Status)) {
+ LoadAndLaunchKernel();
+ }
+
+ DEBUG((DEBUG_ERROR, "-----------------------------------\n"));
+ DEBUG((DEBUG_ERROR, " ERROR: Kernel failed to launch.\n"));
+ DEBUG((DEBUG_ERROR, "-----------------------------------\n"));
+ return Status;
+}
+
+//---------------------------------------------------------------------------
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.h b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.h
new file mode 100644
index 0000000000..479fb8cbfd
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.h
@@ -0,0 +1,193 @@
+/** @file
+
+Copyright (c) 2021, American Megatrends International LLC. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/**
+ *
+ * Header for library definitions and prototypes.
+ *
+ */
+
+#ifndef __LINUX_BOOT_PRIVATE__H__
+#define __LINUX_BOOT_PRIVATE__H__
+#ifdef __cplusplus
+extern "C" {
+#endif // #ifdef __cplusplus
+
+//---------------------------------------------------------------------------
+
+//#include <Token.h>
+
+#define BOOTSIG 0x1FE
+#define SETUP_HDR 0x53726448 /* 0x53726448 == "HdrS" */
+
+#define E820_RAM 1
+#define E820_RESERVED 2
+#define E820_ACPI 3
+#define E820_NVS 4
+#define E820_UNUSABLE 5
+
+#pragma pack(1)
+
+struct setup_header {
+ UINT8 setup_secs; /* Sectors for setup code */
+ UINT16 root_flags;
+ UINT32 sys_size;
+ UINT16 ram_size;
+ UINT16 video_mode;
+ UINT16 root_dev;
+ UINT16 signature; /* Boot signature */
+ UINT16 jump;
+ UINT32 header;
+ UINT16 version;
+ UINT16 su_switch;
+ UINT16 setup_seg;
+ UINT16 start_sys;
+ UINT16 kernel_ver;
+ UINT8 loader_id;
+ UINT8 load_flags;
+ UINT16 movesize;
+ UINT32 code32_start; /* Start of code loaded high */
+ UINT32 ramdisk_start; /* Start of initial ramdisk */
+ UINT32 ramdisk_len; /* Length of initial ramdisk */
+ UINT32 bootsect_kludge;
+ UINT16 heap_end;
+ UINT8 ext_loader_ver; /* Extended boot loader version */
+ UINT8 ext_loader_type; /* Extended boot loader ID */
+ UINT32 cmd_line_ptr; /* 32-bit pointer to the kernel command line */
+ UINT32 ramdisk_max; /* Highest legal initrd address */
+ UINT32 kernel_alignment; /* Physical addr alignment required for kernel */
+ UINT8 relocatable_kernel; /* Whether kernel is relocatable or not */
+ UINT8 min_alignment;
+ UINT16 xloadflags;
+ UINT32 cmdline_size;
+ UINT32 hardware_subarch;
+ UINT64 hardware_subarch_data;
+ UINT32 payload_offset;
+ UINT32 payload_length;
+ UINT64 setup_data;
+ UINT64 pref_address;
+ UINT32 init_size;
+ UINT32 handover_offset;
+};
+
+struct efi_info {
+ UINT32 efi_loader_signature;
+ UINT32 efi_systab;
+ UINT32 efi_memdesc_size;
+ UINT32 efi_memdesc_version;
+ UINT32 efi_memmap;
+ UINT32 efi_memmap_size;
+ UINT32 efi_systab_hi;
+ UINT32 efi_memmap_hi;
+};
+
+struct e820_entry {
+ UINT64 addr; /* start of memory segment */
+ UINT64 size; /* size of memory segment */
+ UINT32 type; /* type of memory segment */
+};
+
+struct screen_info {
+ UINT8 orig_x; /* 0x00 */
+ UINT8 orig_y; /* 0x01 */
+ UINT16 ext_mem_k; /* 0x02 */
+ UINT16 orig_video_page; /* 0x04 */
+ UINT8 orig_video_mode; /* 0x06 */
+ UINT8 orig_video_cols; /* 0x07 */
+ UINT8 flags; /* 0x08 */
+ UINT8 unused2; /* 0x09 */
+ UINT16 orig_video_ega_bx;/* 0x0a */
+ UINT16 unused3; /* 0x0c */
+ UINT8 orig_video_lines; /* 0x0e */
+ UINT8 orig_video_isVGA; /* 0x0f */
+ UINT16 orig_video_points;/* 0x10 */
+
+ /* VESA graphic mode -- linear frame buffer */
+ UINT16 lfb_width; /* 0x12 */
+ UINT16 lfb_height; /* 0x14 */
+ UINT16 lfb_depth; /* 0x16 */
+ UINT32 lfb_base; /* 0x18 */
+ UINT32 lfb_size; /* 0x1c */
+ UINT16 cl_magic, cl_offset; /* 0x20 */
+ UINT16 lfb_linelength; /* 0x24 */
+ UINT8 red_size; /* 0x26 */
+ UINT8 red_pos; /* 0x27 */
+ UINT8 green_size; /* 0x28 */
+ UINT8 green_pos; /* 0x29 */
+ UINT8 blue_size; /* 0x2a */
+ UINT8 blue_pos; /* 0x2b */
+ UINT8 rsvd_size; /* 0x2c */
+ UINT8 rsvd_pos; /* 0x2d */
+ UINT16 vesapm_seg; /* 0x2e */
+ UINT16 vesapm_off; /* 0x30 */
+ UINT16 pages; /* 0x32 */
+ UINT16 vesa_attributes; /* 0x34 */
+ UINT32 capabilities; /* 0x36 */
+ UINT8 _reserved[6]; /* 0x3a */
+};
+
+struct boot_params {
+ struct screen_info screen_info;
+ UINT8 apm_bios_info[0x14];
+ UINT8 _pad2[4];
+ UINT64 tboot_addr;
+ UINT8 ist_info[0x10];
+ UINT8 _pad3[16];
+ UINT8 hd0_info[16];
+ UINT8 hd1_info[16];
+ UINT8 sys_desc_table[0x10];
+ UINT8 olpc_ofw_header[0x10];
+ UINT8 _pad4[128];
+ UINT8 edid_info[0x80];
+ struct efi_info efi_info;
+ UINT32 alt_mem_k;
+ UINT32 scratch;
+ UINT8 e820_entries;
+ UINT8 eddbuf_entries;
+ UINT8 edd_mbr_sig_buf_entries;
+ UINT8 _pad6[6];
+ struct setup_header hdr;
+ UINT8 _pad7[0x290-0x1f1-sizeof(struct setup_header)];
+ UINT32 edd_mbr_sig_buffer[16];
+ struct e820_entry e820_map[128];
+ UINT8 _pad8[48];
+ UINT8 eddbuf[0x1ec];
+ UINT8 _pad9[276];
+};
+#pragma pack ()
+
+//---------------------------------------------------------------------------
+
+#ifndef MIN
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#endif // #ifndef MIN
+
+#define KERNEL_SETUP_SIZE 16384
+
+//---------------------------------------------------------------------------
+
+///
+/// Function prototypes from Bds module
+///
+VOID ConnectEverything();
+VOID RecoverTheMemoryAbove4Gb();
+VOID SignalAllDriversConnectedEvent();
+VOID SignalProtocolEvent(IN EFI_GUID *ProtocolGuid);
+
+#if LINUXBOOT_SIGNAL_EXITPMAUTH == 1
+VOID SignalExitPmAuthProtocolEvent(VOID);
+#endif // #if LINUXBOOT_SIGNAL_EXITPMAUTH == 1
+
+typedef VOID (BDS_CONTROL_FLOW_FUNCTION)();
+
+//---------------------------------------------------------------------------
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif // #ifdef __cplusplus
+#endif // #ifndef __LINUX_BOOT_PRIVATE__H__
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.inf b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.inf
new file mode 100644
index 0000000000..62e09a75c8
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.inf
@@ -0,0 +1,46 @@
+## @file
+#
+# Copyright (c) 2021, American Megatrends International LLC. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+##
+#
+# This library links with the Bds module to launch the Linux kernel.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ VERSION_STRING = 1.0
+ BASE_NAME = LinuxBoot
+ FILE_GUID = 74a41ddc-fac5-4787-afad-d81ee30a8b63 # {0x74a41ddc, 0xfac5, 0x4787, {0xaf, 0xad, 0xd8, 0x1e, 0xe3, 0x0a, 0x8b, 0x63}}
+ MODULE_TYPE = DXE_DRIVER
+ LIBRARY_CLASS = LinuxBootLib|DXE_DRIVER
+[Sources]
+ LinuxBoot.c
+ LinuxBoot.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ DxeServicesLib
+ BaseMemoryLib
+ DebugLib
+ UefiRuntimeServicesTableLib
+ UefiBootServicesTableLib
+ UefiLib
+ LoadLinuxLib
+
+[Guids]
+
+[Protocols]
+ gEfiLoadedImageProtocolGuid
+
+[Pcd]
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.c b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.c
new file mode 100644
index 0000000000..fa6ea117f4
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.c
@@ -0,0 +1,43 @@
+/** @file
+
+Copyright (c) 2021, American Megatrends International LLC. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/**
+ *
+ * This library will load the Linux kernel and initrd from the BIOS and launch it.
+ *
+ */
+
+//---------------------------------------------------------------------------
+
+#include <PiDxe.h>
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+
+/**
+ * This is the main function for this feature. This will handle finding and launching
+ * the Linux kernel.
+ *
+ * @note In general, this function will never return to BDS. The LINUXBOOT_ALLOW_RETURN_TO_BDS
+ * token will allow you to return to BDS if the kernel fails to launch for some reason.
+ *
+ * @param None
+ *
+ * @retval None
+ */
+
+EFI_STATUS
+LinuxBootStart (
+ VOID
+ )
+{
+
+ return EFI_SUCCESS;
+}
+
+//---------------------------------------------------------------------------
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.inf b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.inf
new file mode 100644
index 0000000000..3ed53c6ba0
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.inf
@@ -0,0 +1,31 @@
+## @file
+#
+# Copyright (c) 2021, American Megatrends International LLC. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+##
+#
+# This library links with the Bds module to launch the Linux kernel.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ VERSION_STRING = 1.0
+ BASE_NAME = LinuxBoot
+ FILE_GUID = 0551B6D3-0594-4B02-AF42-5A9C7515CEC8
+ MODULE_TYPE = DXE_DRIVER
+ LIBRARY_CLASS = LinuxBootLib|DXE_DRIVER
+[Sources]
+ LinuxBootNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ DxeServicesLib
\ No newline at end of file
diff --git a/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec b/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
index 4dcec5430b..0c1ab318b8 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
+++ b/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
@@ -49,6 +49,8 @@

gPlatformTokenSpaceGuid.PcdUpdateConsoleInBds|TRUE|BOOLEAN|0x30000035

+ gPlatformTokenSpaceGuid.PcdLinuxBootEnable|FALSE|BOOLEAN|0x30000036
+
[PcdsDynamicEx]
gPlatformTokenSpaceGuid.PcdDfxAdvDebugJumper|FALSE|BOOLEAN|0x6000001D

diff --git a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
index b3b8ceba6f..bd0509ab10 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
+++ b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
@@ -2,6 +2,7 @@
This file include all platform action which can be customized by IBV/OEM.

Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2021, American Megatrends International LLC.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -31,6 +32,12 @@ BOOLEAN gPPRequireUIConfirm;

extern UINTN mBootMenuOptionNumber;

+EFI_STATUS
+LinuxBootStart (
+ VOID
+ );
+
+
GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath = {
{
{
@@ -1268,6 +1275,8 @@ PlatformBootManagerAfterConsole (
LocalBootMode = gBootMode;
DEBUG ((DEBUG_INFO, "Current local bootmode - %x\n", LocalBootMode));

+ LinuxBootStart();
+
//
// Go the different platform policy with different boot mode
// Notes: this part code can be change with the table policy
diff --git a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
index 5790743565..21ac65257c 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
+++ b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
@@ -2,6 +2,7 @@
# Component name for module DxePlatformBootManagerLib
#
# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2021, American Megatrends International LLC.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -40,6 +41,7 @@
PerformanceLib
TimerLib
Tcg2PhysicalPresenceLib
+ LinuxBootLib

[Packages]
MdePkg/MdePkg.dec
diff --git a/Platform/Intel/Readme.md b/Platform/Intel/Readme.md
index 06c5f32b1e..a34784ccb8 100644
--- a/Platform/Intel/Readme.md
+++ b/Platform/Intel/Readme.md
@@ -87,6 +87,11 @@ A UEFI firmware implementation using MinPlatformPkg is constructed using the fol
----------------------------------------|--------------------------------------------|------------------------------|--------------------|
| Mt. Olympus | Purley | PurleyOpenBoardPkg | BoardMtOlympus |

+| Machine Name | Supported Chipsets | BoardPkg | Board Name |
+----------------------------------------|--------------------------------------------|------------------------------|--------------------|
+| TiogaPass | Purley | PurleyOpenBoardPkg | BoardTiogaPass |
+
+
#### Simics

| Machine Name | Supported Chipsets | BoardPkg | Board Name |
@@ -250,6 +255,12 @@ return back to the minimum platform caller.
| | | | build settings, environment variables.
| | | |---build_board.py: Optional board-specific pre-build,
| | | build, post-build and clean functions.
+ | | |------PurleyOpenBoardPkg
+ | | | |------BoardTiogaPass
+ | | | |---build_config.cfg: BoardTiogaPass specific
+ | | | | build settings, environment variables.
+ | | | |---build_board.py: Optional board-specific pre-build,
+ | | | build, post-build and clean functions.
| | |
| | |------SimicsOpenBoardPkg
| | | |------BoardX58Ich10
@@ -292,6 +303,18 @@ For PurleyOpenBoardPkg
"bld cache-consume" Consume a cache of binary files from the specified directory, BINARY_CACHE_PATH is empty,
used "BinCache" as default path.

+For PurleyOpenBoardPkg (TiogaPass)
+1. Open command window, go to the workspace directory, e.g. c:\Edk2Workspace.
+2. Type "cd edk2-platforms\Platform\Intel\PurleyOpenBoardPkg\BoardTiogaPass".
+3. Type "GitEdk2MinBoardTiogaPass.bat" to setup GIT environment.
+4. Type "bld" to build Purley BoardTiogaPass board UEFI firmware image, "bld release" for release build, "bld clean" to
+ remove intermediate files."bld cache-produce" Generate a cache of binary files in the specified directory,
+ "bld cache-consume" Consume a cache of binary files from the specified directory, BINARY_CACHE_PATH is empty,
+ used "BinCache" as default path.
+5. Final BIOS image will be Build\PurleyOpenBoardPkg\BoardTiagoPass\DEBUG_VS2015x86\FV\PLATFORM.fd or
+ Build\PurleyOpenBoardPkg\BoardTiagoPass\RELEASE_VS2015x86\FV\PLATFORM.fd, depending on bld batch script input.
+6. This BIOS image needs to be merged with SPS FW
+
### **Known limitations**

**KabylakeOpenBoardPkg**
@@ -307,6 +330,25 @@ For PurleyOpenBoardPkg
2. This firmware project does not build with the GCC compiler.
3. The validated version of iASL compiler that can build MinPurley is 20180629. Older versions may generate ACPI build errors.

+**PurleyOpenBoardPkg Tioga Pass **
+1. This firmware project has only been tested on the Tioga Pass hardware.
+2. This firmware project build has only been tested using the Microsoft Visual Studio 2015 build tools.
+3. This firmware project does not build with the GCC compiler.
+4. The validated version of iASL compiler that can build MinPurley is 20180629. Older versions may generate ACPI build errors.
+5. Installed and booted to UEFI Windows 2016 on M.2 NVME slot
+6. Installed and booted to UEFI Windows 2019 on M.2 NVME slot and with SATA HDD.
+7. Installed and booted to UEFI RHEL 7.3 on SATA HDD
+8. Installed and booted to Ubuntu 18.04 on M.2 NVME slot.
+9. Verified Mellanox card detection during POST and OS
+10. LINUX Boot Support (PcdLinuxBootEnable needs to be enabled)
+
+1. Follow directions on http://osresearch.net/Building/ to compile the heads kernel and initrd for qemu-system_x86_64
+2. Copy the following built files
+(1) initrd.cpio.xz to LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
+(2) bzimage to LinuxBootPkg/LinuxBinaries/linux.efi
+
+
+
**SimicsOpenBoardPkg**
1. This firmware project has only been tested booting to Microsoft Windows 10 x64 and Ubuntu 17.10 with AHCI mode.

--
2.25.0.windows.1


Please consider the environment before printing this email.

The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.
GitPatchExtractor 1.1


Oram, Isaac W
 

Manic,

I don't think that there is much value in having two different flash maps for LinuxBoot enabled or disabled. It strikes me as unnecessary code to maintain.
LinuxKernel.inf is missing a properly formatted file header.
LinuxBoot.c should be run through code style compliance tools. Also there is unnecessary commented out code and things like #if 1 that should be removed.
LinuxBoot.h has tabs in the source disrupting structure layout and not following coding style.
Please rename LinuxBootPkg as it is not an edk2 package and the name is a bit misleading.

We should do an RFC to talk about the various LinuxBoot integrations that we see across the community and maybe discuss at the design meeting. I think you are fine to commit this version as it is fairly specific to your use case, so that design discussion shouldn't block this fix.

Regards,
Isaac

-----Original Message-----
From: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>
Sent: Wednesday, June 16, 2021 5:52 PM
To: devel@edk2.groups.io
Cc: KARPAGAVINAYAGAM, MANICKAVASAKAM <manickavasakamk@ami.com>; Oram, Isaac W <isaac.w.oram@intel.com>; Felix Polyudov <Felixp@ami.com>; DOPPALAPUDI, HARIKRISHNA <harikrishnad@ami.com>; Jha, Manish <manishj@ami.com>; Bobroff, Zachary <zacharyb@ami.com>
Subject: [edk2-platforms] [PATCH V1] PurleyOpenBoardPkg : Support for LINUX Boot

From: Manickavasakam Karpagavinayagam <manickavasakamk@ami.com>

Support for LINUX Boot
To enable/disable feature, PcdLinuxBootEnable can be used
1. Follow directions on http://osresearch.net/Building/ to compile the heads kernel and initrd for qemu-system_x86_64
2. Copy the following built files
(1) initrd.cpio.xz to LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
(2) bzimage to LinuxBootPkg/LinuxBinaries/linux.efi

Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Felix Polyudov <Felixp@ami.com>
Cc: Harikrishna Doppalapudi <harikrishnad@ami.com>
Cc: Manish Jha <manishj@ami.com>
Cc: Zachary Bobroff <zacharyb@ami.com>
Cc: Manickavasakam Karpagavinayagam <manickavasakamk@ami.com>
---
.../BoardTiogaPass/CoreDxeInclude.dsc | 5 +-
.../BoardTiogaPass/CoreUefiBootInclude.fdf | 5 +-
.../BoardTiogaPass/OpenBoardPkg.dsc | 7 +
.../BoardTiogaPass/OpenBoardPkg.fdf | 57 ++-
.../BoardTiogaPass/PlatformPkgConfig.dsc | 7 +
.../LinuxBinaries/LinuxKernel.inf | 9 +
.../LinuxBootPkg/LinuxBinaries/initrd.cpio.xz | Bin 0 -> 16 bytes
.../LinuxBootPkg/LinuxBinaries/linux.efi | Bin 0 -> 16 bytes
.../LinuxBootPkg/LinuxBoot.c | 422 ++++++++++++++++++
.../LinuxBootPkg/LinuxBoot.h | 193 ++++++++
.../LinuxBootPkg/LinuxBoot.inf | 46 ++
.../LinuxBootPkg/LinuxBootNull.c | 43 ++
.../LinuxBootPkg/LinuxBootNull.inf | 31 ++
.../Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec | 2 +
.../DxePlatformBootManagerLib/BdsPlatform.c | 9 +
.../DxePlatformBootManagerLib.inf | 2 +
Platform/Intel/Readme.md | 42 ++
17 files changed, 872 insertions(+), 8 deletions(-) create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/LinuxKernel.inf
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/linux.efi
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.c
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.h
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.inf
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.c
create mode 100644 Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.inf

diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
index b0660d72dd..a17015704b 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.ds
+++ c
@@ -83,6 +83,7 @@
$(PLATFORM_BOARD_PACKAGE)/Override/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
#TiogaPass Override END

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
@@ -97,10 +98,11 @@
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
FatPkg/EnhancedFatDxe/Fat.inf
-
+!endif
#MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

@@ -124,6 +126,7 @@
<LibraryClasses>
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
}
+!endif

!if gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly == FALSE
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclude.fdf b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclude.fdf
index 141ce5dda3..6cd8ba6626 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclude.fdf
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclu
+++ de.fdf
@@ -47,6 +47,7 @@ INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
INF $(PLATFORM_BOARD_PACKAGE)/Override/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
#TiogaPass Override END

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
@@ -62,10 +63,12 @@ INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
INF FatPkg/EnhancedFatDxe/Fat.inf
+!endif

#INF MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

@@ -79,4 +82,4 @@ INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf

INF MdeModulePkg/Application/UiApp/UiApp.inf
INF MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
-
+!endif
diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
index e4c8e7fbf1..06ed3f610e 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
@@ -104,6 +104,13 @@
################################################################################

[LibraryClasses.common]
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+ LinuxBootLib|$(PLATFORM_BOARD_PACKAGE)/LinuxBootPkg/LinuxBoot.inf
+ LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
+!else
+ LinuxBootLib|$(PLATFORM_BOARD_PACKAGE)/LinuxBootPkg/LinuxBootNull.inf
+!endif
+
!if gPlatformTokenSpaceGuid.PcdFastBoot == FALSE
PlatformBootManagerLib|$(PLATFORM_PACKAGE)/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
!else
diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
index 43cd8d94e1..adbf28a936 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
@@ -19,6 +19,38 @@
# Also all values will have a PCD assigned so that they can be used in the system, and
# the FlashMap edit tool can be used to change the values here, without effecting the code.
# This requires all code to only use the PCD tokens to recover the values.
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset = 0x00000000 # Flash addr (0xFF840000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize = 0x00300000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset = 0x00300000 # Flash addr (0xFF8A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset = 0x00400000 # Flash addr (0xFF910000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset = 0x00500000 # Flash addr (0xFFE00000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset = 0x00600000 # Flash addr (0xFF9A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize = 0x00600000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset = 0x00C00000 # Flash addr (0xFF800000)
+SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize = 0x0007C000 #
+
+!else
+
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset = 0x00000000 # Flash addr (0xFF840000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize = 0x00500000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset = 0x00500000 # Flash addr (0xFF8A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset = 0x00600000 # Flash addr (0xFF910000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize = 0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset = 0x00700000 # Flash addr (0xFFE00000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize = 0x00200000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset = 0x00900000 # Flash addr (0xFF9A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize = 0x00300000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset = 0x00C00000 # Flash addr (0xFF800000)
+SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize = 0x0007C000 #
+
+!endif
+

[FD.Platform]
BaseAddress = 0xFF000000 | gEfiPchTokenSpaceGuid.PcdFlashAreaBaseAddress
@@ -27,27 +59,27 @@ ErasePolarity = 1
BlockSize = 0x10000
NumBlocks = 0x100

-0x00000000|0x00500000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset|gMinPlatformPkgT
+okenSpaceGuid.PcdFlashFvAdvancedSize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize
FV = FvAdvanced

-0x00500000|0x00100000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset|gMinPlatformPkgT
+okenSpaceGuid.PcdFlashFvSecuritySize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize
FV = FvSecurity

-0x00600000|0x00100000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset|gMinPlatformPkgTok
+enSpaceGuid.PcdFlashFvOsBootSize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize
FV = FvOsBoot

-0x00700000|0x00200000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset|gMinPlatformPkgToken
+SpaceGuid.PcdFlashFvFspUSize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize
FV = FvLateSiliconCompressed

-0x00900000|0x00300000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset|gMinPlatformPkgT
+okenSpaceGuid.PcdFlashFvUefiBootSize
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootBase|gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize
FV = FvUefiBoot

-0x00C00000|0x0007C000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset|gEfiMdeMo
+dulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
#NV_VARIABLE_STORE
DATA = {
@@ -303,6 +335,19 @@ FILE DRIVER = db90bb7e-e4ba-4f07-96d6-b7076713bd2c {

INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+
+FILE DRIVER = 81339b04-fa8c-4be0-9ca7-916fc5319eb5 {
+ SECTION DXE_DEPEX_EXP = {FALSE}
+ SECTION PE32 =
+$(PLATFORM_BOARD_PACKAGE)/LinuxBootPkg/LinuxBinaries/linux.efi
+}
+
+FILE FREEFORM = 16b60e5d-f1c5-42f0-9b34-08C81C430473 {
+ SECTION RAW =
+$(PLATFORM_BOARD_PACKAGE)/LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
+}
+
+!endif
+

[FV.FvUefiBoot]
FvAlignment = 16
diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.dsc b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.dsc
index 36a29c8d68..ff27252233 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.dsc
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig
+++ .dsc
@@ -51,7 +51,14 @@

gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable|TRUE

+ gPlatformTokenSpaceGuid.PcdLinuxBootEnable|FALSE
+
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+ gPlatformTokenSpaceGuid.PcdFastBoot|TRUE
+!else
gPlatformTokenSpaceGuid.PcdFastBoot|FALSE
+!endif
+
!if gPlatformTokenSpaceGuid.PcdFastBoot == TRUE
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable|FALSE
gPlatformTokenSpaceGuid.PcdUpdateConsoleInBds|FALSE
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/LinuxKernel.inf b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/LinuxKernel.inf
new file mode 100644
index 0000000000..a249027d22
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/Linux
+++ Kernel.inf
@@ -0,0 +1,9 @@
+[Defines]
+ INF_VERSION = 1.27
+ BASE_NAME = LinuxKernel
+ FILE_GUID = 81339b04-fa8c-4be0-9ca7-916fc5319eb5
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+
+[Binaries.common.AARCH64]
+ PE32|linux.efi|*
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/initrd.cpio.xz b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
new file mode 100644
index 0000000000000000000000000000000000000000..01d633b27e8ea9b17084fc911d0c8cc43a4170a9
GIT binary patch
literal 16
KcmZQzKm`B*5C8!H

literal 0
HcmV?d00001

diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/linux.efi b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBinaries/linux.efi
new file mode 100644
index 0000000000000000000000000000000000000000..01d633b27e8ea9b17084fc911d0c8cc43a4170a9
GIT binary patch
literal 16
KcmZQzKm`B*5C8!H

literal 0
HcmV?d00001

diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.c b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.c
new file mode 100644
index 0000000000..eec05824d6
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.c
@@ -0,0 +1,422 @@
+/** @file
+
+Copyright (c) 2021, American Megatrends International LLC. All rights
+reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/**
+ *
+ * This library will load the Linux kernel and initrd from the BIOS and launch it.
+ *
+ */
+
+//---------------------------------------------------------------------
+------
+
+#include <PiDxe.h>
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h> #include
+<Library/UefiBootServicesTableLib.h>
+#include <Guid/DxeServices.h>
+#include <Library/DxeServicesTableLib.h> #include <Library/UefiLib.h>
+#include <Protocol/FirmwareVolume2.h> #include <Protocol/LoadedImage.h>
+#include <Guid/MemoryTypeInformation.h> #include <Pi/PiDxeCis.h>
+#include <Pi/PiHob.h> #include <Library/PcdLib.h> #include
+<Library/DxeServicesLib.h> #include "LinuxBoot.h"
+
+//16b60e5d-f1c5-42f0-9b34-08C81C430473
+#define LINUX_BOOT_INITRD_GUID \
+ { \
+ 0x16b60e5d, 0xf1c5, 0x42f0, {0x9b, 0x34, 0x08, 0xc8, 0x1c, 0x43,
+0x04, 0x73} \
+ }
+
+#define LINUX_BOOT_KERNEL_GUID \
+ { \
+ 0x81339b04, 0xfa8c, 0x4be0, {0x9c, 0xa7, 0x91, 0x6f, 0xc5, 0x31,
+0x9e, 0xb5} \
+ }
+
+
+EFI_STATUS
+EFIAPI
+LoadLinuxCheckKernelSetup (
+ IN VOID *KernelSetup,
+ IN UINTN KernelSetupSize
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateKernelSetupPages (
+ IN UINTN Pages
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinuxInitializeKernelSetup (
+ IN VOID *KernelSetup
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateKernelPages (
+ IN VOID *KernelSetup,
+ IN UINTN Pages
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinuxSetCommandLine (
+ IN OUT VOID *KernelSetup,
+ IN CHAR8 *CommandLine
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinux (
+ IN VOID *Kernel,
+ IN OUT VOID *KernelSetup
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateInitrdPages (
+ IN VOID *KernelSetup,
+ IN UINTN Pages
+ );
+
+EFI_GUID gLinuxBootInitrdFileGuid = LINUX_BOOT_INITRD_GUID;
+
+EFI_GUID gLinuxBootKernelFileGuid = LINUX_BOOT_KERNEL_GUID;
+
+//---------------------------------------------------------------------
+------
+
+/**
+ Dump some hexadecimal data to the screen.
+
+ @note Function taken from
+ ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c in EDKII
+
+ @param[in] Indent How many spaces to indent the output.
+ @param[in] Offset The offset of the printing.
+ @param[in] DataSize The size in bytes of UserData.
+ @param[in] UserData The data to print out.
+**/
+static
+VOID
+DumpHex (
+ IN UINTN Indent,
+ IN UINTN Offset,
+ IN UINTN DataSize,
+ IN VOID *UserData
+ )
+{
+ UINT8 *Data;
+ CHAR8 Val[50];
+ CHAR8 Str[20];
+ UINT8 TempByte;
+ UINTN Size;
+ UINTN Index;
+ CHAR8 Hex[] = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
+ };
+
+ DEBUG((DEBUG_INFO, "%*a 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n", Indent, ""));
+ DEBUG((DEBUG_INFO, "%*a ------------------------------------------------\n", Indent, ""));
+
+ Data = UserData;
+ while (DataSize != 0) {
+ Size = 16;
+ if (Size > DataSize) {
+ Size = DataSize;
+ }
+
+ for (Index = 0; Index < Size; Index += 1) {
+ TempByte = Data[Index];
+ Val[Index * 3 + 0] = Hex[TempByte >> 4];
+ Val[Index * 3 + 1] = Hex[TempByte & 0xF];
+ Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' ');
+ Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
+ }
+
+ Val[Index * 3] = 0;
+ Str[Index] = 0;
+ DEBUG((DEBUG_INFO, "%*a%08X: %-48a %a\n", Indent, "", Offset, Val,
+ Str));
+
+ Data += Size;
+ Offset += Size;
+ DataSize -= Size;
+ }
+}
+
+
+/**
+ * This function completes a minimal amount of the necessary BDS
+functions to prepare
+ * for booting the kernel.
+ *
+ * @param None
+ *
+ * @retval EFI_SUCCESS Successfully completed remaining tasks
+ * @return EFI_ERROR Could not complete BDS tasks
+ */
+EFI_STATUS
+CompleteBdsTasks (
+ VOID
+)
+{
+
+ return EFI_SUCCESS;
+}
+
+/**
+ * This function will load and launch the Linux kernel from a BIOS FV.
+ *
+ * @note This function is not intended to return. Any exiting from this function indicates
+ * a problem loading or launching the kernel.
+ *
+ * @param None
+ *
+ * @return EFI_ERROR Any error code
+ */
+EFI_STATUS
+LoadAndLaunchKernel (
+ VOID
+)
+{
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage = NULL;
+ EFI_STATUS Status;
+ EFI_HANDLE KernelHandle = NULL;
+ VOID *KernelBuffer = NULL;
+ VOID *KernelFfsBuffer = NULL;
+ UINTN KernelFfsSize = 0;
+ VOID *InitrdData = NULL;
+ VOID *InitrdBuffer = NULL;
+ UINTN InitrdSize = 0;
+ struct boot_params *BootParams = NULL;
+ struct boot_params *HandoverParams = NULL;
+ UINT32 StartOffset = 0;
+ UINT32 KernelLength = 0;
+ UINT8 *Temp;
+ UINT8 CmdLine[] = " ";
+
+ DEBUG((DEBUG_INFO, "LoadAndLaunchKernel Entry\n"));
+
+ ///
+ /// Kernel load and preparation
+ ///
+ DEBUG((DEBUG_INFO, "Preparing the kernel...\n"));
+
+ // Retrieve the kernel from the firmware volume
+ Status = GetSectionFromAnyFv(
+ &gLinuxBootKernelFileGuid,
+ EFI_SECTION_PE32,
+ 0,
+ &KernelFfsBuffer,
+ &KernelFfsSize
+ );
+
+ DEBUG((DEBUG_INFO, "Status %r\n",Status));
+ DEBUG((DEBUG_INFO, "KernelFfsBuffer %x\n",KernelFfsBuffer));
+ DEBUG((DEBUG_INFO, "KernelFfsSize %x\n",KernelFfsSize));
+
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not retrieve kernel; %r.\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Loaded kernel to buffer at 0x%p with size 0x%X.\n", KernelFfsBuffer, KernelFfsSize));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes:\n",
+ MIN(KernelFfsSize, 0x100)));
+
+ DumpHex(2, 0, MIN(0x100, KernelFfsSize), KernelFfsBuffer);
+
+ // Create a LoadImage protocol for the kernel
+ Status = gBS->LoadImage(TRUE, gImageHandle, NULL, KernelFfsBuffer, KernelFfsSize, &KernelHandle);
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not create LoadImage for kernel %r\n", Status));
+ goto FatalError;
+ }
+
+ // Get the new LoadedImage protocol to retrieve information about the kernel
+ Status = gBS->HandleProtocol(KernelHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not get kernel LoadedImage protocol; %r\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Kernel LoadedImage information:\n"));
+ DEBUG((DEBUG_INFO, " ImageBase = 0x%p\n", LoadedImage->ImageBase));
+ DEBUG((DEBUG_INFO, " ImageSize = 0x%p\n",
+ LoadedImage->ImageSize));
+
+ // Verify the kernel boot parameters from the LoadedImage and allocate an initalization buffer once verified
+ BootParams = (struct boot_params*) LoadedImage->ImageBase;
+
+ Status = LoadLinuxCheckKernelSetup((VOID *) BootParams, sizeof(struct boot_params));
+ if (EFI_ERROR (Status)) {
+ DEBUG((DEBUG_ERROR, "LoadLinuxCheckKernelSetup failed; %r.\n", Status));
+ goto FatalError;
+ }
+
+ HandoverParams = LoadLinuxAllocateKernelSetupPages(EFI_SIZE_TO_PAGES(KERNEL_SETUP_SIZE));
+ if (HandoverParams == NULL) {
+ DEBUG((DEBUG_ERROR, "Could not allocate memory for kernel handover parameters.\n"));
+ goto FatalError;
+ }
+ DEBUG((DEBUG_INFO, "Handover parameters allocated at 0x%p\n",
+ HandoverParams));
+
+ gBS->CopyMem(&HandoverParams->hdr, &BootParams->hdr, sizeof(struct
+ setup_header));
+
+ Status = LoadLinuxInitializeKernelSetup(HandoverParams);
+ if (EFI_ERROR (Status)) {
+ DEBUG((DEBUG_ERROR, "Unable to initialize the handover parameters; %r.\n", Status));
+ goto FatalError;
+ }
+
+ // Allocate space for the kernel and copy it into the new buffer
+ KernelBuffer = LoadLinuxAllocateKernelPages(HandoverParams, EFI_SIZE_TO_PAGES(HandoverParams->hdr.init_size));
+ if (KernelBuffer == NULL) {
+ DEBUG((DEBUG_ERROR, "Unable to allocate memory for kernel.\n"));
+ goto FatalError;
+ }
+
+ StartOffset = (HandoverParams->hdr.setup_secs + 1) * 512;
+ KernelLength = (UINT32) (KernelFfsSize - StartOffset);
+ Temp = (UINT8 *) LoadedImage->ImageBase;
+
+ DEBUG((DEBUG_INFO, "Kernel starts at offset 0x%X with length
+ 0x%X\n", StartOffset, KernelLength));
+
+ gBS->CopyMem(KernelBuffer, (Temp + StartOffset), KernelLength);
+ DEBUG((DEBUG_INFO, "First 0x%X bytes of new kernel buffer
+ contents:\n", MIN(0x100, KernelLength)));
+
+ DumpHex(2, 0, MIN(0x100, KernelLength), KernelBuffer);
+
+ // Prepare the command line
+ Status = LoadLinuxSetCommandLine(HandoverParams, (UINT8 *) &CmdLine);
+ if (EFI_ERROR (Status)) {
+ DEBUG((EFI_D_INFO, "Unable to set linux command line; %r.\n", Status));
+ goto FatalError;
+ }
+
+ HandoverParams->hdr.code32_start = (UINT32)(UINTN) KernelBuffer;
+ HandoverParams->hdr.loader_id = 0x21;
+
+ DEBUG((DEBUG_INFO, "Kernel loaded.\n"));
+
+#if 1
+//#if defined(INTEGRATED_INITRAM_FS) && (INTEGRATED_INITRAM_FS ==0)
+ ///
+ /// Initrd load and preparation
+ ///
+ DEBUG((DEBUG_INFO, "Preparing the initrd...\n"));
+
+ // Retrieve the initrd from the firmware volume
+ Status = GetSectionFromAnyFv(
+ &gLinuxBootInitrdFileGuid,
+ EFI_SECTION_RAW,
+ 0,
+ &InitrdBuffer,
+ &InitrdSize
+ );
+
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not retrieve initrd; %r.\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Loaded initrd to buffer at 0x%p with size 0x%X.\n", InitrdBuffer, InitrdSize));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes:\n", MIN(0x100, InitrdSize)));
+ DumpHex(2, 0, MIN(0x100, InitrdSize), InitrdBuffer);
+
+ // Allocate the initrd for the kernel and copy it in
+ InitrdData = LoadLinuxAllocateInitrdPages(HandoverParams, EFI_SIZE_TO_PAGES(InitrdSize));
+ if (InitrdData == NULL) {
+ DEBUG((DEBUG_ERROR, "Unable to allocate memory for initrd.\n"));
+ goto FatalError;
+ }
+
+ gBS->CopyMem(InitrdData, InitrdBuffer, InitrdSize);
+
+ HandoverParams->hdr.ramdisk_start = (UINT32)(UINTN) InitrdData;
+ HandoverParams->hdr.ramdisk_len = (UINT32) InitrdSize;
+
+ DEBUG((DEBUG_INFO, "Initrd loaded.\n"));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes of initrd buffer:\n", MIN(0x100, InitrdSize)));
+ DumpHex(2, 0, MIN(0x100, InitrdSize), InitrdData);
+
+ // General cleanup before launching the kernel
+ gBS->FreePool(InitrdBuffer);
+ InitrdBuffer = NULL;
+#endif
+
+ gBS->UnloadImage(KernelHandle);
+ gBS->FreePool(KernelFfsBuffer);
+ KernelFfsBuffer = NULL;
+
+ DEBUG((DEBUG_ERROR, "Launching the kernel\n"));
+
+
+ //
+ // Signal the EFI_EVENT_GROUP_READY_TO_BOOT event.
+ //
+ EfiSignalEventReadyToBoot();
+
+
+ // Launch the kernel
+ Status = LoadLinux(KernelBuffer, HandoverParams);
+
+ ///
+ /// LoadLinux should never return if the kernel boots. Anything past here is an error scenario
+ ///
+ DEBUG((DEBUG_ERROR, "ERROR: LoadLinux has returned with status;
+ %r.\n", Status));
+
+FatalError:
+ // Free everything
+ if (InitrdData != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS) InitrdData, EFI_SIZE_TO_PAGES(InitrdSize));
+ if (KernelBuffer != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS) KernelBuffer, EFI_SIZE_TO_PAGES(HandoverParams->hdr.init_size));
+ if (HandoverParams != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS) HandoverParams, EFI_SIZE_TO_PAGES(KERNEL_SETUP_SIZE));
+ if (InitrdBuffer != NULL) gBS->FreePool(InitrdBuffer);
+ if (KernelHandle != NULL) gBS->UnloadImage(KernelHandle);
+ if (KernelFfsBuffer != NULL) gBS->FreePool(KernelFfsBuffer);
+
+ return EFI_NOT_FOUND;
+}
+
+/**
+ * This is the main function for this feature. This will handle
+finding and launching
+ * the Linux kernel.
+ *
+ * @note In general, this function will never return to BDS. The LINUXBOOT_ALLOW_RETURN_TO_BDS
+ * token will allow you to return to BDS if the kernel fails to launch for some reason.
+ *
+ * @param None
+ *
+ * @retval None
+ */
+
+EFI_STATUS
+LinuxBootStart (
+ VOID
+ )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ // Finish BDS and then try to launch the kernel
+ //Status = CompleteBdsTasks();
+
+ if (!EFI_ERROR(Status)) {
+ LoadAndLaunchKernel();
+ }
+
+ DEBUG((DEBUG_ERROR, "-----------------------------------\n"));
+ DEBUG((DEBUG_ERROR, " ERROR: Kernel failed to launch.\n"));
+ DEBUG((DEBUG_ERROR, "-----------------------------------\n"));
+ return Status;
+}
+
+//---------------------------------------------------------------------
+------
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.h b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.h
new file mode 100644
index 0000000000..479fb8cbfd
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.h
@@ -0,0 +1,193 @@
+/** @file
+
+Copyright (c) 2021, American Megatrends International LLC. All rights
+reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/**
+ *
+ * Header for library definitions and prototypes.
+ *
+ */
+
+#ifndef __LINUX_BOOT_PRIVATE__H__
+#define __LINUX_BOOT_PRIVATE__H__
+#ifdef __cplusplus
+extern "C" {
+#endif // #ifdef __cplusplus
+
+//---------------------------------------------------------------------
+------
+
+//#include <Token.h>
+
+#define BOOTSIG 0x1FE
+#define SETUP_HDR 0x53726448 /* 0x53726448 == "HdrS" */
+
+#define E820_RAM 1
+#define E820_RESERVED 2
+#define E820_ACPI 3
+#define E820_NVS 4
+#define E820_UNUSABLE 5
+
+#pragma pack(1)
+
+struct setup_header {
+ UINT8 setup_secs; /* Sectors for setup code */
+ UINT16 root_flags;
+ UINT32 sys_size;
+ UINT16 ram_size;
+ UINT16 video_mode;
+ UINT16 root_dev;
+ UINT16 signature; /* Boot signature */
+ UINT16 jump;
+ UINT32 header;
+ UINT16 version;
+ UINT16 su_switch;
+ UINT16 setup_seg;
+ UINT16 start_sys;
+ UINT16 kernel_ver;
+ UINT8 loader_id;
+ UINT8 load_flags;
+ UINT16 movesize;
+ UINT32 code32_start; /* Start of code loaded high */
+ UINT32 ramdisk_start; /* Start of initial ramdisk */
+ UINT32 ramdisk_len; /* Length of initial ramdisk */
+ UINT32 bootsect_kludge;
+ UINT16 heap_end;
+ UINT8 ext_loader_ver; /* Extended boot loader version */
+ UINT8 ext_loader_type; /* Extended boot loader ID */
+ UINT32 cmd_line_ptr; /* 32-bit pointer to the kernel command line */
+ UINT32 ramdisk_max; /* Highest legal initrd address */
+ UINT32 kernel_alignment; /* Physical addr alignment required for kernel */
+ UINT8 relocatable_kernel; /* Whether kernel is relocatable or not */
+ UINT8 min_alignment;
+ UINT16 xloadflags;
+ UINT32 cmdline_size;
+ UINT32 hardware_subarch;
+ UINT64 hardware_subarch_data;
+ UINT32 payload_offset;
+ UINT32 payload_length;
+ UINT64 setup_data;
+ UINT64 pref_address;
+ UINT32 init_size;
+ UINT32 handover_offset;
+};
+
+struct efi_info {
+ UINT32 efi_loader_signature;
+ UINT32 efi_systab;
+ UINT32 efi_memdesc_size;
+ UINT32 efi_memdesc_version;
+ UINT32 efi_memmap;
+ UINT32 efi_memmap_size;
+ UINT32 efi_systab_hi;
+ UINT32 efi_memmap_hi;
+};
+
+struct e820_entry {
+ UINT64 addr; /* start of memory segment */
+ UINT64 size; /* size of memory segment */
+ UINT32 type; /* type of memory segment */
+};
+
+struct screen_info {
+ UINT8 orig_x; /* 0x00 */
+ UINT8 orig_y; /* 0x01 */
+ UINT16 ext_mem_k; /* 0x02 */
+ UINT16 orig_video_page; /* 0x04 */
+ UINT8 orig_video_mode; /* 0x06 */
+ UINT8 orig_video_cols; /* 0x07 */
+ UINT8 flags; /* 0x08 */
+ UINT8 unused2; /* 0x09 */
+ UINT16 orig_video_ega_bx;/* 0x0a */
+ UINT16 unused3; /* 0x0c */
+ UINT8 orig_video_lines; /* 0x0e */
+ UINT8 orig_video_isVGA; /* 0x0f */
+ UINT16 orig_video_points;/* 0x10 */
+
+ /* VESA graphic mode -- linear frame buffer */
+ UINT16 lfb_width; /* 0x12 */
+ UINT16 lfb_height; /* 0x14 */
+ UINT16 lfb_depth; /* 0x16 */
+ UINT32 lfb_base; /* 0x18 */
+ UINT32 lfb_size; /* 0x1c */
+ UINT16 cl_magic, cl_offset; /* 0x20 */
+ UINT16 lfb_linelength; /* 0x24 */
+ UINT8 red_size; /* 0x26 */
+ UINT8 red_pos; /* 0x27 */
+ UINT8 green_size; /* 0x28 */
+ UINT8 green_pos; /* 0x29 */
+ UINT8 blue_size; /* 0x2a */
+ UINT8 blue_pos; /* 0x2b */
+ UINT8 rsvd_size; /* 0x2c */
+ UINT8 rsvd_pos; /* 0x2d */
+ UINT16 vesapm_seg; /* 0x2e */
+ UINT16 vesapm_off; /* 0x30 */
+ UINT16 pages; /* 0x32 */
+ UINT16 vesa_attributes; /* 0x34 */
+ UINT32 capabilities; /* 0x36 */
+ UINT8 _reserved[6]; /* 0x3a */
+};
+
+struct boot_params {
+ struct screen_info screen_info;
+ UINT8 apm_bios_info[0x14];
+ UINT8 _pad2[4];
+ UINT64 tboot_addr;
+ UINT8 ist_info[0x10];
+ UINT8 _pad3[16];
+ UINT8 hd0_info[16];
+ UINT8 hd1_info[16];
+ UINT8 sys_desc_table[0x10];
+ UINT8 olpc_ofw_header[0x10];
+ UINT8 _pad4[128];
+ UINT8 edid_info[0x80];
+ struct efi_info efi_info;
+ UINT32 alt_mem_k;
+ UINT32 scratch;
+ UINT8 e820_entries;
+ UINT8 eddbuf_entries;
+ UINT8 edd_mbr_sig_buf_entries;
+ UINT8 _pad6[6];
+ struct setup_header hdr;
+ UINT8 _pad7[0x290-0x1f1-sizeof(struct setup_header)];
+ UINT32 edd_mbr_sig_buffer[16];
+ struct e820_entry e820_map[128];
+ UINT8 _pad8[48];
+ UINT8 eddbuf[0x1ec];
+ UINT8 _pad9[276];
+};
+#pragma pack ()
+
+//---------------------------------------------------------------------
+------
+
+#ifndef MIN
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#endif // #ifndef MIN
+
+#define KERNEL_SETUP_SIZE 16384
+
+//---------------------------------------------------------------------
+------
+
+///
+/// Function prototypes from Bds module /// VOID ConnectEverything();
+VOID RecoverTheMemoryAbove4Gb(); VOID SignalAllDriversConnectedEvent();
+VOID SignalProtocolEvent(IN EFI_GUID *ProtocolGuid);
+
+#if LINUXBOOT_SIGNAL_EXITPMAUTH == 1
+VOID SignalExitPmAuthProtocolEvent(VOID);
+#endif // #if LINUXBOOT_SIGNAL_EXITPMAUTH == 1
+
+typedef VOID (BDS_CONTROL_FLOW_FUNCTION)();
+
+//---------------------------------------------------------------------
+------
+
+/****** DO NOT WRITE BELOW THIS LINE *******/ #ifdef __cplusplus }
+#endif // #ifdef __cplusplus #endif // #ifndef
+__LINUX_BOOT_PRIVATE__H__
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.inf b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.inf
new file mode 100644
index 0000000000..62e09a75c8
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBoot.inf
@@ -0,0 +1,46 @@
+## @file
+#
+# Copyright (c) 2021, American Megatrends International LLC. All rights
+reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # ##
+
+##
+#
+# This library links with the Bds module to launch the Linux kernel.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ VERSION_STRING = 1.0
+ BASE_NAME = LinuxBoot
+ FILE_GUID = 74a41ddc-fac5-4787-afad-d81ee30a8b63 # {0x74a41ddc, 0xfac5, 0x4787, {0xaf, 0xad, 0xd8, 0x1e, 0xe3, 0x0a, 0x8b, 0x63}}
+ MODULE_TYPE = DXE_DRIVER
+ LIBRARY_CLASS = LinuxBootLib|DXE_DRIVER
+[Sources]
+ LinuxBoot.c
+ LinuxBoot.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ DxeServicesLib
+ BaseMemoryLib
+ DebugLib
+ UefiRuntimeServicesTableLib
+ UefiBootServicesTableLib
+ UefiLib
+ LoadLinuxLib
+
+[Guids]
+
+[Protocols]
+ gEfiLoadedImageProtocolGuid
+
+[Pcd]
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.c b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.c
new file mode 100644
index 0000000000..fa6ea117f4
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.c
@@ -0,0 +1,43 @@
+/** @file
+
+Copyright (c) 2021, American Megatrends International LLC. All rights
+reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/**
+ *
+ * This library will load the Linux kernel and initrd from the BIOS and launch it.
+ *
+ */
+
+//---------------------------------------------------------------------
+------
+
+#include <PiDxe.h>
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+
+/**
+ * This is the main function for this feature. This will handle
+finding and launching
+ * the Linux kernel.
+ *
+ * @note In general, this function will never return to BDS. The LINUXBOOT_ALLOW_RETURN_TO_BDS
+ * token will allow you to return to BDS if the kernel fails to launch for some reason.
+ *
+ * @param None
+ *
+ * @retval None
+ */
+
+EFI_STATUS
+LinuxBootStart (
+ VOID
+ )
+{
+
+ return EFI_SUCCESS;
+}
+
+//---------------------------------------------------------------------
+------
diff --git a/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.inf b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.inf
new file mode 100644
index 0000000000..3ed53c6ba0
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/LinuxBootPkg/LinuxBootNull.inf
@@ -0,0 +1,31 @@
+## @file
+#
+# Copyright (c) 2021, American Megatrends International LLC. All rights
+reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # ##
+
+##
+#
+# This library links with the Bds module to launch the Linux kernel.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ VERSION_STRING = 1.0
+ BASE_NAME = LinuxBoot
+ FILE_GUID = 0551B6D3-0594-4B02-AF42-5A9C7515CEC8
+ MODULE_TYPE = DXE_DRIVER
+ LIBRARY_CLASS = LinuxBootLib|DXE_DRIVER
+[Sources]
+ LinuxBootNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ DxeServicesLib
\ No newline at end of file
diff --git a/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec b/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
index 4dcec5430b..0c1ab318b8 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
+++ b/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
@@ -49,6 +49,8 @@

gPlatformTokenSpaceGuid.PcdUpdateConsoleInBds|TRUE|BOOLEAN|0x30000035

+ gPlatformTokenSpaceGuid.PcdLinuxBootEnable|FALSE|BOOLEAN|0x30000036
+
[PcdsDynamicEx]
gPlatformTokenSpaceGuid.PcdDfxAdvDebugJumper|FALSE|BOOLEAN|0x6000001D

diff --git a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
index b3b8ceba6f..bd0509ab10 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
+++ b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatf
+++ ormPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
@@ -2,6 +2,7 @@
This file include all platform action which can be customized by IBV/OEM.

Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2021, American Megatrends International LLC.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -31,6 +32,12 @@ BOOLEAN gPPRequireUIConfirm;

extern UINTN mBootMenuOptionNumber;

+EFI_STATUS
+LinuxBootStart (
+ VOID
+ );
+
+
GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath = {
{
{
@@ -1268,6 +1275,8 @@ PlatformBootManagerAfterConsole (
LocalBootMode = gBootMode;
DEBUG ((DEBUG_INFO, "Current local bootmode - %x\n", LocalBootMode));

+ LinuxBootStart();
+
//
// Go the different platform policy with different boot mode
// Notes: this part code can be change with the table policy diff --git a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
index 5790743565..21ac65257c 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
+++ b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatf
+++ ormPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerL
+++ ib.inf
@@ -2,6 +2,7 @@
# Component name for module DxePlatformBootManagerLib # # Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2021, American Megatrends International LLC.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -40,6 +41,7 @@
PerformanceLib
TimerLib
Tcg2PhysicalPresenceLib
+ LinuxBootLib

[Packages]
MdePkg/MdePkg.dec
diff --git a/Platform/Intel/Readme.md b/Platform/Intel/Readme.md index 06c5f32b1e..a34784ccb8 100644
--- a/Platform/Intel/Readme.md
+++ b/Platform/Intel/Readme.md
@@ -87,6 +87,11 @@ A UEFI firmware implementation using MinPlatformPkg is constructed using the fol ----------------------------------------|--------------------------------------------|------------------------------|--------------------|
| Mt. Olympus | Purley | PurleyOpenBoardPkg | BoardMtOlympus |

+| Machine Name | Supported Chipsets | BoardPkg | Board Name |
+----------------------------------------|--------------------------------------------|------------------------------|--------------------|
+| TiogaPass | Purley | PurleyOpenBoardPkg | BoardTiogaPass |
+
+
#### Simics

| Machine Name | Supported Chipsets | BoardPkg | Board Name |
@@ -250,6 +255,12 @@ return back to the minimum platform caller.
| | | | build settings, environment variables.
| | | |---build_board.py: Optional board-specific pre-build,
| | | build, post-build and clean functions.
+ | | |------PurleyOpenBoardPkg
+ | | | |------BoardTiogaPass
+ | | | |---build_config.cfg: BoardTiogaPass specific
+ | | | | build settings, environment variables.
+ | | | |---build_board.py: Optional board-specific pre-build,
+ | | | build, post-build and clean functions.
| | |
| | |------SimicsOpenBoardPkg
| | | |------BoardX58Ich10
@@ -292,6 +303,18 @@ For PurleyOpenBoardPkg
"bld cache-consume" Consume a cache of binary files from the specified directory, BINARY_CACHE_PATH is empty,
used "BinCache" as default path.

+For PurleyOpenBoardPkg (TiogaPass)
+1. Open command window, go to the workspace directory, e.g. c:\Edk2Workspace.
+2. Type "cd edk2-platforms\Platform\Intel\PurleyOpenBoardPkg\BoardTiogaPass".
+3. Type "GitEdk2MinBoardTiogaPass.bat" to setup GIT environment.
+4. Type "bld" to build Purley BoardTiogaPass board UEFI firmware image, "bld release" for release build, "bld clean" to
+ remove intermediate files."bld cache-produce" Generate a cache of binary files in the specified directory,
+ "bld cache-consume" Consume a cache of binary files from the specified directory, BINARY_CACHE_PATH is empty,
+ used "BinCache" as default path.
+5. Final BIOS image will be Build\PurleyOpenBoardPkg\BoardTiagoPass\DEBUG_VS2015x86\FV\PLATFORM.fd or
+ Build\PurleyOpenBoardPkg\BoardTiagoPass\RELEASE_VS2015x86\FV\PLATFORM.fd, depending on bld batch script input.
+6. This BIOS image needs to be merged with SPS FW
+
### **Known limitations**

**KabylakeOpenBoardPkg**
@@ -307,6 +330,25 @@ For PurleyOpenBoardPkg 2. This firmware project does not build with the GCC compiler.
3. The validated version of iASL compiler that can build MinPurley is 20180629. Older versions may generate ACPI build errors.

+**PurleyOpenBoardPkg Tioga Pass **
+1. This firmware project has only been tested on the Tioga Pass hardware.
+2. This firmware project build has only been tested using the Microsoft Visual Studio 2015 build tools.
+3. This firmware project does not build with the GCC compiler.
+4. The validated version of iASL compiler that can build MinPurley is 20180629. Older versions may generate ACPI build errors.
+5. Installed and booted to UEFI Windows 2016 on M.2 NVME slot 6.
+Installed and booted to UEFI Windows 2019 on M.2 NVME slot and with SATA HDD.
+7. Installed and booted to UEFI RHEL 7.3 on SATA HDD 8. Installed and
+booted to Ubuntu 18.04 on M.2 NVME slot.
+9. Verified Mellanox card detection during POST and OS 10. LINUX Boot
+Support (PcdLinuxBootEnable needs to be enabled)
+
+1. Follow directions on http://osresearch.net/Building/ to compile the heads kernel and initrd for qemu-system_x86_64
+2. Copy the following built files
+(1) initrd.cpio.xz to LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
+(2) bzimage to LinuxBootPkg/LinuxBinaries/linux.efi
+
+
+
**SimicsOpenBoardPkg**
1. This firmware project has only been tested booting to Microsoft Windows 10 x64 and Ubuntu 17.10 with AHCI mode.

--
2.25.0.windows.1


Please consider the environment before printing this email.

The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.
GitPatchExtractor 1.1