public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [Patch v2] common: Add get_effective_memsize() to memsize.c
@ 2014-02-11 19:57 York Sun
  2014-02-12  7:34 ` Albert ARIBAUD
  2014-02-21 19:58 ` [U-Boot] [U-Boot, " Tom Rini
  0 siblings, 2 replies; 4+ messages in thread
From: York Sun @ 2014-02-11 19:57 UTC (permalink / raw)
  To: u-boot

This function has been around for powerpc. It is used for systems with
memory more than CONFIG_MAX_MEM_MAPPED. In case of non-contiguous memory,
this feature can limit U-boot to one block without going over the limit.

Signed-off-by: York Sun <yorksun@freescale.com>
---
Change log:
 v1: The function is added to arch/arm/lib/board.c without changing others
 v2: The function is moved to common/memsize.c, using __weak. The prototype
     is added to include/common.h. Also consolidate existing functions for
     powerpc.

 arch/arm/lib/board.c               |    2 +-
 arch/powerpc/cpu/mpc512x/traps.c   |    1 -
 arch/powerpc/cpu/mpc85xx/traps.c   |    1 -
 arch/powerpc/cpu/mpc86xx/traps.c   |    1 -
 arch/powerpc/lib/board.c           |   18 ------------------
 arch/powerpc/lib/bootm.c           |    1 -
 board/freescale/c29xpcie/spl.c     |    2 +-
 board/freescale/p1022ds/spl.c      |    2 +-
 board/freescale/p1_p2_rdb_pc/spl.c |    2 +-
 common/board_f.c                   |   11 -----------
 common/cmd_log.c                   |    2 +-
 common/memsize.c                   |   16 +++++++++++++++-
 include/common.h                   |    1 +
 13 files changed, 21 insertions(+), 39 deletions(-)

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index b770e25..5fbb3a9 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -322,7 +322,7 @@ void board_init_f(ulong bootflag)
 	gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
 #endif
 
-	addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
+	addr = CONFIG_SYS_SDRAM_BASE + get_effective_memsize();
 
 #ifdef CONFIG_LOGBUFFER
 #ifndef CONFIG_ALT_LB_ADDR
diff --git a/arch/powerpc/cpu/mpc512x/traps.c b/arch/powerpc/cpu/mpc512x/traps.c
index 1016991..9f5bcd7 100644
--- a/arch/powerpc/cpu/mpc512x/traps.c
+++ b/arch/powerpc/cpu/mpc512x/traps.c
@@ -27,7 +27,6 @@ extern unsigned long search_exception_table(unsigned long);
  * amount of memory on the system if we're unable to keep all
  * the memory mapped in.
  */
-extern ulong get_effective_memsize(void);
 #define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize())
 
 /*
diff --git a/arch/powerpc/cpu/mpc85xx/traps.c b/arch/powerpc/cpu/mpc85xx/traps.c
index 3ef6e4a..24adbc3 100644
--- a/arch/powerpc/cpu/mpc85xx/traps.c
+++ b/arch/powerpc/cpu/mpc85xx/traps.c
@@ -35,7 +35,6 @@ extern unsigned long search_exception_table(unsigned long);
  * amount of memory on the system if we're unable to keep all
  * the memory mapped in.
  */
-extern ulong get_effective_memsize(void);
 #define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize())
 
 static __inline__ void set_tsr(unsigned long val)
diff --git a/arch/powerpc/cpu/mpc86xx/traps.c b/arch/powerpc/cpu/mpc86xx/traps.c
index 0b7ea3b..92fb537 100644
--- a/arch/powerpc/cpu/mpc86xx/traps.c
+++ b/arch/powerpc/cpu/mpc86xx/traps.c
@@ -29,7 +29,6 @@ extern unsigned long search_exception_table(unsigned long);
  * amount of memory on the system if we're unable to keep all
  * the memory mapped in.
  */
-extern ulong get_effective_memsize(void);
 #define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize())
 
 /*
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index 34bbfca..13d761c 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -312,17 +312,6 @@ static init_fnc_t *init_sequence[] = {
 	NULL,	/* Terminate this list */
 };
 
