[PATCH 3/3] MMU support for RaspberryPi BSP
Gedare Bloom
gedare at rtems.org
Fri Sep 27 19:09:58 UTC 2013
On Mon, Sep 16, 2013 at 12:20 PM, Hesham AL-Matary
<heshamelmatary at gmail.com> wrote:
> ---
> c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 9 ++-
> 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 | 70 ++++++++++++++++++++++
> 5 files changed, 92 insertions(+), 21 deletions(-)
> create mode 100644 c/src/lib/libbsp/arm/raspberrypi/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..a06979a 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,10 @@ 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/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..71b2ff1 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,33 +25,16 @@
> #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();
> }
>
>
> void BSP_START_TEXT_SECTION bsp_start_hook_1(void)
> {
> bsp_start_copy_sections();
> + bsp_memory_management_initialize();
> bsp_start_clear_bss();
> }
> 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
This file probably should be included with the previous patch, since
it defines the needed "config_table" variables. You should also put an
extern declaration of those variables somewhere useful, perhaps in
arm-cp15-start.h if you intend to generalize the rest of the arm-cp15
BSPs to use the same variables.
> new file mode 100644
> index 0000000..fd85513
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/raspberrypi/startup/mm_config_table.c
> @@ -0,0 +1,70 @@
> +/*
> + * 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/start.h>
> +#include <bsp/arm-cp15-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 arm_cp15_start_section_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);
> --
> 1.8.3.1
>
> _______________________________________________
> rtems-devel mailing list
> rtems-devel at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-devel
More information about the devel
mailing list