2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
6 * Alternatively, this software may be distributed under the terms of the
7 * GNU General Public License ("GPL") version 2 as published by the Free
17 do_rw(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
19 struct blk_desc
*dev_desc
= NULL
;
20 struct disk_partition part_info
;
31 part
= part_get_info_by_dev_and_name_or_num(argv
[1], argv
[2],
32 &dev_desc
, &part_info
, 1);
36 ptr
= map_sysmem(hextoul(argv
[3], NULL
), 0);
37 blk
= hextoul(argv
[4], NULL
);
38 cnt
= hextoul(argv
[5], NULL
);
41 offset
= part_info
.start
;
42 limit
= part_info
.size
;
44 /* Largest address not available in struct blk_desc. */
49 if (cnt
+ blk
> limit
) {
50 printf("%s out of range\n", cmdtp
->name
);
55 if (IS_ENABLED(CONFIG_CMD_WRITE
) && !strcmp(cmdtp
->name
, "write"))
56 res
= blk_dwrite(dev_desc
, offset
+ blk
, cnt
, ptr
);
58 res
= blk_dread(dev_desc
, offset
+ blk
, cnt
, ptr
);
62 printf("%s error\n", cmdtp
->name
);
69 #ifdef CONFIG_CMD_READ
72 "Load binary data from a partition",
73 "<interface> <dev[:part|#partname]> addr blk# cnt"
77 #ifdef CONFIG_CMD_WRITE
80 "Store binary data to a partition",
81 "<interface> <dev[:part|#partname]> addr blk# cnt"