-ulong get_effective_memsize(void)
-{
-#ifndef	CONFIG_VERY_BIG_RAM
-	return gd->ram_size;
-#else
-	/* limit stack to what we can reasonable map */
-	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
-		CONFIG_MAX_MEM_MAPPED : gd->ram_size);
-#endif
-}
-
 static int __fixup_cpu(void)
 {
 	return 0;
@@ -343,13 +332,6 @@ int fixup_cpu(void) __attribute__((weak, alias("__fixup_cpu")));
  * initialized, and stack space is limited to a few kB.
  */
 
-#ifdef CONFIG_LOGBUFFER
-unsigned long logbuffer_base(void)
-{
-	return CONFIG_SYS_SDRAM_BASE + get_effective_memsize() - LOGBUFF_LEN;
-}
-#endif
-
 void board_init_f(ulong bootflag)
 {
 	bd_t *bd;
diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c
index 41fc8f7..c08b62c 100644
--- a/arch/powerpc/lib/bootm.c
+++ b/arch/powerpc/lib/bootm.c
@@ -30,7 +30,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-extern ulong get_effective_memsize(void);
 static ulong get_sp (void);
 extern void ft_fixup_num_cores(void *blob);
 static void set_clocks_in_mhz (bd_t *kbd);
diff --git a/board/freescale/c29xpcie/spl.c b/board/freescale/c29xpcie/spl.c
index 3cfdb72..2111711 100644
--- a/board/freescale/c29xpcie/spl.c
+++ b/board/freescale/c29xpcie/spl.c
@@ -12,7 +12,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-ulong get_effective_memsize(void)
+phys_size_t get_effective_memsize(void)
 {
 	return CONFIG_SYS_L2_SIZE;
 }
diff --git a/board/freescale/p1022ds/spl.c b/board/freescale/p1022ds/spl.c
index 7f151e3..7bd9d29 100644
--- a/board/freescale/p1022ds/spl.c
+++ b/board/freescale/p1022ds/spl.c
@@ -21,7 +21,7 @@ static const u32 sysclk_tbl[] = {
 	99999000, 11111000, 12499800, 13333200
 };
 
-ulong get_effective_memsize(void)
+phys_size_t get_effective_memsize(void)
 {
 	return CONFIG_SYS_L2_SIZE;
 }
diff --git a/board/freescale/p1_p2_rdb_pc/spl.c b/board/freescale/p1_p2_rdb_pc/spl.c
index 9bb0716..8d0d850 100644
--- a/board/freescale/p1_p2_rdb_pc/spl.c
+++ b/board/freescale/p1_p2_rdb_pc/spl.c
@@ -20,7 +20,7 @@ static const u32 sysclk_tbl[] = {
 	99999000, 11111000, 12499800, 13333200
 };
 
-ulong get_effective_memsize(void)
+phys_size_t get_effective_memsize(void)
 {
 	return CONFIG_SYS_L2_SIZE;
 }
diff --git a/common/board_f.c b/common/board_f.c
index aa70c3e..5c7a17f 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -223,17 +223,6 @@ static int show_dram_config(void)
 	return 0;
 }
 
-ulong get_effective_memsize(void)
-{
-#ifndef	CONFIG_VERY_BIG_RAM
-	return gd->ram_size;
-#else
-	/* limit stack to what we can reasonable map */
-	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
-		CONFIG_MAX_MEM_MAPPED : gd->ram_size);
-#endif
-}
-
 void __dram_init_banksize(void)
 {
 #if defined(CONFIG_NR_DRAM_BANKS) && defined(CONFIG_SYS_SDRAM_BASE)
diff --git a/common/cmd_log.c b/common/cmd_log.c
index 8164bdf..38d0f5e 100644
--- a/common/cmd_log.c
+++ b/common/cmd_log.c
@@ -52,7 +52,7 @@ static char *lbuf;
 
 unsigned long __logbuffer_base(void)
 {
-	return CONFIG_SYS_SDRAM_BASE + gd->ram_size - LOGBUFF_LEN;
+	return CONFIG_SYS_SDRAM_BASE + get_effective_memsize() - LOGBUFF_LEN;
 }
 unsigned long logbuffer_base(void)
 __attribute__((weak, alias("__logbuffer_base")));
diff --git a/common/memsize.c b/common/memsize.c
index 73b92c8..589400d 100644
--- a/common/memsize.c
+++ b/common/memsize.c
@@ -5,7 +5,10 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <config.h>
+#include <common.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
 #ifdef __PPC__
 /*
  * At least on G2 PowerPC cores, sequential accesses to non-existent
@@ -76,3 +79,14 @@ long get_ram_size(long *base, long maxsize)
 
 	return (maxsize);
 }
+
+phys_size_t __weak get_effective_memsize(void)
+{
+#ifndef CONFIG_VERY_BIG_RAM
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size);
+#endif
+}
diff --git a/include/common.h b/include/common.h
index 221b776..87d42c2 100644
--- a/include/common.h
+++ b/include/common.h
@@ -454,6 +454,7 @@ void	api_init (void);
 
 /* common/memsize.c */
 long	get_ram_size  (long *, long);
+phys_size_t get_effective_memsize(void);
 
 /* $(BOARD)/$(BOARD).c */
 void	reset_phy     (void);
-- 
1.7.9.5

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

* [U-Boot] [Patch v2] common: Add get_effective_memsize() to memsize.c
  2014-02-11 19:57 [U-Boot] [Patch v2] common: Add get_effective_memsize() to memsize.c York Sun
@ 2014-02-12  7:34 ` Albert ARIBAUD
  2014-02-12 18:13   ` York Sun
  2014-02-21 19:58 ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 1 reply; 4+ messages in thread
From: Albert ARIBAUD @ 2014-02-12  7:34 UTC (permalink / raw)
  To: u-boot

Hi York,

On Tue, 11 Feb 2014 11:57:26 -0800, York Sun <yorksun@freescale.com>
wrote:

> This function has been around for powerpc. It is used for systems with
> memory more than CONFIG_MAX_MEM_MAPPED. In case of non-contiguous memory,
> this feature can limit U-boot to one block without going over the limit.
> 
> Signed-off-by: York Sun <yorksun@freescale.com>
> ---
> Change log:
>  v1: The function is added to arch/arm/lib/board.c without changing others
>  v2: The function is moved to common/memsize.c, using __weak. The prototype
>      is added to include/common.h. Also consolidate existing functions for
>      powerpc.
> 
>  arch/arm/lib/board.c               |    2 +-
>  arch/powerpc/cpu/mpc512x/traps.c   |    1 -
>  arch/powerpc/cpu/mpc85xx/traps.c   |    1 -
>  arch/powerpc/cpu/mpc86xx/traps.c   |    1 -
>  arch/powerpc/lib/board.c           |   18 ------------------
>  arch/powerpc/lib/bootm.c           |    1 -
>  board/freescale/c29xpcie/spl.c     |    2 +-
>  board/freescale/p1022ds/spl.c      |    2 +-
>  board/freescale/p1_p2_rdb_pc/spl.c |    2 +-
>  common/board_f.c                   |   11 -----------
>  common/cmd_log.c                   |    2 +-
>  common/memsize.c                   |   16 +++++++++++++++-
>  include/common.h                   |    1 +
>  13 files changed, 21 insertions(+), 39 deletions(-)

For the trivial ARM change:

Acked-by: Albert ARIBAUD <albert.u.boot@aribaud.net>

Since the rest is essentially PPC, though, it makes sense not to go
through the ARM repo for this patch.

Amicalement,
-- 
Albert.

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

* [U-Boot] [Patch v2] common: Add get_effective_memsize() to memsize.c
  2014-02-12  7:34 ` Albert ARIBAUD
@ 2014-02-12 18:13   ` York Sun
  0 siblings, 0 replies; 4+ messages in thread
From: York Sun @ 2014-02-12 18:13 UTC (permalink / raw)
  To: u-boot

On 02/11/2014 11:34 PM, Albert ARIBAUD wrote:
> Hi York,
> 
> On Tue, 11 Feb 2014 11:57:26 -0800, York Sun <yorksun@freescale.com>
> wrote:
> 
>> This function has been around for powerpc. It is used for systems with
>> memory more than CONFIG_MAX_MEM_MAPPED. In case of non-contiguous memory,
>> this feature can limit U-boot to one block without going over the limit.
>>
>> Signed-off-by: York Sun <yorksun@freescale.com>
>> ---
>> Change log:
>>  v1: The function is added to arch/arm/lib/board.c without changing others
>>  v2: The function is moved to common/memsize.c, using __weak. The prototype
>>      is added to include/common.h. Also consolidate existing functions for
>>      powerpc.
>>
>>  arch/arm/lib/board.c               |    2 +-
>>  arch/powerpc/cpu/mpc512x/traps.c   |    1 -
>>  arch/powerpc/cpu/mpc85xx/traps.c   |    1 -
>>  arch/powerpc/cpu/mpc86xx/traps.c   |    1 -
>>  arch/powerpc/lib/board.c           |   18 ------------------
>>  arch/powerpc/lib/bootm.c           |    1 -
>>  board/freescale/c29xpcie/spl.c     |    2 +-
>>  board/freescale/p1022ds/spl.c      |    2 +-
>>  board/freescale/p1_p2_rdb_pc/spl.c |    2 +-
>>  common/board_f.c                   |   11 -----------
>>  common/cmd_log.c                   |    2 +-
>>  common/memsize.c                   |   16 +++++++++++++++-
>>  include/common.h                   |    1 +
>>  13 files changed, 21 insertions(+), 39 deletions(-)
> 
> For the trivial ARM change:
> 
> Acked-by: Albert ARIBAUD <albert.u.boot@aribaud.net>
> 
> Since the rest is essentially PPC, though, it makes sense not to go
> through the ARM repo for this patch.
> 

Agree. Originally I put the change mainly to arch/arm/lib/board.c. That's why it
went to you.

I will merge it.

York

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

* [U-Boot] [U-Boot, v2] common: Add get_effective_memsize() to memsize.c
  2014-02-11 19:57 [U-Boot] [Patch v2] common: Add get_effective_memsize() to memsize.c York Sun
  2014-02-12  7:34 ` Albert ARIBAUD
@ 2014-02-21 19:58 ` Tom Rini
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2014-02-21 19:58 UTC (permalink / raw)
  To: u-boot

On Tue, Feb 11, 2014 at 11:57:26AM -0800, York Sun wrote:

> This function has been around for powerpc. It is used for systems with
> memory more than CONFIG_MAX_MEM_MAPPED. In case of non-contiguous memory,
> this feature can limit U-boot to one block without going over the limit.
> 
> Signed-off-by: York Sun <yorksun@freescale.com>
> Acked-by: Albert ARIBAUD <albert.u.boot@aribaud.net>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140221/113f2f0b/attachment.pgp>

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

end of thread, other threads:[~2014-02-21 19:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-11 19:57 [U-Boot] [Patch v2] common: Add get_effective_memsize() to memsize.c York Sun
2014-02-12  7:34 ` Albert ARIBAUD
2014-02-12 18:13   ` York Sun
2014-02-21 19:58 ` [U-Boot] [U-Boot, " Tom Rini

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