Blame view

env/remote.c 1.13 KB
83d290c56   Tom Rini   SPDX: Convert all...
1
  // SPDX-License-Identifier: GPL-2.0+
0a85a9e70   Liu Gang   powerpc/corenet_d...
2
3
  /*
   * (C) Copyright 2011-2012 Freescale Semiconductor, Inc.
0a85a9e70   Liu Gang   powerpc/corenet_d...
4
5
6
7
8
9
   */
  
  /* #define DEBUG */
  
  #include <common.h>
  #include <command.h>
f3998fdc4   Simon Glass   env: Rename envir...
10
  #include <env_internal.h>
0a85a9e70   Liu Gang   powerpc/corenet_d...
11
  #include <linux/stddef.h>
3db711085   Simon Glass   crc32: Use the cr...
12
  #include <u-boot/crc.h>
0a85a9e70   Liu Gang   powerpc/corenet_d...
13

0a85a9e70   Liu Gang   powerpc/corenet_d...
14
15
16
17
18
19
20
  #ifdef ENV_IS_EMBEDDED
  env_t *env_ptr = &environment;
  #else /* ! ENV_IS_EMBEDDED */
  env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
  #endif /* ENV_IS_EMBEDDED */
  
  DECLARE_GLOBAL_DATA_PTR;
e5bce247b   Simon Glass   env: Switch over ...
21
  static int env_remote_init(void)
0a85a9e70   Liu Gang   powerpc/corenet_d...
22
23
24
  {
  	if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
  		gd->env_addr = (ulong)&(env_ptr->data);
203e94f6c   Simon Glass   env: Add an enum ...
25
  		gd->env_valid = ENV_VALID;
0a85a9e70   Liu Gang   powerpc/corenet_d...
26
27
  		return 0;
  	}
7938822a6   Simon Glass   env: Drop common ...
28
  	return -ENOENT;
0a85a9e70   Liu Gang   powerpc/corenet_d...
29
30
31
  }
  
  #ifdef CONFIG_CMD_SAVEENV
e5bce247b   Simon Glass   env: Switch over ...
32
  static int env_remote_save(void)
0a85a9e70   Liu Gang   powerpc/corenet_d...
33
  {
461632bd7   Liu Gang   powerpc/corenet_d...
34
35
36
  #ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
  	printf("Can not support the 'saveenv' when boot from SRIO or PCIE!
  ");
0a85a9e70   Liu Gang   powerpc/corenet_d...
37
38
39
40
41
42
  	return 1;
  #else
  	return 0;
  #endif
  }
  #endif /* CONFIG_CMD_SAVEENV */
c59519919   Simon Glass   env: Adjust the l...
43
  static int env_remote_load(void)
0a85a9e70   Liu Gang   powerpc/corenet_d...
44
45
  {
  #ifndef ENV_IS_EMBEDDED
2166ebf78   Simon Goldschmidt   env: make env dri...
46
  	return env_import((char *)env_ptr, 1);
0a85a9e70   Liu Gang   powerpc/corenet_d...
47
  #endif
c59519919   Simon Glass   env: Adjust the l...
48
49
  
  	return 0;
0a85a9e70   Liu Gang   powerpc/corenet_d...
50
  }
4415f1d1f   Simon Glass   env: Create a loc...
51
52
53
  
  U_BOOT_ENV_LOCATION(remote) = {
  	.location	= ENVL_REMOTE,
ac358beb8   Simon Glass   env: Drop the env...
54
  	ENV_NAME("Remote")
e5bce247b   Simon Glass   env: Switch over ...
55
56
57
  	.load		= env_remote_load,
  	.save		= env_save_ptr(env_remote_save),
  	.init		= env_remote_init,
4415f1d1f   Simon Glass   env: Create a loc...
58
  };