bc092b
From 3edabad8fefb112cc4b2d43be6e97d43c909ceee Mon Sep 17 00:00:00 2001
bc092b
From: Vladimir Serbinenko <phcoder@gmail.com>
bc092b
Date: Mon, 8 May 2017 21:59:48 +0200
31cddd
Subject: [PATCH] arm_coreboot: Support grub-mkstandalone.
bc092b
bc092b
---
bc092b
 util/grub-install-common.c  | 12 ++++++++++--
bc092b
 util/grub-install.c         |  7 +++++++
ec4acb
 include/grub/util/install.h |  6 +++++-
bc092b
 3 files changed, 22 insertions(+), 3 deletions(-)
bc092b
bc092b
diff --git a/util/grub-install-common.c b/util/grub-install-common.c
ec4acb
index 8539ff3484d..9e3e358c96a 100644
bc092b
--- a/util/grub-install-common.c
bc092b
+++ b/util/grub-install-common.c
bc092b
@@ -73,6 +73,7 @@ grub_install_help_filter (int key, const char *text,
bc092b
 
bc092b
 static int (*compress_func) (const char *src, const char *dest) = NULL;
bc092b
 char *grub_install_copy_buffer;
bc092b
+static char *dtb;
bc092b
 
bc092b
 int
bc092b
 grub_install_copy_file (const char *src,
bc092b
@@ -364,6 +365,11 @@ grub_install_parse (int key, char *arg)
bc092b
     case GRUB_INSTALL_OPTIONS_INSTALL_FONTS:
bc092b
       handle_install_list (&install_fonts, arg, 0);
bc092b
       return 1;
bc092b
+    case GRUB_INSTALL_OPTIONS_DTB:
bc092b
+      if (dtb)
bc092b
+	free (dtb);
bc092b
+      dtb = xstrdup (arg);
bc092b
+      return 1;
bc092b
     case GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS:
bc092b
       if (strcmp (arg, "no") == 0
bc092b
 	  || strcmp (arg, "none") == 0)
bc092b
@@ -486,9 +492,10 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix,
bc092b
 
bc092b
   grub_util_info ("grub-mkimage --directory '%s' --prefix '%s'"
bc092b
 		  " --output '%s' "
bc092b
+		  " --dtb '%s' "
bc092b
 		  "--format '%s' --compression '%s' %s %s\n",
bc092b
 		  dir, prefix,
bc092b
-		  outname, mkimage_target,
bc092b
+		  outname, dtb ? : "", mkimage_target,
bc092b
 		  compnames[compression], note ? "--note" : "", s);
bc092b
   free (s);
bc092b
 
bc092b
@@ -499,7 +506,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix,
bc092b
   grub_install_generate_image (dir, prefix, fp, outname,
bc092b
 			       modules.entries, memdisk_path,
bc092b
 			       pubkeys, npubkeys, config_path, tgt,
bc092b
-			       note, compression, 0);
bc092b
+			       note, compression, dtb);
bc092b
   while (dc--)
bc092b
     grub_install_pop_module ();
bc092b
 }
bc092b
@@ -666,6 +673,7 @@ static struct
bc092b
     [GRUB_INSTALL_PLATFORM_ARM_EFI] =          { "arm",     "efi"       },
bc092b
     [GRUB_INSTALL_PLATFORM_ARM64_EFI] =        { "arm64",   "efi"       },
bc092b
     [GRUB_INSTALL_PLATFORM_ARM_UBOOT] =        { "arm",     "uboot"     },
bc092b
+    [GRUB_INSTALL_PLATFORM_ARM_COREBOOT] =     { "arm",     "coreboot"  },
bc092b
   }; 
bc092b
 
bc092b
 char *
bc092b
diff --git a/util/grub-install.c b/util/grub-install.c
ec4acb
index 9074d3e9e52..75e3e5ba6f0 100644
bc092b
--- a/util/grub-install.c
bc092b
+++ b/util/grub-install.c
bc092b
@@ -486,6 +486,7 @@ have_bootdev (enum grub_install_plat pl)
bc092b
 
bc092b
     case GRUB_INSTALL_PLATFORM_I386_QEMU:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_COREBOOT:
bc092b
+    case GRUB_INSTALL_PLATFORM_ARM_COREBOOT:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT:
bc092b
     case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS:
bc092b
     case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS:
bc092b
@@ -911,6 +912,7 @@ main (int argc, char *argv[])
bc092b
 
