[PATCH 2/3] shared MMU initialization for ARM BSPs

Hesham Moustafa heshamelmatary at gmail.com
Mon Sep 16 16:27:23 UTC 2013


Please review the patch on the previous reply only.



On Mon, Sep 16, 2013 at 6:23 PM, Hesham Moustafa
<heshamelmatary at gmail.com>wrote:

> From 4d2a4662da9b0988c9e871490ed4ca466940754b Mon Sep 17 00:00:00 2001
> From: Hesham AL-Matary <heshamelmatary at gmail.com>
> Date: Sun, 15 Sep 2013 12:37:25 +0200
> Subject: [PATCH 2/3] shared MMU initialization for ARM BSPs
>
> The newly added ORed flag: ARM_CP15_CTRL_XP is vital to get RaspberryPi
> MMU working properly and to share the container function between various
> ARM BSPs. The new ORed flags do not affect the current BSPs that make use
> of arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache
> function.
>
> The rest is of the patch targets MMU initialization for ARM architectures,
> desgined to be shared. Later patches make use of shared mminit
> implementation.
> ---
>  .../lib/libbsp/arm/shared/include/arm-cp15-start.h | 12 +++++----
>  c/src/lib/libbsp/arm/shared/mminit.c               | 27
> +++++++++++++++++++
>  c/src/lib/libbsp/shared/include/mm.h               | 31
> ++++++++++++++++++++++
>  3 files changed, 65 insertions(+), 5 deletions(-)
>  create mode 100644 c/src/lib/libbsp/arm/shared/mminit.c
>  create mode 100644 c/src/lib/libbsp/shared/include/mm.h
>
> 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
> index 01f3104..70b0f60 100644
> --- a/c/src/lib/libbsp/arm/shared/include/arm-cp15-start.h
> +++ b/c/src/lib/libbsp/arm/shared/include/arm-cp15-start.h
> @@ -1,4 +1,5 @@
> -/*
> +/*
> + * Copyright (c) 2013 Hesham AL-Matary.
>   * Copyright (c) 2009-2013 embedded brains GmbH.  All rights reserved.
>   *
>   *  embedded brains GmbH
> @@ -16,7 +17,6 @@
>  #define LIBBSP_ARM_SHARED_ARM_CP15_START_H
>
>  #include <libcpu/arm-cp15.h>
> -
>  #include <bsp/start.h>
>
>  #ifdef __cplusplus
> @@ -87,9 +87,9 @@
> arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
>    arm_cp15_set_domain_access_control(dac);
>    arm_cp15_set_translation_table_base(ttb);
>
> -  /* Initialize translation table with invalid entries */
> +  /* Initialize translation table with fixed-map read-write entries */
>    for (i = 0; i < ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT; ++i) {
> -    ttb [i] = 0;
> +    ttb [i] = (i << ARM_MMU_SECT_BASE_SHIFT) | ARMV7_MMU_DATA_READ_WRITE;
>    }
>
>    for (i = 0; i < config_count; ++i) {
> @@ -97,7 +97,9 @@
> arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
>    }
>
>    /* Enable MMU and cache */
> -  ctrl |= ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M;
> +  ctrl |= ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_S | ARM_CP15_CTRL_I |
> +          ARM_CP15_CTRL_C | ARM_CP15_CTRL_M  | ARM_CP15_CTRL_XP;
> +
>    arm_cp15_set_control(ctrl);
>  }
>
> diff --git a/c/src/lib/libbsp/arm/shared/mminit.c
> b/c/src/lib/libbsp/arm/shared/mminit.c
> new file mode 100644
> index 0000000..c3d9f16
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/shared/mminit.c
> @@ -0,0 +1,27 @@
> +/*
> + * Copyright (c) 2013 Hesham AL-Matary.
> + *
> + * 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 <bsp/linker-symbols.h>
> +#include <bsp/mm.h>
> +#include <bsp/start.h>
> +
> +extern const arm_cp15_start_section_config bsp_mm_config_table[];
> +extern const size_t bsp_mm_config_table_size;
> +
> +BSP_START_TEXT_SECTION void bsp_memory_management_initialize(void)
> +{
> +  uint32_t ctrl = arm_cp15_get_control();
> +
> +  arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
> +    ctrl,
> +    (uint32_t *) bsp_translation_table_base,
> +    ARM_MMU_DEFAULT_CLIENT_DOMAIN,
> +    &bsp_mm_config_table[0],
> +    bsp_mm_config_table_size
> +  );
> +}
> diff --git a/c/src/lib/libbsp/shared/include/mm.h
> b/c/src/lib/libbsp/shared/include/mm.h
> new file mode 100644
> index 0000000..476c288
> --- /dev/null
> +++ b/c/src/lib/libbsp/shared/include/mm.h
> @@ -0,0 +1,31 @@
> +/*
> + * Copyright (c) 2013 Hesham AL-Matary.
> + * Copyright (c) 2013 Gedare Bloom.
> + *
> + * 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.
> + */
> +
> +#ifndef __LIBBSP_MM_H
> +#define __LIBBSP_MM_H
> +
> +#include <stdint.h>
> +#include <stdlib.h>
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +void bsp_memory_management_initialize(void);
> +
> +void bsp_memory_management_set_attributes(
> +  uintptr_t base,
> +  size_t size,
> +  uint32_t attr
> +);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +#endif
> --
> 1.8.3.1
>
>
>
> On Mon, Sep 16, 2013 at 6:17 PM, Hesham AL-Matary <
> heshamelmatary at gmail.com> wrote:
>
>> The newly added ORed flag: ARM_CP15_CTRL_XP is vital to get RaspberryPi
>> MMU working properly and to share the container function between various
>> ARM BSPs. The new ORed flags do not affect the current BSPs that make use
>> of arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache
>> function.
>>
>> The rest is of the patch targets MMU initialization for ARM architectures,
>> desgined to be shared. Later patches make use of shared mminit
>> implementation.
>>
>> ---
>>  c/src/lib/libbsp/arm/shared/mminit.c | 27 +++++++++++++++++++++++++++
>>  c/src/lib/libbsp/shared/include/mm.h | 31 +++++++++++++++++++++++++++++++
>>  2 files changed, 58 insertions(+)
>>  create mode 100644 c/src/lib/libbsp/arm/shared/mminit.c
>>  create mode 100644 c/src/lib/libbsp/shared/include/mm.h
>>
>> diff --git a/c/src/lib/libbsp/arm/shared/mminit.c
>> b/c/src/lib/libbsp/arm/shared/mminit.c
>> new file mode 100644
>> index 0000000..c3d9f16
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/arm/shared/mminit.c
>> @@ -0,0 +1,27 @@
>> +/*
>> + * Copyright (c) 2013 Hesham AL-Matary.
>> + *
>> + * 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 <bsp/linker-symbols.h>
>> +#include <bsp/mm.h>
>> +#include <bsp/start.h>
>> +
>> +extern const arm_cp15_start_section_config bsp_mm_config_table[];
>> +extern const size_t bsp_mm_config_table_size;
>> +
>> +BSP_START_TEXT_SECTION void bsp_memory_management_initialize(void)
>> +{
>> +  uint32_t ctrl = arm_cp15_get_control();
>> +
>> +  arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
>> +    ctrl,
>> +    (uint32_t *) bsp_translation_table_base,
>> +    ARM_MMU_DEFAULT_CLIENT_DOMAIN,
>> +    &bsp_mm_config_table[0],
>> +    bsp_mm_config_table_size
>> +  );
>> +}
>> diff --git a/c/src/lib/libbsp/shared/include/mm.h
>> b/c/src/lib/libbsp/shared/include/mm.h
>> new file mode 100644
>> index 0000000..476c288
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/shared/include/mm.h
>> @@ -0,0 +1,31 @@
>> +/*
>> + * Copyright (c) 2013 Hesham AL-Matary.
>> + * Copyright (c) 2013 Gedare Bloom.
>> + *
>> + * 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.
>> + */
>> +
>> +#ifndef __LIBBSP_MM_H
>> +#define __LIBBSP_MM_H
>> +
>> +#include <stdint.h>
>> +#include <stdlib.h>
>> +
>> +#ifdef __cplusplus
>> +extern "C" {
>> +#endif
>> +
>> +void bsp_memory_management_initialize(void);
>> +
>> +void bsp_memory_management_set_attributes(
>> +  uintptr_t base,
>> +  size_t size,
>> +  uint32_t attr
>> +);
>> +
>> +#ifdef __cplusplus
>> +}
>> +#endif
>> +#endif
>> --
>> 1.8.3.1
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20130916/8bed64cf/attachment-0001.html>


More information about the devel mailing list