Fix incorrect use of getenv() before relocation

A large number of boards incorrectly used getenv() in their board init
code running before relocation.  In some cases this caused U-Boot to
hang when certain environment variables grew too long.
Fix the code to use getenv_r().

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: The LEOX team <team@leox.org>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Georg Schardt <schardt@team-ctech.de>
Cc: Werner Pfister <Pfister_Werner@intercontrol.de>
Cc: Dirk Eibach <eibach@gdsys.de>
Cc: Peter De Schrijver <p2@mind.be>
Cc: John Zhan <zhanz@sinovee.com>
Cc: Rishi Bhattacharya <rishi@ti.com>
Cc: Peter Tyser <ptyser@xes-inc.com>
This commit is contained in:
Wolfgang Denk 2011-05-04 10:32:28 +00:00
parent a02a884b95
commit f0c0b3a9e6
61 changed files with 327 additions and 263 deletions

View File

@ -169,9 +169,10 @@ int board_early_init_f (void)
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
if (!s || strncmp (s, "ELPT860", 7)) if ((i < 0) || strncmp(buf, "ELPT860", 7))
printf ("### No HW ID - assuming ELPT860\n"); printf ("### No HW ID - assuming ELPT860\n");
return (0); /* success */ return (0); /* success */

View File

@ -93,14 +93,16 @@ const uint sdram_table[] =
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
int i;
int l = getenv_f("serial#", buf, sizeof(buf));
puts ("Board: RRvision "); puts ("Board: RRvision ");
for (; s && *s; ++s) { for (i=0; i < l; ++i) {
if (*s == ' ') if (buf[i] == ' ')
break; break;
putc (*s); putc (buf[i]);
} }
putc ('\n'); putc ('\n');

View File

@ -89,14 +89,15 @@ int board_init (void)
*/ */
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
puts ("Board: AcTux-1 rev."); puts ("Board: AcTux-1 rev.");
putc (ACTUX1_BOARDREL + 'A' - 1); putc (ACTUX1_BOARDREL + 'A' - 1);
if (s != NULL) { if (i > 0) {
puts (", serial# "); puts(", serial# ");
puts (s); puts(buf);
} }
putc ('\n'); putc ('\n');

View File

@ -96,14 +96,15 @@ int board_init (void)
*/ */
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
puts ("Board: AcTux-2 rev."); puts ("Board: AcTux-2 rev.");
putc (ACTUX2_BOARDREL + 'A' - 1); putc (ACTUX2_BOARDREL + 'A' - 1);
if (s != NULL) { if (i > 0) {
puts (", serial# "); puts(", serial# ");
puts (s); puts(buf);
} }
putc ('\n'); putc ('\n');

View File

@ -111,14 +111,15 @@ int board_init (void)
*/ */
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
puts ("Board: AcTux-3 rev."); puts ("Board: AcTux-3 rev.");
putc (ACTUX3_BOARDREL + 'A' - 1); putc (ACTUX3_BOARDREL + 'A' - 1);
if (s != NULL) { if (i > 0) {
puts (", serial# "); puts (", serial# ");
puts (s); puts (buf);
} }
putc ('\n'); putc ('\n');

View File

