[PATCH 1/5] libmm score API
Hesham AL-Matary
heshamelmatary at gmail.com
Mon Aug 26 00:14:51 UTC 2013
---
cpukit/score/Makefile.am | 2 +
cpukit/score/include/rtems/score/mm.h | 52 ++++++++++++++++++++
cpukit/score/include/rtems/score/mmimpl.h | 80 +++++++++++++++++++++++++++++++
cpukit/score/preinstall.am | 8 ++++
4 files changed, 142 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..43f6fc9
--- /dev/null
+++ b/cpukit/score/include/rtems/score/mm.h
@@ -0,0 +1,52 @@
+/**
+ * @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
+
+/* @defgroup SuperCoreMM Memory Management Support
+ *
+ * @ingroup Score
+ */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief _Memory_management_Region Flags defs
+ */
+#define RTEMS_MM_REGION_NO_PROTECTION 0x0
+#define RTEMS_MM_REGION_PROTECTION_READ_ONLY 0x1
+#define RTEMS_MM_REGION_PROTECTION_WRITE 0x2
+#define RTEMS_MM_REGION_NO_ACCESS 0x3
+//#define RTEMS_MM_REGION_PROTECTION_EXEC 0x4
+
+void _Memory_management_Initialize( void );
+
+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..7eecef0
--- /dev/null
+++ b/cpukit/score/include/rtems/score/mmimpl.h
@@ -0,0 +1,80 @@
+/**
+ * @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 <libcpu/mm.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup SuperCoreMM
+ */
+/**@{**/
+
+#ifdef RTEMS_SMP
+SMP_lock_Control mm_lock;
+#endif
+
+/**
+ * @brief Calls _CPU_Memory_management_Initialize.
+ */
+void _Memory_management_Initialize( void )
+{
+#ifdef RTEMS_SMP
+ _SMP_lock_Initialize( &mm_lock );
+#endif
+
+ _CPU_Memory_management_Initialize();
+}
+
+/**
+ * @brief Calls _CPU_Memory_management_Set_attributes.
+ */
+void _Memory_management_Set_attributes(
+ uintptr_t base,
+ size_t size,
+ uint32_t attr
+)
+{
+#ifdef RTEMS_SMP
+ _SMP_lock_Acquire( &mm_lock );
+#endif
+
+ _CPU_Memory_management_Set_attributes(base, size, attr);
+
+#ifdef RTEMS_SMP
+ _SMP_lock_Release( &mm_lock );
+#endif
+}
+
+/** @}*/
+
+#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
More information about the devel
mailing list