diff options
Diffstat (limited to '')
-rw-r--r-- | c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 9 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/raspberrypi/preinstall.am | 8 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c | 22 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds | 4 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/raspberrypi/startup/mm_config_table.c | 70 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/shared/include/arm-cp15-start.h | 25 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/shared/mminit.c | 24 | ||||
-rw-r--r-- | c/src/lib/libbsp/shared/include/mm.h | 25 |
8 files changed, 156 insertions, 31 deletions
diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index 24d396c70b..a06979a887 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 056c5f1eaa..a638e642bb 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 a2241687cc..71b2ff1a44 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 b9a0dd88dc..c12b348cf5 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 new file mode 100644 index 0000000000..5436a76870 --- /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@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); 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 01f3104ade..88f903b1dc 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,13 +17,21 @@ #define LIBBSP_ARM_SHARED_ARM_CP15_START_H #include <libcpu/arm-cp15.h> - #include <bsp/start.h> #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +typedef struct { + uint32_t begin; + uint32_t end; + uint32_t flags; +} arm_cp15_start_section_config; + +extern const arm_cp15_start_section_config bsp_mm_config_table[]; +extern const size_t bsp_mm_config_table_size; + BSP_START_TEXT_SECTION static inline void arm_cp15_set_domain_access_control(uint32_t val); @@ -47,12 +56,6 @@ arm_cp15_get_multiprocessor_affinity(void); BSP_START_TEXT_SECTION static inline uint32_t arm_cortex_a9_get_multiprocessor_cpu_id(void); -typedef struct { - uint32_t begin; - uint32_t end; - uint32_t flags; -} arm_cp15_start_section_config; - BSP_START_TEXT_SECTION static inline void arm_cp15_start_set_translation_table_entries( uint32_t *ttb, @@ -87,9 +90,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 +100,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 0000000000..23e71e62a7 --- /dev/null +++ b/c/src/lib/libbsp/arm/shared/mminit.c @@ -0,0 +1,24 @@ +/* + * 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> + +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 0000000000..1a1eb7ffa2 --- /dev/null +++ b/c/src/lib/libbsp/shared/include/mm.h @@ -0,0 +1,25 @@ +/* + * 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); + +#ifdef __cplusplus +} +#endif +#endif |