bc092b
     case GRUB_INSTALL_PLATFORM_I386_QEMU:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_COREBOOT:
bc092b
+    case GRUB_INSTALL_PLATFORM_ARM_COREBOOT:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT:
bc092b
     case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON:
bc092b
     case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS:
bc092b
@@ -946,6 +948,7 @@ main (int argc, char *argv[])
bc092b
     case GRUB_INSTALL_PLATFORM_ARM_UBOOT:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_QEMU:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_COREBOOT:
bc092b
+    case GRUB_INSTALL_PLATFORM_ARM_COREBOOT:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT:
bc092b
     case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON:
bc092b
     case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS:
bc092b
@@ -1448,6 +1451,7 @@ main (int argc, char *argv[])
bc092b
 		  case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON:
bc092b
 		  case GRUB_INSTALL_PLATFORM_I386_QEMU:
bc092b
 		  case GRUB_INSTALL_PLATFORM_I386_COREBOOT:
bc092b
+		  case GRUB_INSTALL_PLATFORM_ARM_COREBOOT:
bc092b
 		  case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT:
bc092b
 		  case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS:
bc092b
 		  case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS:
bc092b
@@ -1542,6 +1546,7 @@ main (int argc, char *argv[])
bc092b
       break;
bc092b
 
bc092b
     case GRUB_INSTALL_PLATFORM_I386_COREBOOT:
bc092b
+    case GRUB_INSTALL_PLATFORM_ARM_COREBOOT:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_IEEE1275:
bc092b
     case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275:
bc092b
@@ -1629,6 +1634,7 @@ main (int argc, char *argv[])
bc092b
     case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS:
bc092b
     case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_COREBOOT:
bc092b
+    case GRUB_INSTALL_PLATFORM_ARM_COREBOOT:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_PC:
bc092b
     case GRUB_INSTALL_PLATFORM_MIPSEL_ARC:
bc092b
@@ -1889,6 +1895,7 @@ main (int argc, char *argv[])
bc092b
     case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS:
bc092b
     case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_COREBOOT:
bc092b
+    case GRUB_INSTALL_PLATFORM_ARM_COREBOOT:
bc092b
     case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT:
bc092b
     case GRUB_INSTALL_PLATFORM_MIPSEL_ARC:
bc092b
     case GRUB_INSTALL_PLATFORM_ARM_UBOOT:
ec4acb
diff --git a/include/grub/util/install.h b/include/grub/util/install.h
ec4acb
index 6abd288c313..5910b0c09bc 100644
ec4acb
--- a/include/grub/util/install.h
ec4acb
+++ b/include/grub/util/install.h
ec4acb
@@ -29,6 +29,8 @@
ec4acb
 #define GRUB_INSTALL_OPTIONS					  \
ec4acb
   { "modules",      GRUB_INSTALL_OPTIONS_MODULES, N_("MODULES"),	  \
ec4acb
     0, N_("pre-load specified modules MODULES"), 1 },			  \
ec4acb
+  { "dtb",      GRUB_INSTALL_OPTIONS_DTB, N_("FILE"),	  \
ec4acb
+    0, N_("embed a specific DTB"), 1 },			  \
ec4acb
   { "install-modules", GRUB_INSTALL_OPTIONS_INSTALL_MODULES,	  \
ec4acb
     N_("MODULES"), 0,							  \
ec4acb
     N_("install only MODULES and their dependencies [default=all]"), 1 }, \
ec4acb
@@ -99,6 +101,7 @@ enum grub_install_plat
ec4acb
     GRUB_INSTALL_PLATFORM_I386_XEN,
ec4acb
     GRUB_INSTALL_PLATFORM_X86_64_XEN,
ec4acb
     GRUB_INSTALL_PLATFORM_ARM64_EFI,
ec4acb
+    GRUB_INSTALL_PLATFORM_ARM_COREBOOT,
ec4acb
     GRUB_INSTALL_PLATFORM_MAX
ec4acb
   };
ec4acb
 
ec4acb
@@ -115,7 +118,8 @@ enum grub_install_options {
ec4acb
   GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY,
ec4acb
   GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY,
ec4acb
   GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE,
ec4acb
-  GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS
ec4acb
+  GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS,
ec4acb
+  GRUB_INSTALL_OPTIONS_DTB
ec4acb
 };
ec4acb
 
ec4acb
 extern char *grub_install_source_directory;