aboutsummaryrefslogtreecommitdiffstats
path: root/packages/arm-kernel-shim/files/cmdline_if_none.patch
blob: 460f7be09026b173e2a25227b6a026153accb46f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--- arm-kernel-shim-1.3/main.c.orig	2007-02-14 19:05:35.000000000 -0600
+++ arm-kernel-shim-1.3/main.c	2007-02-14 22:48:06.000000000 -0600
@@ -153,6 +153,42 @@
   p->hdr.tag		= ATAG_NONE;
   p->hdr.size		= 0;
 
+#else
+
+#ifdef CMDLINE_IF_NONE
+
+  /* Walk over the ATAG list, we need to find the end of the list.
+   * If we find a command line tag, stash away the pointer to the
+   * actual command line itself.  Note that the implementation
+   * below assumes a single ATAG_CMDLINE passed in from the
+   * bootloader, which may not be a good assumption in all cases.
+   */
+  {
+    char *c = 0;
+    for_each_tag(p, (struct tag*) PHYS_PARAMS)
+      if (p->hdr.tag == ATAG_CMDLINE) c = p->u.cmdline.cmdline;
+
+  /* p -> final tag (ATAG_NONE), and c -> command line if found */
+  /* if no ATAG_CMDLINE, or command line is empty, add the default one. */
+
+    if ((c == 0) || (*c == 0)) {
+      p->hdr.tag = ATAG_CMDLINE;
+      p->hdr.size = tag_size (tag_cmdline)
+        + (sizeof (cmdline)+3)/4 - 1;
+      {
+        const char* sz = cmdline + offset;
+        int i;
+        for (i = 0; i < sizeof (cmdline); ++i)
+          p->u.cmdline.cmdline[i] = sz[i];
+      }
+      p = tag_next (p);
+      p->hdr.tag = ATAG_NONE;
+      p->hdr.size = 0;
+    }
+  }
+
+#endif
+
 #endif
 
 	/* Pass control to the kernel */