[syslinux:master] linux.c32: allow loading arbitrary setup_data blobs

syslinux-bot for H. Peter Anvin hpa at linux.intel.com
Fri Jun 29 16:24:03 PDT 2012


Commit-ID:  911b2fd754c0364487c92a2282a77b6812d7823e
Gitweb:     http://www.syslinux.org/commit/911b2fd754c0364487c92a2282a77b6812d7823e
Author:     H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Fri, 29 Jun 2012 16:21:13 -0700
Committer:  H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Fri, 29 Jun 2012 16:21:54 -0700

linux.c32: allow loading arbitrary setup_data blobs

Allow loading arbitrary setup_data blobs via the syntax
blob.NN=filename where NN is a decimal number.

This also allows loading multiple device tree blobs.

Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>

---
 com32/modules/linux.c |   48 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/com32/modules/linux.c b/com32/modules/linux.c
index 1099875..a429537 100644
--- a/com32/modules/linux.c
+++ b/com32/modules/linux.c
@@ -109,6 +109,26 @@ static char *make_cmdline(char **argv)
     return cmdline;
 }
 
+static int setup_data_file(struct setup_data *setup_data,
+			   uint32_t type, const char *filename,
+			   bool opt_quiet)
+{
+    if (!opt_quiet)
+	printf("Loading %s... ", filename);
+
+    if (setup_data_load(setup_data, type, filename)) {
+	if (opt_quiet)
+	    printf("Loading %s ", filename);
+	printf("failed\n");
+	return -1;
+    }
+	    
+    if (!opt_quiet)
+	printf("ok\n");
+    
+    return 0;
+}
+
 int main(int argc, char *argv[])
 {
     const char *kernel_name;
@@ -122,7 +142,7 @@ int main(int argc, char *argv[])
     bool opt_quiet = false;
     void *dhcpdata;
     size_t dhcplen;
-    char **argp, *arg, *p;
+    char **argp, **argl, *arg, *p;
 
     openconsole(&dev_null_r, &dev_stdcon_w);
 
@@ -228,19 +248,23 @@ int main(int argc, char *argv[])
     if (!setup_data)
 	goto bail;
 
-    if ((arg = find_argument(argp, "dtb="))) {
-	if (!opt_quiet) {
-	    printf("Loading %s... ", arg);
+    for (argl = argv; (arg = *argl); argl++) {
+	if (!memcmp(arg, "dtb=", 4)) {
+	    if (setup_data_file(setup_data, SETUP_DTB, arg+4, opt_quiet))
+		goto bail;
+	} else if (!memcmp(arg, "blob.", 5)) {
+	    uint32_t type;
+	    char *ep;
 
-	    if (setup_data_load(setup_data, SETUP_DTB, arg)) {
-		if (opt_quiet)
-		    printf("Loading %s ", arg);
-		printf("failed\n");
+	    type = strtoul(arg + 5, &ep, 10);
+	    if (ep[0] != '=' || !ep[1])
+		continue;
+
+	    if (!type)
+		continue;
+
+	    if (setup_data_file(setup_data, type, ep+1, opt_quiet))
 		goto bail;
-	    }
-	    
-	    if (!opt_quiet)
-		printf("ok\n");
 	}
     }
 


More information about the Syslinux-commits mailing list