[PATCH 5/6] libmm-arm-bsps-support-raspberrypi-realview-xilinx_zynq Modifications for ARM BSPs to support libmm. Each BSP defines its memory configuration table which describes memory regions and their attributes. The configuration table is passed to memory management initialization routine which initialzes page tables and MMU hardware at BSP startup.

Hesham AL-Matary heshamelmatary at gmail.com
Thu Sep 12 06:59:32 UTC 2013


---
 c/src/lib/libbsp/arm/raspberrypi/Makefile.am       | 10 ++-
 c/src/lib/libbsp/arm/raspberrypi/preinstall.am     |  8 +++
 .../libbsp/arm/raspberrypi/startup/bspstarthooks.c | 22 +-----
 c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds  |  4 +-
 .../arm/raspberrypi/startup/mm_config_table.c      | 71 +++++++++++++++++++
 c/src/lib/libbsp/arm/realview-pbx-a9/Makefile.am   |  6 ++
 c/src/lib/libbsp/arm/realview-pbx-a9/preinstall.am | 12 ++--
 .../arm/realview-pbx-a9/startup/bspstarthooks.c    | 80 +---------------------
 .../arm/realview-pbx-a9/startup/mm_config_table.c  | 79 +++++++++++++++++++++
 c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am       |  6 ++
 c/src/lib/libbsp/arm/xilinx-zynq/preinstall.am     |  4 ++
 .../libbsp/arm/xilinx-zynq/startup/bspstarthooks.c | 74 +-------------------
 .../arm/xilinx-zynq/startup/mm_config_table.c      | 79 +++++++++++++++++++++
 13 files changed, 280 insertions(+), 175 deletions(-)
 create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/mm_config_table.c
 create mode 100644 c/src/lib/libbsp/arm/realview-pbx-a9/startup/mm_config_table.c
 create mode 100644 c/src/lib/libbsp/arm/xilinx-zynq/startup/mm_config_table.c

diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
index 24d396c..e1a38e3 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,11 @@ 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/mm.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 056c5f1..a638e64 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 a224168..bb887ca 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,28 +25,11 @@
 #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();
+  bsp_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..c12b348 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 0000000..35d5ebd
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/mm_config_table.c
@@ -0,0 +1,71 @@
+/*
+ * 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/mm.h>
+#include <libcpu/arm-cp15.h>
+#include <bsp/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 mm_init_start_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);
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..d663f4a 100644
--- a/c/src/lib/libbsp/arm/realview-pbx-a9/Makefile.am
+++ b/c/src/lib/libbsp/arm/realview-pbx-a9/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
@@ -127,6 +128,11 @@ 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 += startup/mm_config_table.c
+libbsp_a_SOURCES += ../shared/mm.c
+libbsp_a_SOURCES += ../shared/mminit.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..d5e1a96 100644
--- a/c/src/lib/libbsp/arm/realview-pbx-a9/preinstall.am
+++ b/c/src/lib/libbsp/arm/realview-pbx-a9/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
@@ -98,10 +102,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,6 +146,10 @@ $(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)/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
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..a3cde20 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,8 @@
 
 #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 <bsp/mm.h>
 
 BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
 {
@@ -102,6 +26,6 @@ BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
 {
   arm_a9mpcore_start_hook_1();
   bsp_start_copy_sections();
-  setup_mmu_and_cache();
+  bsp_memory_management_initialize();
   bsp_start_clear_bss();
 }
diff --git a/c/src/lib/libbsp/arm/realview-pbx-a9/startup/mm_config_table.c b/c/src/lib/libbsp/arm/realview-pbx-a9/startup/mm_config_table.c
new file mode 100644
index 0000000..46e88a5
--- /dev/null
+++ b/c/src/lib/libbsp/arm/realview-pbx-a9/startup/mm_config_table.c
@@ -0,0 +1,79 @@
+/*
+ * 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/mm.h>
+#include <libcpu/arm-cp15.h>
+#include <bsp/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 mm_init_start_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
+  }, {
+    .begin = 0x10000000U,
+    .end = 0x10020000U,
+    .flags = ARMV7_MMU_DEVICE
+  }, {
+    .begin = 0x1f000000U,
+    .end = 0x20000000U,
+    .flags = ARMV7_MMU_DEVICE
+  }
+};
+
+BSP_START_DATA_SECTION const size_t bsp_mm_config_table_size = 
+RTEMS_ARRAY_SIZE(&bsp_mm_config_table);
diff --git a/c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am b/c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am
index 99ad202..30e8b56 100644
--- a/c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am
+++ b/c/src/lib/libbsp/arm/xilinx-zynq/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
@@ -126,6 +127,11 @@ libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c
 libbsp_a_SOURCES += include/cache_.h
 libbsp_a_CPPFLAGS += -I$(srcdir)/include
 
+# LIBMM
+libbsp_a_SOURCES += startup/mm_config_table.c
+libbsp_a_SOURCES += ../shared/mm.c
+libbsp_a_SOURCES += ../shared/mminit.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..50e25f6 100644
--- a/c/src/lib/libbsp/arm/xilinx-zynq/preinstall.am
+++ b/c/src/lib/libbsp/arm/xilinx-zynq/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
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..fd5003e 100644
--- a/c/src/lib/libbsp/arm/xilinx-zynq/startup/bspstarthooks.c
+++ b/c/src/lib/libbsp/arm/xilinx-zynq/startup/bspstarthooks.c
@@ -14,9 +14,8 @@
 
 #include <bsp.h>
 #include <bsp/start.h>
-#include <bsp/arm-cp15-start.h>
 #include <bsp/arm-a9mpcore-start.h>
-#include <bsp/linker-symbols.h>
+#include <bsp/mm.h>
 
 #ifdef RTEMS_SMP
   #define MMU_DATA_READ_WRITE ARMV7_MMU_DATA_READ_WRITE_SHAREABLE
@@ -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();
+  bsp_memory_management_initialize();
   bsp_start_clear_bss();
 }
diff --git a/c/src/lib/libbsp/arm/xilinx-zynq/startup/mm_config_table.c b/c/src/lib/libbsp/arm/xilinx-zynq/startup/mm_config_table.c
new file mode 100644
index 0000000..bac3741
--- /dev/null
+++ b/c/src/lib/libbsp/arm/xilinx-zynq/startup/mm_config_table.c
@@ -0,0 +1,79 @@
+/*
+ * 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/mm.h>
+#include <libcpu/arm-cp15.h>
+#include <bsp/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 mm_init_start_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
+  }, {
+    .begin = 0xe0000000U,
+    .end = 0xe0200000U,
+    .flags = ARMV7_MMU_DEVICE
+  }, {
+    .begin = 0xf8000000U,
+    .end = 0xf9000000U,
+    .flags = ARMV7_MMU_DEVICE
+  }
+};
+
+BSP_START_DATA_SECTION const size_t bsp_mm_config_table_size =
+RTEMS_ARRAY_SIZE(&bsp_mm_config_table);
-- 
1.8.3.1




More information about the devel mailing list