From c7694dd4837ba12db3bcda872a1047a44566e0e8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 1 Aug 2019 09:46:46 -0600 Subject: env: Move env_set_hex() to env.h Move env_set_hex() over to the new header file along with env_set_addr() which uses it. Signed-off-by: Simon Glass Acked-by: Joe Hershberger --- api/api.c | 1 + 1 file changed, 1 insertion(+) (limited to 'api') diff --git a/api/api.c b/api/api.c index 9f03f1a35bb..8a41b7cce77 100644 --- a/api/api.c +++ b/api/api.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include -- cgit v1.3.1 From dd2408cac1ea0f5e9ab4b07539c6edaee57918cb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 2 Aug 2019 09:44:18 -0600 Subject: env: Drop the ENTRY typedef U-Boot is not supposed to use typedef for structs anymore. Also this name is the same as the ENTRY() macro used in assembler files, and 'entry' itself is widely used in U-Boot (>8k matches). Drop the typedef and rename the struct to env_entry to reduce confusion. Signed-off-by: Simon Glass Acked-by: Joe Hershberger --- api/api.c | 2 +- cmd/nvedit.c | 12 ++++++------ drivers/tee/sandbox.c | 2 +- env/callback.c | 6 +++--- env/common.c | 2 +- env/flags.c | 10 +++++----- include/env_callback.h | 2 +- include/env_flags.h | 6 +++--- include/search.h | 21 ++++++++++++--------- lib/hashtable.c | 45 +++++++++++++++++++++++---------------------- test/env/hashtable.c | 12 ++++++------ 11 files changed, 62 insertions(+), 58 deletions(-) (limited to 'api') diff --git a/api/api.c b/api/api.c index 8a41b7cce77..a0fc62ca9e5 100644 --- a/api/api.c +++ b/api/api.c @@ -497,7 +497,7 @@ static int API_env_enum(va_list ap) { int i, buflen; char *last, **next, *s; - ENTRY *match, search; + struct env_entry *match, search; static char *var; last = (char *)va_arg(ap, unsigned long); diff --git a/cmd/nvedit.c b/cmd/nvedit.c index acbe85b8e4c..39140c07339 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -94,7 +94,7 @@ static int env_print(char *name, int flag) ssize_t len; if (name) { /* print a single name */ - ENTRY e, *ep; + struct env_entry e, *ep; e.key = name; e.data = NULL; @@ -225,7 +225,7 @@ static int _do_env_set(int flag, int argc, char * const argv[], int env_flag) { int i, len; char *name, *value, *s; - ENTRY e, *ep; + struct env_entry e, *ep; debug("Initial value for argc=%d\n", argc); @@ -473,7 +473,7 @@ static int print_static_binding(const char *var_name, const char *callback_name, return 0; } -static int print_active_callback(ENTRY *entry) +static int print_active_callback(struct env_entry *entry) { struct env_clbk_tbl *clbkp; int i; @@ -554,7 +554,7 @@ static int print_static_flags(const char *var_name, const char *flags, return 0; } -static int print_active_flags(ENTRY *entry) +static int print_active_flags(struct env_entry *entry) { enum env_flags_vartype type; enum env_flags_varaccess access; @@ -662,7 +662,7 @@ static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char *env_get(const char *name) { if (gd->flags & GD_FLG_ENV_READY) { /* after import into hashtable */ - ENTRY e, *ep; + struct env_entry e, *ep; WATCHDOG_RESET(); @@ -1262,7 +1262,7 @@ static int do_env_info(cmd_tbl_t *cmdtp, int flag, static int do_env_exists(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - ENTRY e, *ep; + struct env_entry e, *ep; if (argc < 2) return CMD_RET_USAGE; diff --git a/drivers/tee/sandbox.c b/drivers/tee/sandbox.c index 2f3355c7b77..4bbcf749673 100644 --- a/drivers/tee/sandbox.c +++ b/drivers/tee/sandbox.c @@ -79,7 +79,7 @@ static u32 ta_avb_invoke_func(struct udevice *dev, u32 func, uint num_params, struct tee_param *params) { struct sandbox_tee_state *state = dev_get_priv(dev); - ENTRY e, *ep; + struct env_entry e, *ep; char *name; u32 res; uint slot; diff --git a/env/callback.c b/env/callback.c index 95be80d4542..d539da93aaa 100644 --- a/env/callback.c +++ b/env/callback.c @@ -43,7 +43,7 @@ static const char *callback_list; * This is called specifically when the variable did not exist in the hash * previously, so the blanket update did not find this variable. */ -void env_callback_init(ENTRY *var_entry) +void env_callback_init(struct env_entry *var_entry) { const char *var_name = var_entry->key; char callback_name[256] = ""; @@ -80,7 +80,7 @@ void env_callback_init(ENTRY *var_entry) * Called on each existing env var prior to the blanket update since removing * a callback association should remove its callback. */ -static int clear_callback(ENTRY *entry) +static int clear_callback(struct env_entry *entry) { entry->callback = NULL; @@ -92,7 +92,7 @@ static int clear_callback(ENTRY *entry) */ static int set_callback(const char *name, const char *value, void *priv) { - ENTRY e, *ep; + struct env_entry e, *ep; struct env_clbk_tbl *clbkp; e.key = name; diff --git a/env/common.c b/env/common.c index 1d9d0f934d1..474ea2280b9 100644 --- a/env/common.c +++ b/env/common.c @@ -250,7 +250,7 @@ void env_relocate(void) int env_complete(char *var, int maxv, char *cmdv[], int bufsz, char *buf, bool dollar_comp) { - ENTRY *match; + struct env_entry *match; int found, idx; if (dollar_comp) { diff --git a/env/flags.c b/env/flags.c index 72777115949..fdbad7bf334 100644 --- a/env/flags.c +++ b/env/flags.c @@ -419,7 +419,7 @@ static const char *flags_list; * This is called specifically when the variable did not exist in the hash * previously, so the blanket update did not find this variable. */ -void env_flags_init(ENTRY *var_entry) +void env_flags_init(struct env_entry *var_entry) { const char *var_name = var_entry->key; char flags[ENV_FLAGS_ATTR_MAX_LEN + 1] = ""; @@ -441,7 +441,7 @@ void env_flags_init(ENTRY *var_entry) * Called on each existing env var prior to the blanket update since removing * a flag in the flag list should remove its flags. */ -static int clear_flags(ENTRY *entry) +static int clear_flags(struct env_entry *entry) { entry->flags = 0; @@ -453,7 +453,7 @@ static int clear_flags(ENTRY *entry) */ static int set_flags(const char *name, const char *value, void *priv) { - ENTRY e, *ep; + struct env_entry e, *ep; e.key = name; e.data = NULL; @@ -496,8 +496,8 @@ U_BOOT_ENV_CALLBACK(flags, on_flags); * overwriting of write-once variables. */ -int env_flags_validate(const ENTRY *item, const char *newval, enum env_op op, - int flag) +int env_flags_validate(const struct env_entry *item, const char *newval, + enum env_op op, int flag) { const char *name; const char *oldval = NULL; diff --git a/include/env_callback.h b/include/env_callback.h index 3d30a33f5ba..982c07854d0 100644 --- a/include/env_callback.h +++ b/include/env_callback.h @@ -72,6 +72,6 @@ "serial#:serialno," \ CONFIG_ENV_CALLBACK_LIST_STATIC -void env_callback_init(ENTRY *var_entry); +void env_callback_init(struct env_entry *var_entry); #endif /* __ENV_CALLBACK_H__ */ diff --git a/include/env_flags.h b/include/env_flags.h index f2306436b4d..e5380f29484 100644 --- a/include/env_flags.h +++ b/include/env_flags.h @@ -153,13 +153,13 @@ int env_flags_validate_env_set_params(char *name, char *const val[], int count); * When adding a variable to the environment, initialize the flags for that * variable. */ -void env_flags_init(ENTRY *var_entry); +void env_flags_init(struct env_entry *var_entry); /* * Validate the newval for to conform with the requirements defined by its flags */ -int env_flags_validate(const ENTRY *item, const char *newval, enum env_op op, - int flag); +int env_flags_validate(const struct env_entry *item, const char *newval, + enum env_op op, int flag); #endif /* USE_HOSTCC */ diff --git a/include/search.h b/include/search.h index f9fb29fdf99..81745a917d6 100644 --- a/include/search.h +++ b/include/search.h @@ -25,13 +25,14 @@ typedef enum { ENTER } ACTION; -typedef struct entry { +/** struct env_entry - An entry in the environment hashtable */ +struct env_entry { const char *key; char *data; int (*callback)(const char *name, const char *value, enum env_op op, int flags); int flags; -} ENTRY; +}; /* Opaque type for internal use. */ struct _ENTRY; @@ -54,8 +55,8 @@ struct hsearch_data { * shall force overwriting of write-once variables. * Must return 0 for approval, 1 for denial. */ - int (*change_ok)(const ENTRY *__item, const char *newval, enum env_op, - int flag); + int (*change_ok)(const struct env_entry *__item, const char *newval, + enum env_op, int flag); }; /* Create a new hash table which will contain at most "__nel" elements. */ @@ -70,15 +71,16 @@ extern void hdestroy_r(struct hsearch_data *__htab); * NULL. If ACTION is `ENTER' replace existing data (if any) with * __item.data. * */ -extern int hsearch_r(ENTRY __item, ACTION __action, ENTRY ** __retval, - struct hsearch_data *__htab, int __flag); +extern int hsearch_r(struct env_entry __item, ACTION __action, + struct env_entry **__retval, struct hsearch_data *__htab, + int __flag); /* * Search for an entry matching "__match". Otherwise, Same semantics * as hsearch_r(). */ -extern int hmatch_r(const char *__match, int __last_idx, ENTRY ** __retval, - struct hsearch_data *__htab); +extern int hmatch_r(const char *__match, int __last_idx, + struct env_entry **__retval, struct hsearch_data *__htab); /* Search and delete entry matching "__key" in internal hash table. */ extern int hdelete_r(const char *__key, struct hsearch_data *__htab, @@ -98,7 +100,8 @@ extern int himport_r(struct hsearch_data *__htab, char * const vars[]); /* Walk the whole table calling the callback on each element */ -extern int hwalk_r(struct hsearch_data *__htab, int (*callback)(ENTRY *)); +extern int hwalk_r(struct hsearch_data *__htab, + int (*callback)(struct env_entry *entry)); /* Flags for himport_r(), hexport_r(), hdelete_r(), and hsearch_r() */ #define H_NOCLEAR (1 << 0) /* do not clear hash table before importing */ diff --git a/lib/hashtable.c b/lib/hashtable.c index 0d288d12d99..c77b68f4e62 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -61,12 +61,12 @@ typedef struct _ENTRY { int used; - ENTRY entry; + struct env_entry entry; } _ENTRY; -static void _hdelete(const char *key, struct hsearch_data *htab, ENTRY *ep, - int idx); +static void _hdelete(const char *key, struct hsearch_data *htab, + struct env_entry *ep, int idx); /* * hcreate() @@ -151,7 +151,7 @@ void hdestroy_r(struct hsearch_data *htab) /* free used memory */ for (i = 1; i <= htab->size; ++i) { if (htab->table[i].used > 0) { - ENTRY *ep = &htab->table[i].entry; + struct env_entry *ep = &htab->table[i].entry; free((void *)ep->key); free(ep->data); @@ -200,7 +200,7 @@ void hdestroy_r(struct hsearch_data *htab) * example for functions like hdelete(). */ -int hmatch_r(const char *match, int last_idx, ENTRY ** retval, +int hmatch_r(const char *match, int last_idx, struct env_entry **retval, struct hsearch_data *htab) { unsigned int idx; @@ -224,9 +224,10 @@ int hmatch_r(const char *match, int last_idx, ENTRY ** retval, * Compare an existing entry with the desired key, and overwrite if the action * is ENTER. This is simply a helper function for hsearch_r(). */ -static inline int _compare_and_overwrite_entry(ENTRY item, ACTION action, - ENTRY **retval, struct hsearch_data *htab, int flag, - unsigned int hval, unsigned int idx) +static inline int _compare_and_overwrite_entry(struct env_entry item, + ACTION action, struct env_entry **retval, + struct hsearch_data *htab, int flag, unsigned int hval, + unsigned int idx) { if (htab->table[idx].used == hval && strcmp(item.key, htab->table[idx].entry.key) == 0) { @@ -270,7 +271,7 @@ static inline int _compare_and_overwrite_entry(ENTRY item, ACTION action, return -1; } -int hsearch_r(ENTRY item, ACTION action, ENTRY ** retval, +int hsearch_r(struct env_entry item, ACTION action, struct env_entry **retval, struct hsearch_data *htab, int flag) { unsigned int hval; @@ -431,10 +432,10 @@ int hsearch_r(ENTRY item, ACTION action, ENTRY ** retval, * do that. */ -static void _hdelete(const char *key, struct hsearch_data *htab, ENTRY *ep, - int idx) +static void _hdelete(const char *key, struct hsearch_data *htab, + struct env_entry *ep, int idx) { - /* free used ENTRY */ + /* free used entry */ debug("hdelete: DELETING key \"%s\"\n", key); free((void *)ep->key); free(ep->data); @@ -447,7 +448,7 @@ static void _hdelete(const char *key, struct hsearch_data *htab, ENTRY *ep, int hdelete_r(const char *key, struct hsearch_data *htab, int flag) { - ENTRY e, *ep; + struct env_entry e, *ep; int idx; debug("hdelete: DELETE key \"%s\"\n", key); @@ -528,8 +529,8 @@ int hdelete_r(const char *key, struct hsearch_data *htab, int flag) static int cmpkey(const void *p1, const void *p2) { - ENTRY *e1 = *(ENTRY **) p1; - ENTRY *e2 = *(ENTRY **) p2; + struct env_entry *e1 = *(struct env_entry **)p1; + struct env_entry *e2 = *(struct env_entry **)p2; return (strcmp(e1->key, e2->key)); } @@ -563,8 +564,8 @@ static int match_string(int flag, const char *str, const char *pat, void *priv) return 0; } -static int match_entry(ENTRY *ep, int flag, - int argc, char * const argv[]) +static int match_entry(struct env_entry *ep, int flag, int argc, + char *const argv[]) { int arg; void *priv = NULL; @@ -596,7 +597,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag, char **resp, size_t size, int argc, char * const argv[]) { - ENTRY *list[htab->size]; + struct env_entry *list[htab->size]; char *res, *p; size_t totlen; int i, n; @@ -617,7 +618,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag, for (i = 1, n = 0, totlen = 0; i <= htab->size; ++i) { if (htab->table[i].used > 0) { - ENTRY *ep = &htab->table[i].entry; + struct env_entry *ep = &htab->table[i].entry; int found = match_entry(ep, flag, argc, argv); if ((argc > 0) && (found == 0)) @@ -657,7 +658,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag, #endif /* Sort list by keys */ - qsort(list, n, sizeof(ENTRY *), cmpkey); + qsort(list, n, sizeof(struct env_entry *), cmpkey); /* Check if the user supplied buffer size is sufficient */ if (size) { @@ -869,7 +870,7 @@ int himport_r(struct hsearch_data *htab, } /* Parse environment; allow for '\0' and 'sep' as separators */ do { - ENTRY e, *rv; + struct env_entry e, *rv; /* skip leading white space */ while (isblank(*dp)) @@ -976,7 +977,7 @@ end: * Walk all of the entries in the hash, calling the callback for each one. * this allows some generic operation to be performed on each element. */ -int hwalk_r(struct hsearch_data *htab, int (*callback)(ENTRY *)) +int hwalk_r(struct hsearch_data *htab, int (*callback)(struct env_entry *entry)) { int i; int retval; diff --git a/test/env/hashtable.c b/test/env/hashtable.c index 8c87e654579..bad276bd10a 100644 --- a/test/env/hashtable.c +++ b/test/env/hashtable.c @@ -18,8 +18,8 @@ static int htab_fill(struct unit_test_state *uts, struct hsearch_data *htab, size_t size) { size_t i; - ENTRY item; - ENTRY *ritem; + struct env_entry item; + struct env_entry *ritem; char key[20]; for (i = 0; i < size; i++) { @@ -38,8 +38,8 @@ static int htab_check_fill(struct unit_test_state *uts, struct hsearch_data *htab, size_t size) { size_t i; - ENTRY item; - ENTRY *ritem; + struct env_entry item; + struct env_entry *ritem; char key[20]; for (i = 0; i < size; i++) { @@ -61,8 +61,8 @@ static int htab_create_delete(struct unit_test_state *uts, struct hsearch_data *htab, size_t iterations) { size_t i; - ENTRY item; - ENTRY *ritem; + struct env_entry item; + struct env_entry *ritem; char key[20]; for (i = 0; i < iterations; i++) { -- cgit v1.3.1 From 3f0d6807459bb22431e5bc19e597c1786b3d1ce6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 1 Aug 2019 09:47:09 -0600 Subject: env: Drop the ACTION typedef Avoid using a typedef here which is unnecessary. Add an 'env_' prefix to both the enum and its members to make it clear that these are related to the environment. Add an ENV prefix to these two flags so that it is clear what they relate to. Also move them to env.h since they are part of the public API. Use an enum rather than a #define to tie them together. Signed-off-by: Simon Glass --- api/api.c | 2 +- cmd/nvedit.c | 8 ++++---- drivers/tee/sandbox.c | 6 +++--- env/callback.c | 2 +- env/flags.c | 2 +- include/search.h | 16 ++++++++-------- lib/hashtable.c | 18 +++++++++--------- test/env/hashtable.c | 8 ++++---- 8 files changed, 31 insertions(+), 31 deletions(-) (limited to 'api') diff --git a/api/api.c b/api/api.c index a0fc62ca9e5..cd7487fde26 100644 --- a/api/api.c +++ b/api/api.c @@ -514,7 +514,7 @@ static int API_env_enum(va_list ap) if (s != NULL) *s = 0; search.key = var; - i = hsearch_r(search, FIND, &match, &env_htab, 0); + i = hsearch_r(search, ENV_FIND, &match, &env_htab, 0); if (i == 0) { i = API_EINVAL; goto done; diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 995b6b37af6..8e8572235cb 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -98,7 +98,7 @@ static int env_print(char *name, int flag) e.key = name; e.data = NULL; - hsearch_r(e, FIND, &ep, &env_htab, flag); + hsearch_r(e, ENV_FIND, &ep, &env_htab, flag); if (ep == NULL) return 0; len = printf("%s=%s\n", ep->key, ep->data); @@ -288,7 +288,7 @@ static int _do_env_set(int flag, int argc, char * const argv[], int env_flag) e.key = name; e.data = value; - hsearch_r(e, ENTER, &ep, &env_htab, env_flag); + hsearch_r(e, ENV_ENTER, &ep, &env_htab, env_flag); free(value); if (!ep) { printf("## Error inserting \"%s\" variable, errno=%d\n", @@ -668,7 +668,7 @@ char *env_get(const char *name) e.key = name; e.data = NULL; - hsearch_r(e, FIND, &ep, &env_htab, 0); + hsearch_r(e, ENV_FIND, &ep, &env_htab, 0); return ep ? ep->data : NULL; } @@ -1269,7 +1269,7 @@ static int do_env_exists(cmd_tbl_t *cmdtp, int flag, int argc, e.key = argv[1]; e.data = NULL; - hsearch_r(e, FIND, &ep, &env_htab, 0); + hsearch_r(e, ENV_FIND, &ep, &env_htab, 0); return (ep == NULL) ? 1 : 0; } diff --git a/drivers/tee/sandbox.c b/drivers/tee/sandbox.c index 4bbcf749673..4b91e7db1bc 100644 --- a/drivers/tee/sandbox.c +++ b/drivers/tee/sandbox.c @@ -174,7 +174,7 @@ static u32 ta_avb_invoke_func(struct udevice *dev, u32 func, uint num_params, e.key = name; e.data = NULL; - hsearch_r(e, FIND, &ep, &state->pstorage_htab, 0); + hsearch_r(e, ENV_FIND, &ep, &state->pstorage_htab, 0); if (!ep) return TEE_ERROR_ITEM_NOT_FOUND; @@ -198,13 +198,13 @@ static u32 ta_avb_invoke_func(struct udevice *dev, u32 func, uint num_params, e.key = name; e.data = NULL; - hsearch_r(e, FIND, &ep, &state->pstorage_htab, 0); + hsearch_r(e, ENV_FIND, &ep, &state->pstorage_htab, 0); if (ep) hdelete_r(e.key, &state->pstorage_htab, 0); e.key = name; e.data = value; - hsearch_r(e, ENTER, &ep, &state->pstorage_htab, 0); + hsearch_r(e, ENV_ENTER, &ep, &state->pstorage_htab, 0); if (!ep) return TEE_ERROR_OUT_OF_MEMORY; diff --git a/env/callback.c b/env/callback.c index d539da93aaa..d5469ce3c27 100644 --- a/env/callback.c +++ b/env/callback.c @@ -98,7 +98,7 @@ static int set_callback(const char *name, const char *value, void *priv) e.key = name; e.data = NULL; e.callback = NULL; - hsearch_r(e, FIND, &ep, &env_htab, 0); + hsearch_r(e, ENV_FIND, &ep, &env_htab, 0); /* does the env variable actually exist? */ if (ep != NULL) { diff --git a/env/flags.c b/env/flags.c index fdbad7bf334..93d337a1aa0 100644 --- a/env/flags.c +++ b/env/flags.c @@ -458,7 +458,7 @@ static int set_flags(const char *name, const char *value, void *priv) e.key = name; e.data = NULL; e.callback = NULL; - hsearch_r(e, FIND, &ep, &env_htab, 0); + hsearch_r(e, ENV_FIND, &ep, &env_htab, 0); /* does the env variable actually exist? */ if (ep != NULL) { diff --git a/include/search.h b/include/search.h index c99648f80b7..84fc5fd3fdf 100644 --- a/include/search.h +++ b/include/search.h @@ -19,11 +19,11 @@ #define __set_errno(val) do { errno = val; } while (0) -/* Action which shall be performed in the call to hsearch. */ -typedef enum { - FIND, - ENTER -} ACTION; +/* enum env_action: action which shall be performed in the call to hsearch */ +enum env_action { + ENV_FIND, + ENV_ENTER, +}; /** struct env_entry - An entry in the environment hashtable */ struct env_entry { @@ -64,11 +64,11 @@ extern void hdestroy_r(struct hsearch_data *__htab); /* * Search for entry matching __item.key in internal hash table. If - * ACTION is `FIND' return found entry or signal error by returning - * NULL. If ACTION is `ENTER' replace existing data (if any) with + * __action is `ENV_FIND' return found entry or signal error by returning + * NULL. If __action is `ENV_ENTER' replace existing data (if any) with * __item.data. * */ -extern int hsearch_r(struct env_entry __item, ACTION __action, +extern int hsearch_r(struct env_entry __item, enum env_action __action, struct env_entry **__retval, struct hsearch_data *__htab, int __flag); diff --git a/lib/hashtable.c b/lib/hashtable.c index 1093d8adaa6..2caab0a4c6d 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -194,7 +194,7 @@ void hdestroy_r(struct hsearch_data *htab) * data any more. * - The standard implementation does not provide a way to update an * existing entry. This version will create a new entry or update an - * existing one when both "action == ENTER" and "item.data != NULL". + * existing one when both "action == ENV_ENTER" and "item.data != NULL". * - Instead of returning 1 on success, we return the index into the * internal hash table, which is also guaranteed to be positive. * This allows us direct access to the found hash table slot for @@ -223,17 +223,17 @@ int hmatch_r(const char *match, int last_idx, struct env_entry **retval, /* * Compare an existing entry with the desired key, and overwrite if the action - * is ENTER. This is simply a helper function for hsearch_r(). + * is ENV_ENTER. This is simply a helper function for hsearch_r(). */ static inline int _compare_and_overwrite_entry(struct env_entry item, - ACTION action, struct env_entry **retval, + enum env_action action, struct env_entry **retval, struct hsearch_data *htab, int flag, unsigned int hval, unsigned int idx) { if (htab->table[idx].used == hval && strcmp(item.key, htab->table[idx].entry.key) == 0) { /* Overwrite existing value? */ - if ((action == ENTER) && (item.data != NULL)) { + if (action == ENV_ENTER && item.data) { /* check for permission */ if (htab->change_ok != NULL && htab->change_ok( &htab->table[idx].entry, item.data, @@ -272,8 +272,8 @@ static inline int _compare_and_overwrite_entry(struct env_entry item, return -1; } -int hsearch_r(struct env_entry item, ACTION action, struct env_entry **retval, - struct hsearch_data *htab, int flag) +int hsearch_r(struct env_entry item, enum env_action action, + struct env_entry **retval, struct hsearch_data *htab, int flag) { unsigned int hval; unsigned int count; @@ -354,7 +354,7 @@ int hsearch_r(struct env_entry item, ACTION action, struct env_entry **retval, } /* An empty bucket has been found. */ - if (action == ENTER) { + if (action == ENV_ENTER) { /* * If table is full and another entry should be * entered return with error. @@ -456,7 +456,7 @@ int hdelete_r(const char *key, struct hsearch_data *htab, int flag) e.key = (char *)key; - idx = hsearch_r(e, FIND, &ep, htab, 0); + idx = hsearch_r(e, ENV_FIND, &ep, htab, 0); if (idx == 0) { __set_errno(ESRCH); return 0; /* not found */ @@ -931,7 +931,7 @@ int himport_r(struct hsearch_data *htab, e.key = name; e.data = value; - hsearch_r(e, ENTER, &rv, htab, flag); + hsearch_r(e, ENV_ENTER, &rv, htab, flag); if (rv == NULL) printf("himport_r: can't insert \"%s=%s\" into hash table\n", name, value); diff --git a/test/env/hashtable.c b/test/env/hashtable.c index bad276bd10a..5242c4cc3ed 100644 --- a/test/env/hashtable.c +++ b/test/env/hashtable.c @@ -28,7 +28,7 @@ static int htab_fill(struct unit_test_state *uts, item.data = key; item.flags = 0; item.key = key; - ut_asserteq(1, hsearch_r(item, ENTER, &ritem, htab, 0)); + ut_asserteq(1, hsearch_r(item, ENV_ENTER, &ritem, htab, 0)); } return 0; @@ -48,7 +48,7 @@ static int htab_check_fill(struct unit_test_state *uts, item.flags = 0; item.data = key; item.key = key; - hsearch_r(item, FIND, &ritem, htab, 0); + hsearch_r(item, ENV_FIND, &ritem, htab, 0); ut_assert(ritem); ut_asserteq_str(key, ritem->key); ut_asserteq_str(key, ritem->data); @@ -71,10 +71,10 @@ static int htab_create_delete(struct unit_test_state *uts, item.flags = 0; item.data = key; item.key = key; - hsearch_r(item, ENTER, &ritem, htab, 0); + hsearch_r(item, ENV_ENTER, &ritem, htab, 0); ritem = NULL; - hsearch_r(item, FIND, &ritem, htab, 0); + hsearch_r(item, ENV_FIND, &ritem, htab, 0); ut_assert(ritem); ut_asserteq_str(key, ritem->key); ut_asserteq_str(key, ritem->data); -- cgit v1.3.1 From f3998fdc4d0871727d7be6838bac750c6323c0a8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 2 Aug 2019 09:44:25 -0600 Subject: env: Rename environment.h to env_internal.h This file contains lots of internal details about the environment. Most code can include env.h instead, calling the functions there as needed. Rename this file and add a comment at the top to indicate its internal nature. Signed-off-by: Simon Glass Acked-by: Joe Hershberger Reviewed-by: Simon Goldschmidt [trini: Fixup apalis-tk1.c] Signed-off-by: Tom Rini --- api/api.c | 2 +- arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 2 +- arch/arm/cpu/armv8/fsl-layerscape/soc.c | 2 +- arch/x86/cpu/qemu/e820.c | 2 +- board/Arcturus/ucp1020/spl.c | 2 +- board/amlogic/w400/w400.c | 2 +- board/birdland/bav335x/board.c | 2 +- board/bosch/guardian/board.c | 2 +- board/bosch/shc/board.c | 2 +- board/buffalo/lsxl/lsxl.c | 2 +- board/freescale/b4860qds/spl.c | 2 +- board/freescale/c29xpcie/spl.c | 2 +- board/freescale/ls1012afrdm/ls1012afrdm.c | 2 +- board/freescale/ls1012aqds/ls1012aqds.c | 2 +- board/freescale/ls1012ardb/ls1012ardb.c | 2 +- board/freescale/ls1028a/ls1028a.c | 2 +- board/freescale/ls1088a/ls1088a.c | 2 +- board/freescale/ls2080a/ls2080a.c | 2 +- board/freescale/ls2080aqds/ls2080aqds.c | 2 +- board/freescale/ls2080ardb/ls2080ardb.c | 2 +- board/freescale/lx2160a/lx2160a.c | 2 +- board/freescale/p1010rdb/spl.c | 2 +- board/freescale/p1022ds/spl.c | 2 +- board/freescale/p1_p2_rdb_pc/spl.c | 2 +- board/freescale/t102xqds/spl.c | 2 +- board/freescale/t102xrdb/spl.c | 2 +- board/freescale/t104xrdb/spl.c | 2 +- board/freescale/t208xqds/spl.c | 2 +- board/freescale/t208xrdb/spl.c | 2 +- board/freescale/t4qds/spl.c | 2 +- board/freescale/t4rdb/spl.c | 2 +- board/gardena/smart-gateway-mt7688/board.c | 2 +- board/phytec/phycore_rk3288/phycore-rk3288.c | 2 +- board/renesas/alt/alt.c | 2 +- board/renesas/gose/gose.c | 2 +- board/renesas/koelsch/koelsch.c | 2 +- board/renesas/lager/lager.c | 2 +- board/renesas/porter/porter.c | 2 +- board/renesas/silk/silk.c | 2 +- board/renesas/stout/stout.c | 2 +- board/st/stm32mp1/stm32mp1.c | 2 +- board/sunxi/board.c | 2 +- board/tcl/sl50/board.c | 2 +- board/ti/am335x/board.c | 2 +- board/toradex/apalis-tk1/apalis-tk1.c | 2 +- cmd/nvedit.c | 2 +- common/board_f.c | 2 +- common/board_r.c | 2 +- common/console.c | 2 +- drivers/mtd/cfi_flash.c | 2 +- drivers/serial/serial-uclass.c | 2 +- drivers/serial/serial.c | 2 +- env/callback.c | 2 +- env/common.c | 2 +- env/eeprom.c | 2 +- env/embedded.c | 2 +- env/env.c | 2 +- env/ext4.c | 2 +- env/fat.c | 2 +- env/flags.c | 2 +- env/flash.c | 2 +- env/mmc.c | 2 +- env/nand.c | 2 +- env/nowhere.c | 2 +- env/nvram.c | 2 +- env/onenand.c | 2 +- env/remote.c | 2 +- env/sata.c | 2 +- env/sf.c | 2 +- env/ubi.c | 2 +- include/common.h | 2 +- include/env_internal.h | 278 +++++++++++++++++++++++++++ include/environment.h | 270 -------------------------- lib/efi_loader/efi_variable.c | 2 +- net/net.c | 2 +- tools/envcrc.c | 2 +- 76 files changed, 352 insertions(+), 344 deletions(-) create mode 100644 include/env_internal.h delete mode 100644 include/environment.h (limited to 'api') diff --git a/api/api.c b/api/api.c index cd7487fde26..bc9454eb4b6 100644 --- a/api/api.c +++ b/api/api.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c index 9577ada1134..26f4fdacdb8 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c @@ -33,7 +33,7 @@ #include #ifdef CONFIG_TFABOOT -#include +#include #ifdef CONFIG_CHAIN_OF_TRUST #include #endif diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c b/arch/arm/cpu/armv8/fsl-layerscape/soc.c index 00c705f74eb..ca8005992ae 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c @@ -27,7 +27,7 @@ #endif #include #ifdef CONFIG_TFABOOT -#include +#include DECLARE_GLOBAL_DATA_PTR; #endif diff --git a/arch/x86/cpu/qemu/e820.c b/arch/x86/cpu/qemu/e820.c index 7b3bc7db5e4..e6824865471 100644 --- a/arch/x86/cpu/qemu/e820.c +++ b/arch/x86/cpu/qemu/e820.c @@ -4,7 +4,7 @@ */ #include -#include +#include #include DECLARE_GLOBAL_DATA_PTR; diff --git a/board/Arcturus/ucp1020/spl.c b/board/Arcturus/ucp1020/spl.c index f3b7d99878c..9314fabdf2d 100644 --- a/board/Arcturus/ucp1020/spl.c +++ b/board/Arcturus/ucp1020/spl.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/amlogic/w400/w400.c b/board/amlogic/w400/w400.c index 4737865367e..e60dc3a622e 100644 --- a/board/amlogic/w400/w400.c +++ b/board/amlogic/w400/w400.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/board/birdland/bav335x/board.c b/board/birdland/bav335x/board.c index 9e64cbbc827..8811583ac62 100644 --- a/board/birdland/bav335x/board.c +++ b/board/birdland/bav335x/board.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include "board.h" diff --git a/board/bosch/guardian/board.c b/board/bosch/guardian/board.c index bc3c6d229c2..ec0c4a17f63 100644 --- a/board/bosch/guardian/board.c +++ b/board/bosch/guardian/board.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/bosch/shc/board.c b/board/bosch/shc/board.c index 358118f7577..a96fdef992d 100644 --- a/board/bosch/shc/board.c +++ b/board/bosch/shc/board.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include "mmc.h" #include "board.h" diff --git a/board/buffalo/lsxl/lsxl.c b/board/buffalo/lsxl/lsxl.c index b2ccb83c8a8..95d3a5e1f57 100644 --- a/board/buffalo/lsxl/lsxl.c +++ b/board/buffalo/lsxl/lsxl.c @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/board/freescale/b4860qds/spl.c b/board/freescale/b4860qds/spl.c index d9aa57f41c3..6dfc0c73eca 100644 --- a/board/freescale/b4860qds/spl.c +++ b/board/freescale/b4860qds/spl.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/freescale/c29xpcie/spl.c b/board/freescale/c29xpcie/spl.c index 5db60d8ed97..29040962cf1 100644 --- a/board/freescale/c29xpcie/spl.c +++ b/board/freescale/c29xpcie/spl.c @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include diff --git a/board/freescale/ls1012afrdm/ls1012afrdm.c b/board/freescale/ls1012afrdm/ls1012afrdm.c index b4c611e19f4..31e41ce1696 100644 --- a/board/freescale/ls1012afrdm/ls1012afrdm.c +++ b/board/freescale/ls1012afrdm/ls1012afrdm.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/freescale/ls1012aqds/ls1012aqds.c b/board/freescale/ls1012aqds/ls1012aqds.c index a862fe6a93d..86c72ee357e 100644 --- a/board/freescale/ls1012aqds/ls1012aqds.c +++ b/board/freescale/ls1012aqds/ls1012aqds.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/freescale/ls1012ardb/ls1012ardb.c b/board/freescale/ls1012ardb/ls1012ardb.c index f648a9040b6..e4527c19b88 100644 --- a/board/freescale/ls1012ardb/ls1012ardb.c +++ b/board/freescale/ls1012ardb/ls1012ardb.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/freescale/ls1028a/ls1028a.c b/board/freescale/ls1028a/ls1028a.c index e5de4eb70c4..4aa7cec9ce9 100644 --- a/board/freescale/ls1028a/ls1028a.c +++ b/board/freescale/ls1028a/ls1028a.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/freescale/ls1088a/ls1088a.c b/board/freescale/ls1088a/ls1088a.c index a1c9eb3f468..f0bea7327db 100644 --- a/board/freescale/ls1088a/ls1088a.c +++ b/board/freescale/ls1088a/ls1088a.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/freescale/ls2080a/ls2080a.c b/board/freescale/ls2080a/ls2080a.c index cc1822d0f5c..413a698511b 100644 --- a/board/freescale/ls2080a/ls2080a.c +++ b/board/freescale/ls2080a/ls2080a.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include DECLARE_GLOBAL_DATA_PTR; diff --git a/board/freescale/ls2080aqds/ls2080aqds.c b/board/freescale/ls2080aqds/ls2080aqds.c index e9e0999a186..e9c055745f6 100644 --- a/board/freescale/ls2080aqds/ls2080aqds.c +++ b/board/freescale/ls2080aqds/ls2080aqds.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/freescale/ls2080ardb/ls2080ardb.c b/board/freescale/ls2080ardb/ls2080ardb.c index a278e2fc117..2b2dbbb0ce5 100644 --- a/board/freescale/ls2080ardb/ls2080ardb.c +++ b/board/freescale/ls2080ardb/ls2080ardb.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c index 3b4cb86692d..f3885fa8b7f 100644 --- a/board/freescale/lx2160a/lx2160a.c +++ b/board/freescale/lx2160a/lx2160a.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/freescale/p1010rdb/spl.c b/board/freescale/p1010rdb/spl.c index 95f8b5837dd..8f050b3947d 100644 --- a/board/freescale/p1010rdb/spl.c +++ b/board/freescale/p1010rdb/spl.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/freescale/p1022ds/spl.c b/board/freescale/p1022ds/spl.c index 92fd199876b..06273f1d20e 100644 --- a/board/freescale/p1022ds/spl.c +++ b/board/freescale/p1022ds/spl.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/freescale/p1_p2_rdb_pc/spl.c b/board/freescale/p1_p2_rdb_pc/spl.c index 9d7b5eff6f1..dbf9f739b28 100644 --- a/board/freescale/p1_p2_rdb_pc/spl.c +++ b/board/freescale/p1_p2_rdb_pc/spl.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/freescale/t102xqds/spl.c b/board/freescale/t102xqds/spl.c index 1b58174ed17..3008f0919f1 100644 --- a/board/freescale/t102xqds/spl.c +++ b/board/freescale/t102xqds/spl.c @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include diff --git a/board/freescale/t102xrdb/spl.c b/board/freescale/t102xrdb/spl.c index a226d4b5b53..029e3d212ca 100644 --- a/board/freescale/t102xrdb/spl.c +++ b/board/freescale/t102xrdb/spl.c @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include diff --git a/board/freescale/t104xrdb/spl.c b/board/freescale/t104xrdb/spl.c index 58a7376e7fb..7b0eb8edf51 100644 --- a/board/freescale/t104xrdb/spl.c +++ b/board/freescale/t104xrdb/spl.c @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include diff --git a/board/freescale/t208xqds/spl.c b/board/freescale/t208xqds/spl.c index 27f3c4c84f0..9695dfc2e2e 100644 --- a/board/freescale/t208xqds/spl.c +++ b/board/freescale/t208xqds/spl.c @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include diff --git a/board/freescale/t208xrdb/spl.c b/board/freescale/t208xrdb/spl.c index ecb1e0d73cf..ca7d6a28e05 100644 --- a/board/freescale/t208xrdb/spl.c +++ b/board/freescale/t208xrdb/spl.c @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include diff --git a/board/freescale/t4qds/spl.c b/board/freescale/t4qds/spl.c index 16cc29eaa62..7666fe7556d 100644 --- a/board/freescale/t4qds/spl.c +++ b/board/freescale/t4qds/spl.c @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include diff --git a/board/freescale/t4rdb/spl.c b/board/freescale/t4rdb/spl.c index cc2b2f9ffb0..a19558bd6be 100644 --- a/board/freescale/t4rdb/spl.c +++ b/board/freescale/t4rdb/spl.c @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include diff --git a/board/gardena/smart-gateway-mt7688/board.c b/board/gardena/smart-gateway-mt7688/board.c index baa3e5726c3..bd494c84fc8 100644 --- a/board/gardena/smart-gateway-mt7688/board.c +++ b/board/gardena/smart-gateway-mt7688/board.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include diff --git a/board/phytec/phycore_rk3288/phycore-rk3288.c b/board/phytec/phycore_rk3288/phycore-rk3288.c index 7b9178e3a69..5fcbf65b7c9 100644 --- a/board/phytec/phycore_rk3288/phycore-rk3288.c +++ b/board/phytec/phycore_rk3288/phycore-rk3288.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/renesas/alt/alt.c b/board/renesas/alt/alt.c index 77979704be2..10ef7f931b1 100644 --- a/board/renesas/alt/alt.c +++ b/board/renesas/alt/alt.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/renesas/gose/gose.c b/board/renesas/gose/gose.c index bffa85c2325..f86c9f1a635 100644 --- a/board/renesas/gose/gose.c +++ b/board/renesas/gose/gose.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/renesas/koelsch/koelsch.c b/board/renesas/koelsch/koelsch.c index 1bb3b492e29..841d337f4d3 100644 --- a/board/renesas/koelsch/koelsch.c +++ b/board/renesas/koelsch/koelsch.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/renesas/lager/lager.c b/board/renesas/lager/lager.c index bda3295badb..3cb1a56142a 100644 --- a/board/renesas/lager/lager.c +++ b/board/renesas/lager/lager.c @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/board/renesas/porter/porter.c b/board/renesas/porter/porter.c index d3afc2a4004..86f79da7fdb 100644 --- a/board/renesas/porter/porter.c +++ b/board/renesas/porter/porter.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/renesas/silk/silk.c b/board/renesas/silk/silk.c index bda6a414e65..25221e3c55c 100644 --- a/board/renesas/silk/silk.c +++ b/board/renesas/silk/silk.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/renesas/stout/stout.c b/board/renesas/stout/stout.c index 95b5711fdb8..0a0ff5ff76d 100644 --- a/board/renesas/stout/stout.c +++ b/board/renesas/stout/stout.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 1f9251d7a0d..279c7b77979 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/sunxi/board.c b/board/sunxi/board.c index bb425cbf66d..e3b2d13892c 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/tcl/sl50/board.c b/board/tcl/sl50/board.c index a9c9d377b4f..c7eed319461 100644 --- a/board/tcl/sl50/board.c +++ b/board/tcl/sl50/board.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include "board.h" diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c index 54adcd510de..7eaa6cd96d6 100644 --- a/board/ti/am335x/board.c +++ b/board/ti/am335x/board.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include "../common/board_detect.h" #include "board.h" diff --git a/board/toradex/apalis-tk1/apalis-tk1.c b/board/toradex/apalis-tk1/apalis-tk1.c index beb7e10dfed..bc98858ae02 100644 --- a/board/toradex/apalis-tk1/apalis-tk1.c +++ b/board/toradex/apalis-tk1/apalis-tk1.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 8e8572235cb..1cb0bc1460b 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/common/board_f.c b/common/board_f.c index 18937bf6f5d..31181a9dc45 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/common/board_r.c b/common/board_r.c index f4193cdbecc..1dabf5a11c2 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/common/console.c b/common/console.c index 0f7e0916cd2..89b1e9590ca 100644 --- a/common/console.c +++ b/common/console.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index 6c22f074b0b..c59254c76e3 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index d4488a2cc28..dcdaedefe72 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 09365ba6a1e..b907508dbe5 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include diff --git a/env/callback.c b/env/callback.c index d5469ce3c27..f0904cfdc53 100644 --- a/env/callback.c +++ b/env/callback.c @@ -6,7 +6,7 @@ #include #include -#include +#include #if defined(CONFIG_NEEDS_MANUAL_RELOC) DECLARE_GLOBAL_DATA_PTR; diff --git a/env/common.c b/env/common.c index 474ea2280b9..3fb60509dd8 100644 --- a/env/common.c +++ b/env/common.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/env/eeprom.c b/env/eeprom.c index 91ee3f35ebf..cb04d2ac884 100644 --- a/env/eeprom.c +++ b/env/eeprom.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #if defined(CONFIG_I2C_ENV_EEPROM_BUS) #include diff --git a/env/embedded.c b/env/embedded.c index b1090e90e59..a38e169fe0b 100644 --- a/env/embedded.c +++ b/env/embedded.c @@ -12,7 +12,7 @@ #define __ASM_STUB_PROCESSOR_H__ /* don't include asm/processor. */ #include #undef __ASSEMBLY__ -#include +#include #include /* Handle HOSTS that have prepended crap on symbol names, not TARGETS. */ diff --git a/env/env.c b/env/env.c index 9d421e81256..9237bb9c742 100644 --- a/env/env.c +++ b/env/env.c @@ -6,7 +6,7 @@ #include #include -#include +#include DECLARE_GLOBAL_DATA_PTR; diff --git a/env/ext4.c b/env/ext4.c index 6aa36867b67..1f6b1b5bd81 100644 --- a/env/ext4.c +++ b/env/ext4.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/env/fat.c b/env/fat.c index d23753c6ff3..1836556f361 100644 --- a/env/fat.c +++ b/env/fat.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/env/flags.c b/env/flags.c index 93d337a1aa0..418d6cc7425 100644 --- a/env/flags.c +++ b/env/flags.c @@ -19,7 +19,7 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #else #include -#include +#include #endif #ifdef CONFIG_CMD_NET diff --git a/env/flash.c b/env/flash.c index bdba09e3062..231a5fdf24d 100644 --- a/env/flash.c +++ b/env/flash.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/env/mmc.c b/env/mmc.c index 4ca7c2b9ff1..9f1878def13 100644 --- a/env/mmc.c +++ b/env/mmc.c @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/env/nand.c b/env/nand.c index 3e2235f5f34..9f3dc635cf1 100644 --- a/env/nand.c +++ b/env/nand.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/env/nowhere.c b/env/nowhere.c index 7db4eec8456..f5b0a17652c 100644 --- a/env/nowhere.c +++ b/env/nowhere.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include DECLARE_GLOBAL_DATA_PTR; diff --git a/env/nvram.c b/env/nvram.c index a5b1873aaff..79201bd788b 100644 --- a/env/nvram.c +++ b/env/nvram.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/env/onenand.c b/env/onenand.c index d371bd757cb..dfd4e939f8f 100644 --- a/env/onenand.c +++ b/env/onenand.c @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/env/remote.c b/env/remote.c index b1a7d1a4c12..02531f427ba 100644 --- a/env/remote.c +++ b/env/remote.c @@ -7,7 +7,7 @@ #include #include -#include +#include #include #ifdef ENV_IS_EMBEDDED diff --git a/env/sata.c b/env/sata.c index a5364dda5d8..93697100815 100644 --- a/env/sata.c +++ b/env/sata.c @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/env/sf.c b/env/sf.c index 09646e1eed1..590d0cedd85 100644 --- a/env/sf.c +++ b/env/sf.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/env/ubi.c b/env/ubi.c index a69db14afd5..08aac47df2b 100644 --- a/env/ubi.c +++ b/env/ubi.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/common.h b/include/common.h index 34ae5148058..f8afbc0d705 100644 --- a/include/common.h +++ b/include/common.h @@ -394,7 +394,7 @@ int cpu_release(u32 nr, int argc, char * const argv[]); /* Pull in stuff for the build system */ #ifdef DO_DEPS_ONLY -# include +# include #endif #endif /* __COMMON_H_ */ diff --git a/include/env_internal.h b/include/env_internal.h new file mode 100644 index 00000000000..b1ddcb5adfd --- /dev/null +++ b/include/env_internal.h @@ -0,0 +1,278 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Internal environment header file. This includes direct access to environment + * information such as its size and offset, direct access to the default + * environment and embedded environment (if used). It also provides environment + * drivers with various declarations. + * + * It should not be included by board files, drivers and code other than that + * related to the environment implementation. + * + * (C) Copyright 2002 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + */ + +#ifndef _ENV_INTERNAL_H_ +#define _ENV_INTERNAL_H_ + +#include + +/************************************************************************** + * + * The "environment" is stored as a list of '\0' terminated + * "name=value" strings. The end of the list is marked by a double + * '\0'. New entries are always added at the end. Deleting an entry + * shifts the remaining entries to the front. Replacing an entry is a + * combination of deleting the old value and adding the new one. + * + * The environment is preceded by a 32 bit CRC over the data part. + * + *************************************************************************/ + +#if defined(CONFIG_ENV_IS_IN_FLASH) +# ifndef CONFIG_ENV_ADDR +# define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET) +# endif +# ifndef CONFIG_ENV_OFFSET +# define CONFIG_ENV_OFFSET (CONFIG_ENV_ADDR - CONFIG_SYS_FLASH_BASE) +# endif +# if !defined(CONFIG_ENV_ADDR_REDUND) && defined(CONFIG_ENV_OFFSET_REDUND) +# define CONFIG_ENV_ADDR_REDUND \ + (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET_REDUND) +# endif +# if defined(CONFIG_ENV_SECT_SIZE) || defined(CONFIG_ENV_SIZE) +# ifndef CONFIG_ENV_SECT_SIZE +# define CONFIG_ENV_SECT_SIZE CONFIG_ENV_SIZE +# endif +# ifndef CONFIG_ENV_SIZE +# define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE +# endif +# else +# error "Both CONFIG_ENV_SECT_SIZE and CONFIG_ENV_SIZE undefined" +# endif +# if defined(CONFIG_ENV_ADDR_REDUND) && !defined(CONFIG_ENV_SIZE_REDUND) +# define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE +# endif +# if (CONFIG_ENV_ADDR >= CONFIG_SYS_MONITOR_BASE) && \ + (CONFIG_ENV_ADDR + CONFIG_ENV_SIZE) <= \ + (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) +# define ENV_IS_EMBEDDED +# endif +# if defined(CONFIG_ENV_ADDR_REDUND) || defined(CONFIG_ENV_OFFSET_REDUND) +# define CONFIG_SYS_REDUNDAND_ENVIRONMENT +# endif +# ifdef CONFIG_ENV_IS_EMBEDDED +# error "do not define CONFIG_ENV_IS_EMBEDDED in your board config" +# error "it is calculated automatically for you" +# endif +#endif /* CONFIG_ENV_IS_IN_FLASH */ + +#if defined(CONFIG_ENV_IS_IN_MMC) +# ifdef CONFIG_ENV_OFFSET_REDUND +# define CONFIG_SYS_REDUNDAND_ENVIRONMENT +# endif +#endif + +#if defined(CONFIG_ENV_IS_IN_NAND) +# if defined(CONFIG_ENV_OFFSET_OOB) +# ifdef CONFIG_ENV_OFFSET_REDUND +# error "CONFIG_ENV_OFFSET_REDUND is not supported when CONFIG_ENV_OFFSET_OOB" +# error "is set" +# endif +extern unsigned long nand_env_oob_offset; +# define CONFIG_ENV_OFFSET nand_env_oob_offset +# else +# ifndef CONFIG_ENV_OFFSET +# error "Need to define CONFIG_ENV_OFFSET when using CONFIG_ENV_IS_IN_NAND" +# endif +# ifdef CONFIG_ENV_OFFSET_REDUND +# define CONFIG_SYS_REDUNDAND_ENVIRONMENT +# endif +# endif /* CONFIG_ENV_OFFSET_OOB */ +# ifndef CONFIG_ENV_SIZE +# error "Need to define CONFIG_ENV_SIZE when using CONFIG_ENV_IS_IN_NAND" +# endif +#endif /* CONFIG_ENV_IS_IN_NAND */ + +#if defined(CONFIG_ENV_IS_IN_UBI) +# ifndef CONFIG_ENV_UBI_PART +# error "Need to define CONFIG_ENV_UBI_PART when using CONFIG_ENV_IS_IN_UBI" +# endif +# ifndef CONFIG_ENV_UBI_VOLUME +# error "Need to define CONFIG_ENV_UBI_VOLUME when using CONFIG_ENV_IS_IN_UBI" +# endif +# if defined(CONFIG_ENV_UBI_VOLUME_REDUND) +# define CONFIG_SYS_REDUNDAND_ENVIRONMENT +# endif +# ifndef CONFIG_ENV_SIZE +# error "Need to define CONFIG_ENV_SIZE when using CONFIG_ENV_IS_IN_UBI" +# endif +# ifndef CONFIG_CMD_UBI +# error "Need to define CONFIG_CMD_UBI when using CONFIG_ENV_IS_IN_UBI" +# endif +#endif /* CONFIG_ENV_IS_IN_UBI */ + +/* Embedded env is only supported for some flash types */ +#ifdef CONFIG_ENV_IS_EMBEDDED +# if !defined(CONFIG_ENV_IS_IN_FLASH) && \ + !defined(CONFIG_ENV_IS_IN_NAND) && \ + !defined(CONFIG_ENV_IS_IN_ONENAND) && \ + !defined(CONFIG_ENV_IS_IN_SPI_FLASH) +# error "CONFIG_ENV_IS_EMBEDDED not supported for your flash type" +# endif +#endif + +/* + * For the flash types where embedded env is supported, but it cannot be + * calculated automatically (i.e. NAND), take the board opt-in. + */ +#if defined(CONFIG_ENV_IS_EMBEDDED) && !defined(ENV_IS_EMBEDDED) +# define ENV_IS_EMBEDDED +#endif + +/* The build system likes to know if the env is embedded */ +#ifdef DO_DEPS_ONLY +# ifdef ENV_IS_EMBEDDED +# ifndef CONFIG_ENV_IS_EMBEDDED +# define CONFIG_ENV_IS_EMBEDDED +# endif +# endif +#endif + +#include "compiler.h" + +#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT +# define ENV_HEADER_SIZE (sizeof(uint32_t) + 1) +#else +# define ENV_HEADER_SIZE (sizeof(uint32_t)) +#endif + +#define ENV_SIZE (CONFIG_ENV_SIZE - ENV_HEADER_SIZE) + +/* + * If the environment is in RAM, allocate extra space for it in the malloc + * region. + */ +#if defined(CONFIG_ENV_IS_EMBEDDED) +#define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN +#elif (CONFIG_ENV_ADDR + CONFIG_ENV_SIZE < CONFIG_SYS_MONITOR_BASE) || \ + (CONFIG_ENV_ADDR >= CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) || \ + defined(CONFIG_ENV_IS_IN_NVRAM) +#define TOTAL_MALLOC_LEN (CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE) +#else +#define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN +#endif + +typedef struct environment_s { + uint32_t crc; /* CRC32 over data bytes */ +#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT + unsigned char flags; /* active/obsolete flags ENVF_REDUND_ */ +#endif + unsigned char data[ENV_SIZE]; /* Environment data */ +} env_t; + +#ifdef ENV_IS_EMBEDDED +extern env_t embedded_environment; +#endif /* ENV_IS_EMBEDDED */ + +extern const unsigned char default_environment[]; + +#ifndef DO_DEPS_ONLY + +#include +#include +#include +#include + +enum env_location { + ENVL_UNKNOWN, + ENVL_EEPROM, + ENVL_EXT4, + ENVL_FAT, + ENVL_FLASH, + ENVL_MMC, + ENVL_NAND, + ENVL_NVRAM, + ENVL_ONENAND, + ENVL_REMOTE, + ENVL_SPI_FLASH, + ENVL_UBI, + ENVL_NOWHERE, + + ENVL_COUNT, +}; + +/* value for the various operations we want to perform on the env */ +enum env_operation { + ENVOP_GET_CHAR, /* we want to call the get_char function */ + ENVOP_INIT, /* we want to call the init function */ + ENVOP_LOAD, /* we want to call the load function */ + ENVOP_SAVE, /* we want to call the save function */ + ENVOP_ERASE, /* we want to call the erase function */ +}; + +struct env_driver { + const char *name; + enum env_location location; + + /** + * load() - Load the environment from storage + * + * This method is optional. If not provided, no environment will be + * loaded. + * + * @return 0 if OK, -ve on error + */ + int (*load)(void); + + /** + * save() - Save the environment to storage + * + * This method is required for 'saveenv' to work. + * + * @return 0 if OK, -ve on error + */ + int (*save)(void); + + /** + * erase() - Erase the environment on storage + * + * This method is optional and required for 'eraseenv' to work. + * + * @return 0 if OK, -ve on error + */ + int (*erase)(void); + + /** + * init() - Set up the initial pre-relocation environment + * + * This method is optional. + * + * @return 0 if OK, -ENOENT if no initial environment could be found, + * other -ve on error + */ + int (*init)(void); +}; + +/* Declare a new environment location driver */ +#define U_BOOT_ENV_LOCATION(__name) \ + ll_entry_declare(struct env_driver, __name, env_driver) + +/* Declare the name of a location */ +#ifdef CONFIG_CMD_SAVEENV +#define ENV_NAME(_name) .name = _name, +#else +#define ENV_NAME(_name) +#endif + +#ifdef CONFIG_CMD_SAVEENV +#define env_save_ptr(x) x +#else +#define env_save_ptr(x) NULL +#endif + +extern struct hsearch_data env_htab; + +#endif /* DO_DEPS_ONLY */ + +#endif /* _ENV_INTERNAL_H_ */ diff --git a/include/environment.h b/include/environment.h deleted file mode 100644 index cc8c0546c29..00000000000 --- a/include/environment.h +++ /dev/null @@ -1,270 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * (C) Copyright 2002 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - */ - -#ifndef _ENVIRONMENT_H_ -#define _ENVIRONMENT_H_ - -#include - -/************************************************************************** - * - * The "environment" is stored as a list of '\0' terminated - * "name=value" strings. The end of the list is marked by a double - * '\0'. New entries are always added at the end. Deleting an entry - * shifts the remaining entries to the front. Replacing an entry is a - * combination of deleting the old value and adding the new one. - * - * The environment is preceded by a 32 bit CRC over the data part. - * - *************************************************************************/ - -#if defined(CONFIG_ENV_IS_IN_FLASH) -# ifndef CONFIG_ENV_ADDR -# define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET) -# endif -# ifndef CONFIG_ENV_OFFSET -# define CONFIG_ENV_OFFSET (CONFIG_ENV_ADDR - CONFIG_SYS_FLASH_BASE) -# endif -# if !defined(CONFIG_ENV_ADDR_REDUND) && defined(CONFIG_ENV_OFFSET_REDUND) -# define CONFIG_ENV_ADDR_REDUND \ - (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET_REDUND) -# endif -# if defined(CONFIG_ENV_SECT_SIZE) || defined(CONFIG_ENV_SIZE) -# ifndef CONFIG_ENV_SECT_SIZE -# define CONFIG_ENV_SECT_SIZE CONFIG_ENV_SIZE -# endif -# ifndef CONFIG_ENV_SIZE -# define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE -# endif -# else -# error "Both CONFIG_ENV_SECT_SIZE and CONFIG_ENV_SIZE undefined" -# endif -# if defined(CONFIG_ENV_ADDR_REDUND) && !defined(CONFIG_ENV_SIZE_REDUND) -# define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE -# endif -# if (CONFIG_ENV_ADDR >= CONFIG_SYS_MONITOR_BASE) && \ - (CONFIG_ENV_ADDR + CONFIG_ENV_SIZE) <= \ - (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) -# define ENV_IS_EMBEDDED -# endif -# if defined(CONFIG_ENV_ADDR_REDUND) || defined(CONFIG_ENV_OFFSET_REDUND) -# define CONFIG_SYS_REDUNDAND_ENVIRONMENT -# endif -# ifdef CONFIG_ENV_IS_EMBEDDED -# error "do not define CONFIG_ENV_IS_EMBEDDED in your board config" -# error "it is calculated automatically for you" -# endif -#endif /* CONFIG_ENV_IS_IN_FLASH */ - -#if defined(CONFIG_ENV_IS_IN_MMC) -# ifdef CONFIG_ENV_OFFSET_REDUND -# define CONFIG_SYS_REDUNDAND_ENVIRONMENT -# endif -#endif - -#if defined(CONFIG_ENV_IS_IN_NAND) -# if defined(CONFIG_ENV_OFFSET_OOB) -# ifdef CONFIG_ENV_OFFSET_REDUND -# error "CONFIG_ENV_OFFSET_REDUND is not supported when CONFIG_ENV_OFFSET_OOB" -# error "is set" -# endif -extern unsigned long nand_env_oob_offset; -# define CONFIG_ENV_OFFSET nand_env_oob_offset -# else -# ifndef CONFIG_ENV_OFFSET -# error "Need to define CONFIG_ENV_OFFSET when using CONFIG_ENV_IS_IN_NAND" -# endif -# ifdef CONFIG_ENV_OFFSET_REDUND -# define CONFIG_SYS_REDUNDAND_ENVIRONMENT -# endif -# endif /* CONFIG_ENV_OFFSET_OOB */ -# ifndef CONFIG_ENV_SIZE -# error "Need to define CONFIG_ENV_SIZE when using CONFIG_ENV_IS_IN_NAND" -# endif -#endif /* CONFIG_ENV_IS_IN_NAND */ - -#if defined(CONFIG_ENV_IS_IN_UBI) -# ifndef CONFIG_ENV_UBI_PART -# error "Need to define CONFIG_ENV_UBI_PART when using CONFIG_ENV_IS_IN_UBI" -# endif -# ifndef CONFIG_ENV_UBI_VOLUME -# error "Need to define CONFIG_ENV_UBI_VOLUME when using CONFIG_ENV_IS_IN_UBI" -# endif -# if defined(CONFIG_ENV_UBI_VOLUME_REDUND) -# define CONFIG_SYS_REDUNDAND_ENVIRONMENT -# endif -# ifndef CONFIG_ENV_SIZE -# error "Need to define CONFIG_ENV_SIZE when using CONFIG_ENV_IS_IN_UBI" -# endif -# ifndef CONFIG_CMD_UBI -# error "Need to define CONFIG_CMD_UBI when using CONFIG_ENV_IS_IN_UBI" -# endif -#endif /* CONFIG_ENV_IS_IN_UBI */ - -/* Embedded env is only supported for some flash types */ -#ifdef CONFIG_ENV_IS_EMBEDDED -# if !defined(CONFIG_ENV_IS_IN_FLASH) && \ - !defined(CONFIG_ENV_IS_IN_NAND) && \ - !defined(CONFIG_ENV_IS_IN_ONENAND) && \ - !defined(CONFIG_ENV_IS_IN_SPI_FLASH) -# error "CONFIG_ENV_IS_EMBEDDED not supported for your flash type" -# endif -#endif - -/* - * For the flash types where embedded env is supported, but it cannot be - * calculated automatically (i.e. NAND), take the board opt-in. - */ -#if defined(CONFIG_ENV_IS_EMBEDDED) && !defined(ENV_IS_EMBEDDED) -# define ENV_IS_EMBEDDED -#endif - -/* The build system likes to know if the env is embedded */ -#ifdef DO_DEPS_ONLY -# ifdef ENV_IS_EMBEDDED -# ifndef CONFIG_ENV_IS_EMBEDDED -# define CONFIG_ENV_IS_EMBEDDED -# endif -# endif -#endif - -#include "compiler.h" - -#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT -# define ENV_HEADER_SIZE (sizeof(uint32_t) + 1) -#else -# define ENV_HEADER_SIZE (sizeof(uint32_t)) -#endif - -#define ENV_SIZE (CONFIG_ENV_SIZE - ENV_HEADER_SIZE) - -/* - * If the environment is in RAM, allocate extra space for it in the malloc - * region. - */ -#if defined(CONFIG_ENV_IS_EMBEDDED) -#define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN -#elif (CONFIG_ENV_ADDR + CONFIG_ENV_SIZE < CONFIG_SYS_MONITOR_BASE) || \ - (CONFIG_ENV_ADDR >= CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) || \ - defined(CONFIG_ENV_IS_IN_NVRAM) -#define TOTAL_MALLOC_LEN (CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE) -#else -#define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN -#endif - -typedef struct environment_s { - uint32_t crc; /* CRC32 over data bytes */ -#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT - unsigned char flags; /* active/obsolete flags ENVF_REDUND_ */ -#endif - unsigned char data[ENV_SIZE]; /* Environment data */ -} env_t; - -#ifdef ENV_IS_EMBEDDED -extern env_t embedded_environment; -#endif /* ENV_IS_EMBEDDED */ - -extern const unsigned char default_environment[]; - -#ifndef DO_DEPS_ONLY - -#include -#include -#include -#include - -enum env_location { - ENVL_UNKNOWN, - ENVL_EEPROM, - ENVL_EXT4, - ENVL_FAT, - ENVL_FLASH, - ENVL_MMC, - ENVL_NAND, - ENVL_NVRAM, - ENVL_ONENAND, - ENVL_REMOTE, - ENVL_SPI_FLASH, - ENVL_UBI, - ENVL_NOWHERE, - - ENVL_COUNT, -}; - -/* value for the various operations we want to perform on the env */ -enum env_operation { - ENVOP_GET_CHAR, /* we want to call the get_char function */ - ENVOP_INIT, /* we want to call the init function */ - ENVOP_LOAD, /* we want to call the load function */ - ENVOP_SAVE, /* we want to call the save function */ - ENVOP_ERASE, /* we want to call the erase function */ -}; - -struct env_driver { - const char *name; - enum env_location location; - - /** - * load() - Load the environment from storage - * - * This method is optional. If not provided, no environment will be - * loaded. - * - * @return 0 if OK, -ve on error - */ - int (*load)(void); - - /** - * save() - Save the environment to storage - * - * This method is required for 'saveenv' to work. - * - * @return 0 if OK, -ve on error - */ - int (*save)(void); - - /** - * erase() - Erase the environment on storage - * - * This method is optional and required for 'eraseenv' to work. - * - * @return 0 if OK, -ve on error - */ - int (*erase)(void); - - /** - * init() - Set up the initial pre-relocation environment - * - * This method is optional. - * - * @return 0 if OK, -ENOENT if no initial environment could be found, - * other -ve on error - */ - int (*init)(void); -}; - -/* Declare a new environment location driver */ -#define U_BOOT_ENV_LOCATION(__name) \ - ll_entry_declare(struct env_driver, __name, env_driver) - -/* Declare the name of a location */ -#ifdef CONFIG_CMD_SAVEENV -#define ENV_NAME(_name) .name = _name, -#else -#define ENV_NAME(_name) -#endif - -#ifdef CONFIG_CMD_SAVEENV -#define env_save_ptr(x) x -#else -#define env_save_ptr(x) NULL -#endif - -extern struct hsearch_data env_htab; - -#endif /* DO_DEPS_ONLY */ - -#endif /* _ENVIRONMENT_H_ */ diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 8a0e0db13e7..6687b69a400 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include diff --git a/net/net.c b/net/net.c index f0a3996cd61..40511db645d 100644 --- a/net/net.c +++ b/net/net.c @@ -91,7 +91,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/tools/envcrc.c b/tools/envcrc.c index 7eb7246d45d..672ef4d675e 100644 --- a/tools/envcrc.c +++ b/tools/envcrc.c @@ -59,7 +59,7 @@ #ifdef CONFIG_BUILD_ENVCRC -# include +# include extern unsigned int env_size; extern env_t embedded_environment; #endif /* CONFIG_BUILD_ENVCRC */ -- cgit v1.3.1