Blame view
env/fat.c
3.1 KB
83d290c56 SPDX: Convert all... |
1 |
// SPDX-License-Identifier: GPL-2.0+ |
57210c7cc Add support for l... |
2 3 4 5 6 |
/* * (c) Copyright 2011 by Tigris Elektronik GmbH * * Author: * Maximilian Schwerin <mvs@tigris.de> |
57210c7cc Add support for l... |
7 8 9 10 11 |
*/ #include <common.h> #include <command.h> |
0ac7d722e env: Move get/set... |
12 |
#include <env.h> |
f3998fdc4 env: Rename envir... |
13 |
#include <env_internal.h> |
57210c7cc Add support for l... |
14 15 |
#include <linux/stddef.h> #include <malloc.h> |
cf92e05c0 Move ALLOC_CACHE_... |
16 |
#include <memalign.h> |
57210c7cc Add support for l... |
17 18 19 20 |
#include <search.h> #include <errno.h> #include <fat.h> #include <mmc.h> |
4415f1d1f env: Create a loc... |
21 22 23 24 25 26 27 28 29 30 31 |
#ifdef CONFIG_SPL_BUILD /* TODO(sjg@chromium.org): Figure out why this is needed */ # if !defined(CONFIG_TARGET_AM335X_EVM) || defined(CONFIG_SPL_OS_BOOT) # define LOADENV # endif #else # define LOADENV # if defined(CONFIG_CMD_SAVEENV) # define CMD_SAVEENV # endif #endif |
4415f1d1f env: Create a loc... |
32 |
#ifdef CMD_SAVEENV |
e5bce247b env: Switch over ... |
33 |
static int env_fat_save(void) |
57210c7cc Add support for l... |
34 |
{ |
cda87ec55 Fix misaligned bu... |
35 |
env_t __aligned(ARCH_DMA_MINALIGN) env_new; |
4101f6879 dm: Drop the bloc... |
36 |
struct blk_desc *dev_desc = NULL; |
be354c1a2 env_fat: use get_... |
37 38 |
disk_partition_t info; int dev, part; |
9aa90c1df env: checkpatch c... |
39 |
int err; |
1ad0b98a0 fat: Prepare API ... |
40 |
loff_t size; |
57210c7cc Add support for l... |
41 |
|
7ce1526ed env: Add env_expo... |
42 43 44 |
err = env_export(&env_new); if (err) return err; |
57210c7cc Add support for l... |
45 |
|
43ba3c59c env: Migrate CONF... |
46 47 |
part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE, CONFIG_ENV_FAT_DEVICE_AND_PART, |
be354c1a2 env_fat: use get_... |
48 49 |
&dev_desc, &info, 1); if (part < 0) |
57210c7cc Add support for l... |
50 |
return 1; |
9aa90c1df env: checkpatch c... |
51 |
|
bcce53d04 dm: block: Rename... |
52 |
dev = dev_desc->devnum; |
be354c1a2 env_fat: use get_... |
53 |
if (fat_set_blk_dev(dev_desc, &info) != 0) { |
d0816da54 env: fat: Make th... |
54 55 56 57 58 59 |
/* * This printf is embedded in the messages from env_save that * will calling it. The missing is intentional. */ printf("Unable to use %s %d:%d... ", |
43ba3c59c env: Migrate CONF... |
60 |
CONFIG_ENV_FAT_INTERFACE, dev, part); |
57210c7cc Add support for l... |
61 62 |
return 1; } |
43ba3c59c env: Migrate CONF... |
63 |
err = file_fat_write(CONFIG_ENV_FAT_FILE, (void *)&env_new, 0, sizeof(env_t), |
1ad0b98a0 fat: Prepare API ... |
64 |
&size); |
9aa90c1df env: checkpatch c... |
65 |
if (err == -1) { |
d0816da54 env: fat: Make th... |
66 67 68 69 70 71 |
/* * This printf is embedded in the messages from env_save that * will calling it. The missing is intentional. */ printf("Unable to write \"%s\" from %s%d:%d... ", |
43ba3c59c env: Migrate CONF... |
72 |
CONFIG_ENV_FAT_FILE, CONFIG_ENV_FAT_INTERFACE, dev, part); |
57210c7cc Add support for l... |
73 74 |
return 1; } |
57210c7cc Add support for l... |
75 76 |
return 0; } |
4415f1d1f env: Create a loc... |
77 |
#endif /* CMD_SAVEENV */ |
57210c7cc Add support for l... |
78 |
|
4415f1d1f env: Create a loc... |
79 |
#ifdef LOADENV |
c59519919 env: Adjust the l... |
80 |
static int env_fat_load(void) |
57210c7cc Add support for l... |
81 |
{ |
6d1966e12 env_fat.c: Make s... |
82 |
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE); |
4101f6879 dm: Drop the bloc... |
83 |
struct blk_desc *dev_desc = NULL; |
be354c1a2 env_fat: use get_... |
84 85 |
disk_partition_t info; int dev, part; |
9aa90c1df env: checkpatch c... |
86 |
int err; |
57210c7cc Add support for l... |
87 |
|
95058fbb9 env: mmc/fat/ext4... |
88 |
#ifdef CONFIG_MMC |
26862b4a4 env: mmc/fat/ext4... |
89 90 |
if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc")) mmc_initialize(NULL); |
95058fbb9 env: mmc/fat/ext4... |
91 |
#endif |
26862b4a4 env: mmc/fat/ext4... |
92 |
|
43ba3c59c env: Migrate CONF... |
93 94 |
part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE, CONFIG_ENV_FAT_DEVICE_AND_PART, |
be354c1a2 env_fat: use get_... |
95 96 97 |
&dev_desc, &info, 1); if (part < 0) goto err_env_relocate; |
bcce53d04 dm: block: Rename... |
98 |
dev = dev_desc->devnum; |
be354c1a2 env_fat: use get_... |
99 |
if (fat_set_blk_dev(dev_desc, &info) != 0) { |
d0816da54 env: fat: Make th... |
100 101 102 103 104 105 |
/* * This printf is embedded in the messages from env_save that * will calling it. The missing is intentional. */ printf("Unable to use %s %d:%d... ", |
43ba3c59c env: Migrate CONF... |
106 |
CONFIG_ENV_FAT_INTERFACE, dev, part); |
be354c1a2 env_fat: use get_... |
107 |
goto err_env_relocate; |
57210c7cc Add support for l... |
108 |
} |
43ba3c59c env: Migrate CONF... |
109 |
err = file_fat_read(CONFIG_ENV_FAT_FILE, buf, CONFIG_ENV_SIZE); |
9aa90c1df env: checkpatch c... |
110 |
if (err == -1) { |
d0816da54 env: fat: Make th... |
111 112 113 114 115 116 |
/* * This printf is embedded in the messages from env_save that * will calling it. The missing is intentional. */ printf("Unable to read \"%s\" from %s%d:%d... ", |
43ba3c59c env: Migrate CONF... |
117 |
CONFIG_ENV_FAT_FILE, CONFIG_ENV_FAT_INTERFACE, dev, part); |
be354c1a2 env_fat: use get_... |
118 |
goto err_env_relocate; |
57210c7cc Add support for l... |
119 |
} |
2166ebf78 env: make env dri... |
120 |
return env_import(buf, 1); |
be354c1a2 env_fat: use get_... |
121 122 |
err_env_relocate: |
0ac7d722e env: Move get/set... |
123 |
env_set_default(NULL, 0); |
c59519919 env: Adjust the l... |
124 125 |
return -EIO; |
57210c7cc Add support for l... |
126 |
} |
4415f1d1f env: Create a loc... |
127 128 129 130 |
#endif /* LOADENV */ U_BOOT_ENV_LOCATION(fat) = { .location = ENVL_FAT, |
ac358beb8 env: Drop the env... |
131 |
ENV_NAME("FAT") |
4415f1d1f env: Create a loc... |
132 |
#ifdef LOADENV |
e5bce247b env: Switch over ... |
133 |
.load = env_fat_load, |
4415f1d1f env: Create a loc... |
134 135 |
#endif #ifdef CMD_SAVEENV |
e5bce247b env: Switch over ... |
136 |
.save = env_save_ptr(env_fat_save), |
4415f1d1f env: Create a loc... |
137 |
#endif |
4415f1d1f env: Create a loc... |
138 |
}; |