@ -102,15 +102,16 @@ int misc_init_f(void)
*/ */
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
u8 rev; u8 rev;
rev = in8(CONFIG_SYS_CPLD_BASE + 0); rev = in8(CONFIG_SYS_CPLD_BASE + 0);
printf("Board: Acadia - AMCC PPC405EZ Evaluation Board, Rev. %X", rev); printf("Board: Acadia - AMCC PPC405EZ Evaluation Board, Rev. %X", rev);
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -440,12 +440,13 @@ int board_early_init_f(void)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: Bamboo - AMCC PPC440EP Evaluation Board"); printf("Board: Bamboo - AMCC PPC440EP Evaluation Board");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -78,13 +78,14 @@ int board_early_init_f(void)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
puts("Board: Bluestone Evaluation Board"); puts("Board: Bluestone Evaluation Board");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -53,13 +53,14 @@ int board_early_init_f(void)
*/ */
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
puts("Board: Bubinga - AMCC PPC405EP Evaluation Board"); puts("Board: Bubinga - AMCC PPC405EP Evaluation Board");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -293,7 +293,8 @@ int checkboard(void)
{ {
struct board_bcsr *bcsr_data = struct board_bcsr *bcsr_data =
(struct board_bcsr *)CONFIG_SYS_BCSR_BASE; (struct board_bcsr *)CONFIG_SYS_BCSR_BASE;
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
if (pvr_460ex()) { if (pvr_460ex()) {
printf("Board: Canyonlands - AMCC PPC460EX Evaluation Board"); printf("Board: Canyonlands - AMCC PPC460EX Evaluation Board");
@ -319,9 +320,9 @@ int checkboard(void)
printf(", Rev. %X", in_8(&bcsr_data->cpld_rev)); printf(", Rev. %X", in_8(&bcsr_data->cpld_rev));
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -92,12 +92,13 @@ int board_early_init_f(void)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: Ebony - AMCC PPC440GP Evaluation Board"); printf("Board: Ebony - AMCC PPC440GP Evaluation Board");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -236,12 +236,13 @@ int board_early_init_f (void)
int checkboard (void) int checkboard (void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: Katmai - AMCC 440SPe Evaluation Board"); printf("Board: Katmai - AMCC 440SPe Evaluation Board");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -307,16 +307,17 @@ int board_pcie_last(void)
int checkboard (void) int checkboard (void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
if (is_405exr()) if (is_405exr())
printf("Board: Haleakala - AMCC PPC405EXr Evaluation Board"); printf("Board: Haleakala - AMCC PPC405EXr Evaluation Board");
else else
printf("Board: Kilauea - AMCC PPC405EX Evaluation Board"); printf("Board: Kilauea - AMCC PPC405EX Evaluation Board");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
printf(" (CPLD rev. %ld)\n", gd->board_type); printf(" (CPLD rev. %ld)\n", gd->board_type);

View File

@ -105,13 +105,14 @@ int misc_init_r(void)
************************************************************************/ ************************************************************************/
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: Luan - AMCC PPC440SP Evaluation Board"); printf("Board: Luan - AMCC PPC440SP Evaluation Board");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -224,13 +224,14 @@ int misc_init_r(void)
int checkboard (void) int checkboard (void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: Makalu - AMCC PPC405EX Evaluation Board"); printf("Board: Makalu - AMCC PPC405EX Evaluation Board");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -200,12 +200,13 @@ int board_early_init_f (void)
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf ("Board: Ocotea - AMCC PPC440GX Evaluation Board"); printf ("Board: Ocotea - AMCC PPC440GX Evaluation Board");
if (s != NULL) { if (i > 0) {
puts (", serial# "); puts(", serial# ");
puts (s); puts(buf);
} }
putc ('\n'); putc ('\n');

View File

@ -200,12 +200,13 @@ int board_early_init_f(void)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: Redwood - AMCC 460SX Reference Board"); printf("Board: Redwood - AMCC 460SX Reference Board");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -331,7 +331,8 @@ int misc_init_r(void)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
u8 rev; u8 rev;
u32 clock = get_async_pci_freq(); u32 clock = get_async_pci_freq();
@ -344,9 +345,9 @@ int checkboard(void)
rev = in_8((void *)(CONFIG_SYS_BCSR_BASE + 0)); rev = in_8((void *)(CONFIG_SYS_BCSR_BASE + 0));
printf(", Rev. %X, PCI-Async=%d MHz", rev, clock / 1000000); printf(", Rev. %X, PCI-Async=%d MHz", rev, clock / 1000000);
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -65,13 +65,14 @@ int board_early_init_f(void)
*/ */
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
puts("Board: Taihu - AMCC PPC405EP Evaluation Board"); puts("Board: Taihu - AMCC PPC405EP Evaluation Board");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -193,12 +193,13 @@ int misc_init_r(void)
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf ("Board: Taishan - AMCC PPC440GX Evaluation Board"); printf ("Board: Taishan - AMCC PPC440GX Evaluation Board");
if (s != NULL) { if (i > 0) {
puts (", serial# "); puts(", serial# ");
puts (s); puts(buf);
} }
putc ('\n'); putc ('\n');

View File

@ -67,7 +67,8 @@ int board_early_init_f(void)
*/ */
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
uint pvr = get_pvr(); uint pvr = get_pvr();
if (pvr == PVR_405GPR_RB) { if (pvr == PVR_405GPR_RB) {
@ -76,9 +77,9 @@ int checkboard(void)
puts("Board: Walnut - AMCC PPC405GP Evaluation Board"); puts("Board: Walnut - AMCC PPC405GP Evaluation Board");
} }
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -188,7 +188,8 @@ int misc_init_r (void)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
u8 rev; u8 rev;
u32 clock = get_async_pci_freq(); u32 clock = get_async_pci_freq();
@ -201,9 +202,9 @@ int checkboard(void)
rev = in_8((void *)(CONFIG_SYS_BCSR_BASE + 0)); rev = in_8((void *)(CONFIG_SYS_BCSR_BASE + 0));
printf(", Rev. %X, PCI-Async=%d MHz", rev, clock / 1000000); printf(", Rev. %X, PCI-Async=%d MHz", rev, clock / 1000000);
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -542,12 +542,13 @@ int board_early_init_f (void)
int checkboard (void) int checkboard (void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: Yucca - AMCC 440SPe Evaluation Board"); printf("Board: Yucca - AMCC 440SPe Evaluation Board");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -37,8 +37,8 @@ int board_pre_init (void)
/** serial number and platform display at startup */ /** serial number and platform display at startup */
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
char *e; int l = getenv_f("serial#", buf, sizeof(buf));
/* After a loadace command, the SystemAce control register is left in a wonky state. */ /* After a loadace command, the SystemAce control register is left in a wonky state. */
/* this code did not work in board_pre_init */ /* this code did not work in board_pre_init */
@ -115,17 +115,19 @@ int checkboard (void)
puts ("Serial#: "); puts ("Serial#: ");
if (!s) { if (l < 0) {
printf ("### No HW ID - assuming AMIRIX"); printf ("### No HW ID - assuming AMIRIX");
} else { } else {
for (e = s; *e; ++e) { int i;
if (*e == ' ')
for (i = 0; i < l; ++i) {
if (buf[i] == ' ') {
buf[i] = '\0';
break; break;
}
} }
for (; s < e; ++s) { puts(buf);
putc (*s);
}
} }
putc ('\n'); putc ('\n');
@ -136,9 +138,11 @@ int checkboard (void)
phys_size_t initdram (int board_type) phys_size_t initdram (int board_type)
{ {
char *s = getenv ("dramsize"); char buf[64];
int i = getenv_f("dramsize", buf, sizeof(buf));
if (s != NULL) { if (i > 0) {
char *s = buf;
if ((s[0] == '0') && ((s[1] == 'x') || (s[1] == 'X'))) { if ((s[0] == '0') && ((s[1] == 'x') || (s[1] == 'X'))) {
s += 2; s += 2;
} }

View File

@ -32,20 +32,19 @@
int checkboard(void) int checkboard(void)
{ {
char tmp[64]; char buf[64];
char *s, *e; int i;
int i = getenv_f("serial", tmp, sizeof(tmp)); int l = getenv_f("serial#", buf, sizeof(buf));
if (i < 0) { if (l < 0) {
printf("Avnet Virtex4 FX12 with no serial #"); printf("Avnet Virtex4 FX12 with no serial #");
} else { } else {
for (e = tmp; *e; ++e) {
if (*e == ' ')
break;
}
printf("Avnet Virtex4 FX12 Minimodul # "); printf("Avnet Virtex4 FX12 Minimodul # ");
for (s = tmp; s < e; ++s) for (i = 0; i < l; ++i) {
putc(*s); if (buf[i] == ' ')
break;
putc(buf[i]);
}
} }
putc('\n'); putc('\n');
return 0; return 0;

View File

@ -91,14 +91,16 @@ const uint sdram_table[] =
int checkboard (void) int checkboard (void)
{ {
unsigned char *s = (unsigned char *)getenv ("serial#"); char buf[64];
int i;
int l = getenv_f("serial#", buf, sizeof(buf));
puts ("Board: TTTech C2MON "); puts ("Board: TTTech C2MON ");
for (; s && *s; ++s) { for (i = 0; i < l; ++i) {
if (*s == ' ') if (buf[i] == ' ')
break; break;
putc (*s); putc (buf[i]);
} }
putc ('\n'); putc ('\n');

View File

@ -191,15 +191,16 @@ phys_size_t initdram(int board_type)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
puts ("Board: InterControl digsyMTC"); puts ("Board: InterControl digsyMTC");
#if defined(CONFIG_DIGSY_REV5) #if defined(CONFIG_DIGSY_REV5)
puts (" rev5"); puts (" rev5");
#endif #endif
if (s != NULL) { if (i > 0) {
puts(", "); puts(", ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -92,8 +92,9 @@ const uint sdram_table[] = {
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
char *e; int i;
int l = getenv_f("serial#", buf, sizeof(buf));
puts ("Board: "); puts ("Board: ");
@ -103,19 +104,16 @@ int checkboard (void)
gd->board_type = 1; /* 1 = 1SDRAM-Device */ gd->board_type = 1; /* 1 = 1SDRAM-Device */
#endif #endif
if (!s || strncmp (s, "ETX_", 4)) { if (l < 0 || strncmp(buf, "ETX_", 4)) {
puts ("### No HW ID - assuming ETX_094\n"); puts ("### No HW ID - assuming ETX_094\n");
read_hw_vers (); read_hw_vers ();
return (0); return (0);
} }
for (e = s; *e; ++e) { for (i = 0; i < l; ++i) {
if (*e == ' ') if (buf[i] == ' ')
break; break;
} putc(buf[i]);
for (; s < e; ++s) {
putc (*s);
} }
putc ('\n'); putc ('\n');

View File

@ -225,15 +225,16 @@ static void print_fpga_info(unsigned dev)
*/ */
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: "); printf("Board: ");
printf("DLVision 10G"); printf("DLVision 10G");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
puts("\n"); puts("\n");

View File

@ -87,8 +87,9 @@ err_out:
*/ */
int checkboard(void) int checkboard(void)
{ {
char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
ihs_fpga_t *fpga = (ihs_fpga_t *) CONFIG_SYS_FPGA_BASE(0); ihs_fpga_t *fpga = (ihs_fpga_t *) CONFIG_SYS_FPGA_BASE(0);
char *s = getenv("serial#");
u16 versions = in_le16(&fpga->versions); u16 versions = in_le16(&fpga->versions);
u16 fpga_version = in_le16(&fpga->fpga_version); u16 fpga_version = in_le16(&fpga->fpga_version);
u16 fpga_features = in_le16(&fpga->fpga_features); u16 fpga_features = in_le16(&fpga->fpga_features);
@ -106,9 +107,9 @@ int checkboard(void)
printf("CATCenter Io"); printf("CATCenter Io");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
puts("\n "); puts("\n ");

View File

@ -69,8 +69,9 @@ enum {
*/ */
int checkboard(void) int checkboard(void)
{ {
char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
ihs_fpga_t *fpga = (ihs_fpga_t *) CONFIG_SYS_FPGA_BASE(0); ihs_fpga_t *fpga = (ihs_fpga_t *) CONFIG_SYS_FPGA_BASE(0);
char *s = getenv("serial#");
u16 versions = in_le16(&fpga->versions); u16 versions = in_le16(&fpga->versions);
u16 fpga_version = in_le16(&fpga->fpga_version); u16 fpga_version = in_le16(&fpga->fpga_version);
u16 fpga_features = in_le16(&fpga->fpga_features); u16 fpga_features = in_le16(&fpga->fpga_features);
@ -98,9 +99,9 @@ int checkboard(void)
printf("IoCon"); printf("IoCon");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
puts("\n "); puts("\n ");

View File

@ -75,7 +75,8 @@ int misc_init_r(void)
*/ */
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
u8 channel2_msr = in_8((void *)CONFIG_UART_BASE + 0x26); u8 channel2_msr = in_8((void *)CONFIG_UART_BASE + 0x26);
u8 channel3_msr = in_8((void *)CONFIG_UART_BASE + 0x36); u8 channel3_msr = in_8((void *)CONFIG_UART_BASE + 0x36);
u8 channel7_msr = in_8((void *)CONFIG_UART_BASE + 0x76); u8 channel7_msr = in_8((void *)CONFIG_UART_BASE + 0x76);
@ -108,9 +109,9 @@ int checkboard(void)
break; break;
} }
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
puts("\n "); puts("\n ");

View File

@ -145,13 +145,14 @@ int misc_init_r(void)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: GDPPC440ETX - G&D PPC440EP/GR ETX-module"); printf("Board: GDPPC440ETX - G&D PPC440EP/GR ETX-module");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -124,7 +124,8 @@ int get_cpu_num(void)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
#ifdef CONFIG_DEVCONCENTER #ifdef CONFIG_DEVCONCENTER
printf("Board: DevCon-Center"); printf("Board: DevCon-Center");
@ -132,9 +133,9 @@ int checkboard(void)
printf("Board: Intip"); printf("Board: Intip");
#endif #endif
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -53,7 +53,8 @@ int board_early_init_f(void)
*/ */
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
u16 val = in_le16((void *)CONFIG_FPGA_BASE + 2); u16 val = in_le16((void *)CONFIG_FPGA_BASE + 2);
u8 unit_type; u8 unit_type;
u8 hardware_cpu_ports; u8 hardware_cpu_ports;
@ -62,9 +63,9 @@ int checkboard(void)
printf("Board: CATCenter Neo"); printf("Board: CATCenter Neo");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
puts("\n "); puts("\n ");

View File

@ -214,13 +214,13 @@ const iop_conf_t iop_conf_tab[4][32] = {
/*********************************************************************/ /*********************************************************************/
int checkboard (void) int checkboard (void)
{ {
char *str; char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
puts ("Board: Advent Networks gw8260\n"); puts ("Board: Advent Networks gw8260\n");
str = getenv ("serial#"); if (i > 0) {
if (str != NULL) { printf("SN: %s\n", buf);
printf ("SN: %s\n", str);
} }
return 0; return 0;
} }

View File

@ -107,21 +107,19 @@ const uint sdram_table[] = {
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
char *e; int i;
int l = getenv_f("serial#", buf, sizeof(buf));
puts ("Board: "); puts ("Board: ");
if (!s || strncmp (s, "HERMES", 6)) { if (l < 0 || strncmp(buf, "HERMES", 6)) {
puts ("### No HW ID - assuming HERMES-PRO"); puts ("### No HW ID - assuming HERMES-PRO");
} else { } else {
for (e = s; *e; ++e) { for (i = 0; i < l; i++) {
if (*e == ' ') if (buf[i] == ' ')
break; break;
} putc (buf[i]);
for (; s < e; ++s) {
putc (*s);
} }
} }

View File

@ -83,7 +83,8 @@ int board_init (void)
*/ */
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
#ifdef CONFIG_IXDPG425 #ifdef CONFIG_IXDPG425
puts("Board: IXDPG425 - Intel Network Gateway Reference Platform"); puts("Board: IXDPG425 - Intel Network Gateway Reference Platform");
@ -91,9 +92,9 @@ int checkboard(void)
puts("Board: IXDP425 - Intel Development Platform"); puts("Board: IXDP425 - Intel Development Platform");
#endif #endif
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -333,13 +333,14 @@ int misc_init_r(void)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
puts("Board: lwmon5"); puts("Board: lwmon5");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -80,8 +80,9 @@ phys_size_t initdram(int board_type)
int checkboard(void) int checkboard(void)
{ {
char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
u32 config0 = read_c0_prid(); u32 config0 = read_c0_prid();
char *s = getenv("serial#");
if ((config0 & 0xff0000) == PRID_COMP_LEGACY if ((config0 & 0xff0000) == PRID_COMP_LEGACY
&& (config0 & 0xff00) == PRID_IMP_LX4280) { && (config0 & 0xff00) == PRID_IMP_LX4280) {
@ -108,9 +109,9 @@ int checkboard(void)
} }
printf("Board: Micronas VCT " BOARD_NAME BOARD_NAME_ADD); printf("Board: Micronas VCT " BOARD_NAME BOARD_NAME_ADD);
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -30,23 +30,19 @@ int board_early_init_f (void)
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
char *e; int i;
int l = getenv_f("serial#", buf, sizeof(buf));
if (!s || strncmp (s, "ML2", 9)) { if (l < 0 || strncmp(buf, "ML2", 9)) {
printf ("### No HW ID - assuming ML2"); printf ("### No HW ID - assuming ML2");
} else { } else {
for (e = s; *e; ++e) { for (i = 0; i < l; i++) {
if (*e == ' ') if (buf[i] == ' ')
break; break;
} putc(buf[i]);
for (; s < e; ++s) {
putc (*s);
} }
} }
putc ('\n'); putc ('\n');
return (0); return (0);

View File

@ -275,12 +275,13 @@ int board_early_init_r(void)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: ICON"); printf("Board: ICON");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -509,12 +509,13 @@ int misc_init_r (void)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: PCS440EP"); printf("Board: PCS440EP");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -133,12 +133,13 @@ static int board_rev(void)
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf ("Board: ALPR"); printf ("Board: ALPR");
if (s != NULL) { if (i > 0) {
puts (", serial# "); puts(", serial# ");
puts (s); puts(buf);
} }
printf(" (Rev. %d)\n", board_rev()); printf(" (Rev. %d)\n", board_rev());

View File

@ -335,13 +335,14 @@ void after_reloc (ulong dest_addr, gd_t * gd)
int checkboard (void) int checkboard (void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: %s", CONFIG_SYS_BOARD_NAME); printf("Board: %s", CONFIG_SYS_BOARD_NAME);
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -122,12 +122,13 @@ int board_early_init_f(void)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: P3P440"); printf("Board: P3P440");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
if (is_monarch()) { if (is_monarch()) {

View File

@ -101,13 +101,14 @@ int board_init(void)
*/ */
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
puts("Board: PDNB3"); puts("Board: PDNB3");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -58,16 +58,17 @@ int board_early_init_f(void)
*/ */
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
#ifdef DISPLAY_BOARD_INFO #ifdef DISPLAY_BOARD_INFO
sys_info_t sysinfo; sys_info_t sysinfo;
#endif #endif
puts("Board: Quad100hd"); puts("Board: Quad100hd");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -87,14 +87,16 @@ const uint sdram_table[] = {
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
int i;
int l = getenv_f("serial#", buf, sizeof(buf));
puts ("Board QUANTUM, Serial No: "); puts ("Board QUANTUM, Serial No: ");
for (; s && *s; ++s) { for (i = 0; i < l; ++i) {
if (*s == ' ') if (buf[i] == ' ')
break; break;
putc (*s); putc (buf[i]);
} }
putc ('\n'); putc ('\n');
return (0); /* success */ return (0); /* success */

View File

@ -127,15 +127,16 @@ const uint static_table[] =
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
if (!s || strncmp (s, "TQM8", 4)) { if (i < 0 || strncmp(buf, "TQM8", 4)) {
printf ("### No HW ID - assuming RBC823\n"); printf ("### No HW ID - assuming RBC823\n");
return (0); return (0);
} }
puts (s); puts(buf);
putc ('\n'); putc('\n');
return (0); return (0);
} }

View File

@ -52,15 +52,17 @@ ulong flash_get_size (ulong base, int banknum);
int checkboard (void) int checkboard (void)
{ {
volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
char buf[64];
char *src;
int f; int f;
char *s = getenv("serial#"); int i = getenv_f("serial#", buf, sizeof(buf));
#ifdef CONFIG_PCI
char *src;
#endif
puts("Board: Socrates"); puts("Board: Socrates");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -75,27 +75,29 @@ const uint sdram_table[] =
* Return 1 for "SC8xx" type, 0 else. * Return 1 for "SC8xx" type, 0 else.
*/ */
int checkboard (void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int board_type; int i;
int l = getenv_f("serial#", buf, sizeof(buf));
int board_type;
if (l < 0 || strncmp(buf, "SVM8", 4)) {
printf("### No HW ID - assuming SVM SC8xx\n");
return (0);
}
board_type = 1;
for (i = 0; i < l; ++i) {
if (buf[i] == ' ')
break;
putc(buf[i]);
}
putc('\n');
if (!s || strncmp(s, "SVM8", 4)) {
printf ("### No HW ID - assuming SVM SC8xx\n");
return (0); return (0);
}
board_type = 1;
for (; *s; ++s) {
if (*s == ' ')
break;
putc (*s);
}
putc ('\n');
return (0);
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */

View File

@ -89,13 +89,14 @@ int board_early_init_f(void)
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf("Board: T3CORP"); printf("Board: T3CORP");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -295,13 +295,14 @@ void peripheral_power_enable (void)
*/ */
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
puts("Board: OSK5912"); puts("Board: OSK5912");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');

View File

@ -195,17 +195,17 @@ const iop_conf_t iop_conf_tab[4][32] = {
*/ */
int checkboard (void) int checkboard (void)
{ {
char str[64]; char buf[64];
int i = getenv_f("serial#", str, sizeof (str)); int i = getenv_f("serial#", buf, sizeof(buf));
puts ("Board: "); puts ("Board: ");
if (!i || strncmp (str, "TQM82", 5)) { if (i < 0 || strncmp(buf, "TQM82", 5)) {
puts ("### No HW ID - assuming TQM8260\n"); puts ("### No HW ID - assuming TQM8260\n");
return (0); return (0);
} }
puts (str); puts (buf);
putc ('\n'); putc ('\n');
return 0; return 0;

View File

@ -514,12 +514,16 @@ static inline int scanChar (char *p, int len, unsigned long *number)
static int dump_hwib(void) static int dump_hwib(void)
{ {
HWIB_INFO *hw = &hwinf; HWIB_INFO *hw = &hwinf;
char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
char *s = getenv("serial#");
if (i < 0)
buf[0] = '\0';
if (hw->OK) { if (hw->OK) {
printf ("HWIB on %x\n", HWIB_INFO_START_ADDR); printf ("HWIB on %x\n", HWIB_INFO_START_ADDR);
printf ("serial : %s\n", s); printf ("serial : %s\n", buf);
printf ("ethaddr: %s\n", hw->ethaddr); printf ("ethaddr: %s\n", hw->ethaddr);
printf ("FLASH : %x nr:%d\n", hw->flash, hw->flash_nr); printf ("FLASH : %x nr:%d\n", hw->flash, hw->flash_nr);
printf ("RAM : %x cs:%d\n", hw->ram, hw->ram_cs); printf ("RAM : %x cs:%d\n", hw->ram, hw->ram_cs);

View File

@ -227,17 +227,19 @@ static const int casl_table[] = { 20, 25, 30 };
int cas_latency (void) int cas_latency (void)
{ {
char *s = getenv ("serial#"); char buf[128];
int casl; int casl;
int val; int val;
int i; int i;
casl = CONFIG_DDR_DEFAULT_CL; casl = CONFIG_DDR_DEFAULT_CL;
if (s != NULL) { i = getenv_f("serial#", buf, sizeof(buf));
if (strncmp(s + strlen (s) - strlen (CASL_STRING1),
if (i >0) {
if (strncmp(buf + strlen (buf) - strlen (CASL_STRING1),
CASL_STRING2, strlen (CASL_STRING2)) == 0) { CASL_STRING2, strlen (CASL_STRING2)) == 0) {
val = simple_strtoul (s + strlen (s) - 2, NULL, 10); val = simple_strtoul (buf + strlen (buf) - 2, NULL, 10);
for (i = 0; i < N_CASL; ++i) { for (i = 0; i < N_CASL; ++i) {
if (val == casl_table[i]) { if (val == casl_table[i]) {
@ -252,12 +254,13 @@ int cas_latency (void)
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
printf ("Board: %s", CONFIG_BOARDNAME); printf ("Board: %s", CONFIG_BOARDNAME);
if (s != NULL) { if (i > 0) {
puts (", serial# "); puts(", serial# ");
puts (s); puts(buf);
} }
putc ('\n'); putc ('\n');

View File

@ -106,31 +106,33 @@ const uint sdram_table[] =
int checkboard (void) int checkboard (void)
{ {
char *s = getenv ("serial#"); char buf[64];
int i;
int l = getenv_f("serial#", buf, sizeof(buf));
puts ("Board: "); puts ("Board: ");
if (!s || strncmp (s, "TQM8", 4)) { if (l < 0 || strncmp(buf, "TQM8", 4)) {
puts ("### No HW ID - assuming TQM8xxL\n"); puts ("### No HW ID - assuming TQM8xxL\n");
return (0); return (0);
} }
if ((*(s + 6) == 'L')) { /* a TQM8xxL type */ if ((buf[6] == 'L')) { /* a TQM8xxL type */
gd->board_type = 'L'; gd->board_type = 'L';
} }
if ((*(s + 6) == 'M')) { /* a TQM8xxM type */ if ((buf[6] == 'M')) { /* a TQM8xxM type */
gd->board_type = 'M'; gd->board_type = 'M';
} }
if ((*(s + 6) == 'D')) { /* a TQM885D type */ if ((buf[6] == 'D')) { /* a TQM885D type */
gd->board_type = 'D'; gd->board_type = 'D';
} }
for (; *s; ++s) { for (i = 0; i < l; ++i) {
if (*s == ' ') if (buf[i] == ' ')
break; break;
putc (*s); putc (buf[i]);
} }
#ifdef CONFIG_VIRTLAB2 #ifdef CONFIG_VIRTLAB2
puts (" (Virtlab2)"); puts (" (Virtlab2)");

View File

@ -13,7 +13,9 @@
int checkboard(void) int checkboard(void)
{ {
char name[] = CONFIG_SYS_BOARD_NAME; char name[] = CONFIG_SYS_BOARD_NAME;
char buf[64];
char *s; char *s;
int i;
#ifdef CONFIG_SYS_FORM_CUSTOM #ifdef CONFIG_SYS_FORM_CUSTOM
s = "Custom"; s = "Custom";
@ -52,12 +54,15 @@ int checkboard(void)
/* Display board specific information */ /* Display board specific information */
puts(" "); puts(" ");
if ((s = getenv("board_rev"))) i = getenv_f("board_rev", buf, sizeof(buf));
printf("Rev %s, ", s); if (i > 0)
if ((s = getenv("serial#"))) printf("Rev %s, ", buf);
printf("Serial# %s, ", s); i = getenv_f("serial#", buf, sizeof(buf));
if ((s = getenv("board_cfg"))) if (i > 0)
printf("Cfg %s", s); printf("Serial# %s, ", buf);
i = getenv_f("board_cfg", buf, sizeof(buf));
if (i > 0)
printf("Cfg %s", buf);
puts("\n"); puts("\n");
return 0; return 0;

View File

@ -112,19 +112,20 @@ int board_early_init_f(void)
int checkboard(void) int checkboard(void)
{ {
char *s; char buf[64];
int i;
printf("Board: X-ES %s PMC SBC\n", CONFIG_SYS_BOARD_NAME); printf("Board: X-ES %s PMC SBC\n", CONFIG_SYS_BOARD_NAME);
printf(" "); printf(" ");
s = getenv("board_rev"); i = getenv_f("board_rev", buf, sizeof(buf));
if (s) if (i > 0)
printf("Rev %s, ", s); printf("Rev %s, ", buf);
s = getenv("serial#"); i = getenv_f("serial#", buf, sizeof(buf));
if (s) if (i > 0)
printf("Serial# %s, ", s); printf("Serial# %s, ", buf);
s = getenv("board_cfg"); i = getenv_f("board_cfg", buf, sizeof(buf));
if (s) if (i > 0)
printf("Cfg %s", s); printf("Cfg %s", buf);
printf("\n"); printf("\n");
return 0; return 0;

View File

@ -161,7 +161,8 @@ int misc_init_r(void)
*/ */
int checkboard(void) int checkboard(void)
{ {
char *s = getenv("serial#"); char buf[64];
int i = getenv_f("serial#", buf, sizeof(buf));
puts("Board: Zeus-"); puts("Board: Zeus-");
@ -172,9 +173,9 @@ int checkboard(void)
puts(" of BulletEndPoint"); puts(" of BulletEndPoint");
if (s != NULL) { if (i > 0) {
puts(", serial# "); puts(", serial# ");
puts(s); puts(buf);
} }
putc('\n'); putc('\n');