[U-Boot-Users] [PATCH v2] memsize.c: support larger memory ranges

Wolfgang Denk wd at denx.de
Thu Jun 5 00:05:57 CEST 2008


The "long" data types used so far in "common/memsize.c" cause
problems with larger memories, i. e. when accessing memory above
0x80000000.

Pointed out by David Bellavance <dbellavance at dekaresearch.com>
on Tue, 1 Apr 2008 14:19:37 -0400

Signed-off-by: Wolfgang Denk <wd at denx.de>
---
 common/memsize.c |   26 +++++++++++++-------------
 include/common.h |    2 +-
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/common/memsize.c b/common/memsize.c
index 6c275c9..70c2801 100644
--- a/common/memsize.c
+++ b/common/memsize.c
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2004
+ * (C) Copyright 2004-2008
  * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
  *
  * See file CREDITS for list of people who contributed to this
@@ -37,16 +37,16 @@
  * the actually available RAM size between addresses `base' and
  * `base + maxsize'.
  */
-long get_ram_size(volatile long *base, long maxsize)
+phys_size_t get_ram_size(volatile phys_addr_t *base, phys_size_t maxsize)
 {
-	volatile long *addr;
-	long           save[32];
-	long           cnt;
-	long           val;
-	long           size;
-	int            i = 0;
+	volatile phys_addr_t *addr;
+	phys_addr_t	save[64];
+	phys_size_t	cnt;
+	phys_size_t	val;
+	phys_size_t	size;
+	int		i = 0;
 
-	for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
+	for (cnt = (maxsize / sizeof (phys_addr_t)) >> 1; cnt > 0; cnt >>= 1) {
 		addr = base + cnt;	/* pointer arith! */
 		sync ();
 		save[i++] = *addr;
@@ -66,7 +66,7 @@ long get_ram_size(volatile long *base, long maxsize)
 		 */
 		sync ();
 		*addr = save[i];
-		for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
+		for (cnt = 1; cnt < maxsize / sizeof(phys_addr_t); cnt <<= 1) {
 			addr  = base + cnt;
 			sync ();
 			*addr = save[--i];
@@ -74,15 +74,15 @@ long get_ram_size(volatile long *base, long maxsize)
 		return (0);
 	}
 
-	for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
+	for (cnt = 1; cnt < maxsize / sizeof (phys_addr_t); cnt <<= 1) {
 		addr = base + cnt;	/* pointer arith! */
 		val = *addr;
 		*addr = save[--i];
 		if (val != ~cnt) {
-			size = cnt * sizeof (long);
+			size = cnt * sizeof (phys_addr_t);
 			/* Restore the original data before leaving the function.
 			 */
-			for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
+			for (cnt <<= 1; cnt < maxsize / sizeof (phys_addr_t); cnt <<= 1) {
 				addr  = base + cnt;
 				*addr = save[--i];
 			}
diff --git a/include/common.h b/include/common.h
index d0f5704..eea609c 100644
--- a/include/common.h
+++ b/include/common.h
@@ -285,7 +285,7 @@ void	jumptable_init(void);
 void	api_init (void);
 
 /* common/memsize.c */
-long	get_ram_size  (volatile long *, long);
+phys_size_t get_ram_size (volatile phys_addr_t *, phys_size_t);
 
 /* $(BOARD)/$(BOARD).c */
 void	reset_phy     (void);
-- 
1.5.4.1





More information about the U-Boot mailing list