Blame view
cmd/fat.c
4.43 KB
83d290c56 SPDX: Convert all... |
1 |
// SPDX-License-Identifier: GPL-2.0+ |
71f951180 * Fix CONFIG_NET_... |
2 3 4 |
/* * (C) Copyright 2002 * Richard Jones, rjones@nexus-tech.net |
71f951180 * Fix CONFIG_NET_... |
5 6 7 8 9 10 11 |
*/ /* * Boot support */ #include <common.h> #include <command.h> |
71f951180 * Fix CONFIG_NET_... |
12 13 14 |
#include <s_record.h> #include <net.h> #include <ata.h> |
31e997f92 fs: fatwrite: use... |
15 |
#include <asm/io.h> |
0eb25b619 common: Make sure... |
16 |
#include <mapmem.h> |
735dd97b1 [PATCH 1_4] Merge... |
17 |
#include <part.h> |
71f951180 * Fix CONFIG_NET_... |
18 |
#include <fat.h> |
045fa1e11 fs: add filesyste... |
19 |
#include <fs.h> |
7205e4075 * Patches by Deni... |
20 |
|
cf6598193 fs: implement siz... |
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
int do_fat_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { return do_size(cmdtp, flag, argc, argv, FS_TYPE_FAT); } U_BOOT_CMD( fatsize, 4, 0, do_fat_size, "determine a file's size", "<interface> <dev[:part]> <filename> " " - Find file 'filename' from 'dev' on 'interface' " " and determine its size." ); |
144499823 common: Move func... |
35 |
int do_fat_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
71f951180 * Fix CONFIG_NET_... |
36 |
{ |
b770e88a6 Fix number base h... |
37 |
return do_load(cmdtp, flag, argc, argv, FS_TYPE_FAT); |
71f951180 * Fix CONFIG_NET_... |
38 |
} |
7205e4075 * Patches by Deni... |
39 |
|
0d4983930 Patch by Kenneth ... |
40 |
U_BOOT_CMD( |
1170e634d FAT: Make it poss... |
41 |
fatload, 7, 0, do_fat_fsload, |
2fb2604d5 Command usage cle... |
42 |
"load binary file from a dos filesystem", |
6b367467f Fix help text of ... |
43 44 |
"<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]] " |
1170e634d FAT: Make it poss... |
45 46 47 48 49 50 51 52 53 54 |
" - Load binary file 'filename' from 'dev' on 'interface' " " to address 'addr' from dos filesystem. " " 'pos' gives the file position to start loading from. " " If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'. " " 'bytes' gives the size to load. If 'bytes' is 0 or omitted, " |
3f83c87ee fs: fix number ba... |
55 56 |
" the load stops on end of file. " |
01fac041c cmd_fat.c: Note i... |
57 58 59 60 |
" If either 'pos' or 'bytes' are not aligned to " " ARCH_DMA_MINALIGN then a misaligned buffer warning will " |
b770e88a6 Fix number base h... |
61 |
" be printed and performance will suffer for the load." |
b0fce99bf Fix some missing ... |
62 |
); |
088f1b199 common/cmd_*.c: s... |
63 |
static int do_fat_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
71f951180 * Fix CONFIG_NET_... |
64 |
{ |
045fa1e11 fs: add filesyste... |
65 |
return do_ls(cmdtp, flag, argc, argv, FS_TYPE_FAT); |
71f951180 * Fix CONFIG_NET_... |
66 |
} |
0d4983930 Patch by Kenneth ... |
67 |
U_BOOT_CMD( |
7205e4075 * Patches by Deni... |
68 |
fatls, 4, 1, do_fat_ls, |
2fb2604d5 Command usage cle... |
69 |
"list files in a directory (default /)", |
cfda5aeab cmd_fat: use comm... |
70 71 |
"<interface> [<dev[:part]>] [directory] " |
a89c33db9 General help mess... |
72 |
" - list files from 'dev' on 'interface' in a 'directory'" |
b0fce99bf Fix some missing ... |
73 |
); |
088f1b199 common/cmd_*.c: s... |
74 75 |
static int do_fat_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
71f951180 * Fix CONFIG_NET_... |
76 |
{ |
cfda5aeab cmd_fat: use comm... |
77 |
int dev, part; |
4101f6879 dm: Drop the bloc... |
78 |
struct blk_desc *dev_desc; |
cfda5aeab cmd_fat: use comm... |
79 |
disk_partition_t info; |
71f951180 * Fix CONFIG_NET_... |
80 |
|
7205e4075 * Patches by Deni... |
81 |
if (argc < 2) { |
cfda5aeab cmd_fat: use comm... |
82 83 |
printf("usage: fatinfo <interface> [<dev[:part]>] "); |
7385c28e9 fs/fat: Big code ... |
84 |
return 0; |
7205e4075 * Patches by Deni... |
85 |
} |
cfda5aeab cmd_fat: use comm... |
86 |
|
e35929e4a dm: blk: Rename g... |
87 |
part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1); |
cfda5aeab cmd_fat: use comm... |
88 |
if (part < 0) |
7205e4075 * Patches by Deni... |
89 |
return 1; |
cfda5aeab cmd_fat: use comm... |
90 |
|
bcce53d04 dm: block: Rename... |
91 |
dev = dev_desc->devnum; |
5e8f98319 FAT: implement fa... |
92 |
if (fat_set_blk_dev(dev_desc, &info) != 0) { |
7385c28e9 fs/fat: Big code ... |
93 94 95 96 |
printf(" ** Unable to use %s %d:%d for fatinfo ** ", argv[1], dev, part); |
7205e4075 * Patches by Deni... |
97 98 |
return 1; } |
7385c28e9 fs/fat: Big code ... |
99 |
return file_fat_detectfs(); |
71f951180 * Fix CONFIG_NET_... |
100 |
} |
0d4983930 Patch by Kenneth ... |
101 |
U_BOOT_CMD( |
7205e4075 * Patches by Deni... |
102 |
fatinfo, 3, 1, do_fat_fsinfo, |
2fb2604d5 Command usage cle... |
103 |
"print information about filesystem", |
cfda5aeab cmd_fat: use comm... |
104 105 |
"<interface> [<dev[:part]>] " |
a89c33db9 General help mess... |
106 |
" - print information about filesystem from 'dev' on 'interface'" |
b0fce99bf Fix some missing ... |
107 |
); |
656f4c653 cmd_fat: add FAT ... |
108 109 110 111 112 |
#ifdef CONFIG_FAT_WRITE static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { |
1ad0b98a0 fat: Prepare API ... |
113 114 |
loff_t size; int ret; |
656f4c653 cmd_fat: add FAT ... |
115 116 |
unsigned long addr; unsigned long count; |
cda40b2ae cmd: fat: add off... |
117 |
long offset; |
4101f6879 dm: Drop the bloc... |
118 |
struct blk_desc *dev_desc = NULL; |
cfda5aeab cmd_fat: use comm... |
119 |
disk_partition_t info; |
656f4c653 cmd_fat: add FAT ... |
120 121 |
int dev = 0; int part = 1; |
31e997f92 fs: fatwrite: use... |
122 |
void *buf; |
656f4c653 cmd_fat: add FAT ... |
123 124 125 |
if (argc < 5) return cmd_usage(cmdtp); |
e35929e4a dm: blk: Rename g... |
126 |
part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1); |
cfda5aeab cmd_fat: use comm... |
127 |
if (part < 0) |
656f4c653 cmd_fat: add FAT ... |
128 |
return 1; |
cfda5aeab cmd_fat: use comm... |
129 |
|
bcce53d04 dm: block: Rename... |
130 |
dev = dev_desc->devnum; |
cfda5aeab cmd_fat: use comm... |
131 |
|
5e8f98319 FAT: implement fa... |
132 |
if (fat_set_blk_dev(dev_desc, &info) != 0) { |
656f4c653 cmd_fat: add FAT ... |
133 134 135 136 137 138 139 |
printf(" ** Unable to use %s %d:%d for fatwrite ** ", argv[1], dev, part); return 1; } addr = simple_strtoul(argv[3], NULL, 16); |
454e3d903 cmd/fat: Do not c... |
140 |
count = (argc <= 5) ? 0 : simple_strtoul(argv[5], NULL, 16); |
cda40b2ae cmd: fat: add off... |
141 142 |
/* offset should be a hex, but "-1" is allowed */ offset = (argc <= 6) ? 0 : simple_strtol(argv[6], NULL, 16); |
656f4c653 cmd_fat: add FAT ... |
143 |
|
31e997f92 fs: fatwrite: use... |
144 |
buf = map_sysmem(addr, count); |
cda40b2ae cmd: fat: add off... |
145 |
ret = file_fat_write(argv[4], buf, offset, count, &size); |
31e997f92 fs: fatwrite: use... |
146 |
unmap_sysmem(buf); |
1ad0b98a0 fat: Prepare API ... |
147 |
if (ret < 0) { |
656f4c653 cmd_fat: add FAT ... |
148 149 150 151 152 153 |
printf(" ** Unable to write \"%s\" from %s %d:%d ** ", argv[4], argv[1], dev, part); return 1; } |
1ad0b98a0 fat: Prepare API ... |
154 155 |
printf("%llu bytes written ", size); |
656f4c653 cmd_fat: add FAT ... |
156 157 158 159 160 |
return 0; } U_BOOT_CMD( |
cda40b2ae cmd: fat: add off... |
161 |
fatwrite, 7, 0, do_fat_fswrite, |
656f4c653 cmd_fat: add FAT ... |
162 |
"write file into a dos filesystem", |
cda40b2ae cmd: fat: add off... |
163 164 |
"<interface> <dev[:part]> <addr> <filename> [<bytes> [<offset>]] " |
656f4c653 cmd_fat: add FAT ... |
165 166 167 168 |
" - write file 'filename' from the address 'addr' in RAM " " to 'dev' on 'interface'" ); |
0349da510 cmd: fat: add fat... |
169 |
|
d4b751e9f cmd: fat: add fat... |
170 171 172 173 174 175 176 177 178 179 180 181 |
static int do_fat_rm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { return do_rm(cmdtp, flag, argc, argv, FS_TYPE_FAT); } U_BOOT_CMD( fatrm, 4, 1, do_fat_rm, "delete a file", "<interface> [<dev[:part]>] <filename> " " - delete a file from 'dev' on 'interface'" ); |
0349da510 cmd: fat: add fat... |
182 183 184 185 186 187 188 189 190 191 192 193 194 |
static int do_fat_mkdir(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { return do_mkdir(cmdtp, flag, argc, argv, FS_TYPE_FAT); } U_BOOT_CMD( fatmkdir, 4, 1, do_fat_mkdir, "create a directory", "<interface> [<dev[:part]>] <directory> " " - create a directory in 'dev' on 'interface'" ); |
656f4c653 cmd_fat: add FAT ... |
195 |
#endif |