summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorPeter Nessrup <peter.nessrup@stericsson.com>2010-09-16 10:10:40 +0200
committerMichael BRANDT <michael.brandt@stericsson.com>2010-09-20 16:16:28 +0200
commit3af26ab6c59e9527353f7759eaff21923bf5726d (patch)
treed5469ccf00f815113b62b1b1217ae980bf0fadb3 /common
parente8c699eb1f7a50b4f10024c41b8c86f907233f8d (diff)
Added TOC commands
TOC commands added under common to be able to print the TOC and sub TOC and to be able to load whatever a TOC entry points to into RAM at the address specified in the TOC entry loadaddr field New file: cmd_toc.c CONFIG_TOC_PARTITION needs to be set for it to be available ST-Ericsson ID: ER256835 Change-Id: I826337e2608076fad74b1a7125d7e93b5ad66e43 Signed-off-by: Peter Nessrup <peter.nessrup@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/5112 Reviewed-by: Ulf HANSSON <ulf.hansson@stericsson.com> Reviewed-by: Michael BRANDT <michael.brandt@stericsson.com>
Diffstat (limited to 'common')
-rwxr-xr-xcommon/Makefile1
-rw-r--r--common/cmd_toc.c116
2 files changed, 117 insertions, 0 deletions
diff --git a/common/Makefile b/common/Makefile
index 3824d3e56..0945735f7 100755
--- a/common/Makefile
+++ b/common/Makefile
@@ -153,6 +153,7 @@ endif
COBJS-$(CONFIG_CMD_XIMG) += cmd_ximg.o
COBJS-$(CONFIG_YAFFS2) += cmd_yaffs2.o
COBJS-$(CONFIG_VFD) += cmd_vfd.o
+COBJS-$(CONFIG_TOC_PARTITION) += cmd_toc.o
# others
COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o
diff --git a/common/cmd_toc.c b/common/cmd_toc.c
new file mode 100644
index 000000000..e7312df63
--- /dev/null
+++ b/common/cmd_toc.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2010
+ * Author: Peter Nessrup <peter.nessrup@stericsson.com> for
+ * ST-Ericsson.
+ * License terms: GNU General Public License (GPL), version 2.
+ */
+
+/*
+ * Support for printing the TOC and sub TOC structures
+ *
+ * Support also for reading data pointed to by a TOC entry, into RAM,
+ * at the destintion address specified in the TOC entry
+ */
+#include <common.h>
+#include <part.h>
+
+#if !defined(CONFIG_TOC_PARTITION)
+#error TOC partition support must be selected
+#endif
+
+int do_toc_print (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ block_dev_desc_t *dev_desc;
+ char *ep;
+
+ if (argc < 2) {
+ cmd_usage(cmdtp);
+ return 1;
+ }
+
+ dev_desc = get_dev(argv[1], (int) simple_strtoul(argv[2], &ep, 16));
+
+ if (dev_desc == NULL) {
+ printf("Invalid device\n");
+ return 1;
+ }
+
+ if (dev_desc->part_type == PART_TYPE_TOC)
+ print_part(dev_desc);
+ else
+ printf("Device is not TOC partitioned!\n");
+
+ return 0;
+}
+
+
+U_BOOT_CMD(
+ tocprint, 3, 1, do_toc_print,
+ "prints the TOC and sub TOC contents",
+ "<interface> <dev>\n"
+ " - print TOC and sub TOC from 'dev' on 'interface'"
+);
+
+
+int do_toc_entry_load(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ u32 offset;
+ u32 size;
+ u32 addr;
+ char loadaddr[16];
+ block_dev_desc_t *dev_desc;
+ int blks;
+ char *ep;
+
+ if (argc < 3) {
+ cmd_usage(cmdtp);
+ return 1;
+ }
+
+ dev_desc = get_dev(argv[1], (int) simple_strtoul(argv[2], &ep, 16));
+
+ if (dev_desc == NULL) {
+ printf("Invalid device\n");
+ return 1;
+ }
+
+ if (dev_desc->part_type != PART_TYPE_TOC) {
+ printf("Device is not TOC partitioned!\n");
+ return 1;
+ }
+
+ if (get_entry_info_toc(dev_desc,
+ argv[3],
+ &offset,
+ &size,
+ &addr) == 0) {
+
+ blks = (size / dev_desc->blksz) +
+ (size % dev_desc->blksz ? 1 : 0);
+
+ if (dev_desc->block_read(dev_desc->dev,
+ offset / dev_desc->blksz,
+ blks,
+ (ulong *) addr) != blks) {
+ printf("Unable to read from block device\n");
+ return 1;
+ }
+
+ sprintf(loadaddr, "0x%x", addr);
+ setenv("loadaddr", loadaddr);
+
+ return 0;
+ } else
+ printf("Failed to get TOC entry!\n");
+
+ return 1;
+}
+
+U_BOOT_CMD(
+ tocload, 4, 0, do_toc_entry_load,
+ "load from the TOC entry to memory",
+ "<interface> <dev> <entry ID>\n"
+ " - load the data pointed to by the <entry ID> to the RAM address\n"
+ " specified in the TOC entry loadaddr field, from <dev> on\n"
+ " <interface>"
+);