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