env: Use getenv_yesno() more generally
Move the getenv_yesno() to env_common.c and change most checks for 'y' or 'n' to use this helper. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
This commit is contained in:
parent
7afcf3a55b
commit
ec8a252cd4
|
@ -540,15 +540,13 @@ void board_init_r(gd_t *id, ulong dest_addr)
|
||||||
flash_size = flash_init();
|
flash_size = flash_init();
|
||||||
if (flash_size > 0) {
|
if (flash_size > 0) {
|
||||||
# ifdef CONFIG_SYS_FLASH_CHECKSUM
|
# ifdef CONFIG_SYS_FLASH_CHECKSUM
|
||||||
char *s = getenv("flashchecksum");
|
|
||||||
|
|
||||||
print_size(flash_size, "");
|
print_size(flash_size, "");
|
||||||
/*
|
/*
|
||||||
* Compute and print flash CRC if flashchecksum is set to 'y'
|
* Compute and print flash CRC if flashchecksum is set to 'y'
|
||||||
*
|
*
|
||||||
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
|
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
|
||||||
*/
|
*/
|
||||||
if (s && (*s == 'y')) {
|
if (getenv_yesno("flashchecksum") == 1) {
|
||||||
printf(" CRC: %08X", crc32(0,
|
printf(" CRC: %08X", crc32(0,
|
||||||
(const unsigned char *) CONFIG_SYS_FLASH_BASE,
|
(const unsigned char *) CONFIG_SYS_FLASH_BASE,
|
||||||
flash_size));
|
flash_size));
|
||||||
|
|
|
@ -462,8 +462,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
|
||||||
*
|
*
|
||||||
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
|
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
|
||||||
*/
|
*/
|
||||||
s = getenv ("flashchecksum");
|
if (getenv_yesno("flashchecksum") == 1) {
|
||||||
if (s && (*s == 'y')) {
|
|
||||||
printf (" CRC: %08X",
|
printf (" CRC: %08X",
|
||||||
crc32 (0,
|
crc32 (0,
|
||||||
(const unsigned char *) CONFIG_SYS_FLASH_BASE,
|
(const unsigned char *) CONFIG_SYS_FLASH_BASE,
|
||||||
|
|
|
@ -74,7 +74,6 @@ void board_init_f(ulong not_used)
|
||||||
gd = (gd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
|
gd = (gd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
|
||||||
bd = (bd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
|
bd = (bd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
|
||||||
- GENERATED_BD_INFO_SIZE);
|
- GENERATED_BD_INFO_SIZE);
|
||||||
__maybe_unused char *s;
|
|
||||||
#if defined(CONFIG_CMD_FLASH)
|
#if defined(CONFIG_CMD_FLASH)
|
||||||
ulong flash_size = 0;
|
ulong flash_size = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -143,8 +142,7 @@ void board_init_f(ulong not_used)
|
||||||
*
|
*
|
||||||
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
|
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
|
||||||
*/
|
*/
|
||||||
s = getenv ("flashchecksum");
|
if (getenv_yesno("flashchecksum") == 1) {
|
||||||
if (s && (*s == 'y')) {
|
|
||||||
printf (" CRC: %08X",
|
printf (" CRC: %08X",
|
||||||
crc32(0, (const u8 *)bd->bi_flashstart,
|
crc32(0, (const u8 *)bd->bi_flashstart,
|
||||||
flash_size)
|
flash_size)
|
||||||
|
|
|
@ -46,10 +46,8 @@ u32 get_my_id()
|
||||||
*/
|
*/
|
||||||
int hold_cores_in_reset(int verbose)
|
int hold_cores_in_reset(int verbose)
|
||||||
{
|
{
|
||||||
const char *s = getenv("mp_holdoff");
|
|
||||||
|
|
||||||
/* Default to no, overriden by 'y', 'yes', 'Y', 'Yes', or '1' */
|
/* Default to no, overriden by 'y', 'yes', 'Y', 'Yes', or '1' */
|
||||||
if (s && (*s == 'y' || *s == 'Y' || *s == '1')) {
|
if (getenv_yesno("mp_holdoff") == 1) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
puts("Secondary cores are being held in reset.\n");
|
puts("Secondary cores are being held in reset.\n");
|
||||||
puts("See 'mp_holdoff' environment variable\n");
|
puts("See 'mp_holdoff' environment variable\n");
|
||||||
|
|
|
@ -739,16 +739,13 @@ void board_init_r(gd_t *id, ulong dest_addr)
|
||||||
flash_size = 0;
|
flash_size = 0;
|
||||||
} else if ((flash_size = flash_init()) > 0) {
|
} else if ((flash_size = flash_init()) > 0) {
|
||||||
#ifdef CONFIG_SYS_FLASH_CHECKSUM
|
#ifdef CONFIG_SYS_FLASH_CHECKSUM
|
||||||
char *s;
|
|
||||||
|
|
||||||
print_size(flash_size, "");
|
print_size(flash_size, "");
|
||||||
/*
|
/*
|
||||||
* Compute and print flash CRC if flashchecksum is set to 'y'
|
* Compute and print flash CRC if flashchecksum is set to 'y'
|
||||||
*
|
*
|
||||||
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
|
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
|
||||||
*/
|
*/
|
||||||
s = getenv("flashchecksum");
|
if (getenv_yesno("flashchecksum") == 1) {
|
||||||
if (s && (*s == 'y')) {
|
|
||||||
printf(" CRC: %08X",
|
printf(" CRC: %08X",
|
||||||
crc32(0,
|
crc32(0,
|
||||||
(const unsigned char *)
|
(const unsigned char *)
|
||||||
|
@ -841,9 +838,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
|
||||||
* "i2cfast" into account
|
* "i2cfast" into account
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
char *s = getenv("i2cfast");
|
if (getenv_yesno("i2cfast") == 1) {
|
||||||
|
|
||||||
if (s && ((*s == 'y') || (*s == 'Y'))) {
|
|
||||||
bd->bi_iic_fast[0] = 1;
|
bd->bi_iic_fast[0] = 1;
|
||||||
bd->bi_iic_fast[1] = 1;
|
bd->bi_iic_fast[1] = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,8 +284,7 @@ void board_init_f(ulong bootflag)
|
||||||
*
|
*
|
||||||
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
|
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
|
||||||
*/
|
*/
|
||||||
s = getenv("flashchecksum");
|
if (getenv_yesno("flashchecksum") == 1) {
|
||||||
if (s && (*s == 'y')) {
|
|
||||||
printf(" CRC: %08lX",
|
printf(" CRC: %08lX",
|
||||||
crc32(0, (const unsigned char *)CONFIG_SYS_FLASH_BASE,
|
crc32(0, (const unsigned char *)CONFIG_SYS_FLASH_BASE,
|
||||||
flash_size)
|
flash_size)
|
||||||
|
|
|
@ -834,15 +834,11 @@ int mem_test_walk (void)
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
int testdram (void)
|
int testdram (void)
|
||||||
{
|
{
|
||||||
char *s;
|
|
||||||
int rundata, runaddress, runwalk;
|
int rundata, runaddress, runwalk;
|
||||||
|
|
||||||
s = getenv ("testdramdata");
|
rundata = getenv_yesno("testdramdata") == 1;
|
||||||
rundata = (s && (*s == 'y')) ? 1 : 0;
|
runaddress = getenv_yesno("testdramaddress") == 1;
|
||||||
s = getenv ("testdramaddress");
|
runwalk = getenv_yesno("testdramwalk") == 1;
|
||||||
runaddress = (s && (*s == 'y')) ? 1 : 0;
|
|
||||||
s = getenv ("testdramwalk");
|
|
||||||
runwalk = (s && (*s == 'y')) ? 1 : 0;
|
|
||||||
|
|
||||||
/* rundata = 1; */
|
/* rundata = 1; */
|
||||||
/* runaddress = 0; */
|
/* runaddress = 0; */
|
||||||
|
|
|
@ -834,15 +834,11 @@ int mem_test_walk (void)
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
int testdram (void)
|
int testdram (void)
|
||||||
{
|
{
|
||||||
char *s;
|
|
||||||
int rundata, runaddress, runwalk;
|
int rundata, runaddress, runwalk;
|
||||||
|
|
||||||
s = getenv ("testdramdata");
|
rundata = getenv_yesno("testdramdata") == 1;
|
||||||
rundata = (s && (*s == 'y')) ? 1 : 0;
|
runaddress = getenv_yesno("testdramaddress") == 1;
|
||||||
s = getenv ("testdramaddress");
|
runwalk = getenv_yesno("testdramwalk") == 1;
|
||||||
runaddress = (s && (*s == 'y')) ? 1 : 0;
|
|
||||||
s = getenv ("testdramwalk");
|
|
||||||
runwalk = (s && (*s == 'y')) ? 1 : 0;
|
|
||||||
|
|
||||||
/* rundata = 1; */
|
/* rundata = 1; */
|
||||||
/* runaddress = 0; */
|
/* runaddress = 0; */
|
||||||
|
|
|
@ -953,22 +953,18 @@ int mem_test_walk (void)
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
int testdram (void)
|
int testdram (void)
|
||||||
{
|
{
|
||||||
char *s;
|
|
||||||
int rundata = 0;
|
int rundata = 0;
|
||||||
int runaddress = 0;
|
int runaddress = 0;
|
||||||
int runwalk = 0;
|
int runwalk = 0;
|
||||||
|
|
||||||
#ifdef CONFIG_SYS_DRAM_TEST_DATA
|
#ifdef CONFIG_SYS_DRAM_TEST_DATA
|
||||||
s = getenv ("testdramdata");
|
rundata = getenv_yesno("testdramdata") == 1;
|
||||||
rundata = (s && (*s == 'y')) ? 1 : 0;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_SYS_DRAM_TEST_ADDRESS
|
#ifdef CONFIG_SYS_DRAM_TEST_ADDRESS
|
||||||
s = getenv ("testdramaddress");
|
runaddress = getenv_yesno("testdramaddress") == 1;
|
||||||
runaddress = (s && (*s == 'y')) ? 1 : 0;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_SYS_DRAM_TEST_WALK
|
#ifdef CONFIG_SYS_DRAM_TEST_WALK
|
||||||
s = getenv ("testdramwalk");
|
runwalk = getenv_yesno("testdramwalk") == 1;
|
||||||
runwalk = (s && (*s == 'y')) ? 1 : 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
|
if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
|
||||||
|
|
|
@ -544,15 +544,11 @@ int mem_test_walk (void)
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
int testdram (void)
|
int testdram (void)
|
||||||
{
|
{
|
||||||
char *s;
|
|
||||||
int rundata, runaddress, runwalk;
|
int rundata, runaddress, runwalk;
|
||||||
|
|
||||||
s = getenv ("testdramdata");
|
rundata = getenv_yesno("testdramdata") == 1;
|
||||||
rundata = (s && (*s == 'y')) ? 1 : 0;
|
runaddress = getenv_yesno("testdramaddress") == 1;
|
||||||
s = getenv ("testdramaddress");
|
runwalk = getenv_yesno("testdramwalk") == 1;
|
||||||
runaddress = (s && (*s == 'y')) ? 1 : 0;
|
|
||||||
s = getenv ("testdramwalk");
|
|
||||||
runwalk = (s && (*s == 'y')) ? 1 : 0;
|
|
||||||
|
|
||||||
if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
|
if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
|
||||||
printf ("Testing RAM ... ");
|
printf ("Testing RAM ... ");
|
||||||
|
|
|
@ -768,22 +768,18 @@ int mem_test_walk (void)
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
int testdram (void)
|
int testdram (void)
|
||||||
{
|
{
|
||||||
char *s;
|
|
||||||
int rundata = 0;
|
int rundata = 0;
|
||||||
int runaddress = 0;
|
int runaddress = 0;
|
||||||
int runwalk = 0;
|
int runwalk = 0;
|
||||||
|
|
||||||
#ifdef CONFIG_SYS_DRAM_TEST_DATA
|
#ifdef CONFIG_SYS_DRAM_TEST_DATA
|
||||||
s = getenv ("testdramdata");
|
rundata = getenv_yesno("testdramdata") == 1;
|
||||||
rundata = (s && (*s == 'y')) ? 1 : 0;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_SYS_DRAM_TEST_ADDRESS
|
#ifdef CONFIG_SYS_DRAM_TEST_ADDRESS
|
||||||
s = getenv ("testdramaddress");
|
runaddress = getenv_yesno("testdramaddress") == 1;
|
||||||
runaddress = (s && (*s == 'y')) ? 1 : 0;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_SYS_DRAM_TEST_WALK
|
#ifdef CONFIG_SYS_DRAM_TEST_WALK
|
||||||
s = getenv ("testdramwalk");
|
runwalk = getenv_yesno("testdramwalk") == 1;
|
||||||
runwalk = (s && (*s == 'y')) ? 1 : 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((rundata == 1) || (runaddress == 1) || (runwalk == 1))
|
if ((rundata == 1) || (runaddress == 1) || (runwalk == 1))
|
||||||
|
|
|
@ -81,6 +81,20 @@ const uchar *env_get_addr(int index)
|
||||||
return &default_environment[index];
|
return &default_environment[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read an environment variable as a boolean
|
||||||
|
* Return -1 if variable does not exist (default to true)
|
||||||
|
*/
|
||||||
|
int getenv_yesno(const char *var)
|
||||||
|
{
|
||||||
|
char *s = getenv(var);
|
||||||
|
|
||||||
|
if (s == NULL)
|
||||||
|
return -1;
|
||||||
|
return (*s == '1' || *s == 'y' || *s == 'Y' || *s == 't' || *s == 'T') ?
|
||||||
|
1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
void set_default_env(const char *s)
|
void set_default_env(const char *s)
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
|
@ -416,12 +416,6 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
|
||||||
/* Shared dual-format routines */
|
/* Shared dual-format routines */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
#ifndef USE_HOSTCC
|
#ifndef USE_HOSTCC
|
||||||
int getenv_yesno(char *var)
|
|
||||||
{
|
|
||||||
char *s = getenv(var);
|
|
||||||
return (s && (*s == 'n')) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong getenv_bootm_low(void)
|
ulong getenv_bootm_low(void)
|
||||||
{
|
{
|
||||||
char *s = getenv("bootm_low");
|
char *s = getenv("bootm_low");
|
||||||
|
|
|
@ -340,6 +340,11 @@ int envmatch (uchar *, int);
|
||||||
char *getenv (const char *);
|
char *getenv (const char *);
|
||||||
int getenv_f (const char *name, char *buf, unsigned len);
|
int getenv_f (const char *name, char *buf, unsigned len);
|
||||||
ulong getenv_ulong(const char *name, int base, ulong default_val);
|
ulong getenv_ulong(const char *name, int base, ulong default_val);
|
||||||
|
/*
|
||||||
|
* Read an environment variable as a boolean
|
||||||
|
* Return -1 if variable does not exist (default to true)
|
||||||
|
*/
|
||||||
|
int getenv_yesno(const char *var);
|
||||||
int saveenv (void);
|
int saveenv (void);
|
||||||
int setenv (const char *, const char *);
|
int setenv (const char *, const char *);
|
||||||
int setenv_ulong(const char *varname, ulong value);
|
int setenv_ulong(const char *varname, ulong value);
|
||||||
|
|
|
@ -460,7 +460,6 @@ static inline void image_set_name(image_header_t *hdr, const char *name)
|
||||||
int image_check_hcrc(const image_header_t *hdr);
|
int image_check_hcrc(const image_header_t *hdr);
|
||||||
int image_check_dcrc(const image_header_t *hdr);
|
int image_check_dcrc(const image_header_t *hdr);
|
||||||
#ifndef USE_HOSTCC
|
#ifndef USE_HOSTCC
|
||||||
int getenv_yesno(char *var);
|
|
||||||
ulong getenv_bootm_low(void);
|
ulong getenv_bootm_low(void);
|
||||||
phys_size_t getenv_bootm_size(void);
|
phys_size_t getenv_bootm_size(void);
|
||||||
phys_size_t getenv_bootm_mapsize(void);
|
phys_size_t getenv_bootm_mapsize(void);
|
||||||
|
|
32
net/net.c
32
net/net.c
|
@ -214,26 +214,24 @@ static int NetTryCount;
|
||||||
*/
|
*/
|
||||||
void net_auto_load(void)
|
void net_auto_load(void)
|
||||||
{
|
{
|
||||||
|
#if defined(CONFIG_CMD_NFS)
|
||||||
const char *s = getenv("autoload");
|
const char *s = getenv("autoload");
|
||||||
|
|
||||||
if (s != NULL) {
|
if (s != NULL && strcmp(s, "NFS") == 0) {
|
||||||
if (*s == 'n') {
|
/*
|
||||||
/*
|
* Use NFS to load the bootfile.
|
||||||
* Just use BOOTP/RARP to configure system;
|
*/
|
||||||
* Do not use TFTP to load the bootfile.
|
NfsStart();
|
||||||
*/
|
return;
|
||||||
net_set_state(NETLOOP_SUCCESS);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if defined(CONFIG_CMD_NFS)
|
|
||||||
if (strcmp(s, "NFS") == 0) {
|
|
||||||
/*
|
|
||||||
* Use NFS to load the bootfile.
|
|
||||||
*/
|
|
||||||
NfsStart();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
if (getenv_yesno("autoload") == 0) {
|
||||||
|
/*
|
||||||
|
* Just use BOOTP/RARP to configure system;
|
||||||
|
* Do not use TFTP to load the bootfile.
|
||||||
|
*/
|
||||||
|
net_set_state(NETLOOP_SUCCESS);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
TftpStart(TFTPGET);
|
TftpStart(TFTPGET);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue