<div dir="ltr">Hi,<div><br></div><div>This patch includes basic files and modifications to add libmm support. It includes the high-level score functions API, stubs for BSPs that do not support libmm at low-level and a test case called mmtest1. SPARC BSP is modified to support the stubs and run mmtest1. Another big patch is ready to add nop (stubs) libmm support for *ALL* BSPs after this patch is reviewed. </div>
<div><br></div><div><div>diff --git a/testsuites/libtests/mmtest1/Makefile.am b/testsuites/libtests/mmtest1/Makefile.am</div><div>new file mode 100644</div><div>index 0000000..a08e557</div><div>--- /dev/null</div><div>+++ b/testsuites/libtests/mmtest1/Makefile.am</div>
<div>@@ -0,0 +1,18 @@</div><div>+</div><div>+rtems_tests_PROGRAMS = mmtest1</div><div>+mmtest1_SOURCES = init.c system.h</div><div>+</div><div>+dist_rtems_tests_DATA = mmtests.scn</div><div>+</div><div>+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg</div>
<div>+include $(top_srcdir)/../automake/<a href="http://compile.am">compile.am</a></div><div>+include $(top_srcdir)/../automake/<a href="http://leaf.am">leaf.am</a></div><div>+</div><div>+LINK_OBJS = $(mmtest1_OBJECTS) $(mmtest1_LDADD)</div>
<div>+LINK_LIBS = $(mmtest1_LDLIBS)</div><div>+</div><div>+mmtest1$(EXEEXT): $(mmtest1_OBJECTS) $(mmtest1_DEPENDENCIES)</div><div>+<span class="" style="white-space:pre">  </span>  @rm -f mmtest1$(EXEEXT)</div><div>+<span class="" style="white-space:pre"> </span>  $(make-exe)</div>
<div>+</div><div>+include $(top_srcdir)/../automake/<a href="http://local.am">local.am</a></div><div>diff --git a/testsuites/libtests/mmtest1/init.c b/testsuites/libtests/mmtest1/init.c</div><div>new file mode 100644</div>
<div>index 0000000..9b5c4c4</div><div>--- /dev/null</div><div>+++ b/testsuites/libtests/mmtest1/init.c</div><div>@@ -0,0 +1,59 @@</div><div>+/* Init</div><div>+ *</div><div>+ * This routine is the initialization task for this test program.</div>
<div>+ *</div><div>+ */</div><div>+</div><div>+/*</div><div>+ * Copyright (c) 2013 Gedare Bloom.</div><div>+ * Copyright (c) 2012 Hesham Al-Matary.</div><div>+ *</div><div>+ * The license and distribution terms for this file may be</div>
<div>+ * found in the file LICENSE in this distribution or at</div><div>+ * <a href="http://www.rtems.com/license/LICENSE">http://www.rtems.com/license/LICENSE</a>.</div><div>+ */</div><div>+</div><div>+#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__</div>
<div>+#define CONFIGURE_INIT</div><div>+#include "system.h"</div><div>+#include <stdio.h></div><div>+#include <stdlib.h></div><div>+#include <rtems/score/mm.h></div><div>+</div><div>+rtems_task Init(</div>
<div>+  rtems_task_argument ignored</div><div>+)</div><div>+{</div><div>+  Memory_management_Entry mme1 = {</div><div>+    .name = "Valid Entry-1",</div><div>+    .base = 0x00100000,</div><div>+    .size = 0x200000,</div>
<div>+    .installed = false,</div><div>+    .bsp_mme = NULL</div><div>+  };</div><div>+  Memory_management_Entry mme2 = {</div><div>+    .name = "Valid Entry-2",</div><div>+    .base = 0x00400000,</div><div>+    .size = 0x100000,</div>
<div>+    .installed = false,</div><div>+    .bsp_mme = NULL</div><div>+  };</div><div>+</div><div>+  puts( "\n\n*** Start of mmtest1 ***\n" );</div><div>+</div><div>+  /* Initializing libmm is now done at BSP startup */</div>
<div>+  //puts( "initialize the memory management manager\n");</div><div>+  //_Memory_management_Initialize ( );</div><div>+</div><div>+  printf("Test 1: Installing Entry-1 \</div><div>+and set it as Read only\n");</div>
<div>+  _Memory_management_Install_entry( &mme1, RTEMS_MM_REGION_PROTECTION_READ_ONLY);</div><div>+</div><div>+  printf("Test 2 : Installing Entry-2\</div><div>+and set it as Write enabled\n");</div><div>+  _Memory_management_Install_entry( &mme2, RTEMS_MM_REGION_PROTECTION_WRITE);</div>
<div>+</div><div>+  printf( "\n\n*** End of mmtest1 ***\n" );</div><div>+</div><div>+  exit( 0 );</div><div>+}</div><div>diff --git a/testsuites/libtests/mmtest1/mmtest1.doc b/testsuites/libtests/mmtest1/mmtest1.doc</div>
<div>new file mode 100644</div><div>index 0000000..210a761</div><div>--- /dev/null</div><div>+++ b/testsuites/libtests/mmtest1/mmtest1.doc</div><div>@@ -0,0 +1 @@</div><div>+Simple tests that tries to install memory management entries.</div>
<div>diff --git a/testsuites/libtests/mmtest1/mmtests.scn b/testsuites/libtests/mmtest1/mmtests.scn</div><div>new file mode 100644</div><div>index 0000000..8b13789</div><div>--- /dev/null</div><div>+++ b/testsuites/libtests/mmtest1/mmtests.scn</div>
<div>@@ -0,0 +1 @@</div><div>+</div><div>diff --git a/testsuites/libtests/mmtest1/system.h b/testsuites/libtests/mmtest1/system.h</div><div>new file mode 100644</div><div>index 0000000..7560e1d</div><div>--- /dev/null</div>
<div>+++ b/testsuites/libtests/mmtest1/system.h</div><div>@@ -0,0 +1,33 @@</div><div>+/* system.h</div><div>+ *</div><div>+ * Copyright (c) 2013 Gedare Bloom.</div><div>+ *</div><div>+ * The license and distribution terms for this file may be</div>
<div>+ * found in the file LICENSE in this distribution or at</div><div>+ * <a href="http://www.rtems.com/license/LICENSE">http://www.rtems.com/license/LICENSE</a>.</div><div>+ */</div><div>+</div><div>+#include <rtems.h></div>
<div>+</div><div>+/* functions */</div><div>+</div><div>+rtems_task Init(</div><div>+  rtems_task_argument argument</div><div>+);</div><div>+</div><div>+/* configuration information */</div><div>+</div><div>+#include <bsp.h> /* for device driver prototypes */</div>
<div>+</div><div>+/* NOTICE: the clock driver is explicitly disabled */</div><div>+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER</div><div>+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER</div><div>+</div><div>+#define CONFIGURE_MAXIMUM_TASKS            9</div>
<div>+</div><div>+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE</div><div>+</div><div>+#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM</div><div>+</div><div>+#include <rtems/confdefs.h></div><div>+/* end of include file */</div>
<div>diff --git a/c/src/lib/libcpu/shared/include/mm.h b/c/src/lib/libcpu/shared/include/mm.h</div><div>new file mode 100644</div><div>index 0000000..02903f1</div><div>--- /dev/null</div><div>+++ b/c/src/lib/libcpu/shared/include/mm.h</div>
<div>@@ -0,0 +1,23 @@</div><div>+/*</div><div>+ * Copyright (c) 2013 Gedare Bloom.</div><div>+ *</div><div>+ * The license and distribution terms for this file may be</div><div>+ * found in the file LICENSE in this distribution or at</div>
<div>+ * <a href="http://www.rtems.com/license/LICENSE">http://www.rtems.com/license/LICENSE</a>.</div><div>+ */</div><div>+</div><div>+#ifndef __LIBCPU_MM_H</div><div>+#define __LIBCPU_MM_H</div><div>+</div><div>+#include <rtems/score/mm.h></div>
<div>+</div><div>+#ifdef __cplusplus</div><div>+extern "C" {</div><div>+#endif</div><div>+</div><div>+void _CPU_Memory_management_Initialize(void);</div><div>+</div><div>+#ifdef __cplusplus</div><div>+}</div><div>
+#endif</div><div>+#endif</div><div>diff --git a/c/src/lib/libcpu/shared/src/no_memorymanagement.c b/c/src/lib/libcpu/shared/src/no_memorymanagement.c</div><div>new file mode 100644</div><div>index 0000000..2e3f528</div><div>
--- /dev/null</div><div>+++ b/c/src/lib/libcpu/shared/src/no_memorymanagement.c</div><div>@@ -0,0 +1,17 @@</div><div>+/*</div><div>+ * Copyright (c) 2013 Hesham AL-Matary</div><div>+ * Copyright (c) 2013 Gedare Bloom.</div>
<div>+ *</div><div>+ * The license and distribution terms for this file may be</div><div>+ * found in the file LICENSE in this distribution or at</div><div>+ * <a href="http://www.rtems.com/license/LICENSE">http://www.rtems.com/license/LICENSE</a>.</div>
<div>+ */</div><div>+</div><div>+#include <rtems.h></div><div>+#include <libcpu/mm.h></div><div>+</div><div>+void _CPU_Memory_management_Initialize( void ) { }</div><div>+</div><div>+void _CPU_Memory_management_Install_entry( Memory_management_Entry *mpe, uint32_t flags ) { }</div>
<div>+</div><div>+void _CPU_Memory_management_Uninstall_entry( Memory_management_Entry *mpe ) { }</div><div>diff --git a/c/src/lib/libbsp/sparc/erc32/Makefile.am b/c/src/lib/libbsp/sparc/erc32/Makefile.am</div><div>index 988f3ec..545d945 100644</div>
<div>--- a/c/src/lib/libbsp/sparc/erc32/Makefile.am</div><div>+++ b/c/src/lib/libbsp/sparc/erc32/Makefile.am</div><div>@@ -3,6 +3,7 @@ ACLOCAL_AMFLAGS = -I ../../../../aclocal</div><div> include $(top_srcdir)/../../../../automake/<a href="http://compile.am">compile.am</a></div>
<div> </div><div> include_bspdir = $(includedir)/bsp</div><div>+include_libcpudir = $(includedir)/libcpu</div><div> </div><div> dist_project_lib_DATA = bsp_specs</div><div> </div><div>@@ -18,6 +19,8 @@ noinst_PROGRAMS =</div>
<div> include_HEADERS += include/erc32.h</div><div> include_HEADERS += ../../shared/include/coverhd.h</div><div> </div><div>+include_libcpu_HEADERS = ../../../libcpu/shared/include/mm.h</div><div>+</div><div> noinst_LIBRARIES = libbspstart.a</div>
<div> libbspstart_a_SOURCES = ../../sparc/shared/start.S</div><div> project_lib_DATA = start.$(OBJEXT)</div><div>@@ -65,6 +68,9 @@ libbsp_a_SOURCES += \</div><div>     ../../shared/src/irq-server.c \</div><div>     ../../shared/src/irq-shell.c</div>
<div> </div><div>+# LIBMM </div><div>+libbsp_a_SOURCES += ../../../libcpu/shared/src/no_memorymanagement.c</div><div>+</div><div> if HAS_SMP</div><div> libbsp_a_SOURCES += ../../shared/smp/getcpuid.c ../../shared/smp/smp_stub.c</div>
<div> endif</div><div>diff --git a/c/src/lib/libbsp/sparc/erc32/<a href="http://preinstall.am">preinstall.am</a> b/c/src/lib/libbsp/sparc/erc32/<a href="http://preinstall.am">preinstall.am</a></div><div>index a235296..e422e9d 100644</div>
<div>--- a/c/src/lib/libbsp/sparc/erc32/<a href="http://preinstall.am">preinstall.am</a></div><div>+++ b/c/src/lib/libbsp/sparc/erc32/<a href="http://preinstall.am">preinstall.am</a></div><div>@@ -33,6 +33,11 @@ $(PROJECT_INCLUDE)/bsp/$(dirstamp):</div>
<div> <span class="" style="white-space:pre">   </span>@: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)</div><div> PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)</div><div> </div><div>+$(PROJECT_INCLUDE)/libcpu/$(dirstamp):</div>
<div>+<span class="" style="white-space:pre">   </span>@$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu</div><div>+<span class="" style="white-space:pre">     </span>@: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp)</div><div>+PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp)</div>
<div>+</div><div> $(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)</div><div> <span class="" style="white-space:pre">     </span>$(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs</div><div> PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs</div>
<div>@@ -61,6 +66,10 @@ $(PROJECT_INCLUDE)/coverhd.h: ../../shared/include/coverhd.h $(PROJECT_INCLUDE)/</div><div> <span class="" style="white-space:pre"> </span>$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h</div><div>
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h</div><div> </div><div>+$(PROJECT_INCLUDE)/libcpu/mm.h: ../../../libcpu/shared/include/mm.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)</div><div>+<span class="" style="white-space:pre">     </span>$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/mm.h</div>
<div>+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/mm.h</div><div>+</div><div> $(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)</div><div> <span class="" style="white-space:pre">       </span>$(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)</div>
<div> TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)</div><div>diff --git a/c/src/lib/libbsp/sparc/leon2/Makefile.am b/c/src/lib/libbsp/sparc/leon2/Makefile.am</div><div>index ae6dfb0..bafccee 100644</div><div>--- a/c/src/lib/libbsp/sparc/leon2/Makefile.am</div>
<div>+++ b/c/src/lib/libbsp/sparc/leon2/Makefile.am</div><div>@@ -3,6 +3,7 @@ ACLOCAL_AMFLAGS = -I ../../../../aclocal</div><div> include $(top_srcdir)/../../../../automake/<a href="http://compile.am">compile.am</a></div>
<div> </div><div> include_bspdir = $(includedir)/bsp</div><div>+include_libcpudir = $(includedir)/libcpu</div><div> </div><div> dist_project_lib_DATA = bsp_specs</div><div> </div><div>@@ -28,6 +29,7 @@ include_HEADERS += ../../sparc/shared/include/pci.h</div>
<div> </div><div> nodist_include_HEADERS = include/bspopts.h</div><div> nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h</div><div>+include_libcpu_HEADERS = ../../../libcpu/shared/include/mm.h</div><div> DISTCLEANFILES = include/bspopts.h</div>
<div> </div><div> noinst_PROGRAMS =</div><div>@@ -118,6 +120,9 @@ libbsp_a_SOURCES += ../../sparc/shared/i2c/i2cmst.c</div><div> # timer</div><div> libbsp_a_SOURCES += timer/timer.c</div><div> </div><div>+# LIBMM </div><div>
+libbsp_a_SOURCES += ../../../libcpu/shared/src/no_memorymanagement.c</div><div>+</div><div> if HAS_SMP</div><div> libbsp_a_SOURCES += ../../shared/smp/getcpuid.c ../../shared/smp/smp_stub.c</div><div> endif</div><div>diff --git a/c/src/lib/libbsp/sparc/leon2/<a href="http://preinstall.am">preinstall.am</a> b/c/src/lib/libbsp/sparc/leon2/<a href="http://preinstall.am">preinstall.am</a></div>
<div>index 84aa2b4..d4fa808 100644</div><div>--- a/c/src/lib/libbsp/sparc/leon2/<a href="http://preinstall.am">preinstall.am</a></div><div>+++ b/c/src/lib/libbsp/sparc/leon2/<a href="http://preinstall.am">preinstall.am</a></div>
<div>@@ -33,6 +33,11 @@ $(PROJECT_INCLUDE)/bsp/$(dirstamp):</div><div> <span class="" style="white-space:pre">      </span>@: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)</div><div> PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)</div>
<div> </div><div>+$(PROJECT_INCLUDE)/libcpu/$(dirstamp):</div><div>+<span class="" style="white-space:pre">     </span>@$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu</div><div>+<span class="" style="white-space:pre">     </span>@: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp)</div>
<div>+PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp)</div><div>+</div><div> $(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)</div><div> <span class="" style="white-space:pre">     </span>$(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs</div>
<div> PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs</div><div>@@ -121,6 +126,10 @@ $(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INC</div><div> <span class="" style="white-space:pre">   </span>$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h</div>
<div> PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h</div><div> </div><div>+$(PROJECT_INCLUDE)/libcpu/mm.h: ../../../libcpu/shared/include/mm.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)</div><div>+<span class="" style="white-space:pre">     </span>$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/mm.h</div>
<div>+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/mm.h</div><div>+</div><div> $(PROJECT_INCLUDE)/leon.h: include/leon.h $(PROJECT_INCLUDE)/$(dirstamp)</div><div> <span class="" style="white-space:pre"> </span>$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/leon.h</div>
<div> PREINSTALL_FILES += $(PROJECT_INCLUDE)/leon.h</div><div>diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am b/c/src/lib/libbsp/sparc/leon3/Makefile.am</div><div>index 8b21893..113ff99 100644</div><div>--- a/c/src/lib/libbsp/sparc/leon3/Makefile.am</div>
<div>+++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am</div><div>@@ -3,6 +3,7 @@ ACLOCAL_AMFLAGS = -I ../../../../aclocal</div><div> include $(top_srcdir)/../../../../automake/<a href="http://compile.am">compile.am</a></div>
<div> </div><div> include_bspdir = $(includedir)/bsp</div><div>+include_libcpudir = $(includedir)/libcpu</div><div> </div><div> dist_project_lib_DATA = bsp_specs</div><div> </div><div>@@ -12,6 +13,7 @@ include_HEADERS += ../../sparc/shared/include/debug_defs.h</div>
<div> </div><div> nodist_include_HEADERS = include/bspopts.h</div><div> nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h</div><div>+include_libcpu_HEADERS = ../../../libcpu/shared/include/mm.h</div><div> DISTCLEANFILES = include/bspopts.h</div>
<div> </div><div> noinst_PROGRAMS =</div><div>@@ -112,6 +114,9 @@ libbsp_a_SOURCES += ../../sparc/shared/i2c/i2cmst.c</div><div> # timer</div><div> libbsp_a_SOURCES += timer/timer.c</div><div> </div><div>+# LIBMM </div><div>
+libbsp_a_SOURCES += ../../../libcpu/shared/src/no_memorymanagement.c</div><div>+</div><div> if HAS_SMP</div><div> libbsp_a_SOURCES += smp/getcpuid.c</div><div> libbsp_a_SOURCES += smp/smp_leon3.c</div><div>diff --git a/c/src/lib/libbsp/sparc/leon3/<a href="http://preinstall.am">preinstall.am</a> b/c/src/lib/libbsp/sparc/leon3/<a href="http://preinstall.am">preinstall.am</a></div>
<div>index dffbb5a..6d7b5be 100644</div><div>--- a/c/src/lib/libbsp/sparc/leon3/<a href="http://preinstall.am">preinstall.am</a></div><div>+++ b/c/src/lib/libbsp/sparc/leon3/<a href="http://preinstall.am">preinstall.am</a></div>
<div>@@ -33,6 +33,11 @@ $(PROJECT_INCLUDE)/bsp/$(dirstamp):</div><div> <span class="" style="white-space:pre">      </span>@: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)</div><div> PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)</div>
<div> </div><div>+$(PROJECT_INCLUDE)/libcpu/$(dirstamp):</div><div>+<span class="" style="white-space:pre">     </span>@$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu</div><div>+<span class="" style="white-space:pre">     </span>@: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp)</div>
<div>+PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp)</div><div>+</div><div> $(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)</div><div> <span class="" style="white-space:pre">     </span>$(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs</div>
<div> PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs</div><div>@@ -57,6 +62,10 @@ $(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INC</div><div> <span class="" style="white-space:pre">     </span>$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h</div>
<div> PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h</div><div> </div><div>+$(PROJECT_INCLUDE)/libcpu/mm.h: ../../../libcpu/shared/include/mm.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)</div><div>+<span class="" style="white-space:pre">     </span>$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/mm.h</div>
<div>+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/mm.h</div><div>+</div><div> $(PROJECT_INCLUDE)/leon.h: include/leon.h $(PROJECT_INCLUDE)/$(dirstamp)</div><div> <span class="" style="white-space:pre"> </span>$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/leon.h</div>
<div> PREINSTALL_FILES += $(PROJECT_INCLUDE)/leon.h</div></div><div><br></div><div><br></div><div>Thanks,</div><div>Hesham</div></div>