Blame view
cmd/yaffs2.c
6.99 KB
753ac6108 u-boot: Update ya... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
/* Yaffs commands. * Modified by Charles Manning by adding ydevconfig command. * * Use ydevconfig to configure a mountpoint before use. * For example: * # Configure mountpt xxx using nand device 0 using blocks 100-500 * ydevconfig xxx 0 100 500 * # Mount it * ymount xxx * # yls, yrdm etc * yls -l xxx * yrdm xxx/boot-image 82000000 * ... */ |
90ef117b6 Incorporate yaffs... |
15 16 17 18 |
#include <common.h> #include <config.h> #include <command.h> |
753ac6108 u-boot: Update ya... |
19 20 |
#ifdef YAFFS2_DEBUG #define PRINTF(fmt, args...) printf(fmt, ##args) |
90ef117b6 Incorporate yaffs... |
21 |
#else |
753ac6108 u-boot: Update ya... |
22 |
#define PRINTF(fmt, args...) do { } while (0) |
90ef117b6 Incorporate yaffs... |
23 |
#endif |
753ac6108 u-boot: Update ya... |
24 25 26 27 |
extern void cmd_yaffs_dev_ls(void); extern void cmd_yaffs_tracemask(unsigned set, unsigned mask); extern void cmd_yaffs_devconfig(char *mp, int flash_dev, int start_block, int end_block); |
90ef117b6 Incorporate yaffs... |
28 29 30 |
extern void cmd_yaffs_mount(char *mp); extern void cmd_yaffs_umount(char *mp); extern void cmd_yaffs_read_file(char *fn); |
753ac6108 u-boot: Update ya... |
31 |
extern void cmd_yaffs_write_file(char *fn, char bval, int sizeOfFile); |
90ef117b6 Incorporate yaffs... |
32 33 34 35 36 37 38 |
extern void cmd_yaffs_ls(const char *mountpt, int longlist); extern void cmd_yaffs_mwrite_file(char *fn, char *addr, int size); extern void cmd_yaffs_mread_file(char *fn, char *addr); extern void cmd_yaffs_mkdir(const char *dir); extern void cmd_yaffs_rmdir(const char *dir); extern void cmd_yaffs_rm(const char *path); extern void cmd_yaffs_mv(const char *oldPath, const char *newPath); |
753ac6108 u-boot: Update ya... |
39 40 41 42 43 44 45 46 47 |
extern int yaffs_dump_dev(const char *path); /* ytrace - show/set yaffs trace mask */ int do_ytrace(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { if (argc > 1) cmd_yaffs_tracemask(1, simple_strtol(argv[1], NULL, 16)); else cmd_yaffs_tracemask(0, 0); |
90ef117b6 Incorporate yaffs... |
48 |
|
753ac6108 u-boot: Update ya... |
49 50 |
return 0; } |
90ef117b6 Incorporate yaffs... |
51 |
|
753ac6108 u-boot: Update ya... |
52 53 |
/* ydevls - lists yaffs mount points. */ int do_ydevls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
90ef117b6 Incorporate yaffs... |
54 |
{ |
753ac6108 u-boot: Update ya... |
55 |
cmd_yaffs_dev_ls(); |
4b0708093 Coding Style clea... |
56 |
|
753ac6108 u-boot: Update ya... |
57 |
return 0; |
90ef117b6 Incorporate yaffs... |
58 |
} |
753ac6108 u-boot: Update ya... |
59 60 |
/* ydevconfig mount_pt mtd_dev_num start_block end_block */ int do_ydevconfig(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
90ef117b6 Incorporate yaffs... |
61 |
{ |
753ac6108 u-boot: Update ya... |
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
char *mtpoint; int mtd_dev; int start_block; int end_block; if (argc != 5) { printf ("Bad arguments: ydevconfig mount_pt mtd_dev start_block end_block "); return -1; } mtpoint = argv[1]; mtd_dev = simple_strtol(argv[2], NULL, 16); start_block = simple_strtol(argv[3], NULL, 16); end_block = simple_strtol(argv[4], NULL, 16); |
4b0708093 Coding Style clea... |
78 |
|
753ac6108 u-boot: Update ya... |
79 80 81 |
cmd_yaffs_devconfig(mtpoint, mtd_dev, start_block, end_block); return 0; |
90ef117b6 Incorporate yaffs... |
82 |
} |
753ac6108 u-boot: Update ya... |
83 |
int do_ymount(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
90ef117b6 Incorporate yaffs... |
84 |
{ |
753ac6108 u-boot: Update ya... |
85 86 87 88 89 90 91 92 93 94 95 |
char *mtpoint; if (argc != 2) { printf("Bad arguments: ymount mount_pt "); return -1; } mtpoint = argv[1]; printf("Mounting yaffs2 mount point %s ", mtpoint); |
4b0708093 Coding Style clea... |
96 |
|
753ac6108 u-boot: Update ya... |
97 |
cmd_yaffs_mount(mtpoint); |
90ef117b6 Incorporate yaffs... |
98 |
|
753ac6108 u-boot: Update ya... |
99 |
return 0; |
90ef117b6 Incorporate yaffs... |
100 |
} |
753ac6108 u-boot: Update ya... |
101 |
int do_yumount(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
90ef117b6 Incorporate yaffs... |
102 |
{ |
753ac6108 u-boot: Update ya... |
103 |
char *mtpoint; |
90ef117b6 Incorporate yaffs... |
104 |
|
753ac6108 u-boot: Update ya... |
105 106 107 108 109 |
if (argc != 2) { printf("Bad arguments: yumount mount_pt "); return -1; } |
90ef117b6 Incorporate yaffs... |
110 |
|
753ac6108 u-boot: Update ya... |
111 112 113 114 115 116 |
mtpoint = argv[1]; printf("Unmounting yaffs2 mount point %s ", mtpoint); cmd_yaffs_umount(mtpoint); return 0; |
90ef117b6 Incorporate yaffs... |
117 |
} |
753ac6108 u-boot: Update ya... |
118 |
int do_yls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
90ef117b6 Incorporate yaffs... |
119 |
{ |
753ac6108 u-boot: Update ya... |
120 121 122 123 124 125 126 |
char *dirname; if (argc < 2 || argc > 3 || (argc == 3 && strcmp(argv[1], "-l"))) { printf("Bad arguments: yls [-l] dir "); return -1; } |
90ef117b6 Incorporate yaffs... |
127 |
|
753ac6108 u-boot: Update ya... |
128 |
dirname = argv[argc - 1]; |
90ef117b6 Incorporate yaffs... |
129 |
|
753ac6108 u-boot: Update ya... |
130 |
cmd_yaffs_ls(dirname, (argc > 2) ? 1 : 0); |
90ef117b6 Incorporate yaffs... |
131 |
|
753ac6108 u-boot: Update ya... |
132 |
return 0; |
90ef117b6 Incorporate yaffs... |
133 |
} |
753ac6108 u-boot: Update ya... |
134 |
int do_yrd(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
90ef117b6 Incorporate yaffs... |
135 |
{ |
753ac6108 u-boot: Update ya... |
136 137 138 139 140 141 142 |
char *filename; if (argc != 2) { printf("Bad arguments: yrd file_name "); return -1; } |
90ef117b6 Incorporate yaffs... |
143 |
|
753ac6108 u-boot: Update ya... |
144 |
filename = argv[1]; |
90ef117b6 Incorporate yaffs... |
145 |
|
753ac6108 u-boot: Update ya... |
146 147 148 149 150 151 152 |
printf("Reading file %s ", filename); cmd_yaffs_read_file(filename); printf("done "); return 0; |
90ef117b6 Incorporate yaffs... |
153 |
} |
753ac6108 u-boot: Update ya... |
154 |
int do_ywr(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
90ef117b6 Incorporate yaffs... |
155 |
{ |
753ac6108 u-boot: Update ya... |
156 157 158 159 160 161 162 163 164 |
char *filename; ulong value; ulong numValues; if (argc != 4) { printf("Bad arguments: ywr file_name value n_values "); return -1; } |
90ef117b6 Incorporate yaffs... |
165 |
|
753ac6108 u-boot: Update ya... |
166 167 168 |
filename = argv[1]; value = simple_strtoul(argv[2], NULL, 16); numValues = simple_strtoul(argv[3], NULL, 16); |
90ef117b6 Incorporate yaffs... |
169 |
|
753ac6108 u-boot: Update ya... |
170 171 172 173 174 175 176 177 |
printf("Writing value (%lx) %lx times to %s... ", value, numValues, filename); cmd_yaffs_write_file(filename, value, numValues); printf("done "); return 0; |
90ef117b6 Incorporate yaffs... |
178 |
} |
753ac6108 u-boot: Update ya... |
179 |
int do_yrdm(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
90ef117b6 Incorporate yaffs... |
180 |
{ |
753ac6108 u-boot: Update ya... |
181 182 183 184 185 186 187 188 |
char *filename; ulong addr; if (argc != 3) { printf("Bad arguments: yrdm file_name addr "); return -1; } |
90ef117b6 Incorporate yaffs... |
189 |
|
753ac6108 u-boot: Update ya... |
190 191 |
filename = argv[1]; addr = simple_strtoul(argv[2], NULL, 16); |
90ef117b6 Incorporate yaffs... |
192 |
|
753ac6108 u-boot: Update ya... |
193 194 195 |
cmd_yaffs_mread_file(filename, (char *)addr); return 0; |
90ef117b6 Incorporate yaffs... |
196 |
} |
753ac6108 u-boot: Update ya... |
197 |
int do_ywrm(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
90ef117b6 Incorporate yaffs... |
198 |
{ |
753ac6108 u-boot: Update ya... |
199 200 201 202 203 204 205 206 207 208 209 210 211 |
char *filename; ulong addr; ulong size; if (argc != 4) { printf("Bad arguments: ywrm file_name addr size "); return -1; } filename = argv[1]; addr = simple_strtoul(argv[2], NULL, 16); size = simple_strtoul(argv[3], NULL, 16); |
90ef117b6 Incorporate yaffs... |
212 |
|
753ac6108 u-boot: Update ya... |
213 |
cmd_yaffs_mwrite_file(filename, (char *)addr, size); |
90ef117b6 Incorporate yaffs... |
214 |
|
753ac6108 u-boot: Update ya... |
215 |
return 0; |
90ef117b6 Incorporate yaffs... |
216 |
} |
753ac6108 u-boot: Update ya... |
217 |
int do_ymkdir(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
90ef117b6 Incorporate yaffs... |
218 |
{ |
753ac6108 u-boot: Update ya... |
219 |
char *dirname; |
90ef117b6 Incorporate yaffs... |
220 |
|
753ac6108 u-boot: Update ya... |
221 222 223 224 225 |
if (argc != 2) { printf("Bad arguments: ymkdir dir_name "); return -1; } |
90ef117b6 Incorporate yaffs... |
226 |
|
753ac6108 u-boot: Update ya... |
227 228 229 230 |
dirname = argv[1]; cmd_yaffs_mkdir(dirname); return 0; |
90ef117b6 Incorporate yaffs... |
231 |
} |
753ac6108 u-boot: Update ya... |
232 |
int do_yrmdir(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
90ef117b6 Incorporate yaffs... |
233 |
{ |
753ac6108 u-boot: Update ya... |
234 235 236 237 238 239 240 |
char *dirname; if (argc != 2) { printf("Bad arguments: yrmdir dir_name "); return -1; } |
90ef117b6 Incorporate yaffs... |
241 |
|
753ac6108 u-boot: Update ya... |
242 243 |
dirname = argv[1]; cmd_yaffs_rmdir(dirname); |
90ef117b6 Incorporate yaffs... |
244 |
|
753ac6108 u-boot: Update ya... |
245 |
return 0; |
90ef117b6 Incorporate yaffs... |
246 |
} |
753ac6108 u-boot: Update ya... |
247 |
int do_yrm(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
90ef117b6 Incorporate yaffs... |
248 |
{ |
753ac6108 u-boot: Update ya... |
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
char *name; if (argc != 2) { printf("Bad arguments: yrm name "); return -1; } name = argv[1]; cmd_yaffs_rm(name); return 0; } int do_ymv(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { char *oldPath; char *newPath; if (argc != 3) { printf("Bad arguments: ymv old_path new_path "); return -1; } oldPath = argv[1]; newPath = argv[2]; cmd_yaffs_mv(newPath, oldPath); return 0; |
90ef117b6 Incorporate yaffs... |
281 |
} |
753ac6108 u-boot: Update ya... |
282 283 |
U_BOOT_CMD(ytrace, 2, 0, do_ytrace, "show/set yaffs trace mask", |
5bd15b7a5 cmd_yaffs: Clean ... |
284 |
"[new_mask] show/set yaffs trace mask"); |
753ac6108 u-boot: Update ya... |
285 286 287 288 289 290 |
U_BOOT_CMD(ydevls, 1, 0, do_ydevls, "list yaffs mount points", "list yaffs mount points"); U_BOOT_CMD(ydevconfig, 5, 0, do_ydevconfig, "configure yaffs mount point", |
5bd15b7a5 cmd_yaffs: Clean ... |
291 |
"mtpoint mtd_id start_block end_block configures a yaffs2 mount point"); |
753ac6108 u-boot: Update ya... |
292 293 |
U_BOOT_CMD(ymount, 2, 0, do_ymount, |
5bd15b7a5 cmd_yaffs: Clean ... |
294 |
"mount yaffs", "mtpoint mounts a yaffs2 mount point"); |
753ac6108 u-boot: Update ya... |
295 296 |
U_BOOT_CMD(yumount, 2, 0, do_yumount, |
5bd15b7a5 cmd_yaffs: Clean ... |
297 |
"unmount yaffs", "mtpoint unmounts a yaffs2 mount point"); |
753ac6108 u-boot: Update ya... |
298 |
|
5bd15b7a5 cmd_yaffs: Clean ... |
299 |
U_BOOT_CMD(yls, 3, 0, do_yls, "yaffs ls", "[-l] dirname"); |
753ac6108 u-boot: Update ya... |
300 301 |
U_BOOT_CMD(yrd, 2, 0, do_yrd, |
5bd15b7a5 cmd_yaffs: Clean ... |
302 |
"read file from yaffs", "path read file from yaffs"); |
753ac6108 u-boot: Update ya... |
303 304 305 |
U_BOOT_CMD(ywr, 4, 0, do_ywr, "write file to yaffs", |
5bd15b7a5 cmd_yaffs: Clean ... |
306 |
"filename value num_vlues write values to yaffs file"); |
753ac6108 u-boot: Update ya... |
307 308 309 |
U_BOOT_CMD(yrdm, 3, 0, do_yrdm, "read file to memory from yaffs", |
5bd15b7a5 cmd_yaffs: Clean ... |
310 |
"filename offset reads yaffs file into memory"); |
753ac6108 u-boot: Update ya... |
311 312 313 |
U_BOOT_CMD(ywrm, 4, 0, do_ywrm, "write file from memory to yaffs", |
5bd15b7a5 cmd_yaffs: Clean ... |
314 |
"filename offset size writes memory to yaffs file"); |
753ac6108 u-boot: Update ya... |
315 316 |
U_BOOT_CMD(ymkdir, 2, 0, do_ymkdir, |
5bd15b7a5 cmd_yaffs: Clean ... |
317 |
"YAFFS mkdir", "dir create a yaffs directory"); |
753ac6108 u-boot: Update ya... |
318 319 |
U_BOOT_CMD(yrmdir, 2, 0, do_yrmdir, |
5bd15b7a5 cmd_yaffs: Clean ... |
320 |
"YAFFS rmdir", "dirname removes a yaffs directory"); |
753ac6108 u-boot: Update ya... |
321 |
|
5bd15b7a5 cmd_yaffs: Clean ... |
322 |
U_BOOT_CMD(yrm, 2, 0, do_yrm, "YAFFS rm", "path removes a yaffs file"); |
753ac6108 u-boot: Update ya... |
323 324 325 |
U_BOOT_CMD(ymv, 4, 0, do_ymv, "YAFFS mv", |
5bd15b7a5 cmd_yaffs: Clean ... |
326 |
"old_path new_path moves/rename files within a yaffs mount point"); |