[PATCH] Code refactor: Changes to memory management initialization
Rohini Kulkarni
krohini1593 at gmail.com
Sun Jul 12 16:58:22 UTC 2015
Hi,
Please review the changes. I will work on the suggestions and make the
required modifications.
Thanks.
On 9 Jul 2015 19:24, <krohini1593 at gmail.com> wrote:
From: Rohini Kulkarni <krohini1593 at gmail.com>
---
c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 1 +
c/src/lib/libbsp/arm/raspberrypi/include/bsp.h | 14 ++++----
.../libbsp/arm/raspberrypi/startup/bspstarthooks.c | 8 ++---
.../libbsp/arm/raspberrypi/startup/bspstartmmu.c | 34
++++++++++++++++++++
c/src/lib/libbsp/arm/shared/mminit.c | 20 ++++++++----
c/src/lib/libbsp/shared/include/mm.h | 6 +++-
6 files changed, 65 insertions(+), 18 deletions(-)
create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/bspstartmmu.c
diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
index d59263c..74545d6 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
@@ -131,6 +131,7 @@ libbsp_a_CPPFLAGS +=
-I$(srcdir)/../../../libcpu/arm/shared/include
# Start hooks
libbsp_a_SOURCES += startup/bspstarthooks.c
+libbsp_a_SOURCES += startup/bspstartmmu.c
# LIBMM
libbsp_a_SOURCES += startup/mm_config_table.c
diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h
b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h
index c05a410..410d9ab 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h
+++ b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h
@@ -33,12 +33,6 @@ extern "C" {
#define BSP_FEATURE_IRQ_EXTENSION
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* LIBBSP_ARM_RASPBERRYPI_BSP_H */
-
/**
* @defgroup arm_raspberrypi Raspberry Pi Support
*
@@ -47,3 +41,11 @@ extern "C" {
* @brief Raspberry Pi support package
*
*/
+
+void raspberrypi_setup_mmu_and_cache(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* LIBBSP_ARM_RASPBERRYPI_BSP_H */
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c
b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c
index 047c8ad..107649f 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c
@@ -26,15 +26,15 @@
#include <bsp/start.h>
#include <bsp/raspberrypi.h>
#include <bsp/mm.h>
+#include <bsp.h>
void BSP_START_TEXT_SECTION bsp_start_hook_0(void)
-{
+{
}
-
void BSP_START_TEXT_SECTION bsp_start_hook_1(void)
{
bsp_start_copy_sections();
- bsp_memory_management_initialize();
+ raspberrypi_setup_mmu_and_cache();
bsp_start_clear_bss();
-}
+}
\ No newline at end of file
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstartmmu.c
b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstartmmu.c
new file mode 100644
index 0000000..3741070
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstartmmu.c
@@ -0,0 +1,34 @@
+#define ARM_CP15_TEXT_SECTION BSP_START_TEXT_SECTION
+
+#include <bsp/start.h>
+#include <bsp/arm-cp15-start.h>
+#include <bsp/linker-symbols.h>
+#include <libcpu/arm-cp15.h>
+#include <bsp/mm.h>
+#include <bsp.h>
+
+void raspberrypi_setup_mmu_and_cache(void)
+{
+ uint32_t bsp_initial_mmu_ctrl_set;
+ uint32_t bsp_initial_mmu_ctrl_clear;
+ uint32_t domain_set;
+
+#if (BSP_IS_RPI2 == 1)
+ /* Enable SMP in auxiliary control */
+ uint32_t actlr = arm_cp15_get_auxiliary_control();
+ actlr |= ARM_CORTEX_A9_ACTL_SMP;
+ arm_cp15_set_auxiliary_control(actlr);
+ bsp_initial_mmu_ctrl_clear = ARM_CP15_CTRL_A;
+ bsp_initial_mmu_ctrl_set = ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z;
+#else
+ bsp_initial_mmu_ctrl_clear = 0;
+ bsp_initial_mmu_ctrl_set = ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_S |
ARM_CP15_CTRL_XP;
+#endif
+ domain_set = ARM_MMU_DEFAULT_CLIENT_DOMAIN;
+
+ bsp_memory_management_initialize(
+ bsp_initial_mmu_ctrl_set,
+ bsp_initial_mmu_ctrl_clear,
+ domain_set
+ );
+}
\ No newline at end of file
diff --git a/c/src/lib/libbsp/arm/shared/mminit.c
b/c/src/lib/libbsp/arm/shared/mminit.c
index acfbfc0..b477482 100644
--- a/c/src/lib/libbsp/arm/shared/mminit.c
+++ b/c/src/lib/libbsp/arm/shared/mminit.c
@@ -11,19 +11,25 @@
#include <bsp/start.h>
#include <bsp/arm-cp15-start.h>
#include <bsp/linker-symbols.h>
+#include <libcpu/arm-cp15.h>
#include <bsp/mm.h>
-BSP_START_TEXT_SECTION void bsp_memory_management_initialize(void)
-{
- uint32_t ctrl = arm_cp15_get_control();
-
- ctrl |= ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_S | ARM_CP15_CTRL_XP;
+BSP_START_TEXT_SECTION void bsp_memory_management_initialize(
+ uint32_t bsp_initial_mmu_ctrl_set,
+ uint32_t bsp_initial_mmu_ctrl_clear,
+ uint32_t domain_set
+)
+{
+ uint32_t ctrl = arm_cp15_start_setup_mmu_and_cache(
+ bsp_initial_mmu_ctrl_clear,
+ bsp_initial_mmu_ctrl_set );
+
arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
ctrl,
(uint32_t *) bsp_translation_table_base,
- ARM_MMU_DEFAULT_CLIENT_DOMAIN,
+ domain_set,
&arm_cp15_start_mmu_config_table[0],
arm_cp15_start_mmu_config_table_size
);
-}
+}
\ No newline at end of file
diff --git a/c/src/lib/libbsp/shared/include/mm.h
b/c/src/lib/libbsp/shared/include/mm.h
index 2152f68..49ee472 100644
--- a/c/src/lib/libbsp/shared/include/mm.h
+++ b/c/src/lib/libbsp/shared/include/mm.h
@@ -33,7 +33,11 @@ extern "C" {
* @brief MM Support Package
*/
-void bsp_memory_management_initialize(void);
+void bsp_memory_management_initialize(
+ uint32_t bsp_initial_mmu_ctrl_set,
+ uint32_t bsp_initial_mmu_ctrl_clear,
+ uint32_t domain_set
+);
#ifdef __cplusplus
}
--
1.7.9.5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20150712/73fa7acd/attachment-0002.html>
More information about the devel
mailing list