]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
common: Rewrite hiding the end of memory
authorYork Sun <yorksun@freescale.com>
Mon, 7 Dec 2015 19:05:29 +0000 (11:05 -0800)
committerYork Sun <yorksun@freescale.com>
Tue, 15 Dec 2015 00:57:33 +0000 (08:57 +0800)
As the name may be confusing, the CONFIG_SYS_MEM_TOP_HIDE reserves
some memory from the end of ram, tracked by gd->ram_size. It is not
always the top of u-boot visible memory. Rewrite the macro with a
weak function to provide flexibility for complex calcuation. Legacy
use of this macro is still supported.

Signed-off-by: York Sun <yorksun@freescale.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
README
common/board_f.c

diff --git a/README b/README
index 6ea1af2678e656c9ec43c193ff797ce7c04f0686..4aa2aaeb23e2c1b946dfe4722d43d49f54116fd9 100644 (file)
--- a/README
+++ b/README
@@ -3877,7 +3877,7 @@ Configuration Settings:
                the RAM base is not zero, or RAM is divided into banks,
                this variable needs to be recalcuated to get the address.
 
-- CONFIG_SYS_MEM_TOP_HIDE (PPC only):
+- CONFIG_SYS_MEM_TOP_HIDE:
                If CONFIG_SYS_MEM_TOP_HIDE is defined in the board config header,
                this specified memory area will get subtracted from the top
                (end) of RAM and won't get "touched" at all by U-Boot. By
index bd5a4862480e655dc31c863141e411cf8d03fa3a..8094ac4efe0d6feb120433e021f0cd2e723c85dd 100644 (file)
@@ -317,6 +317,15 @@ __weak ulong board_get_usable_ram_top(ulong total_size)
        return gd->ram_top;
 }
 
+__weak phys_size_t board_reserve_ram_top(phys_size_t ram_size)
+{
+#ifdef CONFIG_SYS_MEM_TOP_HIDE
+       return ram_size - CONFIG_SYS_MEM_TOP_HIDE;
+#else
+       return ram_size;
+#endif
+}
+
 static int setup_dest_addr(void)
 {
        debug("Monitor len: %08lX\n", gd->mon_len);
@@ -333,19 +342,17 @@ static int setup_dest_addr(void)
         */
        gd->secure_ram = gd->ram_size;
 #endif
-#if defined(CONFIG_SYS_MEM_TOP_HIDE)
        /*
         * Subtract specified amount of memory to hide so that it won't
         * get "touched" at all by U-Boot. By fixing up gd->ram_size
         * the Linux kernel should now get passed the now "corrected"
-        * memory size and won't touch it either. This should work
-        * for arch/ppc and arch/powerpc. Only Linux board ports in
-        * arch/powerpc with bootwrapper support, that recalculate the
-        * memory size from the SDRAM controller setup will have to
-        * get fixed.
+        * memory size and won't touch it either. This has been used
+        * by arch/powerpc exclusively. Now ARMv8 takes advantage of
+        * thie mechanism. If memory is split into banks, addresses
+        * need to be calculated.
         */
-       gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
-#endif
+       gd->ram_size = board_reserve_ram_top(gd->ram_size);
+
 #ifdef CONFIG_SYS_SDRAM_BASE
        gd->ram_top = CONFIG_SYS_SDRAM_BASE;
 #endif