[PATCH 1/2] Add support for a mmap file handler

2017-05-20 Thread Kevin Kirspel
---
 cpukit/dev/i2c/i2c-bus.c|   1 +
 cpukit/dev/i2c/i2c-dev.c|   1 +
 cpukit/dev/spi/spi-bus.c|   1 +
 cpukit/libblock/src/blkdev-imfs.c   |   1 +
 cpukit/libcsupport/include/rtems/libio.h|  38 
 cpukit/libcsupport/include/rtems/termiostypes.h |  13 ++
 cpukit/libcsupport/src/__usrenv.c   |   1 +
 cpukit/libcsupport/src/termios.c|   1 +
 cpukit/libfs/Makefile.am|   1 +
 cpukit/libfs/src/defaults/default_handlers.c|   1 +
 cpukit/libfs/src/defaults/default_mmap.c|  40 
 cpukit/libfs/src/devfs/devfs_init.c |   1 +
 cpukit/libfs/src/dosfs/msdos_handlers_dir.c |   1 +
 cpukit/libfs/src/dosfs/msdos_handlers_file.c|   1 +
 cpukit/libfs/src/imfs/imfs_dir_default.c|   1 +
 cpukit/libfs/src/imfs/imfs_dir_minimal.c|   1 +
 cpukit/libfs/src/imfs/imfs_fifo.c   |   1 +
 cpukit/libfs/src/imfs/imfs_handlers_device.c|   1 +
 cpukit/libfs/src/imfs/imfs_linfile.c|   1 +
 cpukit/libfs/src/imfs/imfs_link.c   |   1 +
 cpukit/libfs/src/imfs/imfs_memfile.c|   1 +
 cpukit/libfs/src/imfs/imfs_symlink.c|   1 +
 cpukit/libfs/src/jffs2/src/fs-rtems.c   |   3 +
 cpukit/libfs/src/nfsclient/src/nfs.c|   3 +
 cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c  |   1 +
 cpukit/libfs/src/rfs/rtems-rfs-rtems-dir.c  |   1 +
 cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c |   1 +
 cpukit/libfs/src/rfs/rtems-rfs-rtems.c  |   1 +
 cpukit/libnetworking/lib/ftpfs.c|   2 +
 cpukit/libnetworking/lib/tftpDriver.c   |   1 +
 cpukit/libnetworking/rtems/rtems_syscall.c  |   1 +
 cpukit/posix/src/mmap.c | 255 ++--
 cpukit/posix/src/munmap.c   |  18 +-
 cpukit/posix/src/shmopen.c  |  30 +++
 34 files changed, 313 insertions(+), 114 deletions(-)
 create mode 100644 cpukit/libfs/src/defaults/default_mmap.c

