linux.c32: add support for a device tree blob (dtb)
authorH. Peter Anvin <hpa@linux.intel.com>
Fri, 29 Jun 2012 22:24:02 +0000 (15:24 -0700)
committerH. Peter Anvin <hpa@linux.intel.com>
Fri, 29 Jun 2012 22:24:02 +0000 (15:24 -0700)
Based on a patch by Thierry Reding, add support for loading a device
tree blob using the generic setup_data framework.

I used the name dtb= instead of fdt= since it looks like dtb= is the
common acronym for the filenames and what is used in the kernel.

Originally-by: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
com32/modules/linux.c

index 102e877..1099875 100644 (file)
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------- *
  *
  *   Copyright 2007-2008 H. Peter Anvin - All Rights Reserved
- *   Copyright 2009 Intel Corporation; author: H. Peter Anvin
+ *   Copyright 2009-2012 Intel Corporation; author: H. Peter Anvin
  *
  *   Permission is hereby granted, free of charge, to any person
  *   obtaining a copy of this software and associated documentation
@@ -113,6 +113,7 @@ int main(int argc, char *argv[])
 {
     const char *kernel_name;
     struct initramfs *initramfs;
+    struct setup_data *setup_data;
     char *cmdline;
     char *boot_image;
     void *kernel_data;
@@ -222,9 +223,31 @@ int main(int argc, char *argv[])
        }
     }
 
+    /* Handle dtb and eventually other setup data */
+    setup_data = setup_data_init();
+    if (!setup_data)
+       goto bail;
+
+    if ((arg = find_argument(argp, "dtb="))) {
+       if (!opt_quiet) {
+           printf("Loading %s... ", arg);
+
+           if (setup_data_load(setup_data, SETUP_DTB, arg)) {
+               if (opt_quiet)
+                   printf("Loading %s ", arg);
+               printf("failed\n");
+               goto bail;
+           }
+           
+           if (!opt_quiet)
+               printf("ok\n");
+       }
+    }
+
     /* This should not return... */
     errno = 0;
-    syslinux_boot_linux(kernel_data, kernel_len, initramfs, NULL, cmdline);
+    syslinux_boot_linux(kernel_data, kernel_len, initramfs,
+                       setup_data, cmdline);
     fprintf(stderr, "syslinux_boot_linux() failed: ");
 
 bail: