]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
Avoid initrd and logbuffer area overlaps
authorMarian Balakowicz <m8@semihalf.com>
Tue, 13 May 2008 13:53:29 +0000 (15:53 +0200)
committerWolfgang Denk <wd@denx.de>
Tue, 3 Jun 2008 17:34:19 +0000 (19:34 +0200)
Add logbuffer to reserved LMB areas to prevent initrd allocation
from overlaping with it.

Make sure to use correct logbuffer base address.

Signed-off-by: Marian Balakowicz <m8@semihalf.com>
common/cmd_log.c
common/image.c
include/logbuff.h
lib_ppc/board.c

index c6e72ac3c0ca3a84485e5b0b3ae924da13b13916..fdcc57571aa9d43a3a0ce849aa03ae453bf09c56 100644 (file)
@@ -66,6 +66,12 @@ static logbuff_t *log;
 #endif
 static char *lbuf;
 
+unsigned long __logbuffer_base(void)
+{
+       return CFG_SDRAM_BASE + gd->bd->bi_memsize - LOGBUFF_LEN;
+}
+unsigned long logbuffer_base (void) __attribute__((weak, alias("__logbuffer_base")));
+
 void logbuff_init_ptrs (void)
 {
        unsigned long tag, post_word;
@@ -75,7 +81,7 @@ void logbuff_init_ptrs (void)
        log = (logbuff_t *)CONFIG_ALT_LH_ADDR;
        lbuf = (char *)CONFIG_ALT_LB_ADDR;
 #else
-       log = (logbuff_t *)(gd->bd->bi_memsize-LOGBUFF_LEN) - 1;
+       log = (logbuff_t *)(logbuffer_base ()) - 1;
        lbuf = (char *)log->buf;
 #endif
 
index 67e594df6939056801e2003d710f87c044277eda..9188024802d7b9f0cd87e08c048047c55e3c08b6 100644 (file)
 #include <dataflash.h>
 #endif
 
+#ifdef CONFIG_LOGBUFFER
+#include <logbuff.h>
+#endif
+
 #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
 #include <rtc.h>
 #endif
@@ -1013,6 +1017,12 @@ int boot_ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,
                initrd_high = ~0;
        }
 
+
+#ifdef CONFIG_LOGBUFFER
+       /* Prevent initrd from overwriting logbuffer */
+       lmb_reserve(lmb, logbuffer_base() - LOGBUFF_OVERHEAD, LOGBUFF_RESERVE);
+#endif
+
        debug ("## initrd_high = 0x%08lx, copy_to_ram = %d\n",
                        initrd_high, initrd_copy_to_ram);
 
index d06d208844264e7b29e22f5a5ebc7b088c9e37ac..ae7908ca3d20ca34e83200b51560c19fd03fc69a 100644 (file)
@@ -58,6 +58,7 @@ int drv_logbuff_init (void);
 void logbuff_init_ptrs (void);
 void logbuff_log(char *msg);
 void logbuff_reset (void);
+unsigned long logbuffer_base (void);
 
 #endif /* CONFIG_LOGBUFFER */
 
index 6f7242d622ca4d208cc8167811ac97fffea9e1e9..a90883162c2f6752cf06178bf2d5c4ca50a4d85a 100644 (file)
@@ -396,6 +396,13 @@ ulong get_effective_memsize(void)
  ************************************************************************
  */
 
+#ifdef CONFIG_LOGBUFFER
+unsigned long logbuffer_base(void)
+{
+       return CFG_SDRAM_BASE + get_effective_memsize() - LOGBUFF_LEN;
+}
+#endif
+
 void board_init_f (ulong bootflag)
 {
        bd_t *bd;