3 * Andre Schwarz, Matrix Vision GmbH, andre.schwarz@matrix-vision.de
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <environment.h>
14 DECLARE_GLOBAL_DATA_PTR;
16 #ifndef CONFIG_ENV_IS_NOWHERE
17 static char* entries_to_keep[] = {
18 "serial#", "ethaddr", "eth1addr", "model_info", "sensor_cnt",
19 "fpgadatasize", "ddr_size", "use_dhcp", "use_static_ipaddr",
20 "static_ipaddr", "static_netmask", "static_gateway",
21 "syslog", "watchdog", "netboot", "evo8serialnumber" };
23 #define MV_MAX_ENV_ENTRY_LENGTH 64
24 #define MV_KEEP_ENTRIES ARRAY_SIZE(entries_to_keep)
26 void mv_reset_environment(void)
29 char *s[MV_KEEP_ENTRIES];
30 char entries[MV_KEEP_ENTRIES][MV_MAX_ENV_ENTRY_LENGTH];
32 printf("\n*** RESET ENVIRONMENT ***\n");
34 memset(entries, 0, MV_KEEP_ENTRIES * MV_MAX_ENV_ENTRY_LENGTH);
35 for (i = 0; i < MV_KEEP_ENTRIES; i++) {
36 s[i] = getenv(entries_to_keep[i]);
38 printf("save '%s' : %s\n", entries_to_keep[i], s[i]);
39 strncpy(entries[i], s[i], MV_MAX_ENV_ENTRY_LENGTH);
46 for (i = 0; i < MV_KEEP_ENTRIES; i++) {
48 printf("restore '%s' : %s\n", entries_to_keep[i], s[i]);
49 setenv(entries_to_keep[i], s[i]);
57 int mv_load_fpga(void)
61 void *fpga_data = NULL;
62 char *datastr = getenv("fpgadata");
63 char *sizestr = getenv("fpgadatasize");
65 if (getenv("skip_fpga")) {
66 printf("found 'skip_fpga' -> FPGA _not_ loaded !\n");
69 printf("loading FPGA\n");
72 fpga_data = (void *)simple_strtoul(datastr, NULL, 16);
74 data_size = (size_t)simple_strtoul(sizestr, NULL, 16);
76 printf("fpgadatasize invalid -> FPGA _not_ loaded !\n");
80 result = fpga_load(0, fpga_data, data_size);
82 bootstage_mark(BOOTSTAGE_ID_START);
87 u8 *dhcp_vendorex_prep(u8 *e)
91 /* DHCP vendor-class-identifier = 60 */
92 if ((ptr = getenv("dhcp_vendor-class-identifier"))) {
98 /* DHCP_CLIENT_IDENTIFIER = 61 */
99 if ((ptr = getenv("dhcp_client_id"))) {
109 u8 *dhcp_vendorex_proc(u8 *popt)