[PATCH 4/5] libmm support for realview, xilinx_zynq, and raspberry pi BSPs
Hesham AL-Matary
heshamelmatary at gmail.com
Mon Aug 26 00:14:54 UTC 2013
---
c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 11 ++-
c/src/lib/libbsp/arm/raspberrypi/preinstall.am | 16 +++++
.../libbsp/arm/raspberrypi/startup/bspstarthooks.c | 22 ++----
c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds | 2 +
.../arm/raspberrypi/startup/mm_config_table.h | 76 ++++++++++++++++++++
c/src/lib/libbsp/arm/realview-pbx-a9/Makefile.am | 8 ++-
c/src/lib/libbsp/arm/realview-pbx-a9/preinstall.am | 20 ++++--
.../arm/realview-pbx-a9/startup/bspstarthooks.c | 79 +-------------------
.../arm/realview-pbx-a9/startup/mm_config_table.h | 83 ++++++++++++++++++++++
c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am | 6 ++
c/src/lib/libbsp/arm/xilinx-zynq/preinstall.am | 12 ++++
.../libbsp/arm/xilinx-zynq/startup/bspstarthooks.c | 72 +------------------
.../arm/xilinx-zynq/startup/mm_config_table.h | 83 ++++++++++++++++++++++
13 files changed, 318 insertions(+), 172 deletions(-)
create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/mm_config_table.h
create mode 100644 c/src/lib/libbsp/arm/realview-pbx-a9/startup/mm_config_table.h
create mode 100644 c/src/lib/libbsp/arm/xilinx-zynq/startup/mm_config_table.h
diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
index 24d396c..76f9659 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
@@ -35,16 +35,21 @@ 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
include_bsp_HEADERS += include/mmu.h
include_bsp_HEADERS += include/usart.h
include_bsp_HEADERS += include/raspberrypi.h
+include_bsp_HEADERS += startup/mm_config_table.h
include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/cache_.h \
../../../libcpu/arm/shared/include/arm-cp15.h
+include_libcpu_HEADERS += ../../../libcpu/shared/include/mm.h
+include_libcpu_HEADERS += ../../../libcpu/arm/shared/include/arm_cp15_print_fsr.h
+
###############################################################################
# Data #
###############################################################################
@@ -83,7 +88,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 +96,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 +133,9 @@ libbsp_a_CPPFLAGS += -I$(srcdir)/../../../libcpu/arm/shared/include
# Start hooks
libbsp_a_SOURCES += startup/bspstarthooks.c
+# LIBMM
+libbsp_a_SOURCES += ../../../libcpu/arm/shared/src/mm.c
+
###############################################################################
# Network #
###############################################################################
diff --git a/c/src/lib/libbsp/arm/raspberrypi/preinstall.am b/c/src/lib/libbsp/arm/raspberrypi/preinstall.am
index 056c5f1..a86affd 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/preinstall.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/preinstall.am
@@ -94,6 +94,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
@@ -118,6 +122,10 @@ $(PROJECT_INCLUDE)/bsp/raspberrypi.h: include/raspberrypi.h $(PROJECT_INCLUDE)/b
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/raspberrypi.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/raspberrypi.h
+$(PROJECT_INCLUDE)/bsp/mm_config_table.h: startup/mm_config_table.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/mm_config_table.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/mm_config_table.h
+
$(PROJECT_INCLUDE)/libcpu/cache_.h: ../../../libcpu/arm/shared/include/cache_.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/cache_.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/cache_.h
@@ -126,6 +134,14 @@ $(PROJECT_INCLUDE)/libcpu/arm-cp15.h: ../../../libcpu/arm/shared/include/arm-cp1
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/arm-cp15.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/arm-cp15.h
+$(PROJECT_INCLUDE)/libcpu/mm.h: ../../../libcpu/shared/include/mm.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/mm.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/mm.h
+
+$(PROJECT_INCLUDE)/libcpu/arm_cp15_print_fsr.h: ../../../libcpu/arm/shared/include/arm_cp15_print_fsr.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/arm_cp15_print_fsr.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/arm_cp15_print_fsr.h
+
$(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c
index a224168..81f44c6 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
@@ -25,27 +26,12 @@
#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/linker-symbols.h>
+#include <rtems/score/mm.h>
void BSP_START_TEXT_SECTION bsp_start_hook_0(void)
{
- raspberrypi_cache_setup();
+ _CPU_Memory_management_Initialize();
}
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds b/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds
index b9a0dd8..f07a17b 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds
@@ -36,6 +36,7 @@
MEMORY {
VECTOR_RAM (AIW) : ORIGIN = 0x0 , LENGTH = 0x8000
RAM (AIW) : ORIGIN = 0x00008000, LENGTH = 128M - 0x8000
+ 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.h b/c/src/lib/libbsp/arm/raspberrypi/startup/mm_config_table.h
new file mode 100644
index 0000000..018f3a0
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/mm_config_table.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <info at 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/arm-cp15-start.h>
+#include <libcpu/arm-cp15.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 static arm_cp15_start_section_config
+_cpu_mmu_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
+ }
+};
+
+const static uint32_t translation_table[] =
+{
+ ARMV7_MMU_DATA_READ_WRITE,
+ ARMV7_MMU_READ_ONLY,
+ ARMV7_MMU_DATA_READ_WRITE,
+ 0U
+};
diff --git a/c/src/lib/libbsp/arm/realview-pbx-a9/Makefile.am b/c/src/lib/libbsp/arm/realview-pbx-a9/Makefile.am
index e97c120..6b73b71 100644
--- a/c/src/lib/libbsp/arm/realview-pbx-a9/Makefile.am
+++ b/c/src/lib/libbsp/arm/realview-pbx-a9/Makefile.am
@@ -36,7 +36,6 @@ include_bsp_HEADERS += ../shared/include/start.h
include_bsp_HEADERS += ../shared/include/arm-a9mpcore-irq.h
include_bsp_HEADERS += ../shared/include/arm-a9mpcore-regs.h
include_bsp_HEADERS += ../shared/include/arm-a9mpcore-start.h
-include_bsp_HEADERS += ../shared/include/arm-cp15-start.h
include_bsp_HEADERS += ../shared/include/arm-gic.h
include_bsp_HEADERS += ../shared/include/arm-gic-irq.h
include_bsp_HEADERS += ../shared/include/arm-gic-regs.h
@@ -48,8 +47,12 @@ include_bsp_HEADERS += ../shared/include/arm-pl050-regs.h
include_bsp_HEADERS += ../shared/include/arm-pl111-fb.h
include_bsp_HEADERS += ../shared/include/arm-pl111-regs.h
include_bsp_HEADERS += include/irq.h
+include_bsp_HEADERS += ../shared/include/arm-cp15-start.h
+include_bsp_HEADERS += startup/mm_config_table.h
include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/arm-cp15.h
+include_libcpu_HEADERS += ../../../libcpu/shared/include/mm.h
+include_libcpu_HEADERS += ../../../libcpu/arm/shared/include/arm_cp15_print_fsr.h
###############################################################################
# Data #
@@ -127,6 +130,9 @@ libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c
libbsp_a_SOURCES += ../../../libcpu/arm/shared/include/cache_.h
libbsp_a_CPPFLAGS += -I$(srcdir)/../../../libcpu/arm/shared/include
+# LIBMM
+libbsp_a_SOURCES += ../../../libcpu/arm/shared/src/mm.c
+
# Start hooks
libbsp_a_SOURCES += startup/bspstarthooks.c
diff --git a/c/src/lib/libbsp/arm/realview-pbx-a9/preinstall.am b/c/src/lib/libbsp/arm/realview-pbx-a9/preinstall.am
index 8d26e05..d1d49cb 100644
--- a/c/src/lib/libbsp/arm/realview-pbx-a9/preinstall.am
+++ b/c/src/lib/libbsp/arm/realview-pbx-a9/preinstall.am
@@ -98,10 +98,6 @@ $(PROJECT_INCLUDE)/bsp/arm-a9mpcore-start.h: ../shared/include/arm-a9mpcore-star
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-a9mpcore-start.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-a9mpcore-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/arm-gic.h: ../shared/include/arm-gic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-gic.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-gic.h
@@ -146,10 +142,26 @@ $(PROJECT_INCLUDE)/bsp/irq.h: include/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.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/mm_config_table.h: startup/mm_config_table.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/mm_config_table.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/mm_config_table.h
+
$(PROJECT_INCLUDE)/libcpu/arm-cp15.h: ../../../libcpu/arm/shared/include/arm-cp15.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/arm-cp15.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/arm-cp15.h
+$(PROJECT_INCLUDE)/libcpu/mm.h: ../../../libcpu/shared/include/mm.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/mm.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/mm.h
+
+$(PROJECT_INCLUDE)/libcpu/arm_cp15_print_fsr.h: ../../../libcpu/arm/shared/include/arm_cp15_print_fsr.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/arm_cp15_print_fsr.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/arm_cp15_print_fsr.h
+
$(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
diff --git a/c/src/lib/libbsp/arm/realview-pbx-a9/startup/bspstarthooks.c b/c/src/lib/libbsp/arm/realview-pbx-a9/startup/bspstarthooks.c
index e598c06..05bd000 100644
--- a/c/src/lib/libbsp/arm/realview-pbx-a9/startup/bspstarthooks.c
+++ b/c/src/lib/libbsp/arm/realview-pbx-a9/startup/bspstarthooks.c
@@ -14,84 +14,9 @@
#include <bsp.h>
#include <bsp/start.h>
-#include <bsp/arm-cp15-start.h>
#include <bsp/arm-a9mpcore-start.h>
#include <bsp/linker-symbols.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 static const arm_cp15_start_section_config
-rvpbxa9_mmu_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
- }, {
- .begin = 0x10000000U,
- .end = 0x10020000U,
- .flags = ARMV7_MMU_DEVICE
- }, {
- .begin = 0x1f000000U,
- .end = 0x20000000U,
- .flags = ARMV7_MMU_DEVICE
- }
-};
-
-BSP_START_TEXT_SECTION static void setup_mmu_and_cache(void)
-{
- uint32_t ctrl = arm_cp15_start_setup_mmu_and_cache(
- ARM_CP15_CTRL_A,
- ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z
- );
-
- arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
- ctrl,
- (uint32_t *) bsp_translation_table_base,
- ARM_MMU_DEFAULT_CLIENT_DOMAIN,
- &rvpbxa9_mmu_config_table[0],
- RTEMS_ARRAY_SIZE(rvpbxa9_mmu_config_table)
- );
-}
+#include <rtems/score/mm.h>
BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
{
@@ -102,6 +27,6 @@ BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
{
arm_a9mpcore_start_hook_1();
bsp_start_copy_sections();
- setup_mmu_and_cache();
+ _CPU_Memory_management_Initialize();
bsp_start_clear_bss();
}
diff --git a/c/src/lib/libbsp/arm/realview-pbx-a9/startup/mm_config_table.h b/c/src/lib/libbsp/arm/realview-pbx-a9/startup/mm_config_table.h
new file mode 100644
index 0000000..7ada8c7
--- /dev/null
+++ b/c/src/lib/libbsp/arm/realview-pbx-a9/startup/mm_config_table.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <info at 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/arm-cp15-start.h>
+#include <libcpu/arm-cp15.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 static arm_cp15_start_section_config
+_cpu_mmu_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
+ }, {
+ .begin = 0x10000000U,
+ .end = 0x10020000U,
+ .flags = ARMV7_MMU_DEVICE
+ }, {
+ .begin = 0x1f000000U,
+ .end = 0x20000000U,
+ .flags = ARMV7_MMU_DEVICE
+ }
+};
+
+const static uint32_t translation_table[] =
+{
+ ARMV7_MMU_DATA_READ_WRITE,
+ ARMV7_MMU_READ_ONLY,
+ ARMV7_MMU_DATA_READ_WRITE,
+ 0U
+};
diff --git a/c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am b/c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am
index 0e584b5..1a1d7e1 100644
--- a/c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am
+++ b/c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am
@@ -44,8 +44,11 @@ include_bsp_HEADERS += ../shared/include/arm-gic-tm27.h
include_bsp_HEADERS += include/irq.h
include_bsp_HEADERS += include/zynq-uart.h
include_bsp_HEADERS += include/zynq-uart-regs.h
+include_bsp_HEADERS += startup/mm_config_table.h
include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/arm-cp15.h
+include_libcpu_HEADERS += ../../../libcpu/shared/include/mm.h
+include_libcpu_HEADERS += ../../../libcpu/arm/shared/include/arm_cp15_print_fsr.h
###############################################################################
# Data #
@@ -126,6 +129,9 @@ libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c
libbsp_a_SOURCES += ../../../libcpu/arm/shared/include/cache_.h
libbsp_a_CPPFLAGS += -I$(srcdir)/../../../libcpu/arm/shared/include
+# MMU
+libbsp_a_SOURCES += ../../../libcpu/arm/shared/src/mm.c
+
# Start hooks
libbsp_a_SOURCES += startup/bspstarthooks.c
diff --git a/c/src/lib/libbsp/arm/xilinx-zynq/preinstall.am b/c/src/lib/libbsp/arm/xilinx-zynq/preinstall.am
index 838ff2b..959c4ca 100644
--- a/c/src/lib/libbsp/arm/xilinx-zynq/preinstall.am
+++ b/c/src/lib/libbsp/arm/xilinx-zynq/preinstall.am
@@ -130,10 +130,22 @@ $(PROJECT_INCLUDE)/bsp/zynq-uart-regs.h: include/zynq-uart-regs.h $(PROJECT_INCL
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/zynq-uart-regs.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/zynq-uart-regs.h
+$(PROJECT_INCLUDE)/bsp/mm_config_table.h: startup/mm_config_table.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/mm_config_table.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/mm_config_table.h
+
$(PROJECT_INCLUDE)/libcpu/arm-cp15.h: ../../../libcpu/arm/shared/include/arm-cp15.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/arm-cp15.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/arm-cp15.h
+$(PROJECT_INCLUDE)/libcpu/mm.h: ../../../libcpu/shared/include/mm.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/mm.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/mm.h
+
+$(PROJECT_INCLUDE)/libcpu/arm_cp15_print_fsr.h: ../../../libcpu/arm/shared/include/arm_cp15_print_fsr.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/arm_cp15_print_fsr.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/arm_cp15_print_fsr.h
+
$(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
diff --git a/c/src/lib/libbsp/arm/xilinx-zynq/startup/bspstarthooks.c b/c/src/lib/libbsp/arm/xilinx-zynq/startup/bspstarthooks.c
index 8d02c25..54b4f46 100644
--- a/c/src/lib/libbsp/arm/xilinx-zynq/startup/bspstarthooks.c
+++ b/c/src/lib/libbsp/arm/xilinx-zynq/startup/bspstarthooks.c
@@ -14,7 +14,6 @@
#include <bsp.h>
#include <bsp/start.h>
-#include <bsp/arm-cp15-start.h>
#include <bsp/arm-a9mpcore-start.h>
#include <bsp/linker-symbols.h>
@@ -24,75 +23,6 @@
#define MMU_DATA_READ_WRITE ARMV7_MMU_DATA_READ_WRITE_CACHED
#endif
-BSP_START_DATA_SECTION static const arm_cp15_start_section_config
-zynq_mmu_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
- }, {
- .begin = 0xe0000000U,
- .end = 0xe0200000U,
- .flags = ARMV7_MMU_DEVICE
- }, {
- .begin = 0xf8000000U,
- .end = 0xf9000000U,
- .flags = ARMV7_MMU_DEVICE
- }
-};
-
-BSP_START_TEXT_SECTION static void setup_mmu_and_cache(void)
-{
- uint32_t ctrl = arm_cp15_start_setup_mmu_and_cache(
- ARM_CP15_CTRL_A,
- ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z
- );
-
- arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
- ctrl,
- (uint32_t *) bsp_translation_table_base,
- ARM_MMU_DEFAULT_CLIENT_DOMAIN,
- &zynq_mmu_config_table[0],
- RTEMS_ARRAY_SIZE(zynq_mmu_config_table)
- );
-}
-
BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
{
arm_a9mpcore_start_hook_0();
@@ -102,6 +32,6 @@ BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
{
arm_a9mpcore_start_hook_1();
bsp_start_copy_sections();
- setup_mmu_and_cache();
+ _CPU_Memory_management_Initialize();
bsp_start_clear_bss();
}
diff --git a/c/src/lib/libbsp/arm/xilinx-zynq/startup/mm_config_table.h b/c/src/lib/libbsp/arm/xilinx-zynq/startup/mm_config_table.h
new file mode 100644
index 0000000..e6bafef
--- /dev/null
+++ b/c/src/lib/libbsp/arm/xilinx-zynq/startup/mm_config_table.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <info at 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/arm-cp15-start.h>
+#include <libcpu/arm-cp15.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 static const arm_cp15_start_section_config
+_cpu_mmu_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
+ }, {
+ .begin = 0xe0000000U,
+ .end = 0xe0200000U,
+ .flags = ARMV7_MMU_DEVICE
+ }, {
+ .begin = 0xf8000000U,
+ .end = 0xf9000000U,
+ .flags = ARMV7_MMU_DEVICE
+ }
+};
+
+const static uint32_t translation_table[] =
+{
+ ARMV7_MMU_DATA_READ_WRITE,
+ ARMV7_MMU_READ_ONLY,
+ ARMV7_MMU_DATA_READ_WRITE,
+ 0U
+};
--
1.8.3.1
More information about the devel
mailing list