blob: 6c10c90c038518ad7867d3580de20232dfd8a977 [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
Liu Gang85bcd732012-03-08 00:33:20 +000044int env_init(void)
45{
46 if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
47 gd->env_addr = (ulong)&(env_ptr->data);
48 gd->env_valid = 1;
49 return 0;
50 }
51
52 gd->env_addr = (ulong)default_environment;
53 gd->env_valid = 0;
54 return 0;
55}
56
57#ifdef CONFIG_CMD_SAVEENV
58int saveenv(void)
59{
Liu Gangb4611ee2012-08-09 05:10:03 +000060#ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
61 printf("Can not support the 'saveenv' when boot from SRIO or PCIE!\n");
Liu Gang85bcd732012-03-08 00:33:20 +000062 return 1;
63#else
64 return 0;
65#endif
66}
67#endif /* CONFIG_CMD_SAVEENV */
68
69void env_relocate_spec(void)
70{
71#ifndef ENV_IS_EMBEDDED
72 env_import((char *)env_ptr, 1);
73#endif
74}