[PATCH] Add basic infrastructure for libmm

Hesham Moustafa heshamelmatary at gmail.com
Sat Jul 13 00:35:23 UTC 2013


Hi,

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.

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..9b5c4c4
--- /dev/null
+++ b/testsuites/libtests/mmtest1/init.c
@@ -0,0 +1,59 @@
+/* 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
+)
+{
+  Memory_management_Entry mme1 = {
+    .name = "Valid Entry-1",
+    .base = 0x00100000,
+    .size = 0x200000,
+    .installed = false,
+    .bsp_mme = NULL
+  };
+  Memory_management_Entry mme2 = {
+    .name = "Valid Entry-2",
+    .base = 0x00400000,
+    .size = 0x100000,
+    .installed = false,
+    .bsp_mme = NULL
+  };
+
+  puts( "\n\n*** Start of mmtest1 ***\n" );
+
+  /* Initializing libmm is now done at BSP startup */
+  //puts( "initialize the memory management manager\n");
+  //_Memory_management_Initialize ( );
+
+  printf("Test 1: Installing Entry-1 \
+and set it as Read only\n");
+  _Memory_management_Install_entry( &mme1,
RTEMS_MM_REGION_PROTECTION_READ_ONLY);
+
+  printf("Test 2 : Installing Entry-2\
+and set it as Write enabled\n");
+  _Memory_management_Install_entry( &mme2,
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..8b13789
--- /dev/null
+++ b/testsuites/libtests/mmtest1/mmtests.scn
@@ -0,0 +1 @@
+
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 */
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..2e3f528
--- /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( Memory_management_Entry *mpe,
uint32_t flags ) { }
+
+void _CPU_Memory_management_Uninstall_entry( Memory_management_Entry *mpe
) { }
diff --git a/c/src/lib/libbsp/sparc/erc32/Makefile.am
b/c/src/lib/libbsp/sparc/erc32/Makefile.am
index 988f3ec..545d945 100644
--- a/c/src/lib/libbsp/sparc/erc32/Makefile.am
+++ b/c/src/lib/libbsp/sparc/erc32/Makefile.am
@@ -3,6 +3,7 @@ ACLOCAL_AMFLAGS = -I ../../../../aclocal
 include $(top_srcdir)/../../../../automake/compile.am

 include_bspdir = $(includedir)/bsp
+include_libcpudir = $(includedir)/libcpu

 dist_project_lib_DATA = bsp_specs

@@ -18,6 +19,8 @@ noinst_PROGRAMS =
 include_HEADERS += include/erc32.h
 include_HEADERS += ../../shared/include/coverhd.h

+include_libcpu_HEADERS = ../../../libcpu/shared/include/mm.h
+
 noinst_LIBRARIES = libbspstart.a
 libbspstart_a_SOURCES = ../../sparc/shared/start.S
 project_lib_DATA = start.$(OBJEXT)
@@ -65,6 +68,9 @@ libbsp_a_SOURCES += \
     ../../shared/src/irq-server.c \
     ../../shared/src/irq-shell.c

+# LIBMM
+libbsp_a_SOURCES += ../../../libcpu/shared/src/no_memorymanagement.c
+
 if HAS_SMP
 libbsp_a_SOURCES += ../../shared/smp/getcpuid.c ../../shared/smp/smp_stub.c
 endif
diff --git a/c/src/lib/libbsp/sparc/erc32/preinstall.amb/c/src/lib/libbsp/sparc/erc32/
preinstall.am
index a235296..e422e9d 100644
--- a/c/src/lib/libbsp/sparc/erc32/preinstall.am
+++ b/c/src/lib/libbsp/sparc/erc32/preinstall.am
@@ -33,6 +33,11 @@ $(PROJECT_INCLUDE)/bsp/$(dirstamp):
  @: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)
 PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)

