blob: 3bf0f957b3a75f58f0bc0b15356181974bb31aed [file] [log] [blame]
Liu Gang85bcd732012-03-08 00:33:20 +00001/*
2 * (C) Copyright 2011-2012 Freescale Semiconductor, Inc.
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23/* #define DEBUG */
24
25#include <common.h>
26#include <command.h>
27#include <environment.h>
28#include <linux/stddef.h>
29
30char *env_name_spec = "Remote";
31
32#ifdef ENV_IS_EMBEDDED
33env_t *env_ptr = &environment;
34#else /* ! ENV_IS_EMBEDDED */
35env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
36#endif /* ENV_IS_EMBEDDED */
37
38DECLARE_GLOBAL_DATA_PTR;
39
40#if !defined(CONFIG_ENV_OFFSET)
41#define CONFIG_ENV_OFFSET 0
42#endif
43
44uchar env_get_char_spec(int index)
45{
46 return *((uchar *)(gd->env_addr + index));
47}
48
49int env_init(void)
50{
51 if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
52 gd->env_addr = (ulong)&(env_ptr->data);
53 gd->env_valid = 1;
54 return 0;
55 }
56
57 gd->env_addr = (ulong)default_environment;
58 gd->env_valid = 0;
59 return 0;
60}
61
62#ifdef CONFIG_CMD_SAVEENV
63int saveenv(void)
64{
65#ifdef CONFIG_SRIOBOOT_SLAVE
66 printf("Can not support the 'saveenv' when boot from SRIO!\n");
67 return 1;
68#else
69 return 0;
70#endif
71}
72#endif /* CONFIG_CMD_SAVEENV */
73
74void env_relocate_spec(void)
75{
76#ifndef ENV_IS_EMBEDDED
77 env_import((char *)env_ptr, 1);
78#endif
79}