[PATCH 1/2] libmm score and stubs
Hesham AL-Matary
heshamelmatary at gmail.com
Tue Jul 23 21:24:05 UTC 2013
---
c/src/lib/libcpu/shared/include/mm.h | 23 +++++++
c/src/lib/libcpu/shared/src/no_memorymanagement.c | 17 +++++
cpukit/score/Makefile.am | 2 +
cpukit/score/include/rtems/score/mm.h | 55 +++++++++++++++
cpukit/score/inline/rtems/score/mm.inl | 82 +++++++++++++++++++++++
cpukit/score/preinstall.am | 8 +++
testsuites/libtests/Makefile.am | 2 +-
testsuites/libtests/configure.ac | 1 +
testsuites/libtests/mmtest1/Makefile.am | 18 +++++
testsuites/libtests/mmtest1/init.c | 41 ++++++++++++
testsuites/libtests/mmtest1/mmtest1.doc | 1 +
testsuites/libtests/mmtest1/mmtests.scn | 7 ++
testsuites/libtests/mmtest1/system.h | 33 +++++++++
13 files changed, 289 insertions(+), 1 deletion(-)
create mode 100644 c/src/lib/libcpu/shared/include/mm.h
create mode 100644 c/src/lib/libcpu/shared/src/no_memorymanagement.c
create mode 100644 cpukit/score/include/rtems/score/mm.h
create mode 100644 cpukit/score/inline/rtems/score/mm.inl
create mode 100644 testsuites/libtests/mmtest1/Makefile.am
create mode 100644 testsuites/libtests/mmtest1/init.c
create mode 100644 testsuites/libtests/mmtest1/mmtest1.doc
create mode 100644 testsuites/libtests/mmtest1/mmtests.scn
create mode 100644 testsuites/libtests/mmtest1/system.h
diff --git a/c/src/lib/libcpu/shared/include/mm.h b/c/src/lib/libcpu/shared/include/mm.h
new file mode 100644
index 0000000..02903f1
--- /dev/null
+++ b/c/src/lib/libcpu/shared/include/mm.h
@@ -0,0 +1,23 @@
+/*
+ * 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 __LIBCPU_MM_H
+#define __LIBCPU_MM_H
+
+#include <rtems/score/mm.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void _CPU_Memory_management_Initialize(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/c/src/lib/libcpu/shared/src/no_memorymanagement.c b/c/src/lib/libcpu/shared/src/no_memorymanagement.c
new file mode 100644
index 0000000..f5380a0
--- /dev/null
+++ b/c/src/lib/libcpu/shared/src/no_memorymanagement.c
@@ -0,0 +1,17 @@
+/*
+ * 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.
+ */
+
+#include <rtems.h>
+#include <libcpu/mm.h>
+
+void _CPU_Memory_management_Initialize( void ) { }
+
+void _CPU_Memory_management_Install_entry( uintptr_t base, size_t size, uint32_t flags ) { }
+
+void _CPU_Memory_management_Uninstall_entry( uintptr_t base, size_t size ) { }
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 3f6e686..58a865b 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -30,6 +30,7 @@ include_rtems_score_HEADERS += include/rtems/score/protectedheap.h
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/mm.h
include_rtems_score_HEADERS += include/rtems/score/object.h
include_rtems_score_HEADERS += include/rtems/score/percpu.h
include_rtems_score_HEADERS += include/rtems/score/priority.h
@@ -90,6 +91,7 @@ include_rtems_score_HEADERS += inline/rtems/score/coremutex.inl
include_rtems_score_HEADERS += inline/rtems/score/coresem.inl
include_rtems_score_HEADERS += inline/rtems/score/heap.inl
include_rtems_score_HEADERS += inline/rtems/score/isr.inl
+include_rtems_score_HEADERS += inline/rtems/score/mm.inl
include_rtems_score_HEADERS += inline/rtems/score/object.inl
include_rtems_score_HEADERS += inline/rtems/score/priority.inl
include_rtems_score_HEADERS += inline/rtems/score/prioritybitmap.inl
diff --git a/cpukit/score/include/rtems/score/mm.h b/cpukit/score/include/rtems/score/mm.h
new file mode 100644
index 0000000..c1f950d
--- /dev/null
+++ b/cpukit/score/include/rtems/score/mm.h
@@ -0,0 +1,55 @@
+/**
+ * @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
+ */
+/**@{*/
+
+#include <inttypes.h>
+
+#ifdef RTEMS_SMP
+#include <rtems/score/smplock.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/**
+ * @brief _Memory_management_Region Flags defs
+ */
+#define RTEMS_MM_REGION_PROTECTION_READ_ONLY 0x1
+#define RTEMS_MM_REGION_PROTECTION_WRITE 0x2
+//#define RTEMS_MM_REGION_PROTECTION_EXEC 0x4
+
+#ifdef RTEMS_SMP
+SMP_lock_Control mm_lock;
+#endif
+
+#ifndef __RTEMS_APPLICATION__
+#include <rtems/score/mm.inl>
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/**@}*/
+
+#endif
diff --git a/cpukit/score/inline/rtems/score/mm.inl b/cpukit/score/inline/rtems/score/mm.inl
new file mode 100644
index 0000000..765c147
--- /dev/null
+++ b/cpukit/score/inline/rtems/score/mm.inl
@@ -0,0 +1,82 @@
+/**
+ * @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_MM_H
+# error "Never use <rtems/score/mm.inl> directly; include <rtems/score/mm.h> instead."
+#endif
+
+#ifndef _RTEMS_SCORE_MM_INL
+#define _RTEMS_SCORE_MM_INL
+
+/**
+ * @addtogroup SuperCoreMM
+ */
+/**@{**/
+
+/**
+ * @brief Calls _CPU_Memory_management_Initialize.
+ */
+RTEMS_INLINE_ROUTINE void _Memory_management_Initialize( void )
+{
+#ifdef RTEMS_SMP
+ _SMP_lock_Initialize( &mm_lock );
+#endif
+
+ _CPU_Memory_management_Initialize();
+}
+
+/**
+ * @brief Calls _CPU_Memory_management_Install_entry.
+ */
+RTEMS_INLINE_ROUTINE void _Memory_management_Install_entry(
+ uintptr_t base,
+ size_t size,
+ uint32_t attr
+)
+{
+#ifdef RTEMS_SMP
+ _SMP_lock_Acquire( &mm_lock );
+#endif
+
+ _CPU_Memory_management_Install_entry(base, size, attr);
+
+#ifdef RTEMS_SMP
+ _SMP_lock_Release( &mm_lock );
+#endif
+}
+
+/**
+ * @brief Calls _CPU_Memory_management_Uninstall_entry.
+ */
+RTEMS_INLINE_ROUTINE void _Memory_management_Uninstall_entry(
+ uintptr_t base,
+ size_t size
+)
+{
+#ifdef RTEMS_SMP
+ _SMP_lock_Acquire( &mm_lock );
+#endif
+
+ _CPU_Memory_management_Uninstall_entry(base, size);
+
+#ifdef RTEMS_SMP
+ _SMP_lock_Release( &mm_lock );
+#endif
+
+}
+
+/** @}*/
+
+#endif
diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am
index dc84b21..100f090 100644
--- a/cpukit/score/preinstall.am
+++ b/cpukit/score/preinstall.am
@@ -103,6 +103,10 @@ $(PROJECT_INCLUDE)/rtems/score/isrlevel.h: include/rtems/score/isrlevel.h $(PROJ
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/isrlevel.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/isrlevel.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/object.h: include/rtems/score/object.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/object.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/object.h
@@ -298,6 +302,10 @@ $(PROJECT_INCLUDE)/rtems/score/isr.inl: inline/rtems/score/isr.inl $(PROJECT_INC
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/isr.inl
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/isr.inl
+$(PROJECT_INCLUDE)/rtems/score/mm.inl: inline/rtems/score/mm.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/mm.inl
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/mm.inl
+
$(PROJECT_INCLUDE)/rtems/score/object.inl: inline/rtems/score/object.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/object.inl
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/object.inl
diff --git a/testsuites/libtests/Makefile.am b/testsuites/libtests/Makefile.am
index d1ffabc..d56398b 100644
--- a/testsuites/libtests/Makefile.am
+++ b/testsuites/libtests/Makefile.am
@@ -16,7 +16,7 @@ SUBDIRS += flashdisk01
SUBDIRS += bspcmdline01 cpuuse devfs01 devfs02 devfs03 devfs04 \
deviceio01 devnullfatal01 dumpbuf01 gxx01 \
malloctest malloc02 malloc03 malloc04 malloc05 heapwalk \
- putenvtest monitor monitor02 rtmonuse stackchk stackchk01 \
+ putenvtest monitor monitor02 mmtest1 rtmonuse stackchk stackchk01 \
termios termios01 termios02 termios03 termios04 termios05 \
termios06 termios07 termios08 \
rtems++ tztest block01 block02 block03 block04 block05 block06 block07 \
diff --git a/testsuites/libtests/configure.ac b/testsuites/libtests/configure.ac
index 741c603..c1dbb78 100644
--- a/testsuites/libtests/configure.ac
+++ b/testsuites/libtests/configure.ac
@@ -85,6 +85,7 @@ malloc02/Makefile
malloc03/Makefile
malloc04/Makefile
malloc05/Makefile
+mmtest1/Makefile
monitor/Makefile
monitor02/Makefile
mouse01/Makefile
diff --git a/testsuites/libtests/mmtest1/Makefile.am b/testsuites/libtests/mmtest1/Makefile.am
new file mode 100644
index 0000000..a08e557
--- /dev/null
+++ b/testsuites/libtests/mmtest1/Makefile.am
@@ -0,0 +1,18 @@
+
+rtems_tests_PROGRAMS = mmtest1
+mmtest1_SOURCES = init.c system.h
+
+dist_rtems_tests_DATA = mmtests.scn
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+LINK_OBJS = $(mmtest1_OBJECTS) $(mmtest1_LDADD)
+LINK_LIBS = $(mmtest1_LDLIBS)
+
+mmtest1$(EXEEXT): $(mmtest1_OBJECTS) $(mmtest1_DEPENDENCIES)
+ @rm -f mmtest1$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/libtests/mmtest1/init.c b/testsuites/libtests/mmtest1/init.c
new file mode 100644
index 0000000..b110044
--- /dev/null
+++ b/testsuites/libtests/mmtest1/init.c
@@ -0,0 +1,41 @@
+/* Init
+ *
+ * This routine is the initialization task for this test program.
+ *
+ */
+
+/*
+ * Copyright (c) 2013 Gedare Bloom.
+ * Copyright (c) 2012 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.
+ */
+
+#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
+#define CONFIGURE_INIT
+#include "system.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <rtems/score/mm.h>
+
+rtems_task Init(
+ rtems_task_argument ignored
+)
+{
+
+ puts( "\n\n*** Start of mmtest1 ***\n" );
+
+ printf("Test 1: Installing Entry-1 \
+and set it as Read only\n");
+ _Memory_management_Install_entry( 0x00100000, 0x200000, RTEMS_MM_REGION_PROTECTION_READ_ONLY);
+
+ printf("Test 2 : Installing Entry-2\
+and set it as Write enabled\n");
+ _Memory_management_Install_entry( 0x00400000, 0x100000, RTEMS_MM_REGION_PROTECTION_WRITE);
+
+ printf( "\n\n*** End of mmtest1 ***\n" );
+
+ exit( 0 );
+}
diff --git a/testsuites/libtests/mmtest1/mmtest1.doc b/testsuites/libtests/mmtest1/mmtest1.doc
new file mode 100644
index 0000000..210a761
--- /dev/null
+++ b/testsuites/libtests/mmtest1/mmtest1.doc
@@ -0,0 +1 @@
+Simple tests that tries to install memory management entries.
diff --git a/testsuites/libtests/mmtest1/mmtests.scn b/testsuites/libtests/mmtest1/mmtests.scn
new file mode 100644
index 0000000..6ba15c2
--- /dev/null
+++ b/testsuites/libtests/mmtest1/mmtests.scn
@@ -0,0 +1,7 @@
+*** Start of mmtest1 ***
+
+Test 1: Installing Entry-1 and set it as Read only
+Test 2 : Installing Entry-2and set it as Write enabled
+
+
+*** End of mmtest1 ***
diff --git a/testsuites/libtests/mmtest1/system.h b/testsuites/libtests/mmtest1/system.h
new file mode 100644
index 0000000..7560e1d
--- /dev/null
+++ b/testsuites/libtests/mmtest1/system.h
@@ -0,0 +1,33 @@
+/* system.h
+ *
+ * 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.
+ */
+
+#include <rtems.h>
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+/* configuration information */
+
+#include <bsp.h> /* for device driver prototypes */
+
+/* NOTICE: the clock driver is explicitly disabled */
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 9
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
+
+#include <rtems/confdefs.h>
+/* end of include file */
--
1.8.3.1
More information about the devel
mailing list