<div dir="ltr">Hi,<br><br>It has been suggested that the function bsp_memory_management_<div>initialize()
 in mminit.c be modified so that it is shareable between more arm 
variants ( will be useful only for those that support cp15 model  ). <br>I think currently only the 
raspberry pi uses it, and was not suitable for Pi 2 either. <br></div><div>I have made some changes. I request you to review it for further changes as needed.<br></div><br><div>Thanks!<br></div>---<br>c/src/lib/libbsp/arm/<div>raspberrypi/include/bsp.h     |    3 ++<br> .../libbsp/arm/raspberrypi/startup/bspstarthooks.c |    8 ++---<br> .../libbsp/arm/raspberrypi/startup/bspstartmmu.c   |   30 +++++++++++++++++<br> c/src/lib/libbsp/arm/shared/mminit.c               |   35 ++++----------------<br> c/src/lib/libbsp/shared/include/mm.h               |    4 +++<br> 5 files changed, 48 insertions(+), 32 deletions(-)<br> create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/bspstartmmu.c<br><br>diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h<br>index c05a410..d9e86d8 100644<br>--- a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h<br>+++ b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h<br>@@ -47,3 +47,6 @@ extern "C" {<br>  * @brief Raspberry Pi support package<br>  *<br>  */<br>+<br>+void raspberrypi_setup_mmu_and_cache(void);<br>+<br>diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c<br>index 047c8ad..107649f 100644<br>--- a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c<br>+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c<br>@@ -26,15 +26,15 @@<br> #include <bsp/start.h><br> #include <bsp/raspberrypi.h><br> #include <bsp/mm.h><br>+#include <bsp.h><br> <br> void BSP_START_TEXT_SECTION bsp_start_hook_0(void)<br>-{<br>+{ <br> }<br> <br>-<br> void BSP_START_TEXT_SECTION bsp_start_hook_1(void)<br> {<br>   bsp_start_copy_sections();<br>-  bsp_memory_management_initialize();<br>+  raspberrypi_setup_mmu_and_cache();<br>   bsp_start_clear_bss();<br>-}<br>+}<br>\ No newline at end of file<br>diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstartmmu.c b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstartmmu.c<br>new file mode 100644<br>index 0000000..506346e<br>--- /dev/null<br>+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstartmmu.c<br>@@ -0,0 +1,30 @@<br>+#define ARM_CP15_TEXT_SECTION BSP_START_TEXT_SECTION<br>+<br>+#include <bsp/start.h><br>+#include <bsp/arm-cp15-start.h><br>+#include <bsp/linker-symbols.h><br>+#include <libcpu/arm-cp15.h><br>+#include <bsp/mm.h><br>+#include <bsp.h><br>+<br>+uint32_t bsp_initial_mmu_ctrl_set;<br>+uint32_t bsp_initial_mmu_ctrl_clear;<br>+uint32_t domain_set;<br>+<br>+void raspberrypi_setup_mmu_and_cache(void)<br>+{   <br>+#if (BSP_IS_RPI2 == 1)<br>+  /* Enable SMP in auxiliary control */<br>+  uint32_t actlr = arm_cp15_get_auxiliary_control();<br>+  actlr |= ARM_CORTEX_A9_ACTL_SMP;<br>+  arm_cp15_set_auxiliary_control(actlr);  <br>+  bsp_initial_mmu_ctrl_clear = ARM_CP15_CTRL_A;<br>+  bsp_initial_mmu_ctrl_set = ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z;  <br>+#else<br>+  bsp_initial_mmu_ctrl_clear = 0;<br>+  bsp_initial_mmu_ctrl_set = ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_S | ARM_CP15_CTRL_XP;  <br>+#endif<br>+  domain_set = ARM_MMU_DEFAULT_CLIENT_DOMAIN;<br>+  <br>+  bsp_memory_management_initialize();<br>+}<br>\ No newline at end of file<br>diff --git a/c/src/lib/libbsp/arm/shared/mminit.c b/c/src/lib/libbsp/arm/shared/mminit.c<br>index 96ca1ec..c9d42e4 100644<br>--- a/c/src/lib/libbsp/arm/shared/mminit.c<br>+++ b/c/src/lib/libbsp/arm/shared/mminit.c<br>@@ -11,42 +11,21 @@<br> #include <bsp/start.h><br> #include <bsp/arm-cp15-start.h><br> #include <bsp/linker-symbols.h><br>+#include <libcpu/arm-cp15.h><br> #include <bsp/mm.h><br> <br>-#if (BSP_IS_RPI2 == 1)<br>-BSP_START_TEXT_SECTION void bsp_memory_management_initialize(void)<br>-{  <br>-  /* Enable SMP in auxiliary control */<br>-  uint32_t actlr = arm_cp15_get_auxiliary_control();<br>-  actlr |= ARM_CORTEX_A9_ACTL_SMP;<br>-  arm_cp15_set_auxiliary_control(actlr);<br> <br>+BSP_START_TEXT_SECTION void bsp_memory_management_initialize()<br>+{<br>   uint32_t ctrl = arm_cp15_start_setup_mmu_and_cache(<br>-    ARM_CP15_CTRL_A,<br>-    ARM_CP15_CTRL_AFE| ARM_CP15_CTRL_Z<br>-  );<br>+    bsp_initial_mmu_ctrl_clear,<br>+    bsp_initial_mmu_ctrl_set  );<br>   <br>   arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(<br>     ctrl,<br>     (uint32_t *) bsp_translation_table_base,<br>-    ARM_MMU_DEFAULT_CLIENT_DOMAIN,<br>-    &arm_cp15_start_mmu_config_table[0],<br>-    arm_cp15_start_mmu_config_table_size<br>-  );<br>-}<br>-#else<br>-BSP_START_TEXT_SECTION void bsp_memory_management_initialize(void)<br>-{<br>-  uint32_t ctrl = arm_cp15_get_control();<br>-<br>-  ctrl |= ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_S | ARM_CP15_CTRL_XP;<br>-<br>-  arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(<br>-    ctrl,<br>-    (uint32_t *) bsp_translation_table_base,<br>-    ARM_MMU_DEFAULT_CLIENT_DOMAIN,<br>+    domain_set,<br>     &arm_cp15_start_mmu_config_table[0],<br>     arm_cp15_start_mmu_config_table_size<br>   );<br>-}<br>-#endif<br>\ No newline at end of file<br>+}<br>\ No newline at end of file<br>diff --git a/c/src/lib/libbsp/shared/include/mm.h b/c/src/lib/libbsp/shared/include/mm.h<br>index 2152f68..299b6c5 100644<br>--- a/c/src/lib/libbsp/shared/include/mm.h<br>+++ b/c/src/lib/libbsp/shared/include/mm.h<br>@@ -33,6 +33,10 @@ extern "C" {<br>  *  @brief MM Support Package<br>  */<br> <br>+extern uint32_t bsp_initial_mmu_ctrl_set;<br>+extern uint32_t bsp_initial_mmu_ctrl_clear;<br>+extern uint32_t domain_set;<br>+<br> void bsp_memory_management_initialize(void);<br> <br> #ifdef __cplusplus<br>-- <br>1.7.9.5</div><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr">Rohini Kulkarni</div></div>
</div>