Liu Gang | 85bcd73 | 2012-03-08 00:33:20 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 30 | char *env_name_spec = "Remote"; |
| 31 | |
| 32 | #ifdef ENV_IS_EMBEDDED |
| 33 | env_t *env_ptr = &environment; |
| 34 | #else /* ! ENV_IS_EMBEDDED */ |
| 35 | env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR; |
| 36 | #endif /* ENV_IS_EMBEDDED */ |
| 37 | |
| 38 | DECLARE_GLOBAL_DATA_PTR; |
| 39 | |
| 40 | #if !defined(CONFIG_ENV_OFFSET) |
| 41 | #define CONFIG_ENV_OFFSET 0 |
| 42 | #endif |
| 43 | |
Liu Gang | 85bcd73 | 2012-03-08 00:33:20 +0000 | [diff] [blame] | 44 | int 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 |
| 58 | int saveenv(void) |
| 59 | { |
Liu Gang | b4611ee | 2012-08-09 05:10:03 +0000 | [diff] [blame] | 60 | #ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE |
| 61 | printf("Can not support the 'saveenv' when boot from SRIO or PCIE!\n"); |
Liu Gang | 85bcd73 | 2012-03-08 00:33:20 +0000 | [diff] [blame] | 62 | return 1; |
| 63 | #else |
| 64 | return 0; |
| 65 | #endif |
| 66 | } |
| 67 | #endif /* CONFIG_CMD_SAVEENV */ |
| 68 | |
| 69 | void env_relocate_spec(void) |
| 70 | { |
| 71 | #ifndef ENV_IS_EMBEDDED |
| 72 | env_import((char *)env_ptr, 1); |
| 73 | #endif |
| 74 | } |