William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 1 | #include <common.h> |
| 2 | |
| 3 | #include <config.h> |
| 4 | #include <command.h> |
| 5 | |
| 6 | #ifdef YAFFS2_DEBUG |
| 7 | #define PRINTF(fmt,args...) printf (fmt ,##args) |
| 8 | #else |
| 9 | #define PRINTF(fmt,args...) |
| 10 | #endif |
| 11 | |
| 12 | extern void cmd_yaffs_mount(char *mp); |
| 13 | extern void cmd_yaffs_umount(char *mp); |
| 14 | extern void cmd_yaffs_read_file(char *fn); |
| 15 | extern void cmd_yaffs_write_file(char *fn,char bval,int sizeOfFile); |
| 16 | extern void cmd_yaffs_ls(const char *mountpt, int longlist); |
| 17 | extern void cmd_yaffs_mwrite_file(char *fn, char *addr, int size); |
| 18 | extern void cmd_yaffs_mread_file(char *fn, char *addr); |
| 19 | extern void cmd_yaffs_mkdir(const char *dir); |
| 20 | extern void cmd_yaffs_rmdir(const char *dir); |
| 21 | extern void cmd_yaffs_rm(const char *path); |
| 22 | extern void cmd_yaffs_mv(const char *oldPath, const char *newPath); |
| 23 | |
| 24 | extern int yaffs_DumpDevStruct(const char *path); |
| 25 | |
| 26 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 27 | int do_ymount (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 28 | { |
| 29 | char *mtpoint = argv[1]; |
| 30 | cmd_yaffs_mount(mtpoint); |
Wolfgang Denk | 4b07080 | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 31 | |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 32 | return(0); |
| 33 | } |
| 34 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 35 | int do_yumount (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 36 | { |
| 37 | char *mtpoint = argv[1]; |
| 38 | cmd_yaffs_umount(mtpoint); |
Wolfgang Denk | 4b07080 | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 39 | |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 40 | return(0); |
| 41 | } |
| 42 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 43 | int do_yls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 44 | { |
| 45 | char *dirname = argv[argc-1]; |
Wolfgang Denk | 4b07080 | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 46 | |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 47 | cmd_yaffs_ls(dirname, (argc>2)?1:0); |
| 48 | |
| 49 | return(0); |
| 50 | } |
| 51 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 52 | int do_yrd (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 53 | { |
| 54 | char *filename = argv[1]; |
| 55 | printf ("Reading file %s ", filename); |
| 56 | |
| 57 | cmd_yaffs_read_file(filename); |
| 58 | |
| 59 | printf ("done\n"); |
| 60 | return(0); |
| 61 | } |
| 62 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 63 | int do_ywr (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 64 | { |
| 65 | char *filename = argv[1]; |
| 66 | ulong value = simple_strtoul(argv[2], NULL, 16); |
| 67 | ulong numValues = simple_strtoul(argv[3], NULL, 16); |
| 68 | |
| 69 | printf ("Writing value (%x) %x times to %s... ", value, numValues, filename); |
| 70 | |
| 71 | cmd_yaffs_write_file(filename,value,numValues); |
| 72 | |
| 73 | printf ("done\n"); |
| 74 | return(0); |
| 75 | } |
| 76 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 77 | int do_yrdm (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 78 | { |
| 79 | char *filename = argv[1]; |
| 80 | ulong addr = simple_strtoul(argv[2], NULL, 16); |
| 81 | |
| 82 | cmd_yaffs_mread_file(filename, (char *)addr); |
| 83 | |
| 84 | return(0); |
| 85 | } |
| 86 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 87 | int do_ywrm (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 88 | { |
| 89 | char *filename = argv[1]; |
| 90 | ulong addr = simple_strtoul(argv[2], NULL, 16); |
| 91 | ulong size = simple_strtoul(argv[3], NULL, 16); |
| 92 | |
| 93 | cmd_yaffs_mwrite_file(filename, (char *)addr, size); |
| 94 | |
| 95 | return(0); |
| 96 | } |
| 97 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 98 | int do_ymkdir (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 99 | { |
| 100 | char *dirname = argv[1]; |
| 101 | |
| 102 | cmd_yaffs_mkdir(dirname); |
| 103 | |
| 104 | return(0); |
| 105 | } |
| 106 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 107 | int do_yrmdir (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 108 | { |
| 109 | char *dirname = argv[1]; |
| 110 | |
| 111 | cmd_yaffs_rmdir(dirname); |
| 112 | |
| 113 | return(0); |
| 114 | } |
| 115 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 116 | int do_yrm (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 117 | { |
| 118 | char *path = argv[1]; |
| 119 | |
| 120 | cmd_yaffs_rm(path); |
| 121 | |
| 122 | return(0); |
| 123 | } |
| 124 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 125 | int do_ymv (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 126 | { |
| 127 | char *oldPath = argv[1]; |
| 128 | char *newPath = argv[2]; |
| 129 | |
| 130 | cmd_yaffs_mv(newPath, oldPath); |
| 131 | |
| 132 | return(0); |
| 133 | } |
| 134 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 135 | int do_ydump (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 136 | { |
| 137 | char *dirname = argv[1]; |
| 138 | if (yaffs_DumpDevStruct(dirname) != 0) |
Wolfgang Denk | 4b07080 | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 139 | printf("yaffs_DumpDevStruct returning error when dumping path: , %s\n", dirname); |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 140 | return 0; |
| 141 | } |
| 142 | |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 143 | U_BOOT_CMD( |
| 144 | ymount, 3, 0, do_ymount, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 145 | "mount yaffs", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 146 | "" |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 147 | ); |
| 148 | |
| 149 | U_BOOT_CMD( |
| 150 | yumount, 3, 0, do_yumount, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 151 | "unmount yaffs", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 152 | "" |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 153 | ); |
| 154 | |
| 155 | U_BOOT_CMD( |
| 156 | yls, 4, 0, do_yls, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 157 | "yaffs ls", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 158 | "[-l] name" |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 159 | ); |
| 160 | |
| 161 | U_BOOT_CMD( |
| 162 | yrd, 2, 0, do_yrd, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 163 | "read file from yaffs", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 164 | "filename" |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 165 | ); |
| 166 | |
| 167 | U_BOOT_CMD( |
| 168 | ywr, 4, 0, do_ywr, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 169 | "write file to yaffs", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 170 | "filename value num_vlues" |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 171 | ); |
| 172 | |
| 173 | U_BOOT_CMD( |
| 174 | yrdm, 3, 0, do_yrdm, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 175 | "read file to memory from yaffs", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 176 | "filename offset" |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 177 | ); |
| 178 | |
| 179 | U_BOOT_CMD( |
| 180 | ywrm, 4, 0, do_ywrm, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 181 | "write file from memory to yaffs", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 182 | "filename offset size" |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 183 | ); |
| 184 | |
| 185 | U_BOOT_CMD( |
| 186 | ymkdir, 2, 0, do_ymkdir, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 187 | "YAFFS mkdir", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 188 | "dirname" |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 189 | ); |
| 190 | |
| 191 | U_BOOT_CMD( |
| 192 | yrmdir, 2, 0, do_yrmdir, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 193 | "YAFFS rmdir", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 194 | "dirname" |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 195 | ); |
| 196 | |
| 197 | U_BOOT_CMD( |
| 198 | yrm, 2, 0, do_yrm, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 199 | "YAFFS rm", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 200 | "path" |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 201 | ); |
| 202 | |
| 203 | U_BOOT_CMD( |
| 204 | ymv, 4, 0, do_ymv, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 205 | "YAFFS mv", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 206 | "oldPath newPath" |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 207 | ); |
| 208 | |
| 209 | U_BOOT_CMD( |
| 210 | ydump, 2, 0, do_ydump, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 211 | "YAFFS device struct", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 212 | "dirname" |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 213 | ); |