(TEST) SimpleInit: add Boot Menu and Linux Boot
authorBigfootACA <bigfoot@classfun.cn>
星期三, 23 Feb 2022 14:48:16 +0000 (22:48 +0800)
committerBigfootACA <bigfoot@classfun.cn>
星期三, 23 Feb 2022 16:31:12 +0000 (00:31 +0800)
note: at present, the downstream android kernel cannot be started normally

22 files changed:
sdm845Pkg/Binary
sdm845Pkg/CommonDsc.dsc.inc
sdm845Pkg/Devices/845.fdf
sdm845Pkg/Devices/beryllium.fdf
sdm845Pkg/Devices/dipper.fdf
sdm845Pkg/Devices/enchilada.fdf
sdm845Pkg/Devices/fajita.fdf
sdm845Pkg/Devices/m1892.fdf
sdm845Pkg/Devices/odin.fdf
sdm845Pkg/Devices/perseus.fdf
sdm845Pkg/Devices/polaris.fdf
sdm845Pkg/Devices/trident.fdf
sdm845Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf
sdm845Pkg/Include/Library/FdtParserLib.h
sdm845Pkg/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
sdm845Pkg/Library/MemoryInitPeiLib/PeiMemoryAllocationLib.inf
sdm845Pkg/Library/PlatformBootManagerLib/PlatformBm.c
sdm845Pkg/Library/SimpleInit
sdm845Pkg/Library/sdm845Lib/sdm845Helper.S
sdm845Pkg/Library/sdm845Lib/sdm845Lib.inf
sdm845Pkg/sdm845Pkg.dec
sdm845Pkg/sdm845Pkg.dsc

index c775d7fe1713b041219c7dfafc6265219c901d6d..a1954c67cb3feb0ed937844ef0bd7be02642b71d 160000 (submodule)
@@ -1 +1 @@
-Subproject commit c775d7fe1713b041219c7dfafc6265219c901d6d
+Subproject commit a1954c67cb3feb0ed937844ef0bd7be02642b71d
index ca5ca38f28915da27c82f1e47cd9c7219f9c4e67..884d9ea09c8a9e91df64cb4d866356142f4795ab 100644 (file)
@@ -14,7 +14,7 @@
 #
 
 !include MdePkg/MdeLibs.dsc.inc
-!include sdm845Pkg/Library/SimpleInit/SimpleInit.inc
+!include SimpleInit.inc
 
 [LibraryClasses.common]
 !if $(TARGET) == RELEASE
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|32
 
 [PcdsDynamicHii.common.DEFAULT]
-  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|3 # Variable: L"Timeout"
+  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|0 # Variable: L"Timeout"
index 2bda0f5e849a5bf2b051031d3a8708113bda769d..c064d5f83e71bfbb0b97d88cbc35fbadeb1cb38d 100644 (file)
@@ -180,6 +180,11 @@ APRIORI DXE {
     SECTION UI = "PlatformInfoDxeDriver"
   }
 
