env_remote.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * (C) Copyright 2011-2012 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. /* #define DEBUG */
  23. #include <common.h>
  24. #include <command.h>
  25. #include <environment.h>
  26. #include <linux/stddef.h>
  27. char *env_name_spec = "Remote";
  28. #ifdef ENV_IS_EMBEDDED
  29. env_t *env_ptr = &environment;
  30. #else /* ! ENV_IS_EMBEDDED */
  31. env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
  32. #endif /* ENV_IS_EMBEDDED */
  33. DECLARE_GLOBAL_DATA_PTR;
  34. #if !defined(CONFIG_ENV_OFFSET)
  35. #define CONFIG_ENV_OFFSET 0
  36. #endif
  37. uchar env_get_char_spec(int index)
  38. {
  39. return *((uchar *)(gd->env_addr + index));
  40. }
  41. int env_init(void)
  42. {
  43. if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
  44. gd->env_addr = (ulong)&(env_ptr->data);
  45. gd->env_valid = 1;
  46. return 0;
  47. }
  48. gd->env_addr = (ulong)default_environment;
  49. gd->env_valid = 0;
  50. return 0;
  51. }
  52. #ifdef CONFIG_CMD_SAVEENV
  53. int saveenv(void)
  54. {
  55. #ifdef CONFIG_SRIOBOOT_SLAVE
  56. printf("Can not support the 'saveenv' when boot from SRIO!\n");
  57. return 1;
  58. #else
  59. return 0;
  60. #endif
  61. }
  62. #endif /* CONFIG_CMD_SAVEENV */
  63. void env_relocate_spec(void)
  64. {
  65. #ifndef ENV_IS_EMBEDDED
  66. env_import((char *)env_ptr, 1);
  67. #endif
  68. }