2 * (c) Copyright 2011 by Tigris Elektronik GmbH
5 * Maximilian Schwerin <mvs@tigris.de>
7 * SPDX-License-Identifier: GPL-2.0+
13 #include <environment.h>
14 #include <linux/stddef.h>
21 char *env_name_spec = "FAT";
25 DECLARE_GLOBAL_DATA_PTR;
30 gd->env_addr = (ulong)&default_environment[0];
36 #ifdef CONFIG_CMD_SAVEENV
40 block_dev_desc_t *dev_desc = NULL;
41 int dev = FAT_ENV_DEVICE;
42 int part = FAT_ENV_PART;
45 err = env_export(&env_new);
50 if (strcmp(FAT_ENV_INTERFACE, "mmc") == 0) {
51 struct mmc *mmc = find_mmc_device(dev);
54 printf("no mmc device at slot %x\n", dev);
61 #endif /* CONFIG_MMC */
63 dev_desc = get_dev(FAT_ENV_INTERFACE, dev);
64 if (dev_desc == NULL) {
65 printf("Failed to find %s%d\n",
66 FAT_ENV_INTERFACE, dev);
70 err = fat_register_device(dev_desc, part);
72 printf("Failed to register %s%d:%d\n",
73 FAT_ENV_INTERFACE, dev, part);
77 err = file_fat_write(FAT_ENV_FILE, (void *)&env_new, sizeof(env_t));
79 printf("\n** Unable to write \"%s\" from %s%d:%d **\n",
80 FAT_ENV_FILE, FAT_ENV_INTERFACE, dev, part);
87 #endif /* CONFIG_CMD_SAVEENV */
89 void env_relocate_spec(void)
91 char buf[CONFIG_ENV_SIZE];
92 block_dev_desc_t *dev_desc = NULL;
93 int dev = FAT_ENV_DEVICE;
94 int part = FAT_ENV_PART;
98 if (strcmp(FAT_ENV_INTERFACE, "mmc") == 0) {
99 struct mmc *mmc = find_mmc_device(dev);
102 printf("no mmc device at slot %x\n", dev);
103 set_default_env(NULL);
110 #endif /* CONFIG_MMC */
112 dev_desc = get_dev(FAT_ENV_INTERFACE, dev);
113 if (dev_desc == NULL) {
114 printf("Failed to find %s%d\n",
115 FAT_ENV_INTERFACE, dev);
116 set_default_env(NULL);
120 err = fat_register_device(dev_desc, part);
122 printf("Failed to register %s%d:%d\n",
123 FAT_ENV_INTERFACE, dev, part);
124 set_default_env(NULL);
128 err = file_fat_read(FAT_ENV_FILE, (uchar *)&buf, CONFIG_ENV_SIZE);
130 printf("\n** Unable to read \"%s\" from %s%d:%d **\n",
131 FAT_ENV_FILE, FAT_ENV_INTERFACE, dev, part);
132 set_default_env(NULL);