diff --git a/cpukit/dev/i2c/i2c-bus.c b/cpukit/dev/i2c/i2c-bus.c
index 0f27d06..1297b1e 100644
--- a/cpukit/dev/i2c/i2c-bus.c
+++ b/cpukit/dev/i2c/i2c-bus.c
@@ -218,6 +218,7 @@ static const rtems_filesystem_file_handlers_r 
i2c_bus_handler = {
   .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
   .fcntl_h = rtems_filesystem_default_fcntl,
   .kqfilter_h = rtems_filesystem_default_kqfilter,
+  .mmap_h = rtems_filesystem_default_mmap,
   .poll_h = rtems_filesystem_default_poll,
   .readv_h = rtems_filesystem_default_readv,
   .writev_h = rtems_filesystem_default_writev
diff --git a/cpukit/dev/i2c/i2c-dev.c b/cpukit/dev/i2c/i2c-dev.c
index b00a9bd..680732f 100644
--- a/cpukit/dev/i2c/i2c-dev.c
+++ b/cpukit/dev/i2c/i2c-dev.c
@@ -115,6 +115,7 @@ static const rtems_filesystem_file_handlers_r 
i2c_dev_handler = {
   .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
   .fcntl_h = rtems_filesystem_default_fcntl,
   .kqfilter_h = rtems_filesystem_default_kqfilter,
+  .mmap_h = rtems_filesystem_default_mmap,
   .poll_h = rtems_filesystem_default_poll,
   .readv_h = rtems_filesystem_default_readv,
   .writev_h = rtems_filesystem_default_writev
diff --git a/cpukit/dev/spi/spi-bus.c b/cpukit/dev/spi/spi-bus.c
index dd84b02..343e203 100644
--- a/cpukit/dev/spi/spi-bus.c
+++ b/cpukit/dev/spi/spi-bus.c
@@ -235,6 +235,7 @@ static const rtems_filesystem_file_handlers_r 
spi_bus_handler = {
   .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
   .fcntl_h = rtems_filesystem_default_fcntl,
   .kqfilter_h = rtems_filesystem_default_kqfilter,
+  .mmap_h = rtems_filesystem_default_mmap,
   .poll_h = rtems_filesystem_default_poll,
   .readv_h = rtems_filesystem_default_readv,
   .writev_h = rtems_filesystem_default_writev
diff --git a/cpukit/libblock/src/blkdev-imfs.c 
b/cpukit/libblock/src/blkdev-imfs.c
index 7a2d00b..f2008aa 100644
--- a/cpukit/libblock/src/blkdev-imfs.c
+++ b/cpukit/libblock/src/blkdev-imfs.c
@@ -222,6 +222,7 @@ static const rtems_filesystem_file_handlers_r 
rtems_blkdev_imfs_node = {
   .fdatasync_h = rtems_blkdev_imfs_fsync_or_fdatasync,
   .fcntl_h = rtems_filesystem_default_fcntl,
   .kqfilter_h = rtems_filesystem_default_kqfilter,
+  .mmap_h = rtems_filesystem_default_mmap,
   .poll_h = rtems_filesystem_default_poll,
   .readv_h = rtems_filesystem_default_readv,
   .writev_h = rtems_filesystem_default_writev
diff --git a/cpukit/libcsupport/include/rtems/libio.h 
b/cpukit/libcsupport/include/rtems/libio.h
index d0824b4..91733e4 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -977,6 +977,28 @@ typedef int (*rtems_filesystem_kqfilter_t)(
 );

 /**
+ * @brief MMAP support.
+ *
+ * @param[in, out] iop The IO pointer.
+ * @param[in, out] addr The starting address of the mapped memory.
+ * @param[in] len The maximum number of bytes to map.
+ * @param[in] prot The desired memor

[PATCH 2/2] Add a mmap dedicated test case

2017-05-20 Thread Kevin Kirspel
---
 testsuites/psxtests/Makefile.am |   1 +
 testsuites/psxtests/configure.ac|   1 +
 testsuites/psxtests/psxmmap01/Makefile.am   |  22 ++
 testsuites/psxtests/psxmmap01/init.c| 349 
 testsuites/psxtests/psxmmap01/psxmmap01.scn |   0
 testsuites/psxtests/psxmmap01/system.h  |  31 +++
 testsuites/psxtests/psxmmap01/test_driver.c |  60 +
 testsuites/psxtests/psxmmap01/test_driver.h |  13 ++
 testsuites/psxtests/psxmmap01/test_helper.c |  60 +
 testsuites/psxtests/psxmmap01/test_helper.h |  41 
 10 files changed, 578 insertions(+)
 create mode 100644 testsuites/psxtests/psxmmap01/Makefile.am
 create mode 100644 testsuites/psxtests/psxmmap01/init.c
 create mode 100644 testsuites/psxtests/psxmmap01/psxmmap01.scn
 create mode 100644 testsuites/psxtests/psxmmap01/system.h
 create mode 100644 testsuites/psxtests/psxmmap01/test_driver.c
 create mode 100644 testsuites/psxtests/psxmmap01/test_driver.h
 create mode 100644 testsuites/psxtests/psxmmap01/test_helper.c
 create mode 100644 testsuites/psxtests/psxmmap01/test_helper.h

diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index 7bcea46..cccdb39 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -85,6 +85,7 @@ _SUBDIRS += psxrwlock01
 _SUBDIRS += psxsem01
 _SUBDIRS += psxshm01
 _SUBDIRS += psxshm02
+_SUBDIRS += psxmmap01
 _SUBDIRS += psxsignal01
 _SUBDIRS += psxsignal02
 _SUBDIRS += psxsignal03
diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
index 1de1312..96a0149 100644
--- a/testsuites/psxtests/configure.ac
+++ b/testsuites/psxtests/configure.ac
@@ -190,6 +190,7 @@ psxrwlock01/Makefile
 psxsem01/Makefile
 psxshm01/Makefile
 psxshm02/Makefile
+psxmmap01/Makefile
 psxsignal01/Makefile
 psxsignal02/Makefile
 psxsignal03/Makefile
diff --git a/testsuites/psxtests/psxmmap01/Makefile.am 
b/testsuites/psxtests/psxmmap01/Makefile.am
new file mode 100644
index 000..57b0087
--- /dev/null
+++ b/testsuites/psxtests/psxmmap01/Makefile.am
@@ -0,0 +1,22 @@
+
+rtems_tests_PROGRAMS = psxmmap01
+psxmmap01_SOURCES = init.c test_helper.c test_driver.c system.h
+
+dist_rtems_tests_DATA = psxmmap01.scn
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psxmmap01_OBJECTS)
+LINK_LIBS = $(psxmmap01_LDLIBS)
+
+psxmmap01$(EXEEXT): $(psxmmap01_OBJECTS) $(psxmmap01_DEPENDENCIES)
+   @rm -f psxmmap01$(EXEEXT)
+   $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxmmap01/init.c 
b/testsuites/psxtests/psxmmap01/init.c
new file mode 100644
index 000..8b91ce1
--- /dev/null
+++ b/testsuites/psxtests/psxmmap01/init.c
@@ -0,0 +1,349 @@
+/*-
+ * Copyright (c) 2009 Simon L. Nielsen ,
+ *  Bjoern A. Zeeb 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * Copyright (c) 2017 Kevin Kirspel.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+#include "pritime.h"
+#include "test_helper.h"
+#include "test_driver.h"
+
+#include 
+
+#include 
+#include 
+#include 
+
+const char rtems_test_name[] = "PSX MMAP01";
+const char test_driver_name[] = "/dev/test_driver";
+
+static const struct {
+  void  *addr;
+  int ok;
+} map_at_zero_tests[] = {
+  { (void *)0,0 },
+  { (void *)1,   

[PATCH v2 1/2] Add support for a mmap file handler. Add support for MAP_ANON in mmap().

2017-05-20 Thread Kevin Kirspel
---
 cpukit/dev/i2c/i2c-bus.c|   1 +
 cpukit/dev/i2c/i2c-dev.c|   1 +
 cpukit/dev/spi/spi-bus.c|   1 +
 cpukit/libblock/src/blkdev-imfs.c   |   1 +
 cpukit/libcsupport/include/rtems/libio.h|  38 
 cpukit/libcsupport/include/rtems/termiostypes.h |  13 ++
 cpukit/libcsupport/src/__usrenv.c   |   1 +
 cpukit/libcsupport/src/termios.c|   1 +
 cpukit/libfs/Makefile.am|   1 +
 cpukit/libfs/src/defaults/default_handlers.c|   1 +
 cpukit/libfs/src/defaults/default_mmap.c|  40 
 cpukit/libfs/src/devfs/devfs_init.c |   1 +
 cpukit/libfs/src/dosfs/msdos_handlers_dir.c |   1 +
 cpukit/libfs/src/dosfs/msdos_handlers_file.c|   1 +
 cpukit/libfs/src/imfs/imfs_dir_default.c|   1 +
 cpukit/libfs/src/imfs/imfs_dir_minimal.c|   1 +
 cpukit/libfs/src/imfs/imfs_fifo.c   |   1 +
 cpukit/libfs/src/imfs/imfs_handlers_device.c|   1 +
 cpukit/libfs/src/imfs/imfs_linfile.c|   1 +
 cpukit/libfs/src/imfs/imfs_link.c   |   1 +
 cpukit/libfs/src/imfs/imfs_memfile.c|   1 +
 cpukit/libfs/src/imfs/imfs_symlink.c|   1 +
 cpukit/libfs/src/jffs2/src/fs-rtems.c   |   3 +
 cpukit/libfs/src/nfsclient/src/nfs.c|   3 +
 cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c  |   1 +
 cpukit/libfs/src/rfs/rtems-rfs-rtems-dir.c  |   1 +
 cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c |   1 +
 cpukit/libfs/src/rfs/rtems-rfs-rtems.c  |   1 +
 cpukit/libnetworking/lib/ftpfs.c|   2 +
 cpukit/libnetworking/lib/tftpDriver.c   |   1 +
 cpukit/libnetworking/rtems/rtems_syscall.c  |   1 +
 cpukit/posix/src/mmap.c | 255 ++--
 cpukit/posix/src/munmap.c   |  14 +-
 cpukit/posix/src/shmopen.c  |  30 +++
 34 files changed, 311 insertions(+), 112 deletions(-)
 create mode 100644 cpukit/libfs/src/defaults/default_mmap.c

diff --git a/cpukit/dev/i2c/i2c-bus.c b/cpukit/dev/i2c/i2c-bus.c
index 0f27d06..1297b1e 100644
--- a/cpukit/dev/i2c/i2c-bus.c
+++ b/cpukit/dev/i2c/i2c-bus.c
@@ -218,6 +218,7 @@ static const rtems_filesystem_file_handlers_r 
i2c_bus_handler = {
   .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
   .fcntl_h = rtems_filesystem_default_fcntl,
   .kqfilter_h = rtems_filesystem_default_kqfilter,
+  .mmap_h = rtems_filesystem_default_mmap,
   .poll_h = rtems_filesystem_default_poll,
   .readv_h = rtems_filesystem_default_readv,
   .writev_h = rtems_filesystem_default_writev
diff --git a/cpukit/dev/i2c/i2c-dev.c b/cpukit/dev/i2c/i2c-dev.c
index b00a9bd..680732f 100644
--- a/cpukit/dev/i2c/i2c-dev.c
+++ b/cpukit/dev/i2c/i2c-dev.c
@@ -115,6 +115,7 @@ static const rtems_filesystem_file_handlers_r 
i2c_dev_handler = {
   .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
   .fcntl_h = rtems_filesystem_default_fcntl,
   .kqfilter_h = rtems_filesystem_default_kqfilter,
+  .mmap_h = rtems_filesystem_default_mmap,
   .poll_h = rtems_filesystem_default_poll,
   .readv_h = rtems_filesystem_default_readv,
   .writev_h = rtems_filesystem_default_writev
diff --git a/cpukit/dev/spi/spi-bus.c b/cpukit/dev/spi/spi-bus.c
index dd84b02..343e203 100644
--- a/cpukit/dev/spi/spi-bus.c
+++ b/cpukit/dev/spi/spi-bus.c
@@ -235,6 +235,7 @@ static const rtems_filesystem_file_handlers_r 
spi_bus_handler = {
   .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
   .fcntl_h = rtems_filesystem_default_fcntl,
   .kqfilter_h = rtems_filesystem_default_kqfilter,
+  .mmap_h = rtems_filesystem_default_mmap,
   .poll_h = rtems_filesystem_default_poll,
   .readv_h = rtems_filesystem_default_readv,
   .writev_h = rtems_filesystem_default_writev
diff --git a/cpukit/libblock/src/blkdev-imfs.c 
b/cpukit/libblock/src/blkdev-imfs.c
index 7a2d00b..f2008aa 100644
--- a/cpukit/libblock/src/blkdev-imfs.c
+++ b/cpukit/libblock/src/blkdev-imfs.c
@@ -222,6 +222,7 @@ static const rtems_filesystem_file_handlers_r 
rtems_blkdev_imfs_node = {
   .fdatasync_h = rtems_blkdev_imfs_fsync_or_fdatasync,
   .fcntl_h = rtems_filesystem_default_fcntl,
   .kqfilter_h = rtems_filesystem_default_kqfilter,
+  .mmap_h = rtems_filesystem_default_mmap,
   .poll_h = rtems_filesystem_default_poll,
   .readv_h = rtems_filesystem_default_readv,
   .writev_h = rtems_filesystem_default_writev
diff --git a/cpukit/libcsupport/include/rtems/libio.h 
b/cpukit/libcsupport/include/rtems/libio.h
index d0824b4..91733e4 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -977,6 +977,28 @@ typedef int (*rtems_filesystem_kqfilter_t)(
 );
 
 /**
+ * @brief MMAP support.
+ *
+ * @param[in, out] iop The IO pointer.
+ * @param[in, out] addr The starting address of the mapped memory.
+ * @param[in] len The maximum number of bytes to map.
+ * @param[in] prot The desired memo

[PATCH v2 2/2] Add a mmap dedicated test case

2017-05-20 Thread Kevin Kirspel
---
 testsuites/psxtests/Makefile.am |   1 +
 testsuites/psxtests/configure.ac|   1 +
 testsuites/psxtests/psxmmap01/Makefile.am   |  22 ++
 testsuites/psxtests/psxmmap01/init.c| 352 
 testsuites/psxtests/psxmmap01/psxmmap01.scn |   0
 testsuites/psxtests/psxmmap01/system.h  |  31 +++
 testsuites/psxtests/psxmmap01/test_driver.c |  67 ++
 testsuites/psxtests/psxmmap01/test_driver.h |  14 ++
 testsuites/psxtests/psxmmap01/test_helper.c |  32 +++
 testsuites/psxtests/psxmmap01/test_helper.h |  41 
 10 files changed, 561 insertions(+)
 create mode 100644 testsuites/psxtests/psxmmap01/Makefile.am
 create mode 100644 testsuites/psxtests/psxmmap01/init.c
 create mode 100644 testsuites/psxtests/psxmmap01/psxmmap01.scn
 create mode 100644 testsuites/psxtests/psxmmap01/system.h
 create mode 100644 testsuites/psxtests/psxmmap01/test_driver.c
 create mode 100644 testsuites/psxtests/psxmmap01/test_driver.h
 create mode 100644 testsuites/psxtests/psxmmap01/test_helper.c
 create mode 100644 testsuites/psxtests/psxmmap01/test_helper.h

diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index 7bcea46..cccdb39 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -85,6 +85,7 @@ _SUBDIRS += psxrwlock01
 _SUBDIRS += psxsem01
 _SUBDIRS += psxshm01
 _SUBDIRS += psxshm02
+_SUBDIRS += psxmmap01
 _SUBDIRS += psxsignal01
 _SUBDIRS += psxsignal02
 _SUBDIRS += psxsignal03
diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
index 1de1312..96a0149 100644
--- a/testsuites/psxtests/configure.ac
+++ b/testsuites/psxtests/configure.ac
@@ -190,6 +190,7 @@ psxrwlock01/Makefile
 psxsem01/Makefile
 psxshm01/Makefile
 psxshm02/Makefile
+psxmmap01/Makefile
 psxsignal01/Makefile
 psxsignal02/Makefile
 psxsignal03/Makefile
diff --git a/testsuites/psxtests/psxmmap01/Makefile.am 
b/testsuites/psxtests/psxmmap01/Makefile.am
new file mode 100644
index 000..57b0087
--- /dev/null
+++ b/testsuites/psxtests/psxmmap01/Makefile.am
@@ -0,0 +1,22 @@
+
+rtems_tests_PROGRAMS = psxmmap01
+psxmmap01_SOURCES = init.c test_helper.c test_driver.c system.h
+
+dist_rtems_tests_DATA = psxmmap01.scn
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psxmmap01_OBJECTS)
+LINK_LIBS = $(psxmmap01_LDLIBS)
+
+psxmmap01$(EXEEXT): $(psxmmap01_OBJECTS) $(psxmmap01_DEPENDENCIES)
+   @rm -f psxmmap01$(EXEEXT)
+   $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxmmap01/init.c 
b/testsuites/psxtests/psxmmap01/init.c
new file mode 100644
index 000..eb1c747
--- /dev/null
+++ b/testsuites/psxtests/psxmmap01/init.c
@@ -0,0 +1,352 @@
+/*-
+ * Copyright (c) 2009 Simon L. Nielsen ,
+ *  Bjoern A. Zeeb 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * Copyright (c) 2017 Kevin Kirspel.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+#include "pritime.h"
+#include "test_helper.h"
+#include "test_driver.h"
+
+#include 
+
+#include 
+#include 
+#include 
+
+const char rtems_test_name[] = "PSX MMAP01";
+const char test_driver_name[] = "/dev/test_driver";
+
+static const struct {
+  void  *addr;
+  int ok;
+} map_at_zero_tests[] = {
+  { (void *)0,0 },
+  { (void *)1,