|
@@ -51,41 +51,62 @@ Signed-off-by: Adrian Panella <[email protected]>
|
|
|
#else
|
|
#else
|
|
|
#define do_extend_cmdline 0
|
|
#define do_extend_cmdline 0
|
|
|
#endif
|
|
#endif
|
|
|
-@@ -67,6 +69,59 @@ static uint32_t get_cell_size(const void
|
|
|
|
|
|
|
+@@ -67,6 +69,80 @@ static uint32_t get_cell_size(const void
|
|
|
return cell_size;
|
|
return cell_size;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE)
|
|
+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE)
|
|
|
|
|
++/**
|
|
|
|
|
++ * taken from arch/x86/boot/string.c
|
|
|
|
|
++ * local_strstr - Find the first substring in a %NUL terminated string
|
|
|
|
|
++ * @s1: The string to be searched
|
|
|
|
|
++ * @s2: The string to search for
|
|
|
|
|
++ */
|
|
|
|
|
++static char *local_strstr(const char *s1, const char *s2)
|
|
|
|
|
++{
|
|
|
|
|
++ size_t l1, l2;
|
|
|
|
|
++
|
|
|
|
|
++ l2 = strlen(s2);
|
|
|
|
|
++ if (!l2)
|
|
|
|
|
++ return (char *)s1;
|
|
|
|
|
++ l1 = strlen(s1);
|
|
|
|
|
++ while (l1 >= l2) {
|
|
|
|
|
++ l1--;
|
|
|
|
|
++ if (!memcmp(s1, s2, l2))
|
|
|
|
|
++ return (char *)s1;
|
|
|
|
|
++ s1++;
|
|
|
|
|
++ }
|
|
|
|
|
++ return NULL;
|
|
|
|
|
++}
|
|
|
+
|
|
+
|
|
|
+static char *append_rootblock(char *dest, const char *str, int len, void *fdt)
|
|
+static char *append_rootblock(char *dest, const char *str, int len, void *fdt)
|
|
|
+{
|
|
+{
|
|
|
-+ char *ptr, *end;
|
|
|
|
|
|
|
++ char *ptr, *end, *tmp;
|
|
|
+ char *root="root=";
|
|
+ char *root="root=";
|
|
|
|
|
++ char *find_rootblock;
|
|
|
+ int i, l;
|
|
+ int i, l;
|
|
|
+ const char *rootblock;
|
|
+ const char *rootblock;
|
|
|
+
|
|
+
|
|
|
-+ //ARM doesn't have __HAVE_ARCH_STRSTR, so search manually
|
|
|
|
|
-+ ptr = str - 1;
|
|
|
|
|
-+
|
|
|
|
|
-+ do {
|
|
|
|
|
-+ //first find an 'r' at the begining or after a space
|
|
|
|
|
-+ do {
|
|
|
|
|
-+ ptr++;
|
|
|
|
|
-+ ptr = strchr(ptr, 'r');
|
|
|
|
|
-+ if(!ptr) return dest;
|
|
|
|
|
|
|
++ find_rootblock = getprop(fdt, "/chosen", "find-rootblock", &l);
|
|
|
|
|
++ if(!find_rootblock)
|
|
|
|
|
++ find_rootblock = root;
|
|
|
+
|
|
+
|
|
|
-+ } while (ptr != str && *(ptr-1) != ' ');
|
|
|
|
|
|
|
++ //ARM doesn't have __HAVE_ARCH_STRSTR, so it was copied from x86
|
|
|
|
|
++ ptr = local_strstr(str, find_rootblock);
|
|
|
+
|
|
+
|
|
|
-+ //then check for the rest
|
|
|
|
|
-+ for(i = 1; i <= 4; i++)
|
|
|
|
|
-+ if(*(ptr+i) != *(root+i)) break;
|
|
|
|
|
-+
|
|
|
|
|
-+ } while (i != 5);
|
|
|
|
|
|
|
++ if(!ptr)
|
|
|
|
|
++ return dest;
|
|
|
+
|
|
+
|
|
|
+ end = strchr(ptr, ' ');
|
|
+ end = strchr(ptr, ' ');
|
|
|
+ end = end ? (end - 1) : (strchr(ptr, 0) - 1);
|
|
+ end = end ? (end - 1) : (strchr(ptr, 0) - 1);
|
|
|
+
|
|
+
|
|
|
-+ //find partition number (assumes format root=/dev/mtdXX | /dev/mtdblockXX | yy:XX )
|
|
|
|
|
|
|
++ // Some boards ubi.mtd=XX,ZZZZ, so let's check for '," too.
|
|
|
|
|
++ tmp = strchr(ptr, ',');
|
|
|
|
|
++
|
|
|
|
|
++ if(tmp)
|
|
|
|
|
++ end = end < tmp ? end : tmp - 1;
|
|
|
|
|
++
|
|
|
|
|
++ //find partition number (assumes format root=/dev/mtdXX | /dev/mtdblockXX | yy:XX | ubi.mtd=XX,ZZZZ )
|
|
|
+ for( i = 0; end >= ptr && *end >= '0' && *end <= '9'; end--, i++);
|
|
+ for( i = 0; end >= ptr && *end >= '0' && *end <= '9'; end--, i++);
|
|
|
+ ptr = end + 1;
|
|
+ ptr = end + 1;
|
|
|
+
|
|
+
|
|
@@ -111,7 +132,7 @@ Signed-off-by: Adrian Panella <[email protected]>
|
|
|
static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)
|
|
static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)
|
|
|
{
|
|
{
|
|
|
char cmdline[COMMAND_LINE_SIZE];
|
|
char cmdline[COMMAND_LINE_SIZE];
|
|
|
-@@ -86,12 +141,21 @@ static void merge_fdt_bootargs(void *fdt
|
|
|
|
|
|
|
+@@ -86,12 +162,21 @@ static void merge_fdt_bootargs(void *fdt
|
|
|
|
|
|
|
|
/* and append the ATAG_CMDLINE */
|
|
/* and append the ATAG_CMDLINE */
|
|
|
if (fdt_cmdline) {
|
|
if (fdt_cmdline) {
|
|
@@ -133,7 +154,7 @@ Signed-off-by: Adrian Panella <[email protected]>
|
|
|
}
|
|
}
|
|
|
*ptr = '\0';
|
|
*ptr = '\0';
|
|
|
|
|
|
|
|
-@@ -166,7 +230,9 @@ int atags_to_fdt(void *atag_list, void *
|
|
|
|
|
|
|
+@@ -166,7 +251,9 @@ int atags_to_fdt(void *atag_list, void *
|
|
|
else
|
|
else
|
|
|
setprop_string(fdt, "/chosen", "bootargs",
|
|
setprop_string(fdt, "/chosen", "bootargs",
|
|
|
atag->u.cmdline.cmdline);
|
|
atag->u.cmdline.cmdline);
|
|
@@ -144,7 +165,7 @@ Signed-off-by: Adrian Panella <[email protected]>
|
|
|
if (memcount >= sizeof(mem_reg_property)/4)
|
|
if (memcount >= sizeof(mem_reg_property)/4)
|
|
|
continue;
|
|
continue;
|
|
|
if (!atag->u.mem.size)
|
|
if (!atag->u.mem.size)
|
|
|
-@@ -210,6 +276,10 @@ int atags_to_fdt(void *atag_list, void *
|
|
|
|
|
|
|
+@@ -210,6 +297,10 @@ int atags_to_fdt(void *atag_list, void *
|
|
|
setprop(fdt, "/memory", "reg", mem_reg_property,
|
|
setprop(fdt, "/memory", "reg", mem_reg_property,
|
|
|
4 * memcount * memsize);
|
|
4 * memcount * memsize);
|
|
|
}
|
|
}
|