X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fenv_common.c;h=eb33422af4b9c664da8928c1e2d61d986067d338;hb=87621bc24789e024c62a8a12bebd592943cdfb02;hp=f7f268e7b0395d17d2f653a4af017d927a6e6a35;hpb=05706fddd0c9d2b97996e545a7a6d31217bd40b9;p=u-boot diff --git a/common/env_common.c b/common/env_common.c index f7f268e7b0..eb33422af4 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -38,6 +37,13 @@ # define SHOW_BOOT_PROGRESS(arg) #endif +DECLARE_GLOBAL_DATA_PTR; + +#ifdef CONFIG_AMIGAONEG3SE + extern void enable_nvram(void); + extern void disable_nvram(void); +#endif + #undef DEBUG_ENV #ifdef DEBUG_ENV #define DEBUGF(fmt,args...) printf(fmt ,##args) @@ -90,6 +96,9 @@ uchar default_environment[] = { #ifdef CONFIG_ETH2ADDR "eth2addr=" MK_STR(CONFIG_ETH2ADDR) "\0" #endif +#ifdef CONFIG_ETH3ADDR + "eth3addr=" MK_STR(CONFIG_ETH3ADDR) "\0" +#endif #ifdef CONFIG_IPADDR "ipaddr=" MK_STR(CONFIG_IPADDR) "\0" #endif @@ -123,12 +132,18 @@ uchar default_environment[] = { #ifdef CONFIG_CLOCKS_IN_MHZ "clocks_in_mhz=1\0" #endif +#if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0) + "pcidelay=" MK_STR(CONFIG_PCI_BOOTDELAY) "\0" +#endif #ifdef CONFIG_EXTRA_ENV_SETTINGS CONFIG_EXTRA_ENV_SETTINGS #endif "\0" }; +#if defined(CFG_ENV_IS_IN_NAND) /* Environment is in Nand Flash */ +int default_environment_size = sizeof(default_environment); +#endif void env_crc_update (void) { @@ -137,7 +152,6 @@ void env_crc_update (void) static uchar env_get_char_init (int index) { - DECLARE_GLOBAL_DATA_PTR; uchar c; /* if crc was bad, use the default environment */ @@ -151,21 +165,32 @@ static uchar env_get_char_init (int index) return (c); } +#ifdef CONFIG_AMIGAONEG3SE +uchar env_get_char_memory (int index) +{ + uchar retval; + enable_nvram(); + if (gd->env_valid) { + retval = ( *((uchar *)(gd->env_addr + index)) ); + } else { + retval = ( default_environment[index] ); + } + disable_nvram(); + return retval; +} +#else uchar env_get_char_memory (int index) { - DECLARE_GLOBAL_DATA_PTR; - if (gd->env_valid) { return ( *((uchar *)(gd->env_addr + index)) ); } else { return ( default_environment[index] ); } } +#endif uchar *env_get_addr (int index) { - DECLARE_GLOBAL_DATA_PTR; - if (gd->env_valid) { return ( ((uchar *)(gd->env_addr + index)) ); } else { @@ -175,11 +200,13 @@ uchar *env_get_addr (int index) void env_relocate (void) { - DECLARE_GLOBAL_DATA_PTR; - DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__, gd->reloc_off); +#ifdef CONFIG_AMIGAONEG3SE + enable_nvram(); +#endif + #ifdef ENV_IS_EMBEDDED /* * The environment buffer is embedded with the text segment, @@ -228,4 +255,49 @@ void env_relocate (void) env_relocate_spec (); } gd->env_addr = (ulong)&(env_ptr->data); + +#ifdef CONFIG_AMIGAONEG3SE + disable_nvram(); +#endif } + +#ifdef CONFIG_AUTO_COMPLETE +int env_complete(char *var, int maxv, char *cmdv[], int bufsz, char *buf) +{ + int i, nxt, len, vallen, found; + const char *lval, *rval; + + found = 0; + cmdv[0] = NULL; + + len = strlen(var); + /* now iterate over the variables and select those that match */ + for (i=0; env_get_char(i) != '\0'; i=nxt+1) { + + for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) + ; + + lval = (char *)env_get_addr(i); + rval = strchr(lval, '='); + if (rval != NULL) { + vallen = rval - lval; + rval++; + } else + vallen = strlen(lval); + + if (len > 0 && (vallen < len || memcmp(lval, var, len) != 0)) + continue; + + if (found >= maxv - 2 || bufsz < vallen + 1) { + cmdv[found++] = "..."; + break; + } + cmdv[found++] = buf; + memcpy(buf, lval, vallen); buf += vallen; bufsz -= vallen; + *buf++ = '\0'; bufsz--; + } + + cmdv[found] = NULL; + return found; +} +#endif