summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/raspberrypi
diff options
context:
space:
mode:
authorHesham AL-Matary <heshamelmatary@gmail.com>2013-09-28 10:08:25 +0200
committerGedare Bloom <gedare@rtems.org>2013-10-03 08:55:33 -0400
commit5ceefe18f0a6a055e04a1e5333983bae86738be8 (patch)
tree7256c26f30a1cd90a1a5938f7de144d843c06074 /c/src/lib/libbsp/arm/raspberrypi
parentAdd a new necessary definition needed for raspberrypi MMU support (diff)
downloadrtems-5ceefe18f0a6a055e04a1e5333983bae86738be8.tar.bz2
Shared MMU initialization for ARM BSPs and RaspberryPi MMU support
Add support for MMU initialization for RaspberryPi. Introduce new shared MMU configuration table that can be used by other BSPs that call the arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache function. Demonstrate the use of the generic table with RaspberryPi.
Diffstat (limited to '')
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/Makefile.am9
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/preinstall.am8
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c22
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds4
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/startup/mm_config_table.c70
5 files changed, 92 insertions, 21 deletions
diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
index 24d396c70b..a06979a887 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
@@ -27,6 +27,7 @@ nodist_include_HEADERS = ../../shared/include/coverhd.h \
nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h
include_bsp_HEADERS =
+include_bsp_HEADERS += ../../../libbsp/shared/include/mm.h
include_bsp_HEADERS += ../../shared/include/utility.h
include_bsp_HEADERS += ../../shared/include/irq-generic.h
include_bsp_HEADERS += ../../shared/include/irq-info.h
@@ -35,6 +36,7 @@ include_bsp_HEADERS += ../../shared/include/uart-output-char.h
include_bsp_HEADERS += ../../shared/tod.h
include_bsp_HEADERS += ../shared/include/linker-symbols.h
include_bsp_HEADERS += ../shared/include/start.h
+include_bsp_HEADERS += ../shared/include/arm-cp15-start.h
include_bsp_HEADERS += ../shared/lpc/include/lpc-timer.h
include_bsp_HEADERS += ../shared/lpc/include/lpc-dma.h
include_bsp_HEADERS += include/irq.h
@@ -83,7 +85,7 @@ libbsp_a_SOURCES += ../../shared/sbrk.c
libbsp_a_SOURCES += ../../shared/src/stackalloc.c
libbsp_a_SOURCES += ../shared/abort/simple_abort.c
libbsp_a_SOURCES += ../shared/startup/bsp-start-memcpy.S
-
+libbsp_a_SOURCES += ../shared/arm-cp15-set-ttb-entries.c
# Startup
libbsp_a_SOURCES += startup/bspreset.c
@@ -91,6 +93,7 @@ libbsp_a_SOURCES += startup/bspstart.c
# IRQ
libbsp_a_SOURCES += ../../shared/src/irq-default-handler.c
+libbsp_a_SOURCES += ../shared/arm-cp15-set-exception-handler.c
libbsp_a_SOURCES += ../../shared/src/irq-generic.c
libbsp_a_SOURCES += ../../shared/src/irq-info.c
libbsp_a_SOURCES += ../../shared/src/irq-legacy.c
@@ -127,6 +130,10 @@ libbsp_a_CPPFLAGS += -I$(srcdir)/../../../libcpu/arm/shared/include
# Start hooks
libbsp_a_SOURCES += startup/bspstarthooks.c
+# LIBMM
+libbsp_a_SOURCES += startup/mm_config_table.c
+libbsp_a_SOURCES += ../shared/mminit.c
+
###############################################################################
# Network #
###############################################################################
diff --git a/c/src/lib/libbsp/arm/raspberrypi/preinstall.am b/c/src/lib/libbsp/arm/raspberrypi/preinstall.am
index 056c5f1eaa..a638e642bb 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/preinstall.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/preinstall.am
@@ -62,6 +62,10 @@ $(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INC
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h
+$(PROJECT_INCLUDE)/bsp/mm.h: ../../../libbsp/shared/include/mm.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/mm.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/mm.h
+
$(PROJECT_INCLUDE)/bsp/utility.h: ../../shared/include/utility.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/utility.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/utility.h
@@ -94,6 +98,10 @@ $(PROJECT_INCLUDE)/bsp/start.h: ../shared/include/start.h $(PROJECT_INCLUDE)/bsp
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/start.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/start.h
+$(PROJECT_INCLUDE)/bsp/arm-cp15-start.h: ../shared/include/arm-cp15-start.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-cp15-start.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-cp15-start.h
+
$(PROJECT_INCLUDE)/bsp/lpc-timer.h: ../shared/lpc/include/lpc-timer.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/lpc-timer.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/lpc-timer.h
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c
index a2241687cc..71b2ff1a44 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c
@@ -7,6 +7,7 @@
*/
/*
+ * Copyright (c) 2013. Hesham AL-Matary
* Copyright (c) 2013 by Alan Cudmore
* based on work by:
* Copyright (c) 2009
@@ -24,33 +25,16 @@
#include <bspopts.h>
#include <bsp/start.h>
#include <bsp/raspberrypi.h>
-#include <bsp/mmu.h>
-
-static void BSP_START_TEXT_SECTION raspberrypi_cache_setup(void)
-{
- uint32_t ctrl = 0;
-
- /* Disable MMU and cache, basic settings */
- ctrl = arm_cp15_get_control();
- ctrl &= ~(ARM_CP15_CTRL_I | ARM_CP15_CTRL_R | ARM_CP15_CTRL_C
- | ARM_CP15_CTRL_V | ARM_CP15_CTRL_M);
- ctrl |= ARM_CP15_CTRL_S;
- arm_cp15_set_control(ctrl);
-
- arm_cp15_cache_invalidate();
- arm_cp15_tlb_invalidate();
-
-}
-
+#include <bsp/mm.h>
void BSP_START_TEXT_SECTION bsp_start_hook_0(void)
{
- raspberrypi_cache_setup();
}
void BSP_START_TEXT_SECTION bsp_start_hook_1(void)
{
bsp_start_copy_sections();
+ bsp_memory_management_initialize();
bsp_start_clear_bss();
}
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds b/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds
index b9a0dd88dc..c12b348cf5 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds
@@ -35,7 +35,8 @@
MEMORY {
VECTOR_RAM (AIW) : ORIGIN = 0x0 , LENGTH = 0x8000
- RAM (AIW) : ORIGIN = 0x00008000, LENGTH = 128M - 0x8000
+ RAM (AIW) : ORIGIN = 0x00008000, LENGTH = 128M - 48K
+ RAM_MMU (AIW) : ORIGIN = 128M - 16k, LENGTH = 16k
}
REGION_ALIAS ("REGION_START", RAM);
@@ -58,5 +59,6 @@ bsp_stack_irq_size = DEFINED (bsp_stack_irq_size) ? bsp_stack_irq_size : 4096;
bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 1024;
bsp_section_robarrier_align = DEFINED (bsp_section_robarrier_align) ? bsp_section_robarrier_align : 1M;
+bsp_translation_table_base = ORIGIN (RAM_MMU);
INCLUDE linkcmds.armv4
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/mm_config_table.c b/c/src/lib/libbsp/arm/raspberrypi/startup/mm_config_table.c
new file mode 100644
index 0000000000..5436a76870
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/mm_config_table.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <info@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <bsp/start.h>
+#include <bsp/arm-cp15-start.h>
+
+#ifdef RTEMS_SMP
+ #define MMU_DATA_READ_WRITE ARMV7_MMU_DATA_READ_WRITE_SHAREABLE
+#else
+ #define MMU_DATA_READ_WRITE ARMV7_MMU_DATA_READ_WRITE_CACHED
+#endif
+
+BSP_START_DATA_SECTION const arm_cp15_start_section_config
+bsp_mm_config_table[] = {
+ {
+ .begin = (uint32_t) bsp_section_fast_text_begin,
+ .end = (uint32_t) bsp_section_fast_text_end,
+ .flags = ARMV7_MMU_CODE_CACHED
+ }, {
+ .begin = (uint32_t) bsp_section_fast_data_begin,
+ .end = (uint32_t) bsp_section_fast_data_end,
+ .flags = MMU_DATA_READ_WRITE
+ }, {
+ .begin = (uint32_t) bsp_section_start_begin,
+ .end = (uint32_t) bsp_section_start_end,
+ .flags = ARMV7_MMU_CODE_CACHED
+ }, {
+ .begin = (uint32_t) bsp_section_vector_begin,
+ .end = (uint32_t) bsp_section_vector_end,
+ .flags = MMU_DATA_READ_WRITE
+ }, {
+ .begin = (uint32_t) bsp_section_text_begin,
+ .end = (uint32_t) bsp_section_text_end,
+ .flags = ARMV7_MMU_CODE_CACHED
+ }, {
+ .begin = (uint32_t) bsp_section_rodata_begin,
+ .end = (uint32_t) bsp_section_rodata_end,
+ .flags = ARMV7_MMU_DATA_READ_ONLY_CACHED
+ }, {
+ .begin = (uint32_t) bsp_section_data_begin,
+ .end = (uint32_t) bsp_section_data_end,
+ .flags = MMU_DATA_READ_WRITE
+ }, {
+ .begin = (uint32_t) bsp_section_bss_begin,
+ .end = (uint32_t) bsp_section_bss_end,
+ .flags = MMU_DATA_READ_WRITE
+ }, {
+ .begin = (uint32_t) bsp_section_work_begin,
+ .end = (uint32_t) bsp_section_work_end,
+ .flags = MMU_DATA_READ_WRITE
+ }, {
+ .begin = (uint32_t) bsp_section_stack_begin,
+ .end = (uint32_t) bsp_section_stack_end,
+ .flags = MMU_DATA_READ_WRITE
+ }
+};
+
+BSP_START_DATA_SECTION const size_t bsp_mm_config_table_size =
+RTEMS_ARRAY_SIZE(&bsp_mm_config_table);