<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 12, 2013 at 3:01 PM, Gedare Bloom <span dir="ltr"><<a href="mailto:gedare@rtems.org" target="_blank">gedare@rtems.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On Thu, Sep 12, 2013 at 2:59 AM, Hesham AL-Matary<br>
<<a href="mailto:heshamelmatary@gmail.com">heshamelmatary@gmail.com</a>> wrote:<br>
> ---<br>
> .../lib/libbsp/arm/shared/include/arm-cp15-start.h | 11 ++++--<br>
> c/src/lib/libbsp/arm/shared/mm.c | 46 ++++++++++++++++++++++<br>
> c/src/lib/libbsp/arm/shared/mminit.c | 27 +++++++++++++<br>
> 3 files changed, 80 insertions(+), 4 deletions(-)<br>
> create mode 100644 c/src/lib/libbsp/arm/shared/mm.c<br>
> create mode 100644 c/src/lib/libbsp/arm/shared/mminit.c<br>
><br>
> diff --git a/c/src/lib/libbsp/arm/shared/include/arm-cp15-start.h b/c/src/lib/libbsp/arm/shared/include/arm-cp15-start.h<br>
> index 01f3104..b463b1f 100644<br>
> --- a/c/src/lib/libbsp/arm/shared/include/arm-cp15-start.h<br>
> +++ b/c/src/lib/libbsp/arm/shared/include/arm-cp15-start.h<br>
> @@ -1,4 +1,5 @@<br>
> -/*<br>
> +/*<br>
> + * Copyright (c) 2013 Hesham AL-Matary.<br>
> * Copyright (c) 2009-2013 embedded brains GmbH. All rights reserved.<br>
> *<br>
> * embedded brains GmbH<br>
> @@ -89,7 +90,7 @@ arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(<br>
><br>
> /* Initialize translation table with invalid entries */<br>
</div>Fix this comment (assuming the change below now populates the ttb with<br>
valid entries).<br>
<div class="im"><br>
> for (i = 0; i < ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT; ++i) {<br>
> - ttb [i] = 0;<br>
> + ttb [i] = (i << ARM_MMU_SECT_BASE_SHIFT) | ARMV7_MMU_DATA_READ_WRITE;<br>
> }<br>
><br>
> for (i = 0; i < config_count; ++i) {<br>
> @@ -97,11 +98,13 @@ arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(<br>
> }<br>
><br>
> /* Enable MMU and cache */<br>
> - ctrl |= ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M;<br>
> + ctrl |= ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_S | ARM_CP15_CTRL_I |<br>
> + ARM_CP15_CTRL_C | ARM_CP15_CTRL_M | ARM_CP15_CTRL_XP;<br>
> +<br>
> arm_cp15_set_control(ctrl);<br>
> }<br>
><br>
> -BSP_START_TEXT_SECTION static inline uint32_t<br>
> +BSP_START_TEXT_SECTION inline uint32_t<br>
</div>undo this change.<br></blockquote><div>I already did, but that caused undefined reference to <span style="color:rgb(80,0,80)">arm_</span>cp15_start_setup_mmu_and_cache<br>compilation error at arm-a9mpcore-start.h:89 when I was compiling realview with --enable-smp<br>
option.</div><div dir="rtl"> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div class="h5">
> arm_cp15_start_setup_mmu_and_cache(uint32_t ctrl_clear, uint32_t ctrl_set)<br>
> {<br>
> uint32_t ctrl = arm_cp15_get_control();<br>
> diff --git a/c/src/lib/libbsp/arm/shared/mm.c b/c/src/lib/libbsp/arm/shared/mm.c<br>
> new file mode 100644<br>
> index 0000000..36e90be<br>
> --- /dev/null<br>
> +++ b/c/src/lib/libbsp/arm/shared/mm.c<br>
> @@ -0,0 +1,46 @@<br>
> +/*<br>
> + * Copyright (c) 2013 Hesham AL-Matary.<br>
> + *<br>
> + * The license and distribution terms for this file may be<br>
> + * found in the file LICENSE in this distribution or at<br>
> + * <a href="http://www.rtems.com/license/LICENSE" target="_blank">http://www.rtems.com/license/LICENSE</a>.<br>
> + */<br>
> +<br>
> +#include <bsp/mm.h><br>
> +#include <libcpu/arm-cp15.h><br>
> +#include <rtems/score/mm.h><br>
> +<br>
> +#define LIBMM_REGION_IS_CACHE_ENABLED(attr) \<br>
> + (((attr) >> RTEMS_MM_REGION_BIT_CACHE) & 1U)<br>
> +#define LIBMM_REGION_IS_PROTECTION_WRITE_ENABLED(attr) \<br>
> + (((attr) >> RTEMS_MM_REGION_BIT_WRITE) & 1U)<br>
> +#define LIBMM_REGION_IS_DEVICE_TYPE(attr) \<br>
> + (((attr) >> RTEMS_MM_REGION_BIT_DEVICE) & 1U)<br>
> +#define LIBMM_REGION_IS_SHARED_MEMORY(attr) \<br>
> + (((attr) >> RTEMS_MM_REGION_BIT_SHARED) & 1U)<br>
> +<br>
</div></div>Should these macros be provided by the score/mm.h?<br>
<div class="im"><br></div></blockquote><div>mm.h or mmimpl.h whatever. It's used by applications calls as well as </div><div>mm.c which used these definitions to translate attributes to CPU specific ones.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">
> +#define ARM_MMU_BIND_SECTION_TO_CLIENT_DOMAIN \<br>
> + (ARM_MMU_DEFAULT_CLIENT_DOMAIN << ARM_MMU_SECT_DOMAIN_SHIFT)<br>
> +<br>
> +#define LIBMM_TRANSLATE_ATTRIBUTES_TO_CPU(attr) \<br>
> + ((ARM_MMU_BIND_SECTION_TO_CLIENT_DOMAIN) \<br>
> + | (ARM_MMU_SECT_AP_0) \<br>
> + | (LIBMM_REGION_IS_PROTECTION_WRITE_ENABLED(attr) ? \<br>
> + 0U : (ARM_MMU_SECT_AP_2)) \<br>
> + | (LIBMM_REGION_IS_CACHE_ENABLED(attr) ? \<br>
> + (ARM_MMU_SECT_TEX_0|ARM_MMU_SECT_C|ARM_MMU_SECT_B) : 0U) \<br>
> + | (LIBMM_REGION_IS_DEVICE_TYPE(attr) ? ARM_MMU_SECT_B : 0U) \<br>
> + | (LIBMM_REGION_IS_SHARED_MEMORY(attr) ? ARM_MMU_SECT_S : 0U) \<br>
> + | (ARM_MMU_SECT_DEFAULT))<br>
> +<br>
</div>This macro could properly be named something simpler since it is local<br>
to this .c file.<br>
<div class="im"><br></div></blockquote><div>Sure, I just wanted to give it a self-describing name. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">
> +void bsp_memory_management_set_attributes(<br>
> + uintptr_t base,<br>
> + size_t size,<br>
> + uint32_t attr<br>
> +)<br>
> +{<br>
> + uintptr_t end = (uint32_t)base + (uint32_t)size;<br>
</div>Don't cast base and size here.<br>
<div><div class="h5"><br>
> + uint32_t section_flags = LIBMM_TRANSLATE_ATTRIBUTES_TO_CPU(attr);<br>
> +<br>
> + arm_cp15_set_translation_table_entries(base, end, section_flags);<br>
> +}<br>
> diff --git a/c/src/lib/libbsp/arm/shared/mminit.c b/c/src/lib/libbsp/arm/shared/mminit.c<br>
> new file mode 100644<br>
> index 0000000..333d65c<br>
> --- /dev/null<br>
> +++ b/c/src/lib/libbsp/arm/shared/mminit.c<br>
> @@ -0,0 +1,27 @@<br>
> +/*<br>
> + * Copyright (c) 2013 Hesham AL-Matary.<br>
> + *<br>
> + * The license and distribution terms for this file may be<br>
> + * found in the file LICENSE in this distribution or at<br>
> + * <a href="http://www.rtems.com/license/LICENSE" target="_blank">http://www.rtems.com/license/LICENSE</a>.<br>
> + */<br>
> +#include <bsp/arm-cp15-start.h><br>
> +#include <bsp/linker-symbols.h><br>
> +#include <bsp/mm.h><br>
> +#include <bsp/start.h><br>
> +<br>
> +extern const mm_init_start_config bsp_mm_config_table[];<br>
> +extern const size_t bsp_mm_config_table_size;<br>
> +<br>
> +BSP_START_TEXT_SECTION void bsp_memory_management_initialize(void)<br>
> +{<br>
> + uint32_t ctrl = arm_cp15_get_control();<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>
> + &bsp_mm_config_table[0],<br>
> + bsp_mm_config_table_size<br>
> + );<br>
</div></div>Fix indentation level of nested lines of arguments. Also, this<br>
mminit.c file does not make sense until you add at least one of the<br>
ARM bsps using it.<br>
<br></blockquote><div>realview, xilinx, and raspberry currently </div><div>calls the initialization function within this </div><div>mminit.c </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
> +}<br>
<span class=""><font color="#888888">> --<br>
> 1.8.3.1<br>
><br>
> _______________________________________________<br>
> rtems-devel mailing list<br>
> <a href="mailto:rtems-devel@rtems.org">rtems-devel@rtems.org</a><br>
> <a href="http://www.rtems.org/mailman/listinfo/rtems-devel" target="_blank">http://www.rtems.org/mailman/listinfo/rtems-devel</a><br>
</font></span></blockquote></div><br></div></div>