Blame view
cmd/fat.c
3.71 KB
71f951180 * Fix CONFIG_NET_... |
1 2 3 4 |
/* * (C) Copyright 2002 * Richard Jones, rjones@nexus-tech.net * |
1a4596601 Add GPL-2.0+ SPDX... |
5 |
* SPDX-License-Identifier: GPL-2.0+ |
71f951180 * Fix CONFIG_NET_... |
6 7 8 9 10 11 12 |
*/ /* * Boot support */ #include <common.h> #include <command.h> |
71f951180 * Fix CONFIG_NET_... |
13 14 15 |
#include <s_record.h> #include <net.h> #include <ata.h> |
31e997f92 fs: fatwrite: use... |
16 |
#include <asm/io.h> |
0eb25b619 common: Make sure... |
17 |
#include <mapmem.h> |
735dd97b1 [PATCH 1_4] Merge... |
18 |
#include <part.h> |
71f951180 * Fix CONFIG_NET_... |
19 |
#include <fat.h> |
045fa1e11 fs: add filesyste... |
20 |
#include <fs.h> |
7205e4075 * Patches by Deni... |
21 |
|
cf6598193 fs: implement siz... |
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
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." ); |
54841ab50 Make sure that ar... |
36 |
int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
71f951180 * Fix CONFIG_NET_... |
37 |
{ |
b770e88a6 Fix number base h... |
38 |
return do_load(cmdtp, flag, argc, argv, FS_TYPE_FAT); |
71f951180 * Fix CONFIG_NET_... |
39 |
} |
7205e4075 * Patches by Deni... |
40 |
|
0d4983930 Patch by Kenneth ... |
41 |
U_BOOT_CMD( |
1170e634d FAT: Make it poss... |
42 |
fatload, 7, 0, do_fat_fsload, |
2fb2604d5 Command usage cle... |
43 |
"load binary file from a dos filesystem", |
6b367467f Fix help text of ... |
44 45 |
"<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]] " |
1170e634d FAT: Make it poss... |
46 47 48 49 50 51 52 53 54 55 |
" - 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... |
56 57 |
" the load stops on end of file. " |
01fac041c cmd_fat.c: Note i... |
58 59 60 61 |
" If either 'pos' or 'bytes' are not aligned to " " ARCH_DMA_MINALIGN then a misaligned buffer warning will " |
b770e88a6 Fix number base h... |
62 |
" be printed and performance will suffer for the load." |
b0fce99bf Fix some missing ... |
63 |
); |
088f1b199 common/cmd_*.c: s... |
64 |
static int do_fat_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
71f951180 * Fix CONFIG_NET_... |
65 |
{ |
045fa1e11 fs: add filesyste... |
66 |
return do_ls(cmdtp, flag, argc, argv, FS_TYPE_FAT); |
71f951180 * Fix CONFIG_NET_... |
67 |
} |
0d4983930 Patch by Kenneth ... |
68 |
U_BOOT_CMD( |
7205e4075 * Patches by Deni... |
69 |
fatls, 4, 1, do_fat_ls, |
2fb2604d5 Command usage cle... |
70 |
"list files in a directory (default /)", |
cfda5aeab cmd_fat: use comm... |
71 72 |
"<interface> [<dev[:part]>] [directory] " |
a89c33db9 General help mess... |
73 |
" - list files from 'dev' on 'interface' in a 'directory'" |
b0fce99bf Fix some missing ... |
74 |
); |
088f1b199 common/cmd_*.c: s... |
75 76 |
static int do_fat_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
71f951180 * Fix CONFIG_NET_... |
77 |
{ |
cfda5aeab cmd_fat: use comm... |
78 |
int dev, part; |
4101f6879 dm: Drop the bloc... |
79 |
struct blk_desc *dev_desc; |
cfda5aeab cmd_fat: use comm... |
80 |
disk_partition_t info; |
71f951180 * Fix CONFIG_NET_... |
81 |
|
7205e4075 * Patches by Deni... |
82 |
if (argc < 2) { |
cfda5aeab cmd_fat: use comm... |
83 84 |
printf("usage: fatinfo <interface> [<dev[:part]>] "); |
7385c28e9 fs/fat: Big code ... |
85 |
return 0; |
7205e4075 * Patches by Deni... |
86 |
} |
cfda5aeab cmd_fat: use comm... |
87 |
|
e35929e4a dm: blk: Rename g... |
88 |
part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1); |
cfda5aeab cmd_fat: use comm... |
89 |
if (part < 0) |
7205e4075 * Patches by Deni... |
90 |
return 1; |
cfda5aeab cmd_fat: use comm... |
91 |
|
bcce53d04 dm: block: Rename... |
92 |
dev = dev_desc->devnum; |
5e8f98319 FAT: implement fa... |
93 |
if (fat_set_blk_dev(dev_desc, &info) != 0) { |
7385c28e9 fs/fat: Big code ... |
94 95 96 97 |
printf(" ** Unable to use %s %d:%d for fatinfo ** ", argv[1], dev, part); |
7205e4075 * Patches by Deni... |
98 99 |
return 1; } |
7385c28e9 fs/fat: Big code ... |
100 |
return file_fat_detectfs(); |
71f951180 * Fix CONFIG_NET_... |
101 |
} |
0d4983930 Patch by Kenneth ... |
102 |
U_BOOT_CMD( |
7205e4075 * Patches by Deni... |
103 |
fatinfo, 3, 1, do_fat_fsinfo, |
2fb2604d5 Command usage cle... |
104 |
"print information about filesystem", |
cfda5aeab cmd_fat: use comm... |
105 106 |
"<interface> [<dev[:part]>] " |
a89c33db9 General help mess... |
107 |
" - print information about filesystem from 'dev' on 'interface'" |
b0fce99bf Fix some missing ... |
108 |
); |
656f4c653 cmd_fat: add FAT ... |
109 110 111 112 113 |
#ifdef CONFIG_FAT_WRITE static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { |
1ad0b98a0 fat: Prepare API ... |
114 115 |
loff_t size; int ret; |
656f4c653 cmd_fat: add FAT ... |
116 117 |
unsigned long addr; unsigned long count; |
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); |
656f4c653 cmd_fat: add FAT ... |
141 |
|
31e997f92 fs: fatwrite: use... |
142 |
buf = map_sysmem(addr, count); |
1ad0b98a0 fat: Prepare API ... |
143 |
ret = file_fat_write(argv[4], buf, 0, count, &size); |
31e997f92 fs: fatwrite: use... |
144 |
unmap_sysmem(buf); |
1ad0b98a0 fat: Prepare API ... |
145 |
if (ret < 0) { |
656f4c653 cmd_fat: add FAT ... |
146 147 148 149 150 151 |
printf(" ** Unable to write \"%s\" from %s %d:%d ** ", argv[4], argv[1], dev, part); return 1; } |
1ad0b98a0 fat: Prepare API ... |
152 153 |
printf("%llu bytes written ", size); |
656f4c653 cmd_fat: add FAT ... |
154 155 156 157 158 159 160 |
return 0; } U_BOOT_CMD( fatwrite, 6, 0, do_fat_fswrite, "write file into a dos filesystem", |
454e3d903 cmd/fat: Do not c... |
161 162 |
"<interface> <dev[:part]> <addr> <filename> [<bytes>] " |
656f4c653 cmd_fat: add FAT ... |
163 164 165 166 167 |
" - write file 'filename' from the address 'addr' in RAM " " to 'dev' on 'interface'" ); #endif |