]> git.sur5r.net Git - u-boot/blobdiff - common/cmd_nvedit.c
Stop passing around bootmem_base value.
[u-boot] / common / cmd_nvedit.c
index c3b57f2ff3ad6d90945ec0596c9fd0fa5b1ba77f..df0e6dbafdaa63f70ebd17463e82c9f97e6a1446 100644 (file)
@@ -65,7 +65,7 @@ DECLARE_GLOBAL_DATA_PTR;
     !defined(CONFIG_ENV_IS_IN_SPI_FLASH)       && \
     !defined(CONFIG_ENV_IS_NOWHERE)
 # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|DATAFLASH|ONENAND|\
-SPI_FLASH|MG_DISK|NVRAM|MMC|NOWHERE}
+SPI_FLASH|MG_DISK|NVRAM|MMC} or CONFIG_ENV_IS_NOWHERE
 #endif
 
 #define XMK_STR(x)     #x
@@ -76,6 +76,8 @@ SPI_FLASH|MG_DISK|NVRAM|MMC|NOWHERE}
  */
 #define        MAX_ENV_SIZE    (1 << 20)       /* 1 MiB */
 
+ulong load_addr = CONFIG_SYS_LOAD_ADDR;        /* Default Load Address */
+
 /*
  * Table with supported baudrates (defined in config_xyz.h)
  */
@@ -111,7 +113,7 @@ static int env_print(char *name)
 
                e.key = name;
                e.data = NULL;
-               ep = hsearch (e, FIND);
+               hsearch_r(e, FIND, &ep, &env_htab);
                if (ep == NULL)
                        return 0;
                len = printf ("%s=%s\n", ep->key, ep->data);
@@ -119,7 +121,7 @@ static int env_print(char *name)
        }
 
        /* print whole list */
-       len = hexport('\n', &res, 0);
+       len = hexport_r(&env_htab, '\n', &res, 0);
 
        if (len > 0) {
                puts(res);
@@ -184,7 +186,7 @@ int _do_env_set (int flag, int argc, char * const argv[])
         */
        e.key = name;
        e.data = NULL;
-       ep = hsearch (e, FIND);
+       hsearch_r(e, FIND, &ep, &env_htab);
 
        /* Check for console redirection */
        if (strcmp(name,"stdin") == 0) {
@@ -267,7 +269,7 @@ int _do_env_set (int flag, int argc, char * const argv[])
 
        /* Delete only ? */
        if ((argc < 3) || argv[2] == NULL) {
-               int rc = hdelete(name);
+               int rc = hdelete_r(name, &env_htab);
                return !rc;
        }
 
@@ -293,7 +295,7 @@ int _do_env_set (int flag, int argc, char * const argv[])
 
        e.key  = name;
        e.data = value;
-       ep = hsearch(e, ENTER);
+       hsearch_r(e, ENTER, &ep, &env_htab);
        free(value);
        if (!ep) {
                printf("## Error inserting \"%s\" variable, errno=%d\n",
@@ -456,7 +458,7 @@ char *getenv (char *name)
 
                e.key  = name;
                e.data = NULL;
-               ep = hsearch (e, FIND);
+               hsearch_r(e, FIND, &ep, &env_htab);
 
                return (ep ? ep->data : NULL);
        }
@@ -557,6 +559,7 @@ static int do_env_delete(cmd_tbl_t * cmdtp, int flag, int argc, char * const arg
        return 0;
 }
 
+#ifdef CONFIG_CMD_EXPORTENV
 /*
  * env export [-t | -b | -c] addr [size]
  *     -t:     export as text format; if size is given, data will be
@@ -651,13 +654,13 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
        }
 
        if (sep) {              /* export as text file */
-               len = hexport(sep, &addr, size);
+               len = hexport_r(&env_htab, sep, &addr, size);
                if (len < 0) {
                        error("Cannot export environment: errno = %d\n",
                                errno);
                        return 1;
                }
-               sprintf(buf, "%zX", len);
+               sprintf(buf, "%zX", (size_t)len);
                setenv("filesize", buf);
 
                return 0;
@@ -670,7 +673,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
        else                    /* export as raw binary data */
                res = addr;
 
-       len = hexport('\0', &res, ENV_SIZE);
+       len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
        if (len < 0) {
                error("Cannot export environment: errno = %d\n",
                        errno);
@@ -683,7 +686,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
                envp->flags = ACTIVE_FLAG;
 #endif
        }
-       sprintf(buf, "%zX", len + offsetof(env_t,data));
+       sprintf(buf, "%zX", (size_t)(len + offsetof(env_t,data)));
        setenv("filesize", buf);
 
        return 0;
@@ -693,7 +696,9 @@ sep_err:
                cmd);
        return 1;
 }
+#endif
 
+#ifdef CONFIG_CMD_IMPORTENV
 /*
  * env import [-d] [-t | -b | -c] addr [size]
  *     -d:     delete existing environment before importing;
@@ -790,7 +795,7 @@ static int do_env_import(cmd_tbl_t * cmdtp, int flag, int argc, char * const arg
                addr = (char *)ep->data;
        }
 
-       if (himport(addr, size, sep, del ? 0 : H_NOCLEAR) == 0) {
+       if (himport_r(&env_htab, addr, size, sep, del ? 0 : H_NOCLEAR) == 0) {
                error("Environment import failed: errno = %d\n", errno);
                return 1;
        }
@@ -803,6 +808,7 @@ sep_err:
                cmd);
        return 1;
 }
+#endif
 
 #if defined(CONFIG_CMD_RUN)
 extern int do_run (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
@@ -820,8 +826,12 @@ static cmd_tbl_t cmd_env_sub[] = {
 #if defined(CONFIG_CMD_EDITENV)
        U_BOOT_CMD_MKENT(edit, 2, 0, do_env_edit, "", ""),
 #endif
+#if defined(CONFIG_CMD_EXPORTENV)
        U_BOOT_CMD_MKENT(export, 4, 0, do_env_export, "", ""),
+#endif
+#if defined(CONFIG_CMD_IMPORTENV)
        U_BOOT_CMD_MKENT(import, 5, 0, do_env_import, "", ""),
+#endif
        U_BOOT_CMD_MKENT(print, CONFIG_SYS_MAXARGS, 1, do_env_print, "", ""),
 #if defined(CONFIG_CMD_RUN)
        U_BOOT_CMD_MKENT(run, CONFIG_SYS_MAXARGS, 1, do_run, "", ""),