[rtems commit] bsps/powerpc: Support more than 256MiB of RAM

Sebastian Huber sebh at rtems.org
Wed Mar 21 05:59:31 UTC 2018


Module:    rtems
Branch:    master
Commit:    5cf06565149c8cab4c9437e44f1acfda93bdaa55
Changeset: http://git.rtems.org/rtems/commit/?id=5cf06565149c8cab4c9437e44f1acfda93bdaa55

Author:    Éric Tremblay <e.tremblay at axis-canada.com>
Date:      Tue Mar 20 14:14:39 2018 +0100

bsps/powerpc: Support more than 256MiB of RAM

Close #3322.

---

 c/src/lib/libbsp/powerpc/shared/start/start.S      | 17 +++++++++++++++++
 c/src/lib/libbsp/powerpc/shared/startup/bspstart.c | 18 ++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/c/src/lib/libbsp/powerpc/shared/start/start.S b/c/src/lib/libbsp/powerpc/shared/start/start.S
index 729c89c..354b9a9 100644
--- a/c/src/lib/libbsp/powerpc/shared/start/start.S
+++ b/c/src/lib/libbsp/powerpc/shared/start/start.S
@@ -93,6 +93,23 @@ __rtems_entry_point:
 	mtspr	IBAT0L,r8
 	mtspr	IBAT0U,r11
 	isync
+/*   Map section where residual is located if outside
+ *   the first 256Mb of RAM.  This is to support cases
+ *   where the available system memory is larger than
+ *   256Mb of RAM.
+ */
+	mr	r9, r1 /* Get where residual was mapped */
+	lis r12,0xf0000000 at h
+	and	r9,r9,r12
+	cmpi	0,1,r9, 0
+	beq	enter_C_code
+	isync
+	ori r11,r9,0x1ffe
+	mtspr	DBAT1L,r8		/* N.B. 6xx (not 601) have valid */
+	mtspr	DBAT1U,r11		/* bit in upper BAT register */
+	mtspr	IBAT1L,r8
+	mtspr	IBAT1U,r11
+	isync
 
 /*
  * we now have the 1st 256M of ram mapped with the bats. We are still
diff --git a/c/src/lib/libbsp/powerpc/shared/startup/bspstart.c b/c/src/lib/libbsp/powerpc/shared/startup/bspstart.c
index 5a97cc8..dac4b24 100644
--- a/c/src/lib/libbsp/powerpc/shared/startup/bspstart.c
+++ b/c/src/lib/libbsp/powerpc/shared/startup/bspstart.c
@@ -300,6 +300,24 @@ void bsp_start( void )
    */
   _BSP_clear_hostbridge_errors(0 /* enableMCP */, 0/*quiet*/);
 
+  if (BSP_mem_size > 0x10000000)
+  {
+    /* Support cases of system memory size larger than 256Mb.
+     *
+     * We use BAT3 in order to obtain access to the top section of the RAM.
+     * We also need to do this just before setting up the page table because
+     * this is where the page table will be located.
+     */
+    const unsigned int mem256Count = (BSP_mem_size / 0x10000000);
+    const unsigned int BAT3Addr    = ((BSP_mem_size % 0x10000000)  ?
+                                       (mem256Count     * 0x10000000) :
+                                      ((mem256Count-1) * 0x10000000));
+    setdbat(3, BAT3Addr, BAT3Addr, 0x10000000, IO_PAGE);
+#ifdef SHOW_MORE_INIT_SETTINGS
+    printk("Setting up BAT3 for large memory support. (BAT3 --> 0x%x)\n", BAT3Addr);
+#endif
+  }
+
   /* Allocate and set up the page table mappings
    * This is only available on >604 CPUs.
    *




More information about the vc mailing list