]> git.ipfire.org Git - thirdparty/u-boot.git/blame - env/remote.c
Merge tag 'pull-12apr19' of git://git.denx.de/u-boot-dm
[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>
10#include <environment.h>
11#include <linux/stddef.h>
12
0a85a9e7
LG
13#ifdef ENV_IS_EMBEDDED
14env_t *env_ptr = &environment;
15#else /* ! ENV_IS_EMBEDDED */
16env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
17#endif /* ENV_IS_EMBEDDED */
18
19DECLARE_GLOBAL_DATA_PTR;
20
21#if !defined(CONFIG_ENV_OFFSET)
22#define CONFIG_ENV_OFFSET 0
23#endif
24
e5bce247 25static int env_remote_init(void)
0a85a9e7
LG
26{
27 if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
28 gd->env_addr = (ulong)&(env_ptr->data);
203e94f6 29 gd->env_valid = ENV_VALID;
0a85a9e7
LG
30 return 0;
31 }
32
7938822a 33 return -ENOENT;
0a85a9e7
LG
34}
35
36#ifdef CONFIG_CMD_SAVEENV
e5bce247 37static int env_remote_save(void)
0a85a9e7 38{
461632bd
LG
39#ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
40 printf("Can not support the 'saveenv' when boot from SRIO or PCIE!\n");
0a85a9e7
LG
41 return 1;
42#else
43 return 0;
44#endif
45}
46#endif /* CONFIG_CMD_SAVEENV */
47
c5951991 48static int env_remote_load(void)
0a85a9e7
LG
49{
50#ifndef ENV_IS_EMBEDDED
2166ebf7 51 return env_import((char *)env_ptr, 1);
0a85a9e7 52#endif
c5951991
SG
53
54 return 0;
0a85a9e7 55}
4415f1d1
SG
56
57U_BOOT_ENV_LOCATION(remote) = {
58 .location = ENVL_REMOTE,
ac358beb 59 ENV_NAME("Remote")
e5bce247
SG
60 .load = env_remote_load,
61 .save = env_save_ptr(env_remote_save),
62 .init = env_remote_init,
4415f1d1 63};