Blame view

env/remote.c 1.18 KB
0a85a9e70   Liu Gang   powerpc/corenet_d...
1
2
3
  /*
   * (C) Copyright 2011-2012 Freescale Semiconductor, Inc.
   *
3765b3e7b   Wolfgang Denk   Coding Style clea...
4
   * SPDX-License-Identifier:	GPL-2.0+
0a85a9e70   Liu Gang   powerpc/corenet_d...
5
6
7
8
9
10
11
12
   */
  
  /* #define DEBUG */
  
  #include <common.h>
  #include <command.h>
  #include <environment.h>
  #include <linux/stddef.h>
0a85a9e70   Liu Gang   powerpc/corenet_d...
13
14
15
16
17
18
19
20
21
22
23
  #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;
  
  #if !defined(CONFIG_ENV_OFFSET)
  #define CONFIG_ENV_OFFSET 0
  #endif
e5bce247b   Simon Glass   env: Switch over ...
24
  static int env_remote_init(void)
0a85a9e70   Liu Gang   powerpc/corenet_d...
25
26
27
  {
  	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 ...
28
  		gd->env_valid = ENV_VALID;
0a85a9e70   Liu Gang   powerpc/corenet_d...
29
30
  		return 0;
  	}
7938822a6   Simon Glass   env: Drop common ...
31
  	return -ENOENT;
0a85a9e70   Liu Gang   powerpc/corenet_d...
32
33
34
  }
  
  #ifdef CONFIG_CMD_SAVEENV
e5bce247b   Simon Glass   env: Switch over ...
35
  static int env_remote_save(void)
0a85a9e70   Liu Gang   powerpc/corenet_d...
36
  {
461632bd7   Liu Gang   powerpc/corenet_d...
37
38
39
  #ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
  	printf("Can not support the 'saveenv' when boot from SRIO or PCIE!
  ");
0a85a9e70   Liu Gang   powerpc/corenet_d...
40
41
42
43
44
45
  	return 1;
  #else
  	return 0;
  #endif
  }
  #endif /* CONFIG_CMD_SAVEENV */
c59519919   Simon Glass   env: Adjust the l...
46
  static int env_remote_load(void)
0a85a9e70   Liu Gang   powerpc/corenet_d...
47
48
  {
  #ifndef ENV_IS_EMBEDDED
2166ebf78   Simon Goldschmidt   env: make env dri...
49
  	return env_import((char *)env_ptr, 1);
0a85a9e70   Liu Gang   powerpc/corenet_d...
50
  #endif
c59519919   Simon Glass   env: Adjust the l...
51
52
  
  	return 0;
0a85a9e70   Liu Gang   powerpc/corenet_d...
53
  }
4415f1d1f   Simon Glass   env: Create a loc...
54
55
56
  
  U_BOOT_ENV_LOCATION(remote) = {
  	.location	= ENVL_REMOTE,
ac358beb8   Simon Glass   env: Drop the env...
57
  	ENV_NAME("Remote")
e5bce247b   Simon Glass   env: Switch over ...
58
59
60
  	.load		= env_remote_load,
  	.save		= env_save_ptr(env_remote_save),
  	.init		= env_remote_init,
4415f1d1f   Simon Glass   env: Create a loc...
61
  };