Commit cdb74977 authored by Wolfgang Denk's avatar Wolfgang Denk
Browse files

Rename getenv_r() into getenv_f()



While running from flash, i. e. before relocation, we have only a
limited C runtime environment without writable data segment. In this
phase, some configurations (for example with environment in EEPROM)
must not use the normal getenv(), but a special function.  This
function had been called getenv_r(), with the idea that the "_r"
suffix would mean the same as in the _r_eentrant versions of some of
the C library functions (for example getdate vs. getdate_r, getgrent
vs. getgrent_r, etc.).

Unfortunately this was a misleading name, as in U-Boot the "_r"
generally means "running from RAM", i. e. _after_ relocation.

To avoid confusion, rename into getenv_f() [as "running from flash"]
Signed-off-by: default avatarWolfgang Denk <wd@denx.de>
Acked-by: default avatarDetlev Zundel <dzu@denx.de>
parent 78e1e846
......@@ -2572,7 +2572,7 @@ to save the current settings.
Please note that the environment is read-only until the monitor
has been relocated to RAM and a RAM copy of the environment has been
created; also, when using EEPROM you will have to use getenv_r()
created; also, when using EEPROM you will have to use getenv_f()
until then to read environment variables.
The environment is protected by a CRC32 checksum. Before the monitor
......
......@@ -125,7 +125,7 @@ void blue_LED_off(void) __attribute__((weak, alias("__blue_LED_off")));
static int init_baudrate (void)
{
char tmp[64]; /* long enough for environment variables */
int i = getenv_r ("baudrate", tmp, sizeof (tmp));
int i = getenv_f("baudrate", tmp, sizeof (tmp));
gd->bd->bi_baudrate = gd->baudrate = (i > 0)
? (int) simple_strtoul (tmp, NULL, 10)
: CONFIG_BAUDRATE;
......
......@@ -102,7 +102,7 @@ static int init_baudrate(void)
char tmp[64];
int i;
i = getenv_r("baudrate", tmp, sizeof(tmp));
i = getenv_f("baudrate", tmp, sizeof(tmp));
if (i > 0) {
gd->baudrate = simple_strtoul(tmp, NULL, 10);
} else {
......
......@@ -64,7 +64,7 @@ static int display_banner(void)
static int init_baudrate(void)
{
char baudrate[15];
int i = getenv_r("baudrate", baudrate, sizeof(baudrate));
int i = getenv_f("baudrate", baudrate, sizeof(baudrate));
gd->bd->bi_baudrate = gd->baudrate = (i > 0)
? simple_strtoul(baudrate, NULL, 10)
: CONFIG_BAUDRATE;
......
......@@ -168,7 +168,7 @@ static void post_get_flags(int *test_flags)
}
for (i = 0; i < varnum; i++) {
if (getenv_r(var[i], list, sizeof(list)) <= 0)
if (getenv_f(var[i], list, sizeof(list)) <= 0)
continue;
for (j = 0; j < post_list_size; j++) {
......
......@@ -69,7 +69,7 @@ const char version_string[] =
static int init_baudrate (void)
{
char tmp[64]; /* long enough for environment variables */
int i = getenv_r("baudrate", tmp, 64);
int i = getenv_f("baudrate", tmp, 64);
gd->baudrate = (i != 0)
? (int) simple_strtoul (tmp, NULL, 10)
......
......@@ -134,7 +134,7 @@ typedef int (init_fnc_t) (void);
static int init_baudrate (void)
{
char tmp[64]; /* long enough for environment variables */
int i = getenv_r ("baudrate", tmp, sizeof (tmp));
int i = getenv_f("baudrate", tmp, sizeof (tmp));
gd->baudrate = (i > 0)
? (int) simple_strtoul (tmp, NULL, 10)
......@@ -278,7 +278,7 @@ board_init_f (ulong bootflag)
/*
* reserve protected RAM
*/
i = getenv_r ("pram", tmp, sizeof (tmp));
i = getenv_f("pram", tmp, sizeof (tmp));
reg = (i > 0) ? simple_strtoul (tmp, NULL, 10) : CONFIG_PRAM;
addr -= (reg << 10); /* size is in kB */
debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
......@@ -549,7 +549,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
* Fill in missing fields of bd_info.
* We do this here, where we have "normal" access to the
* environment; we used to do this still running from ROM,
* where had to use getenv_r(), which can be pretty slow when
* where had to use getenv_f(), which can be pretty slow when
* the environment is in EEPROM.
*/
bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
......
......@@ -105,7 +105,7 @@ int incaip_set_cpuclk (void)
char tmp[64];
ulong cpuclk;
if (getenv_r ("cpuclk", tmp, sizeof (tmp)) > 0) {
if (getenv_f("cpuclk", tmp, sizeof (tmp)) > 0) {
cpuclk = simple_strtoul (tmp, NULL, 10) * 1000000;
cgu_init (cpuclk);
ebu_init (cpuclk);
......
......@@ -114,7 +114,7 @@ static void display_flash_config(ulong size)
static int init_baudrate (void)
{
char tmp[64]; /* long enough for environment variables */
int i = getenv_r ("baudrate", tmp, sizeof (tmp));
int i = getenv_f("baudrate", tmp, sizeof (tmp));
gd->baudrate = (i > 0)
? (int) simple_strtoul (tmp, NULL, 10)
......
......@@ -266,7 +266,7 @@ int get_clocks_866 (void)
long cpuclk = 0;
long sccr_reg;
if (getenv_r ("cpuclk", tmp, sizeof (tmp)) > 0)
if (getenv_f("cpuclk", tmp, sizeof (tmp)) > 0)
cpuclk = simple_strtoul (tmp, NULL, 10) * 1000000;
if ((CONFIG_SYS_8xx_CPUCLK_MIN > cpuclk) || (CONFIG_SYS_8xx_CPUCLK_MAX < cpuclk))
......
......@@ -985,7 +985,7 @@ u32 DQS_autocalibration(void)
puts(str);
#if defined(DEBUG_PPC4xx_DDR_AUTOCALIBRATION)
i = getenv_r("autocalib", tmp, sizeof(tmp));
i = getenv_f("autocalib", tmp, sizeof(tmp));
if (i < 0)
strcpy(tmp, CONFIG_AUTOCALIB);
......
......@@ -169,7 +169,7 @@ typedef int (init_fnc_t) (void);
static int init_baudrate (void)
{
char tmp[64]; /* long enough for environment variables */
int i = getenv_r ("baudrate", tmp, sizeof (tmp));
int i = getenv_f("baudrate", tmp, sizeof (tmp));
gd->baudrate = (i > 0)
? (int) simple_strtoul (tmp, NULL, 10)
......@@ -442,7 +442,7 @@ void board_init_f (ulong bootflag)
/*
* reserve protected RAM
*/
i = getenv_r ("pram", (char *)tmp, sizeof (tmp));
i = getenv_f("pram", (char *)tmp, sizeof (tmp));
reg = (i > 0) ? simple_strtoul ((const char *)tmp, NULL, 10) : CONFIG_PRAM;
addr -= (reg << 10); /* size is in kB */
debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
......@@ -790,7 +790,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
* Fill in missing fields of bd_info.
* We do this here, where we have "normal" access to the
* environment; we used to do this still running from ROM,
* where had to use getenv_r(), which can be pretty slow when
* where had to use getenv_f(), which can be pretty slow when
* the environment is in EEPROM.
*/
......
......@@ -88,7 +88,7 @@ ulong monitor_flash_len;
static int init_baudrate(void)
{
char tmp[64]; /* long enough for environment variables */
int i = getenv_r("baudrate", tmp, sizeof(tmp));
int i = getenv_f("baudrate", tmp, sizeof(tmp));
gd->baudrate = (i > 0)
? (int)simple_strtoul(tmp, NULL, 10)
......
......@@ -248,7 +248,7 @@ void mv6436x_eth_initialize (bd_t * bis)
return;
}
temp = getenv_r (s, buf, sizeof (buf));
temp = getenv_f(s, buf, sizeof (buf));
s = (temp > 0) ? buf : NULL;
#ifdef DEBUG
......@@ -351,7 +351,7 @@ void mv6436x_eth_initialize (bd_t * bis)
return;
}
temp = getenv_r (s, buf, sizeof (buf));
temp = getenv_f(s, buf, sizeof (buf));
s = (temp > 0) ? buf : NULL;
#ifdef DEBUG
......
......@@ -248,7 +248,7 @@ void mv6446x_eth_initialize (bd_t * bis)
return;
}
temp = getenv_r (s, buf, sizeof (buf));
temp = getenv_f(s, buf, sizeof (buf));
s = (temp > 0) ? buf : NULL;
#ifdef DEBUG
......@@ -350,7 +350,7 @@ void mv6446x_eth_initialize (bd_t * bis)
return;
}
temp = getenv_r (s, buf, sizeof (buf));
temp = getenv_f(s, buf, sizeof (buf));
s = (temp > 0) ? buf : NULL;
#ifdef DEBUG
......
......@@ -34,7 +34,7 @@ int checkboard(void)
{
char tmp[64];
char *s, *e;
int i = getenv_r("serial", tmp, sizeof(tmp));
int i = getenv_f("serial", tmp, sizeof(tmp));
if (i < 0) {
printf("Avnet Virtex4 FX12 with no serial #");
......
......@@ -245,7 +245,7 @@ int testdram (void)
uint *pend = (uint *) L1_MEMSIZE;
uint *p;
if (getenv_r("booted",NULL,0) <= 0)
if (getenv_f("booted",NULL,0) <= 0)
{
printf ("testdram..");
/*AA*/
......
......@@ -183,7 +183,7 @@ int misc_init_r (void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
puts ("Board: ");
......
......@@ -62,7 +62,7 @@ int board_early_init_f (void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof (str));
int i = getenv_f("serial#", str, sizeof (str));
puts ("Board: ");
......
......@@ -404,7 +404,7 @@ int misc_init_r(void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
puts ("Board: ");
......
......@@ -151,7 +151,7 @@ int checkboard (void)
int index;
int len;
char str[64];
int i = getenv_r ("serial#", str, sizeof (str));
int i = getenv_f("serial#", str, sizeof (str));
const unsigned char *fpga;
puts ("Board: ");
......
......@@ -173,7 +173,7 @@ int misc_init_r (void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
puts ("Board: ");
......
......@@ -157,7 +157,7 @@ int checkboard (void)
int index;
int len;
char str[64];
int i = getenv_r ("serial#", str, sizeof (str));
int i = getenv_f("serial#", str, sizeof (str));
puts ("Board: ");
......
......@@ -96,7 +96,7 @@ int checkboard (void)
puts ("Board: ");
if (getenv_r("serial#", str, sizeof(str)) == -1) {
if (getenv_f("serial#", str, sizeof(str)) == -1) {
puts ("### No HW ID - assuming CMS700");
} else {
puts(str);
......
......@@ -94,7 +94,7 @@ int misc_init_r (void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
puts ("Board: ");
......
......@@ -416,7 +416,7 @@ int checkboard(void)
int len;
#endif
char str[64];
int i = getenv_r("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
unsigned short ver;
puts("Board: ");
......
......@@ -248,7 +248,7 @@ void mv6436x_eth_initialize (bd_t * bis)
return;
}
temp = getenv_r (s, buf, sizeof (buf));
temp = getenv_f(s, buf, sizeof (buf));
s = (temp > 0) ? buf : NULL;
#ifdef DEBUG
......@@ -352,7 +352,7 @@ void mv6436x_eth_initialize (bd_t * bis)
return;
}
temp = getenv_r (s, buf, sizeof (buf));
temp = getenv_f(s, buf, sizeof (buf));
s = (temp > 0) ? buf : NULL;
#ifdef DEBUG
......
......@@ -153,7 +153,7 @@ int checkboard (void)
int index;
int len;
char str[64];
int i = getenv_r ("serial#", str, sizeof (str));
int i = getenv_f("serial#", str, sizeof (str));
puts ("Board: ");
......
......@@ -168,7 +168,7 @@ int checkboard (void)
int index;
int len;
char str[64];
int i = getenv_r ("serial#", str, sizeof (str));
int i = getenv_f("serial#", str, sizeof (str));
int fpga;
unsigned short val;
......
......@@ -86,7 +86,7 @@ int misc_init_r (void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
unsigned char trans[16] = {0x0,0x8,0x4,0xc,0x2,0xa,0x6,0xe,
0x1,0x9,0x5,0xd,0x3,0xb,0x7,0xf};
unsigned char id1, id2, rev;
......
......@@ -163,7 +163,7 @@ int checkboard (void)
int index;
int len;
char str[64];
int i = getenv_r ("serial#", str, sizeof (str));
int i = getenv_f("serial#", str, sizeof (str));
puts ("Board: ");
......
......@@ -350,7 +350,7 @@ int checkboard(void)
puts("Board: DU440");
if (getenv_r("serial#", serno, sizeof(serno)) > 0) {
if (getenv_f("serial#", serno, sizeof(serno)) > 0) {
puts(", serial# ");
puts(serno);
}
......
......@@ -650,7 +650,7 @@ int misc_init_r (void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
puts ("Board: ");
......@@ -660,7 +660,7 @@ int checkboard (void)
puts(str);
}
if (getenv_r("bd_type", str, sizeof(str)) != -1) {
if (getenv_f("bd_type", str, sizeof(str)) != -1) {
printf(" (%s", str);
} else {
puts(" (Missing bd_type!");
......@@ -780,7 +780,7 @@ void video_get_info_str (int line_number, char *info)
{
char str[64];
char str2[64];
int i = getenv_r("serial#", str2, sizeof(str));
int i = getenv_f("serial#", str2, sizeof(str));
if (line_number == 1) {
sprintf(str, " Board: ");
......@@ -791,7 +791,7 @@ void video_get_info_str (int line_number, char *info)
strcat(str, str2);
}
if (getenv_r("bd_type", str2, sizeof(str2)) != -1) {
if (getenv_f("bd_type", str2, sizeof(str2)) != -1) {
strcat(str, " (");
strcat(str, str2);
} else {
......
......@@ -196,7 +196,7 @@ int misc_init_r (void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
puts ("Board: ");
......@@ -206,7 +206,7 @@ int checkboard (void)
puts(str);
}
if (getenv_r("bd_type", str, sizeof(str)) != -1) {
if (getenv_f("bd_type", str, sizeof(str)) != -1) {
printf(" (%s", str);
} else {
puts(" (Missing bd_type!");
......
......@@ -184,7 +184,7 @@ int checkboard(void)
puts("Board: EtherCAN/2 Gateway");
break;
}
if (getenv_r("serial#", str, sizeof(str)) > 0) {
if (getenv_f("serial#", str, sizeof(str)) > 0) {
puts(", serial# ");
puts(str);
}
......
......@@ -68,7 +68,7 @@ int board_early_init_f (void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof (str));
int i = getenv_f("serial#", str, sizeof (str));
puts ("Board: ");
......
......@@ -258,7 +258,7 @@ int checkboard(void)
char str[32];
puts("Board: esd ARM9 HMI Panel - OTC570");
if (getenv_r("serial#", str, sizeof(str)) > 0) {
if (getenv_f("serial#", str, sizeof(str)) > 0) {
puts(", serial# ");
puts(str);
}
......@@ -308,7 +308,7 @@ int misc_init_r(void)
printf("USART0: ");
if (getenv_r("usart0", str, sizeof(str)) == -1) {
if (getenv_f("usart0", str, sizeof(str)) == -1) {
printf("No entry - assuming 1-wire\n");
/* CTS pin, works as mode select pin (0 = 1-wire; 1 = RS485) */
at91_set_pio_output(AT91_PIO_PORTA, 29, 0);
......
......@@ -298,7 +298,7 @@ int misc_init_r (void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
puts ("Board: ");
......
......@@ -240,7 +240,7 @@ int misc_init_r(void)
int checkboard(void)
{
char str[64];
int i = getenv_r("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
puts("Board: ");
......
......@@ -123,7 +123,7 @@ int checkboard (void)
{
ulong val;
char str[64];
int i = getenv_r("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
puts ("Board: ");
......
......@@ -271,7 +271,7 @@ int misc_init_r (void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
puts ("Board: ");
......@@ -281,7 +281,7 @@ int checkboard (void)
puts(str);
}
if (getenv_r("bd_type", str, sizeof(str)) != -1) {
if (getenv_f("bd_type", str, sizeof(str)) != -1) {
printf(" (%s)", str);
} else {
puts(" (Missing bd_type!)");
......
......@@ -121,7 +121,7 @@ int misc_init_r (void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
int flashcnt;
int delay;
u8 *led_reg = (u8 *)(CAN_BA + 0x1000);
......
......@@ -173,7 +173,7 @@ int misc_init_r (void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
puts ("Board: ");
......
......@@ -708,7 +708,7 @@ gt6426x_eth_initialize(bd_t *bis)
return;
}
temp = getenv_r (s, buf, sizeof(buf));
temp = getenv_f(s, buf, sizeof(buf));
s = (temp > 0) ? buf : NULL;
#ifdef DEBUG
......
......@@ -91,7 +91,7 @@ int misc_init_r (void)
int checkboard (void)
{
char str[64];
int i = getenv_r ("serial#", str, sizeof(str));
int i = getenv_f("serial#", str, sizeof(str));
puts ("Board: ");
......
......@@ -132,7 +132,7 @@ int checkboard (void)
char buf[64];
int i;
i = getenv_r ("board_id", buf, sizeof (buf));
i = getenv_f("board_id", buf, sizeof (buf));
s = (i > 0) ? buf : NULL;
if (s) {
......@@ -141,7 +141,7 @@ int checkboard (void)
printf ("<unknown> ");
}
i = getenv_r ("serial#", buf, sizeof (buf));
i = getenv_f("serial#", buf, sizeof (buf));
s = (i > 0) ? buf : NULL;
if (s) {
......@@ -276,7 +276,7 @@ int last_stage_init (void)
/*
* Read the environment to see what to do with the beeper
*/
i = getenv_r ("beeper", buf, sizeof (buf));
i = getenv_f("beeper", buf, sizeof (buf));
if (i > 0) {
do_beeper (buf);