+  FILE DRIVER = 7DB0793A-4402-4BE1-906E-D0FABAD2707E {
+    SECTION PE32 = sdm845Pkg/Binary/845/DDRInfoDxe/DDRInfoDxe.efi
+    SECTION UI = "DDRInfoDxe"
+  }
+
   FILE DRIVER = 9A00771F-36D4-4DD5-8916-C48ED9B16B86 {
     SECTION DXE_DEPEX = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.depex
     SECTION PE32 = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.efi
@@ -583,6 +588,8 @@ APRIORI DXE {
   #
   INF src/main/SimpleInitMain.inf
 
+  INF src/kernelfdt/KernelFdtDxe.inf
+
 [FV.FVMAIN_COMPACT]
 FvAlignment        = 8
 ERASE_POLARITY     = 1
index 8f8e5c44c4b97e6c971eb606c0baad78b9a8411b..de57b6ed96bed6c90adced84c413c6f103f311a3 100644 (file)
@@ -180,6 +180,11 @@ APRIORI DXE {
     SECTION UI = "PlatformInfoDxeDriver"
   }
 
+  FILE DRIVER = 7DB0793A-4402-4BE1-906E-D0FABAD2707E {
+    SECTION PE32 = sdm845Pkg/Binary/845/DDRInfoDxe/DDRInfoDxe.efi
+    SECTION UI = "DDRInfoDxe"
+  }
+
   FILE DRIVER = 9A00771F-36D4-4DD5-8916-C48ED9B16B86 {
     SECTION DXE_DEPEX = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.depex
     SECTION PE32 = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.efi
@@ -577,6 +582,8 @@ APRIORI DXE {
   INF MdeModulePkg/Application/UiApp/UiApp.inf
   INF sdm845Pkg/Drivers/LogoDxe/LogoDxe.inf
 
+  INF src/kernelfdt/KernelFdtDxe.inf
+
 [FV.FVMAIN_COMPACT]
 FvAlignment        = 8
 ERASE_POLARITY     = 1
index 31af8eefd5b6490dea73a4b36808ece85883a4e6..757446ac01cd171dab5ef864e73715f7c5e3bdb3 100644 (file)
@@ -180,6 +180,11 @@ APRIORI DXE {
     SECTION UI = "PlatformInfoDxeDriver"
   }
 
+  FILE DRIVER = 7DB0793A-4402-4BE1-906E-D0FABAD2707E {
+    SECTION PE32 = sdm845Pkg/Binary/845/DDRInfoDxe/DDRInfoDxe.efi
+    SECTION UI = "DDRInfoDxe"
+  }
+
   FILE DRIVER = 9A00771F-36D4-4DD5-8916-C48ED9B16B86 {
     SECTION DXE_DEPEX = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.depex
     SECTION PE32 = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.efi
@@ -571,6 +576,7 @@ APRIORI DXE {
   #
   INF src/main/SimpleInitMain.inf
 
+  INF src/kernelfdt/KernelFdtDxe.inf
 
 [FV.FVMAIN_COMPACT]
 FvAlignment        = 8
index 36e641c83a8de44c5eeadb0812f7b1dc628134e9..43d99f6d563bfb416d1e3ddc35c61a77cc505b75 100644 (file)
@@ -180,6 +180,11 @@ APRIORI DXE {
     SECTION UI = "PlatformInfoDxeDriver"
   }
 
+  FILE DRIVER = 7DB0793A-4402-4BE1-906E-D0FABAD2707E {
+    SECTION PE32 = sdm845Pkg/Binary/845/DDRInfoDxe/DDRInfoDxe.efi
+    SECTION UI = "DDRInfoDxe"
+  }
+
   FILE DRIVER = 9A00771F-36D4-4DD5-8916-C48ED9B16B86 {
     SECTION DXE_DEPEX = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.depex
     SECTION PE32 = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.efi
@@ -606,6 +611,8 @@ APRIORI DXE {
   #
   INF src/main/SimpleInitMain.inf
 
+  INF src/kernelfdt/KernelFdtDxe.inf
+
 [FV.FVMAIN_COMPACT]
 FvAlignment        = 8
 ERASE_POLARITY     = 1
index f28cbb55d628b3f8028bd973f5bdd24b01f68841..1025436d37836230cc1c4dca084112af9273a440 100644 (file)
@@ -180,6 +180,11 @@ APRIORI DXE {
     SECTION UI = "PlatformInfoDxeDriver"
   }
 
+  FILE DRIVER = 7DB0793A-4402-4BE1-906E-D0FABAD2707E {
+    SECTION PE32 = sdm845Pkg/Binary/845/DDRInfoDxe/DDRInfoDxe.efi
+    SECTION UI = "DDRInfoDxe"
+  }
+
   FILE DRIVER = 9A00771F-36D4-4DD5-8916-C48ED9B16B86 {
     SECTION DXE_DEPEX = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.depex
     SECTION PE32 = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.efi
@@ -609,6 +614,8 @@ APRIORI DXE {
   #
   INF src/main/SimpleInitMain.inf
 
+  INF src/kernelfdt/KernelFdtDxe.inf
+
 [FV.FVMAIN_COMPACT]
 FvAlignment        = 8
 ERASE_POLARITY     = 1
index a9abeff5a20a05c1d4fcc9988ea87d457bd15464..cb55bbdb5fe11e72ca16f2b0213a324b599d6599 100644 (file)
@@ -180,6 +180,11 @@ APRIORI DXE {
     SECTION UI = "PlatformInfoDxeDriver"
   }
 
+  FILE DRIVER = 7DB0793A-4402-4BE1-906E-D0FABAD2707E {
+    SECTION PE32 = sdm845Pkg/Binary/845/DDRInfoDxe/DDRInfoDxe.efi
+    SECTION UI = "DDRInfoDxe"
+  }
+
   FILE DRIVER = 9A00771F-36D4-4DD5-8916-C48ED9B16B86 {
     SECTION DXE_DEPEX = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.depex
     SECTION PE32 = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.efi
@@ -589,6 +594,8 @@ APRIORI DXE {
   #
   #INF sdm845Pkg/Drivers/Op6tSlotDxe/Op6tSlotDxe.inf
 
+  INF src/kernelfdt/KernelFdtDxe.inf
+
 [FV.FVMAIN_COMPACT]
 FvAlignment        = 8
 ERASE_POLARITY     = 1
index d82112ed2393981787980217eb6e07e56c8acf97..92c4d1d4e9677627ed9f8f7852ce76c9fe65b460 100644 (file)
@@ -180,6 +180,11 @@ APRIORI DXE {
     SECTION UI = "PlatformInfoDxeDriver"
   }
 
+  FILE DRIVER = 7DB0793A-4402-4BE1-906E-D0FABAD2707E {
+    SECTION PE32 = sdm845Pkg/Binary/845/DDRInfoDxe/DDRInfoDxe.efi
+    SECTION UI = "DDRInfoDxe"
+  }
+
   FILE DRIVER = 9A00771F-36D4-4DD5-8916-C48ED9B16B86 {
     SECTION DXE_DEPEX = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.depex
     SECTION PE32 = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.efi
@@ -570,6 +575,8 @@ APRIORI DXE {
   #
   INF src/main/SimpleInitMain.inf
 
+  INF src/kernelfdt/KernelFdtDxe.inf
+
 [FV.FVMAIN_COMPACT]
 FvAlignment        = 8
 ERASE_POLARITY     = 1
index ff9d6c05c452d385ebe655e47b934da19da749a4..80552f989ddebb07298e3cda35407ccb5e3ce758 100644 (file)
@@ -180,6 +180,11 @@ APRIORI DXE {
     SECTION UI = "PlatformInfoDxeDriver"
   }
 
+  FILE DRIVER = 7DB0793A-4402-4BE1-906E-D0FABAD2707E {
+    SECTION PE32 = sdm845Pkg/Binary/845/DDRInfoDxe/DDRInfoDxe.efi
+    SECTION UI = "DDRInfoDxe"
+  }
+
   FILE DRIVER = 9A00771F-36D4-4DD5-8916-C48ED9B16B86 {
     SECTION DXE_DEPEX = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.depex
     SECTION PE32 = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.efi
@@ -581,6 +586,8 @@ APRIORI DXE {
   #
   INF src/main/SimpleInitMain.inf
 
+  INF src/kernelfdt/KernelFdtDxe.inf
+
 [FV.FVMAIN_COMPACT]
 FvAlignment        = 8
 ERASE_POLARITY     = 1
index 43edb2e4e993a35fd31427f8bbdab685aaf5928a..b715af7ced88e997788811e5be4965441b97dfe5 100644 (file)
@@ -179,6 +179,11 @@ APRIORI DXE {
     SECTION UI = "PlatformInfoDxeDriver"\r
   }\r
 \r
+  FILE DRIVER = 7DB0793A-4402-4BE1-906E-D0FABAD2707E {\r
+    SECTION PE32 = sdm845Pkg/Binary/845/DDRInfoDxe/DDRInfoDxe.efi\r
+    SECTION UI = "DDRInfoDxe"\r
+  }\r
+\r
   FILE DRIVER = 9A00771F-36D4-4DD5-8916-C48ED9B16B86 {\r
     SECTION DXE_DEPEX = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.depex\r
     SECTION PE32 = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.efi\r
@@ -580,6 +585,8 @@ APRIORI DXE {
   #\r
   INF src/main/SimpleInitMain.inf\r
 \r
+  INF src/kernelfdt/KernelFdtDxe.inf\r
+\r
 [FV.FVMAIN_COMPACT]\r
 FvAlignment        = 8\r
 ERASE_POLARITY     = 1\r
index 4acccd303f4d2ba699e617c4c1ffc946582c43d4..39f783c0a2cb05a8b0b74534866559c484045e35 100644 (file)
@@ -180,6 +180,11 @@ APRIORI DXE {
     SECTION UI = "PlatformInfoDxeDriver"
   }
 
+  FILE DRIVER = 7DB0793A-4402-4BE1-906E-D0FABAD2707E {
+    SECTION PE32 = sdm845Pkg/Binary/845/DDRInfoDxe/DDRInfoDxe.efi
+    SECTION UI = "DDRInfoDxe"
+  }
+
   FILE DRIVER = 9A00771F-36D4-4DD5-8916-C48ED9B16B86 {
     SECTION DXE_DEPEX = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.depex
     SECTION PE32 = sdm845Pkg/Binary/845/HALIOMMU/HALIOMMU.efi
@@ -595,6 +600,8 @@ APRIORI DXE {
 #   INF sdm845Pkg/Drivers/Op6tSlotDxe/Op6tSlotDxe.inf
 # !endif #$(AB_SLOTS_SUPPORT)
 
+  INF src/kernelfdt/KernelFdtDxe.inf
+
 [FV.FVMAIN_COMPACT]
 FvAlignment        = 8
 ERASE_POLARITY     = 1
index cf4d0142ba56eadb669628223d80bac3f772dadc..cde1284b684df43cd21ac4342477ff655ca3fc2c 100644 (file)
   gsdm845PkgTokenSpaceGuid.PcdDeviceVendor\r
   gsdm845PkgTokenSpaceGuid.PcdDeviceProduct\r
   gsdm845PkgTokenSpaceGuid.PcdDeviceCodeName\r
-  gsdm845PkgTokenSpaceGuid.DeviceTreeStore\r
 \r
 [Protocols]\r
   gEfiSmbiosProtocolGuid                      # PROTOCOL ALWAYS_CONSUMED\r
+  gKernelFdtProtocolGuid\r
 \r
 [Guids]\r
 \r
 [Depex]\r
-  gEfiSmbiosProtocolGuid\r
+  gEfiSmbiosProtocolGuid AND\r
+  gKernelFdtProtocolGuid\r
+\r
index 0c8dd93ca5a37f08f34f3fb11fdd6bfef4e81ea3..26e87676e806883eccbf791391616c41393f8b9b 100644 (file)
@@ -12,6 +12,7 @@
 #include <Library/DebugLib.h>
 #include <Library/PrintLib.h>
 #include <Library/BaseMemoryLib.h>
+#include <KernelFdt.h>
 #include <fdtparser.h>
 #include <param.h>
 #include <keyval.h>
@@ -22,16 +23,35 @@ fdt*
 EFIAPI
 GetFdt(VOID)
 {
-  EFI_PHYSICAL_ADDRESS FdtStore = (EFI_PHYSICAL_ADDRESS)FixedPcdGet64(DeviceTreeStore);
-  EFI_PHYSICAL_ADDRESS FdtAddress = *(EFI_PHYSICAL_ADDRESS*)FdtStore;
+  EFI_PHYSICAL_ADDRESS FdtAddress;
+  #ifndef FDT_DIRECT
+  EFI_STATUS          Status;
+  KERNEL_FDT_PROTOCOL *Fdt;
 
-  DEBUG((EFI_D_INFO, "Device Tree Address: 0x%016lx\n",FdtAddress));
+  Status = gBS->LocateProtocol (
+    &gKernelFdtProtocolGuid,
+    NULL,
+    (VOID**)&Fdt
+    );
+  if (EFI_ERROR (Status)) {
+    DEBUG((EFI_D_ERROR, "Locate Kernel Fdt Protocol failed: %r\n", Status));
+    return NULL;
+  }
+  if (Fdt == NULL || Fdt->Fdt == NULL) {
+    DEBUG((EFI_D_ERROR, "Invalid Device Tree\n"));
+    return NULL;
+  }
+  FdtAddress = (EFI_PHYSICAL_ADDRESS)Fdt->Fdt;
+  #else
+  FdtAddress = *(EFI_PHYSICAL_ADDRESS*)FixedPcdGet64 (PcdDeviceTreeStore);
 
   if (FdtAddress < PcdGet64(PcdSystemMemoryBase)){
     DEBUG((EFI_D_INFO, "Invalid Device Tree Address\n"));
     return NULL;
   }
+  #endif
 
+  DEBUG((EFI_D_INFO, "Device Tree Address: 0x%016lx\n", FdtAddress));
   return get_fdt_from_pointer ((VOID*)FdtAddress);
 }
 
index db27491033b65bae48f325cd9a6293f9dd5bf394..66b78f67a5cf8e0e0ed0ea0a8dfaa82ba3b1033e 100644 (file)
@@ -13,6 +13,7 @@
  *
  **/
 
+#define FDT_DIRECT
 #include <PiPei.h>
 
 #include <Library/ArmMmuLib.h>
index 550e9094209e87dd9445caae1567805758766f3b..93fe4d82825d284020ae85d99da587951f36a093 100644 (file)
@@ -48,7 +48,7 @@
 [FixedPcd]
   gArmTokenSpaceGuid.PcdSystemMemoryBase
   gArmTokenSpaceGuid.PcdSystemMemorySize
-  gsdm845PkgTokenSpaceGuid.DeviceTreeStore
+  gSimpleInitTokenSpaceGuid.PcdDeviceTreeStore
 
 [Depex]
   TRUE
index c403727bb0d16ebf5379398f427b65f99180f943..2a6af2426f005c11090e73b8ff1d8c001e3cb6fb 100644 (file)
@@ -446,10 +446,6 @@ VOID PlatformRegisterOptionsAndKeys(VOID)
   Status          = EfiBootManagerGetBootManagerMenu(&BootOption);
   ASSERT_EFI_ERROR(Status);
 #ifdef ENABLE_SIMPLE_INIT
-  //
-  // Search all boot options
-  //
-  EfiBootManagerRefreshAllBootOption();
 
   //
   // Register Simple Init GUI APP
@@ -463,9 +459,6 @@ VOID PlatformRegisterOptionsAndKeys(VOID)
       NULL, (UINT16)BootOption.OptionNumber, 0, &UP, NULL);
 #endif
   ASSERT(Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
-  Status = EfiBootManagerAddKeyOptionVariable(
-      NULL, (UINT16)BootOption.OptionNumber, 0, &Esc, NULL);
-  ASSERT(Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
 }
 
 //
index 4cc02c44f289cad0bbf18cfc7f9f97655f5946f4..0556e34886c92513a4ec7ac909a082c7afb06fd2 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 4cc02c44f289cad0bbf18cfc7f9f97655f5946f4
+Subproject commit 0556e34886c92513a4ec7ac909a082c7afb06fd2
index 1f274862564999520bacdd12cf630103a1c2b757..5988c04c909606e69ed72b35d4721a49ef8dcc48 100644 (file)
@@ -26,7 +26,7 @@ startlabel:
   bne  docopy
   ret
 docopy:
-  mov x10, FixedPcdGet64 (DeviceTreeStore)
+  mov x10, FixedPcdGet64 (PcdDeviceTreeStore)
   str x0, [x10] // oh my fdt
   // find our start address by getting our expected offset, then subtracting it from our actual address
   ldr  x6, =FixedPcdGet64 (PcdFdBaseAddress)
index 856d5df106c8e7d539998f04e6d57d978f5bb384..86b87c9eb098815461bcbe6841ff52ee65d8a351 100644 (file)
@@ -25,6 +25,7 @@
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
   sdm845Pkg/sdm845Pkg.dec
+  SimpleInit.dec
 
 [LibraryClasses]
   ArmLib
@@ -44,4 +45,4 @@
   gArmTokenSpaceGuid.PcdSystemMemorySize
   gArmTokenSpaceGuid.PcdFdBaseAddress
   gArmTokenSpaceGuid.PcdFdSize
-  gsdm845PkgTokenSpaceGuid.DeviceTreeStore
+  gSimpleInitTokenSpaceGuid.PcdDeviceTreeStore
index be9076fc17bd4c04ec51f0b27e39830095d2556f..878065ccfa540de1797263531db2417f2cf031e6 100644 (file)
@@ -61,5 +61,3 @@
   gsdm845PkgTokenSpaceGuid.PcdDeviceVendor|"Qualcomm"|VOID*|0x0000a301
   gsdm845PkgTokenSpaceGuid.PcdDeviceProduct|"Snapdragon 845 Device"|VOID*|0x0000a302
   gsdm845PkgTokenSpaceGuid.PcdDeviceCodeName|"sdm845"|VOID*|0x0000a303
-
-  gsdm845PkgTokenSpaceGuid.DeviceTreeStore|0x83300000|UINT64|0x0000a501
index 6d77c607188c7e51da55b01bb7b5709e9347e551..cba1b2283f19b2273585827755b1c520ce5eca1a 100644 (file)
   gArmTokenSpaceGuid.PcdSystemMemoryBase|0x80000000
   gArmTokenSpaceGuid.PcdSystemMemorySize|0xC0000000
 
+  gSimpleInitTokenSpaceGuid.PcdDeviceTreeStore|0x83300000
+
   # We bring up eight cores here!
   gArmPlatformTokenSpaceGuid.PcdCoreCount|8
   gArmPlatformTokenSpaceGuid.PcdClusterCount|2
 
   # GUID of the UI app
   gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
-  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|5
+  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|0
 
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE