summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Pisa <ppisa@pikron.com>2016-05-22 00:18:03 +0200
committerPavel Pisa <ppisa@pikron.com>2016-05-31 10:33:43 +0200
commitc64d5f0d0c450f61001538d84d35fa34f52e3590 (patch)
treead0436d0bee88f56aedf7db244a9e04f7cfeb5b1
parentc1a9f6a1286625bc3d623870c23d98672f5af3b9 (diff)
arm/raspberrypi: move MMU in front of application image to respect variable memory size.
The page table is placed at address 0x00004000 which provides required 16 kB space till the start of application image. The RAM size specified in a linker script is upper limit address of RAM utilized for the work area initialization. If VideoCore reports to use lower address than expected then work area size is adjusted (shrinked) appropriately.
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/Makefile.am2
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/include/bsp.h2
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c77
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds6
4 files changed, 83 insertions, 4 deletions
diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
index 285da4fe76..f57146ec96 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
@@ -83,7 +83,6 @@ libbsp_a_LIBADD =
# Shared
libbsp_a_SOURCES += ../../shared/bootcard.c
libbsp_a_SOURCES += ../../shared/bspclean.c
-libbsp_a_SOURCES += ../../shared/bspgetworkarea.c
libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
libbsp_a_SOURCES += ../../shared/cpucounterread.c
libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
@@ -97,6 +96,7 @@ libbsp_a_SOURCES += ../shared/arm-cp15-set-ttb-entries.c
libbsp_a_SOURCES += ../../shared/bspreset_loop.c
libbsp_a_SOURCES += startup/bspstart.c
libbsp_a_SOURCES += startup/cmdline.c
+libbsp_a_SOURCES += startup/bspgetworkarea.c
# IRQ
libbsp_a_SOURCES += ../shared/arm-cp15-set-exception-handler.c
diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h
index 18a94ea7c0..c6cd571fa7 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h
+++ b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h
@@ -32,6 +32,8 @@ extern "C" {
#define BSP_FEATURE_IRQ_EXTENSION
+#define RPI_L2_CACHE_ENABLE 1
+
#define BSP_GPIO_PIN_COUNT 32
#define BSP_GPIO_PINS_PER_BANK 32
#define BSP_GPIO_PINS_PER_SELECT_BANK 10
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c b/c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c
new file mode 100644
index 0000000000..9dc7e02391
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c
@@ -0,0 +1,77 @@
+/**
+ * @file
+ *
+ * @ingroup arm_start
+ *
+ * @brief Raspberry pi workarea initialization.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2008.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * Copyright (c) 2011-2012 embedded brains GmbH.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ *
+ * Copyright (c) 2015 YANG Qiao
+ *
+ * Code is based on c/src/lib/libbsp/shared/bspgetworkarea.c
+ */
+
+#include <string.h>
+#include <bsp.h>
+#include <bsp/bootcard.h>
+#include <bsp/vc.h>
+#ifdef BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN
+ #include <rtems/config.h>
+#endif
+
+#if defined(HAS_UBOOT) && !defined(BSP_DISABLE_UBOOT_WORK_AREA_CONFIG)
+ #define USE_UBOOT
+#endif
+
+/*
+ * These are provided by the linkcmds for ALL of the BSPs which use this file.
+ */
+extern char WorkAreaBase[];
+
+/*
+ * We may get the size information from U-Boot or the linker scripts.
+ */
+#ifdef USE_UBOOT
+ #include <bsp/u-boot.h>
+#else
+ extern char RamBase[];
+ extern char RamSize[];
+#endif
+
+void bsp_work_area_initialize(void)
+{
+ uintptr_t work_base = (uintptr_t) WorkAreaBase;
+ uintptr_t ram_end;
+ bcm2835_get_vc_memory_entries vc_entry;
+ /*
+ * bcm2835_get_arm_memory_entries arm_entry;
+ * is another alternative how to obtain usable memory size
+ */
+
+ #ifdef USE_UBOOT
+ ram_end = (uintptr_t) bsp_uboot_board_info.bi_memstart +
+ bsp_uboot_board_info.bi_memsize;
+ #else
+ ram_end = (uintptr_t)RamBase + (uintptr_t)RamSize;
+ #endif
+
+ #ifdef BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN
+ work_base += rtems_configuration_get_interrupt_stack_size();
+ #endif
+
+ memset( &vc_entry, 0, sizeof(vc_entry) );
+ bcm2835_mailbox_get_vc_memory( &vc_entry );
+ if (vc_entry.base != 0)
+ ram_end = ram_end > vc_entry.base? vc_entry.base: ram_end;
+ bsp_work_area_initialize_default( (void *) work_base, ram_end - work_base );
+}
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds b/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds
index f1ad11cc1e..fc72b5cfd0 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds
@@ -36,9 +36,9 @@
*/
MEMORY {
- VECTOR_RAM (AIW) : ORIGIN = 0x0 , LENGTH = 0x8000
- RAM (AIW) : ORIGIN = 0x00008000, LENGTH = 128M - 48K
- RAM_MMU (AIW) : ORIGIN = 128M - 16k, LENGTH = 16k
+ VECTOR_RAM (AIW) : ORIGIN = 0x0 , LENGTH = 16k
+ RAM_MMU (AIW) : ORIGIN = 0x00004000, LENGTH = 16k
+ RAM (AIW) : ORIGIN = 0x00008000, LENGTH = 128M - 32k
}
REGION_ALIAS ("REGION_START", RAM);