]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Bds/Bds.c
ArmPkg/Application/LinuxLoader: Create a Linux Loader EFI application
[mirror_edk2.git] / ArmPlatformPkg / Bds / Bds.c
index 11116ede96ee73719b6c0843d97d055579fa7c10..5ae7bae77584cbe44bcb0adb34dce12d61b0b35a 100644 (file)
@@ -203,6 +203,11 @@ DefineDefaultBootEntries (
   EFI_STATUS                          Status;
   EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol;
   EFI_DEVICE_PATH*                    BootDevicePath;
+  ARM_BDS_LOADER_ARGUMENTS*           BootArguments;
+  ARM_BDS_LOADER_TYPE                 BootType;
+  EFI_DEVICE_PATH*                    InitrdPath;
+  UINTN                               CmdLineSize;
+  UINTN                               InitrdSize;
 
   //
   // If Boot Order does not exist then create a default entry
@@ -238,11 +243,28 @@ DefineDefaultBootEntries (
 
     // Create the entry is the Default values are correct
     if (BootDevicePath != NULL) {
+      BootType = (ARM_BDS_LOADER_TYPE)PcdGet32 (PcdDefaultBootType);
+
+      if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
+        CmdLineSize = AsciiStrSize ((CHAR8*)PcdGetPtr(PcdDefaultBootArgument));
+        InitrdPath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootInitrdPath));
+        InitrdSize = GetDevicePathSize (InitrdPath);
+
+        BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize);
+        BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
+        BootArguments->LinuxArguments.InitrdSize = InitrdSize;
+
+        CopyMem ((VOID*)(BootArguments + 1), (CHAR8*)PcdGetPtr(PcdDefaultBootArgument), CmdLineSize);
+        CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
+      } else {
+        BootArguments = NULL;
+      }
+
       BootOptionCreate (LOAD_OPTION_ACTIVE | LOAD_OPTION_CATEGORY_BOOT,
         (CHAR16*)PcdGetPtr(PcdDefaultBootDescription),
         BootDevicePath,
-        (BDS_LOADER_TYPE)PcdGet32 (PcdDefaultBootType),
-        (CHAR8*)PcdGetPtr(PcdDefaultBootArgument),
+        BootType,
+        BootArguments,
         &BdsLoadOption
         );
       FreePool (BdsLoadOption);