Blame view
include/env_internal.h
5.62 KB
83d290c56 SPDX: Convert all... |
1 |
/* SPDX-License-Identifier: GPL-2.0+ */ |
c609719b8 Initial revision |
2 |
/* |
f3998fdc4 env: Rename envir... |
3 4 5 6 7 8 9 10 |
* 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. * |
c609719b8 Initial revision |
11 12 |
* (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
c609719b8 Initial revision |
13 |
*/ |
f3998fdc4 env: Rename envir... |
14 15 |
#ifndef _ENV_INTERNAL_H_ #define _ENV_INTERNAL_H_ |
c609719b8 Initial revision |
16 |
|
fb1c43cc3 common: Move envi... |
17 |
#include <linux/kconfig.h> |
c609719b8 Initial revision |
18 19 20 21 22 23 24 25 |
/************************************************************************** * * 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. * |
fc0b5948e Various, accumula... |
26 |
* The environment is preceded by a 32 bit CRC over the data part. |
c609719b8 Initial revision |
27 |
* |
fc0b5948e Various, accumula... |
28 |
*************************************************************************/ |
c609719b8 Initial revision |
29 |
|
5a1aceb06 rename CFG_ENV_IS... |
30 |
#if defined(CONFIG_ENV_IS_IN_FLASH) |
a8992e788 env: Remove usele... |
31 32 33 34 35 |
# if defined(CONFIG_ENV_ADDR_REDUND) && \ ((CONFIG_ENV_ADDR >= CONFIG_SYS_MONITOR_BASE) && \ (CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE) <= \ (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) # define ENV_IS_EMBEDDED |
c609719b8 Initial revision |
36 |
# endif |
507651d61 env: clean enviro... |
37 38 39 |
# if (CONFIG_ENV_ADDR >= CONFIG_SYS_MONITOR_BASE) && \ (CONFIG_ENV_ADDR + CONFIG_ENV_SIZE) <= \ (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) |
6f403bad8 env: remove value... |
40 |
# define ENV_IS_EMBEDDED |
c609719b8 Initial revision |
41 |
# endif |
0a9e4e772 unify {CONFIG_,}E... |
42 43 44 45 |
# 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 |
5a1aceb06 rename CFG_ENV_IS... |
46 |
#endif /* CONFIG_ENV_IS_IN_FLASH */ |
c609719b8 Initial revision |
47 |
|
51bfee192 rename CFG_ENV_IS... |
48 |
#if defined(CONFIG_ENV_IS_IN_NAND) |
c9f7351b5 NAND: environment... |
49 50 51 52 53 54 55 |
# 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 |
c9f7351b5 NAND: environment... |
56 |
# endif /* CONFIG_ENV_OFFSET_OOB */ |
51bfee192 rename CFG_ENV_IS... |
57 |
#endif /* CONFIG_ENV_IS_IN_NAND */ |
e443c944c Support for redun... |
58 |
|
0a9e4e772 unify {CONFIG_,}E... |
59 60 61 62 63 |
/* * 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) |
6f403bad8 env: remove value... |
64 |
# define ENV_IS_EMBEDDED |
0a9e4e772 unify {CONFIG_,}E... |
65 66 67 68 69 |
#endif /* The build system likes to know if the env is embedded */ #ifdef DO_DEPS_ONLY # ifdef ENV_IS_EMBEDDED |
33a6b9e90 environment.h: fi... |
70 71 72 |
# ifndef CONFIG_ENV_IS_EMBEDDED # define CONFIG_ENV_IS_EMBEDDED # endif |
0a9e4e772 unify {CONFIG_,}E... |
73 74 |
# endif #endif |
375660907 compiler.h: unify... |
75 |
#include "compiler.h" |
c609719b8 Initial revision |
76 |
|
6d0f6bcf3 rename CFG_ macro... |
77 |
#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT |
89cdab788 crc32: use uint32... |
78 |
# define ENV_HEADER_SIZE (sizeof(uint32_t) + 1) |
c609719b8 Initial revision |
79 |
#else |
89cdab788 crc32: use uint32... |
80 |
# define ENV_HEADER_SIZE (sizeof(uint32_t)) |
c609719b8 Initial revision |
81 |
#endif |
0e8d15866 rename CFG_ENV ma... |
82 |
#define ENV_SIZE (CONFIG_ENV_SIZE - ENV_HEADER_SIZE) |
c609719b8 Initial revision |
83 |
|
f030b7b26 env: Move TOTAL_M... |
84 85 86 87 88 89 90 91 92 93 94 95 96 |
/* * 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 |
507651d61 env: clean enviro... |
97 |
typedef struct environment_s { |
89cdab788 crc32: use uint32... |
98 |
uint32_t crc; /* CRC32 over data bytes */ |
6d0f6bcf3 rename CFG_ macro... |
99 |
#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT |
d3716dd64 env: Rename the r... |
100 |
unsigned char flags; /* active/obsolete flags ENVF_REDUND_ */ |
c609719b8 Initial revision |
101 102 |
#endif unsigned char data[ENV_SIZE]; /* Environment data */ |
c6831c74a env: Remove CONFI... |
103 |
} env_t; |
c609719b8 Initial revision |
104 |
|
994bc671c env: move extern ... |
105 |
#ifdef ENV_IS_EMBEDDED |
be54ec162 env: Rename envir... |
106 |
extern env_t embedded_environment; |
994bc671c env: move extern ... |
107 |
#endif /* ENV_IS_EMBEDDED */ |
d1459f0fa env: move extern ... |
108 |
extern const unsigned char default_environment[]; |
27aafe988 env: clean env_co... |
109 |
|
2eb1573f0 hashtable: drop a... |
110 |
#ifndef DO_DEPS_ONLY |
170ab1107 env: Add support ... |
111 112 |
#include <env_attr.h> #include <env_callback.h> |
2598090b7 env: Add environm... |
113 |
#include <env_flags.h> |
2eb1573f0 hashtable: drop a... |
114 |
#include <search.h> |
4415f1d1f env: Create a loc... |
115 |
enum env_location { |
e1caa5841 env: Fix env_load... |
116 |
ENVL_UNKNOWN, |
4415f1d1f env: Create a loc... |
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
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, |
4415f1d1f env: Create a loc... |
131 |
}; |
8a3a7e227 env: Pass additio... |
132 133 134 135 136 137 |
/* 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 */ |
cd121bdb6 env: register era... |
138 |
ENVOP_ERASE, /* we want to call the erase function */ |
8a3a7e227 env: Pass additio... |
139 |
}; |
4415f1d1f env: Create a loc... |
140 |
struct env_driver { |
ac358beb8 env: Drop the env... |
141 |
const char *name; |
4415f1d1f env: Create a loc... |
142 143 144 |
enum env_location location; /** |
4415f1d1f env: Create a loc... |
145 146 147 148 |
* load() - Load the environment from storage * * This method is optional. If not provided, no environment will be * loaded. |
c59519919 env: Adjust the l... |
149 150 |
* * @return 0 if OK, -ve on error |
4415f1d1f env: Create a loc... |
151 |
*/ |
c59519919 env: Adjust the l... |
152 |
int (*load)(void); |
4415f1d1f env: Create a loc... |
153 154 155 156 157 158 159 160 161 162 163 |
/** * save() - Save the environment to storage * * This method is required for 'saveenv' to work. * * @return 0 if OK, -ve on error */ int (*save)(void); /** |
cd121bdb6 env: register era... |
164 165 166 167 168 169 170 171 172 |
* 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); /** |
4415f1d1f env: Create a loc... |
173 174 175 176 |
* init() - Set up the initial pre-relocation environment * * This method is optional. * |
7938822a6 env: Drop common ... |
177 178 |
* @return 0 if OK, -ENOENT if no initial environment could be found, * other -ve on error |
4415f1d1f env: Create a loc... |
179 180 181 182 183 184 185 |
*/ int (*init)(void); }; /* Declare a new environment location driver */ #define U_BOOT_ENV_LOCATION(__name) \ ll_entry_declare(struct env_driver, __name, env_driver) |
ac358beb8 env: Drop the env... |
186 187 188 189 190 191 |
/* Declare the name of a location */ #ifdef CONFIG_CMD_SAVEENV #define ENV_NAME(_name) .name = _name, #else #define ENV_NAME(_name) #endif |
4415f1d1f env: Create a loc... |
192 193 194 195 196 |
#ifdef CONFIG_CMD_SAVEENV #define env_save_ptr(x) x #else #define env_save_ptr(x) NULL #endif |
2eb1573f0 hashtable: drop a... |
197 |
extern struct hsearch_data env_htab; |
507651d61 env: clean enviro... |
198 |
#endif /* DO_DEPS_ONLY */ |
2eb1573f0 hashtable: drop a... |
199 |
|
f3998fdc4 env: Rename envir... |
200 |
#endif /* _ENV_INTERNAL_H_ */ |