--- cpukit/score/Makefile.am | 2 + cpukit/score/include/rtems/score/mm.h | 60 ++++++++++++++++++++++++ cpukit/score/include/rtems/score/mmimpl.h | 77 +++++++++++++++++++++++++++++++ cpukit/score/preinstall.am | 8 ++++ 4 files changed, 147 insertions(+) create mode 100644 cpukit/score/include/rtems/score/mm.h create mode 100644 cpukit/score/include/rtems/score/mmimpl.h
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index c9d2d47..b94af80 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -37,6 +37,8 @@ include_rtems_score_HEADERS += include/rtems/score/interr.h include_rtems_score_HEADERS += include/rtems/score/isr.h include_rtems_score_HEADERS += include/rtems/score/isrlevel.h include_rtems_score_HEADERS += include/rtems/score/isrlock.h +include_rtems_score_HEADERS += include/rtems/score/mm.h +include_rtems_score_HEADERS += include/rtems/score/mmimpl.h include_rtems_score_HEADERS += include/rtems/score/freechain.h include_rtems_score_HEADERS += include/rtems/score/object.h include_rtems_score_HEADERS += include/rtems/score/objectimpl.h diff --git a/cpukit/score/include/rtems/score/mm.h b/cpukit/score/include/rtems/score/mm.h new file mode 100644 index 0000000..5b1bdde --- /dev/null +++ b/cpukit/score/include/rtems/score/mm.h @@ -0,0 +1,60 @@ +/** + * @file + * + * @brief Manages use of MPU/MMU units to provide memory management. + */ + +/* + * 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 _RTEMS_SCORE_MM_H +#define _RTEMS_SCORE_MM_H + +#include <stdlib.h> +/* @defgroup SuperCoreMM Memory Management Support + * + * @ingroup Score + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief _Memory_management_Region Flags defs + */ + +#define RTEMS_MM_REGION_BIT_READ 0 +#define RTEMS_MM_REGION_BIT_WRITE 1 +#define RTEMS_MM_REGION_BIT_EXECUTE 2 +#define RTEMS_MM_REGION_BIT_CACHE 3 +#define RTEMS_MM_REGION_BIT_DEVICE 4 +#define RTEMS_MM_REGION_BIT_SHARED 5 + +#define RTEMS_MM_REGION_READ (1U << RTEMS_MM_REGION_BIT_READ) +#define RTEMS_MM_REGION_WRITE (1U << RTEMS_MM_REGION_BIT_WRITE) +#define RTEMS_MM_REGION_EXECUTE (1U << RTEMS_MM_REGION_BIT_EXECUTE) +#define RTEMS_MM_REGION_CACHE (1U << RTEMS_MM_REGION_BIT_CACHE) +#define RTEMS_MM_REGION_DEVICE (1U << RTEMS_MM_REGION_BIT_DEVICE) +#define RTEMS_MM_REGION_SHARED (1U << RTEMS_MM_REGION_BIT_SHARED) + +void _Memory_management_Set_attributes( + uintptr_t base, + size_t size, + uint32_t attr +); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif diff --git a/cpukit/score/include/rtems/score/mmimpl.h b/cpukit/score/include/rtems/score/mmimpl.h new file mode 100644 index 0000000..a306a1e --- /dev/null +++ b/cpukit/score/include/rtems/score/mmimpl.h @@ -0,0 +1,77 @@ +/** + * @file + * + * @brief Inlined Routines from the Memory Management Manager + */ + +/* + * 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 _RTEMS_SCORE_MMIMPL_H +#define _RTEMS_SCORE_MMIMPL_H + +#ifdef RTEMS_SMP +#include <rtems/score/smplock.h> +#endif + +#include <stdint.h> +#include <stdlib.h> +#include <rtems/score/mm.h> +#include <bsp/mm.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup SuperCoreMM + */ +/**@{**/ + +#ifdef RTEMS_SMP +static SMP_lock_Control mm_lock; +#endif + +static inline void libmm_smp_lock_obtain( void ) +{ +#ifdef RTEMS_SMP + _SMP_lock_Acquire( &mm_lock ); +#endif +} + +static inline void libmm_smp_lock_release( void ) +{ +#ifdef RTEMS_SMP + _SMP_lock_Release ( &mm_lock ); +#endif +} + +/** + * @brief Calls bsp_memory_management_set_attributes. + */ +void _Memory_management_Set_attributes( + uintptr_t base, + size_t size, + uint32_t attr +) +{ + libmm_smp_lock_obtain(); + bsp_memory_management_set_attributes(base, size, attr); + libmm_smp_lock_release(); + +} + +/** @}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am index 79a18b5..4b3bfcf 100644 --- a/cpukit/score/preinstall.am +++ b/cpukit/score/preinstall.am @@ -131,6 +131,14 @@ $(PROJECT_INCLUDE)/rtems/score/isrlock.h: include/rtems/score/isrlock.h $(PROJEC $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/isrlock.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/isrlock.h +$(PROJECT_INCLUDE)/rtems/score/mm.h: include/rtems/score/mm.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/mm.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/mm.h + +$(PROJECT_INCLUDE)/rtems/score/mmimpl.h: include/rtems/score/mmimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/mmimpl.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/mmimpl.h + $(PROJECT_INCLUDE)/rtems/score/freechain.h: include/rtems/score/freechain.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/freechain.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/freechain.h -- 1.8.3.1 _______________________________________________ rtems-devel mailing list rtems-devel@rtems.org http://www.rtems.org/mailman/listinfo/rtems-devel