]> git.ipfire.org Git - thirdparty/u-boot.git/blame - env/remote.c
Merge branch 'staging' of https://source.denx.de/u-boot/custodians/u-boot-tegra into...
[thirdparty/u-boot.git] / env / remote.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
0a85a9e7
LG
2/*
3 * (C) Copyright 2011-2012 Freescale Semiconductor, Inc.
0a85a9e7
LG
4 */
5
6/* #define DEBUG */
7
8#include <common.h>
9#include <command.h>
f3998fdc 10#include <env_internal.h>
401d1c4f 11#include <asm/global_data.h>
0a85a9e7 12#include <linux/stddef.h>
3db71108 13#include <u-boot/crc.h>
0a85a9e7 14
0a85a9e7 15#ifdef ENV_IS_EMBEDDED
46d9d1c3 16static env_t *env_ptr = &environment;
0a85a9e7 17#else /* ! ENV_IS_EMBEDDED */
46d9d1c3 18static env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
0a85a9e7
LG
19#endif /* ENV_IS_EMBEDDED */
20
21DECLARE_GLOBAL_DATA_PTR;
22
e5bce247 23static int env_remote_init(void)
0a85a9e7
LG
24{
25 if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
26 gd->env_addr = (ulong)&(env_ptr->data);
203e94f6 27 gd->env_valid = ENV_VALID;
0a85a9e7
LG
28 return 0;
29 }
30
7938822a 31 return -ENOENT;
0a85a9e7
LG
32}
33
34#ifdef CONFIG_CMD_SAVEENV
e5bce247 35static int env_remote_save(void)
0a85a9e7 36{
461632bd
LG
37#ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
38 printf("Can not support the 'saveenv' when boot from SRIO or PCIE!\n");
0a85a9e7
LG
39 return 1;
40#else
41 return 0;
42#endif
43}
44#endif /* CONFIG_CMD_SAVEENV */
45
c5951991 46static int env_remote_load(void)
0a85a9e7
LG
47{
48#ifndef ENV_IS_EMBEDDED
890feeca 49 return env_import((char *)env_ptr, 1, H_EXTERNAL);
0a85a9e7 50#endif
c5951991
SG
51
52 return 0;
0a85a9e7 53}
4415f1d1
SG
54
55U_BOOT_ENV_LOCATION(remote) = {
56 .location = ENVL_REMOTE,
ac358beb 57 ENV_NAME("Remote")
e5bce247
SG
58 .load = env_remote_load,
59 .save = env_save_ptr(env_remote_save),
60 .init = env_remote_init,
4415f1d1 61};