+$(PROJECT_INCLUDE)/libcpu/$(dirstamp):
+ @$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu
+ @: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+
 $(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)
  $(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs
 PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs
@@ -61,6 +66,10 @@ $(PROJECT_INCLUDE)/coverhd.h:
../../shared/include/coverhd.h $(PROJECT_INCLUDE)/
  $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h

+$(PROJECT_INCLUDE)/libcpu/mm.h: ../../../libcpu/shared/include/mm.h
$(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/mm.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/mm.h
+
 $(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
  $(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
 TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
diff --git a/c/src/lib/libbsp/sparc/leon2/Makefile.am
b/c/src/lib/libbsp/sparc/leon2/Makefile.am
index ae6dfb0..bafccee 100644
--- a/c/src/lib/libbsp/sparc/leon2/Makefile.am
+++ b/c/src/lib/libbsp/sparc/leon2/Makefile.am
@@ -3,6 +3,7 @@ ACLOCAL_AMFLAGS = -I ../../../../aclocal
 include $(top_srcdir)/../../../../automake/compile.am

 include_bspdir = $(includedir)/bsp
+include_libcpudir = $(includedir)/libcpu

 dist_project_lib_DATA = bsp_specs

@@ -28,6 +29,7 @@ include_HEADERS += ../../sparc/shared/include/pci.h

 nodist_include_HEADERS = include/bspopts.h
 nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h
+include_libcpu_HEADERS = ../../../libcpu/shared/include/mm.h
 DISTCLEANFILES = include/bspopts.h

 noinst_PROGRAMS =
@@ -118,6 +120,9 @@ libbsp_a_SOURCES += ../../sparc/shared/i2c/i2cmst.c
 # timer
 libbsp_a_SOURCES += timer/timer.c

+# LIBMM
+libbsp_a_SOURCES += ../../../libcpu/shared/src/no_memorymanagement.c
+
 if HAS_SMP
 libbsp_a_SOURCES += ../../shared/smp/getcpuid.c ../../shared/smp/smp_stub.c
 endif
diff --git a/c/src/lib/libbsp/sparc/leon2/preinstall.amb/c/src/lib/libbsp/sparc/leon2/
preinstall.am
index 84aa2b4..d4fa808 100644
--- a/c/src/lib/libbsp/sparc/leon2/preinstall.am
+++ b/c/src/lib/libbsp/sparc/leon2/preinstall.am
@@ -33,6 +33,11 @@ $(PROJECT_INCLUDE)/bsp/$(dirstamp):
  @: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)
 PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)

+$(PROJECT_INCLUDE)/libcpu/$(dirstamp):
+ @$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu
+ @: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+
 $(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)
  $(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs
 PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs
@@ -121,6 +126,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)/libcpu/mm.h: ../../../libcpu/shared/include/mm.h
$(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/mm.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/mm.h
+
 $(PROJECT_INCLUDE)/leon.h: include/leon.h $(PROJECT_INCLUDE)/$(dirstamp)
  $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/leon.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/leon.h
diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am
b/c/src/lib/libbsp/sparc/leon3/Makefile.am
index 8b21893..113ff99 100644
--- a/c/src/lib/libbsp/sparc/leon3/Makefile.am
+++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am
@@ -3,6 +3,7 @@ ACLOCAL_AMFLAGS = -I ../../../../aclocal
 include $(top_srcdir)/../../../../automake/compile.am

 include_bspdir = $(includedir)/bsp
+include_libcpudir = $(includedir)/libcpu

 dist_project_lib_DATA = bsp_specs

@@ -12,6 +13,7 @@ include_HEADERS += ../../sparc/shared/include/debug_defs.h

 nodist_include_HEADERS = include/bspopts.h
 nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h
+include_libcpu_HEADERS = ../../../libcpu/shared/include/mm.h
 DISTCLEANFILES = include/bspopts.h

 noinst_PROGRAMS =
@@ -112,6 +114,9 @@ libbsp_a_SOURCES += ../../sparc/shared/i2c/i2cmst.c
 # timer
 libbsp_a_SOURCES += timer/timer.c

+# LIBMM
+libbsp_a_SOURCES += ../../../libcpu/shared/src/no_memorymanagement.c
+
 if HAS_SMP
 libbsp_a_SOURCES += smp/getcpuid.c
 libbsp_a_SOURCES += smp/smp_leon3.c
diff --git a/c/src/lib/libbsp/sparc/leon3/preinstall.amb/c/src/lib/libbsp/sparc/leon3/
preinstall.am
index dffbb5a..6d7b5be 100644
--- a/c/src/lib/libbsp/sparc/leon3/preinstall.am
+++ b/c/src/lib/libbsp/sparc/leon3/preinstall.am
@@ -33,6 +33,11 @@ $(PROJECT_INCLUDE)/bsp/$(dirstamp):
  @: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)
 PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)

+$(PROJECT_INCLUDE)/libcpu/$(dirstamp):
+ @$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu
+ @: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+
 $(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)
  $(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs
 PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs
@@ -57,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)/libcpu/mm.h: ../../../libcpu/shared/include/mm.h
$(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/mm.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/mm.h
+
 $(PROJECT_INCLUDE)/leon.h: include/leon.h $(PROJECT_INCLUDE)/$(dirstamp)
  $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/leon.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/leon.h


Thanks,
Hesham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20130713/1462f3a7/attachment.html>


More information about the devel mailing list