1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * (C) Copyright 2011-2012 Freescale Semiconductor, Inc. 4 */ 5 6 /* #define DEBUG */ 7 8 #include <common.h> 9 #include <command.h> 10 #include <env_internal.h> 11 #include <asm/global_data.h> 12 #include <linux/stddef.h> 13 #include <u-boot/crc.h> 14 15 #ifdef ENV_IS_EMBEDDED 16 static env_t *env_ptr = &environment; 17 #else /* ! ENV_IS_EMBEDDED */ 18 static env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR; 19 #endif /* ENV_IS_EMBEDDED */ 20 21 DECLARE_GLOBAL_DATA_PTR; 22 env_remote_init(void)23static int env_remote_init(void) 24 { 25 if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) { 26 gd->env_addr = (ulong)&(env_ptr->data); 27 gd->env_valid = ENV_VALID; 28 return 0; 29 } 30 31 return -ENOENT; 32 } 33 34 #ifdef CONFIG_CMD_SAVEENV env_remote_save(void)35static int env_remote_save(void) 36 { 37 #ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE 38 printf("Can not support the 'saveenv' when boot from SRIO or PCIE!\n"); 39 return 1; 40 #else 41 return 0; 42 #endif 43 } 44 #endif /* CONFIG_CMD_SAVEENV */ 45 env_remote_load(void)46static int env_remote_load(void) 47 { 48 #ifndef ENV_IS_EMBEDDED 49 return env_import((char *)env_ptr, 1, H_EXTERNAL); 50 #endif 51 52 return 0; 53 } 54 55 U_BOOT_ENV_LOCATION(remote) = { 56 .location = ENVL_REMOTE, 57 ENV_NAME("Remote") 58 .load = env_remote_load, 59 .save = env_save_ptr(env_remote_save), 60 .init = env_remote_init, 61 }; 62