Skip to content

Commit

Permalink
Fix uboot args and environment
Browse files Browse the repository at this point in the history
  • Loading branch information
pastcompute committed Nov 30, 2014
1 parent 559c426 commit 9d06660
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions sys/mips/atheros/ar71xx_machdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,28 @@ platform_start(__register_t a0 __unused, __register_t a1 __unused,
argc = a0;
argv = (char**)a1;
envp = (char**)a2;
#else // IF CARAMBOLA2
argc = a0;
argv = (char**)a1;
envp = (char**)a2;
#endif
/*
* Protect ourselves from garbage in registers
*/
if (MIPS_IS_VALID_PTR(envp)) {
#ifndef AR71XX_ENV_UBOOT
for (i = 0; envp[i]; i += 2) {
if (strcmp(envp[i], "memsize") == 0)
realmem = btoc(strtoul(envp[i+1], NULL, 16));
}
#else
/* The carambola2 sets memsize=67108864 decimal, not hex */
for (i = 0; envp[i]; i ++) {
if (strncmp(envp[i], "memsize", 8) == 0)
realmem = btoc(strtoul(envp[i]+8, NULL, 10));
}
#endif

}

#ifdef AR71XX_ENV_ROUTERBOOT
Expand Down Expand Up @@ -294,10 +307,19 @@ platform_start(__register_t a0 __unused, __register_t a1 __unused,

printf("Environment:\n");
if (MIPS_IS_VALID_PTR(envp)) {
#ifndef AR71XX_ENV_UBOOT
for (i = 0; envp[i]; i+=2) {
printf(" %s = %s\n", envp[i], envp[i+1]);
kern_setenv(envp[i], envp[i+1]);
}
#else
for (i = 0; envp[i]; i++) {
char *sep = strchr(envp[i], '=');
*sep = 0;
printf(" %s = %s\n", envp[i], sep+1);
kern_setenv(envp[i], sep+1);
}
#endif
}
else
printf ("envp is invalid\n");
Expand Down

0 comments on commit 9d06660

Please sign in to comment.