public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [RFC][PATCH 02/19] relocation: fixup cmdtable
@ 2010-07-29 10:44 Heiko Schocher
  2010-07-29 15:38 ` Peter Tyser
  0 siblings, 1 reply; 5+ messages in thread
From: Heiko Schocher @ 2010-07-29 10:44 UTC (permalink / raw)
  To: u-boot

fixup_cmdtable() did all work for fixing up the cmdtable,
if CONFIG_RELOC_FIXUP_WORKS is not defined.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 common/command.c  |   33 +++++++++++++++++++++++++++++++++
 include/command.h |    3 +++
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/common/command.c b/common/command.c
index 30a9801..7d0ac98 100644
--- a/common/command.c
+++ b/common/command.c
@@ -464,3 +464,36 @@ int cmd_get_data_size(char* arg, int default_size)
 	return default_size;
 }
 #endif
+
+#if !defined(CONFIG_RELOC_FIXUP_WORKS)
+DECLARE_GLOBAL_DATA_PTR;
+
+void fixup_cmdtable(cmd_tbl_t *cmdtp, int size)
+{
+	int	i;
+
+	if (gd->reloc_off == 0)
+		return;
+
+	for (i = 0; i < size; i++) {
+		ulong addr;
+
+		addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
+		cmdtp->cmd =
+			(int (*)(struct cmd_tbl_s *, int, int, char * const []))addr;
+		addr = (ulong)(cmdtp->name) + gd->reloc_off;
+		cmdtp->name = (char *)addr;
+		if (cmdtp->usage) {
+			addr = (ulong)(cmdtp->usage) + gd->reloc_off;
+			cmdtp->usage = (char *)addr;
+		}
+#ifdef	CONFIG_SYS_LONGHELP
+		if (cmdtp->help) {
+			addr = (ulong)(cmdtp->help) + gd->reloc_off;
+			cmdtp->help = (char *)addr;
+		}
+#endif
+		cmdtp++;
+	}
+}
+#endif
diff --git a/include/command.h b/include/command.h
index 9144d69..5c14616 100644
--- a/include/command.h
+++ b/include/command.h
@@ -125,4 +125,7 @@ cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}

 #endif	/* CONFIG_SYS_LONGHELP */

+#if !defined(CONFIG_RELOC_FIXUP_WORKS)
+void fixup_cmdtable(cmd_tbl_t *cmdtp, int size);
+#endif
 #endif	/* __COMMAND_H */
-- 
1.6.2.5

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-08-03 10:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-29 10:44 [U-Boot] [RFC][PATCH 02/19] relocation: fixup cmdtable Heiko Schocher
2010-07-29 15:38 ` Peter Tyser
2010-07-30  6:00   ` Heiko Schocher
2010-07-30 14:46     ` Peter Tyser
2010-08-03 10:15       ` [U-Boot] [RFC][PATCH v2 " Heiko Schocher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox