From: Wolfgang Denk Date: Mon, 12 May 2008 23:53:24 +0200 Subject: [U-Boot-Users] [PATCH] [RFC] memsize.c: support larger memory ranges Message-ID: <1210629204-6503-1-git-send-email-wd@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 on Tue, 1 Apr 2008 14:19:37 -0400 Signed-off-by: Wolfgang Denk --- 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..17965d1 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_addr_t get_ram_size(volatile phys_addr_t *base, phys_addr_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_addr_t cnt; + phys_addr_t val; + phys_addr_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..c10b138 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_addr_t get_ram_size (volatile phys_addr_t *, phys_addr_t); /* $(BOARD)/$(BOARD).c */ void reset_phy (void); -- 1.5.4.2