Blame view
include/environment.h
5.76 KB
c609719b8
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifndef _ENVIRONMENT_H_ |
6f403bad8
|
25 |
#define _ENVIRONMENT_H_ |
c609719b8
|
26 27 28 29 30 31 32 33 34 35 36 37 38 |
/************************************************************************** * * 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 preceeded by a 32 bit CRC over the data part. * ************************************************************************** */ |
5a1aceb06
|
39 |
#if defined(CONFIG_ENV_IS_IN_FLASH) |
507651d61
|
40 41 |
# ifndef CONFIG_ENV_ADDR # define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET) |
c609719b8
|
42 |
# endif |
507651d61
|
43 44 |
# ifndef CONFIG_ENV_OFFSET # define CONFIG_ENV_OFFSET (CONFIG_ENV_ADDR - CONFIG_SYS_FLASH_BASE) |
c609719b8
|
45 |
# endif |
0e8d15866
|
46 |
# if !defined(CONFIG_ENV_ADDR_REDUND) && defined(CONFIG_ENV_OFFSET_REDUND) |
507651d61
|
47 48 |
# define CONFIG_ENV_ADDR_REDUND \ (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET_REDUND) |
c609719b8
|
49 |
# endif |
0e8d15866
|
50 |
# if defined(CONFIG_ENV_SECT_SIZE) || defined(CONFIG_ENV_SIZE) |
507651d61
|
51 52 |
# ifndef CONFIG_ENV_SECT_SIZE # define CONFIG_ENV_SECT_SIZE CONFIG_ENV_SIZE |
500545cc6
|
53 |
# endif |
507651d61
|
54 55 |
# ifndef CONFIG_ENV_SIZE # define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE |
500545cc6
|
56 57 |
# endif # else |
0e8d15866
|
58 |
# error "Both CONFIG_ENV_SECT_SIZE and CONFIG_ENV_SIZE undefined" |
c609719b8
|
59 |
# endif |
0e8d15866
|
60 61 |
# if defined(CONFIG_ENV_ADDR_REDUND) && !defined(CONFIG_ENV_SIZE_REDUND) # define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE |
c609719b8
|
62 |
# endif |
507651d61
|
63 64 65 |
# if (CONFIG_ENV_ADDR >= CONFIG_SYS_MONITOR_BASE) && \ (CONFIG_ENV_ADDR + CONFIG_ENV_SIZE) <= \ (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) |
6f403bad8
|
66 |
# define ENV_IS_EMBEDDED |
c609719b8
|
67 |
# endif |
0e8d15866
|
68 |
# if defined(CONFIG_ENV_ADDR_REDUND) || defined(CONFIG_ENV_OFFSET_REDUND) |
6f403bad8
|
69 |
# define CONFIG_SYS_REDUNDAND_ENVIRONMENT |
c609719b8
|
70 |
# endif |
0a9e4e772
|
71 72 73 74 |
# 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
|
75 |
#endif /* CONFIG_ENV_IS_IN_FLASH */ |
c609719b8
|
76 |
|
51bfee192
|
77 |
#if defined(CONFIG_ENV_IS_IN_NAND) |
c9f7351b5
|
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# 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 */ |
0e8d15866
|
93 94 |
# ifndef CONFIG_ENV_SIZE # error "Need to define CONFIG_ENV_SIZE when using CONFIG_ENV_IS_IN_NAND" |
e443c944c
|
95 |
# endif |
51bfee192
|
96 |
#endif /* CONFIG_ENV_IS_IN_NAND */ |
e443c944c
|
97 |
|
0a9e4e772
|
98 99 |
/* Embedded env is only supported for some flash types */ #ifdef CONFIG_ENV_IS_EMBEDDED |
507651d61
|
100 101 102 103 |
# 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) |
0a9e4e772
|
104 105 106 107 108 109 110 111 112 |
# 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) |
6f403bad8
|
113 |
# define ENV_IS_EMBEDDED |
0a9e4e772
|
114 115 116 117 118 |
#endif /* The build system likes to know if the env is embedded */ #ifdef DO_DEPS_ONLY # ifdef ENV_IS_EMBEDDED |
33a6b9e90
|
119 120 121 |
# ifndef CONFIG_ENV_IS_EMBEDDED # define CONFIG_ENV_IS_EMBEDDED # endif |
0a9e4e772
|
122 123 |
# endif #endif |
375660907
|
124 |
#include "compiler.h" |
c609719b8
|
125 |
|
6d0f6bcf3
|
126 |
#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT |
89cdab788
|
127 |
# define ENV_HEADER_SIZE (sizeof(uint32_t) + 1) |
b218ccb54
|
128 129 130 |
# define ACTIVE_FLAG 1 # define OBSOLETE_FLAG 0 |
c609719b8
|
131 |
#else |
89cdab788
|
132 |
# define ENV_HEADER_SIZE (sizeof(uint32_t)) |
c609719b8
|
133 |
#endif |
d09b1787a
|
134 135 136 |
#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) extern char *env_name_spec; #endif |
c609719b8
|
137 |
|
0e8d15866
|
138 |
#define ENV_SIZE (CONFIG_ENV_SIZE - ENV_HEADER_SIZE) |
c609719b8
|
139 |
|
507651d61
|
140 |
typedef struct environment_s { |
89cdab788
|
141 |
uint32_t crc; /* CRC32 over data bytes */ |
6d0f6bcf3
|
142 |
#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT |
c609719b8
|
143 144 145 146 |
unsigned char flags; /* active/obsolete flags */ #endif unsigned char data[ENV_SIZE]; /* Environment data */ } env_t; |
994bc671c
|
147 148 149 |
#ifdef ENV_IS_EMBEDDED extern env_t environment; #endif /* ENV_IS_EMBEDDED */ |
d1459f0fa
|
150 |
extern const unsigned char default_environment[]; |
27aafe988
|
151 152 153 154 155 156 157 158 |
extern env_t *env_ptr; extern void env_relocate_spec(void); extern unsigned char env_get_char_spec(int); #if defined(CONFIG_NEEDS_MANUAL_RELOC) extern void env_reloc(void); #endif |
d1459f0fa
|
159 |
|
2eb1573f0
|
160 161 162 163 164 |
#ifndef DO_DEPS_ONLY #include <search.h> extern struct hsearch_data env_htab; |
b502611b5
|
165 |
/* Function that returns a character from the environment */ |
507651d61
|
166 |
unsigned char env_get_char(int); |
a8409f4f1
|
167 168 |
/* Function that returns a pointer to a value from the environment */ |
147c7169e
|
169 |
const unsigned char *env_get_addr(int); |
507651d61
|
170 |
unsigned char env_get_char_memory(int index); |
a8409f4f1
|
171 172 |
/* Function that updates CRC of the enironment */ |
507651d61
|
173 |
void env_crc_update(void); |
a8409f4f1
|
174 |
|
5bb12dbd7
|
175 |
/* [re]set to the default environment */ |
ea882baf9
|
176 177 178 179 |
void set_default_env(const char *s); /* Import from binary representation into hash table */ int env_import(const char *buf, int check); |
5bb12dbd7
|
180 |
|
507651d61
|
181 |
#endif /* DO_DEPS_ONLY */ |
2eb1573f0
|
182 |
|
507651d61
|
183 |
#endif /* _ENVIRONMENT_H_ */ |