[U-Boot] [PATCH 2/3] [RFC] Make memory commands usable before relocation to SDRAM

Peter Tyser ptyser at xes-inc.com
Fri Aug 15 23:16:43 CEST 2008


Signed-off-by: Peter Tyser <ptyser at xes-inc.com>
---
 common/cmd_mem.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index f3299bd..6eb1fd4 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -43,6 +43,8 @@
     || defined(CONFIG_CMD_PCI)		\
     || defined(CONFIG_CMD_PORTIO)
 
+DECLARE_GLOBAL_DATA_PTR;
+
 int cmd_get_data_size(char* arg, int default_size)
 {
 	/* Check for a size specification .b, .w or .l.
@@ -83,7 +85,7 @@ uint	dp_last_addr, dp_last_size;
 uint	dp_last_length = 0x40;
 uint	mm_last_addr, mm_last_size;
 
-static	ulong	base_address = 0;
+static	ulong	base_address __attribute__ ((section(".data"))) = 0;
 
 /* Memory Display
  *
@@ -103,8 +105,10 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	/* We use the last specified parameters, unless new ones are
 	 * entered.
 	 */
-	addr = dp_last_addr;
-	size = dp_last_size;
+	if (gd->flags & GD_FLG_RELOC) {
+		addr = dp_last_addr;
+		size = dp_last_size;
+	}
 	length = dp_last_length;
 
 	if (argc < 2) {
@@ -183,9 +187,12 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	}
 #endif
 
-	dp_last_addr = addr;
-	dp_last_length = length;
-	dp_last_size = size;
+	if (gd->flags & GD_FLG_RELOC) {
+		dp_last_addr = addr;
+		dp_last_length = length;
+		dp_last_size = size;
+	}
+
 	return (rc);
 }
 
@@ -1025,8 +1032,10 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[])
 	/* We use the last specified parameters, unless new ones are
 	 * entered.
 	 */
-	addr = mm_last_addr;
-	size = mm_last_size;
+	if (gd->flags & GD_FLG_RELOC) {
+		addr = mm_last_addr;
+		size = mm_last_size;
+	}
 
 	if ((flag & CMD_FLAG_REPEAT) == 0) {
 		/* New command specified.  Check for a size specification.
@@ -1106,8 +1115,11 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[])
 		}
 	} while (nbytes);
 
-	mm_last_addr = addr;
-	mm_last_size = size;
+	if (gd->flags & GD_FLG_RELOC) {
+		mm_last_addr = addr;
+		mm_last_size = size;
+	}
+
 	return 0;
 }
 
-- 
1.5.4.3




More information about the U-Boot mailing list