mv_common.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * (C) Copyright 2008
  3. * Andre Schwarz, Matrix Vision GmbH, andre.schwarz@matrix-vision.de
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <malloc.h>
  25. #include <environment.h>
  26. #include <fpga.h>
  27. #include <asm/io.h>
  28. DECLARE_GLOBAL_DATA_PTR;
  29. #ifndef CONFIG_ENV_IS_NOWHERE
  30. static char* entries_to_keep[] = {
  31. "serial#", "ethaddr", "eth1addr", "model_info", "sensor_cnt",
  32. "fpgadatasize", "ddr_size", "use_dhcp", "use_static_ipaddr",
  33. "static_ipaddr", "static_netmask", "static_gateway",
  34. "syslog", "watchdog", "netboot", "evo8serialnumber" };
  35. #define MV_MAX_ENV_ENTRY_LENGTH 64
  36. #define MV_KEEP_ENTRIES ARRAY_SIZE(entries_to_keep)
  37. void mv_reset_environment(void)
  38. {
  39. int i;
  40. char *s[MV_KEEP_ENTRIES];
  41. char entries[MV_KEEP_ENTRIES][MV_MAX_ENV_ENTRY_LENGTH];
  42. printf("\n*** RESET ENVIRONMENT ***\n");
  43. memset(entries, 0, MV_KEEP_ENTRIES * MV_MAX_ENV_ENTRY_LENGTH);
  44. for (i = 0; i < MV_KEEP_ENTRIES; i++) {
  45. s[i] = getenv(entries_to_keep[i]);
  46. if (s[i]) {
  47. printf("save '%s' : %s\n", entries_to_keep[i], s[i]);
  48. strncpy(entries[i], s[i], MV_MAX_ENV_ENTRY_LENGTH);
  49. }
  50. }
  51. gd->env_valid = 0;
  52. env_relocate();
  53. for (i = 0; i < MV_KEEP_ENTRIES; i++) {
  54. if (s[i]) {
  55. printf("restore '%s' : %s\n", entries_to_keep[i], s[i]);
  56. setenv(entries_to_keep[i], s[i]);
  57. }
  58. }
  59. saveenv();
  60. }
  61. #endif
  62. int mv_load_fpga(void)
  63. {
  64. int result;
  65. size_t data_size = 0;
  66. void *fpga_data = NULL;
  67. char *datastr = getenv("fpgadata");
  68. char *sizestr = getenv("fpgadatasize");
  69. if (getenv("skip_fpga")) {
  70. printf("found 'skip_fpga' -> FPGA _not_ loaded !\n");
  71. return -1;
  72. }
  73. printf("loading FPGA\n");
  74. if (datastr)
  75. fpga_data = (void *)simple_strtoul(datastr, NULL, 16);
  76. if (sizestr)
  77. data_size = (size_t)simple_strtoul(sizestr, NULL, 16);
  78. if (!data_size) {
  79. printf("fpgadatasize invalid -> FPGA _not_ loaded !\n");
  80. return -1;
  81. }
  82. result = fpga_load(0, fpga_data, data_size);
  83. if (!result)
  84. bootstage_mark(BOOTSTAGE_ID_START);
  85. return result;
  86. }
  87. u8 *dhcp_vendorex_prep(u8 *e)
  88. {
  89. char *ptr;
  90. /* DHCP vendor-class-identifier = 60 */
  91. if ((ptr = getenv("dhcp_vendor-class-identifier"))) {
  92. *e++ = 60;
  93. *e++ = strlen(ptr);
  94. while (*ptr)
  95. *e++ = *ptr++;
  96. }
  97. /* DHCP_CLIENT_IDENTIFIER = 61 */
  98. if ((ptr = getenv("dhcp_client_id"))) {
  99. *e++ = 61;
  100. *e++ = strlen(ptr);
  101. while (*ptr)
  102. *e++ = *ptr++;
  103. }
  104. return e;
  105. }
  106. u8 *dhcp_vendorex_proc(u8 *popt)
  107. {
  108. return NULL;
  109. }