[PATCH 7/7] Adding pipe support

2016-12-09 Thread Kevin Kirspel
---
 testsuite/selectpollkqueue01/test_main.c | 186 ++-
 1 file changed, 182 insertions(+), 4 deletions(-)
 mode change 100644 => 100755 testsuite/selectpollkqueue01/test_main.c

diff --git a/testsuite/selectpollkqueue01/test_main.c 
b/testsuite/selectpollkqueue01/test_main.c
old mode 100644
new mode 100755
index 8f76049..470f4de
--- a/testsuite/selectpollkqueue01/test_main.c
+++ b/testsuite/selectpollkqueue01/test_main.c
@@ -55,7 +55,7 @@
 #include 
 #include 
 
-#define TEST_NAME "LIBBSD SELECT AND POLL AND KQUEUE 1"
+#define TEST_NAME "LIBBSD SELECT AND POLL AND KQUEUE AND PIPE 1"
 
 #define PRIO_MASTER 1
 
@@ -71,6 +71,8 @@
 
 #define EVENT_SHUTDOWN RTEMS_EVENT_4
 
+#define EVENT_CLOSE_PIPE RTEMS_EVENT_5
+
 #define BUF_SIZE 4096
 
 #define PORT 1234
@@ -88,6 +90,7 @@ typedef struct {
int afd;
int rfd;
int wfd;
+   int pfd[2];
struct sockaddr_in caddr;
rtems_id worker_task;
 } test_context;
@@ -173,6 +176,8 @@ worker_task(rtems_task_argument arg)
ssize_t n;
int rv;
int cfd = ctx->cfd;
+   int rfd = ctx->pfd[0];
+   int wfd = ctx->pfd[1];
 
sc = rtems_event_receive(
RTEMS_ALL_EVENTS,
@@ -236,6 +241,19 @@ worker_task(rtems_task_argument arg)
assert(rv == 0);
}
 
+   if ((events & EVENT_CLOSE_PIPE) != 0) {
+   puts("worker: close pipe");
+
+   ctx->pfd[0] = -1;
+   ctx->pfd[1] = -1;
+
+   rv = close(wfd);
+   assert(rv == 0);
+
+   rv = close(rfd);
+   assert(rv == 0);
+   }
+
if ((events & EVENT_SHUTDOWN) != 0) {
puts("worker: shutdown");
 
@@ -280,10 +298,14 @@ start_worker(test_context *ctx)
 static void
 set_non_blocking(int fd, int enable)
 {
-   int rv;
+   int flags = fcntl(fd, F_GETFL, 0);
 
-   rv = ioctl(fd, FIONBIO, );
-   assert(rv == 0);
+   if (enable ) {
+   fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+   }
+   else{
+   fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
+   }
 }
 
 static void
@@ -1004,6 +1026,157 @@ test_kqueue_user(test_context *ctx)
 }
 
 static void
+test_pipe_timeout(test_context *ctx)
+{
+   struct pipe_poll_events
+   {
+   short event;
+   int rv;
+   };
+   const struct pipe_poll_events events[] = {
+   { POLLIN, 0 },
+   { POLLPRI, 0 },
+   { POLLOUT, 1 },
+   { POLLRDNORM, 0 },
+   { POLLWRNORM, 1 },
+   { POLLRDBAND, 0 },
+   { POLLWRBAND, 0 },
+   { POLLINIGNEOF, 0 }
+   };
+
+   int timeout = 100;
+   struct pollfd pfd;
+   size_t i;
+   int rv;
+
+   puts("test pipe timeout");
+
+   rv = pipe(ctx->pfd);
+   assert(rv == 0);
+
+   pfd.fd = ctx->pfd[1];
+
+   for (i = 0; i < nitems(events); ++i) {
+   int rv;
+
+   pfd.events = events[i].event;
+   pfd.revents = 0;
+
+   rv = poll(, 1, timeout);
+   assert(rv == events[i].rv);
+   }
+}
+
+static void
+test_pipe_read(test_context *ctx)
+{
+   int rfd = ctx->pfd[0];
+   int wfd = ctx->pfd[1];
+   struct pollfd pfd = {
+   .fd = rfd,
+   .events = POLLIN
+   };
+   int timeout = -1;
+   int rv;
+   ssize_t n;
+
+   puts("test pipe read");
+
+   assert(rfd >= 0);
+   assert(wfd >= 0);
+
+   ctx->wfd = wfd;
+   ctx->wbuf = [0];
+   ctx->wn = sizeof(msg);
+   send_events(ctx, EVENT_WRITE);
+
+   set_non_blocking(rfd, 1);
+
+   errno = 0;
+   n = read(rfd, >buf[0], sizeof(ctx->buf));
+   assert(n == -1);
+   assert(errno == EAGAIN);
+
+   rv = poll(, 1, timeout);
+   assert(rv == 1);
+   assert(pfd.revents == POLLIN);
+
+   n = read(rfd, >buf[0], sizeof(ctx->buf));
+   assert(n == (ssize_t) sizeof(msg));
+   assert(memcmp([0], >buf[0], sizeof(msg)) == 0);
+}
+
+static void
+test_pipe_write(test_context *ctx)
+{
+   int rfd = ctx->pfd[0];
+   int wfd = ctx->pfd[1];
+   struct pollfd pfd = {
+   .fd = wfd,
+   .events = POLLOUT
+   };
+   int timeout = -1;
+   int rv;
+   ssize_t n;
+
+   puts("test pipe write");
+
+   assert(rfd >= 0);
+   assert(wfd >= 0);
+
+   ctx->rfd = rfd;
+   ctx->rbuf = >buf[0];
+   ctx->rn = sizeof(ctx->buf);
+   send_events(ctx, EVENT_READ);
+
+   set_non_blocking(wfd, 1);
+
+   do {
+   errno = 0;
+   n = write(wfd, >buf[0], sizeof(ctx->buf));
+   if (n == -1) {
+   assert(errno == EAGAIN);
+   }
+   } while (n > 

[PATCH 6/7] Adding pipe support

2016-12-09 Thread Kevin Kirspel
---
 rtemsbsd/sys/fs/devfs/devfs_devs.c | 29 +
 1 file changed, 29 insertions(+)
 mode change 100644 => 100755 rtemsbsd/sys/fs/devfs/devfs_devs.c

diff --git a/rtemsbsd/sys/fs/devfs/devfs_devs.c 
b/rtemsbsd/sys/fs/devfs/devfs_devs.c
old mode 100644
new mode 100755
index a38bb4d..75c9e27
--- a/rtemsbsd/sys/fs/devfs/devfs_devs.c
+++ b/rtemsbsd/sys/fs/devfs/devfs_devs.c
@@ -33,6 +33,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -45,8 +46,12 @@
 
 #include 
 
+#define DEVFS_ROOTINO 2
+
 const char rtems_cdev_directory[] = RTEMS_CDEV_DIRECTORY;
 
+struct unrhdr *devfs_inos;
+
 static struct cdev *
 devfs_imfs_get_context_by_iop(rtems_libio_t *iop)
 {
@@ -325,3 +330,27 @@ devfs_dev_exists(const char *name)
else
return 0;
 }
+
+ino_t
+devfs_alloc_cdp_inode(void)
+{
+
+   return (alloc_unr(devfs_inos));
+}
+
+void
+devfs_free_cdp_inode(ino_t ino)
+{
+
+   if (ino > 0)
+   free_unr(devfs_inos, ino);
+}
+
+static void
+   devfs_devs_init(void *junk __unused)
+{
+
+   devfs_inos = new_unrhdr(DEVFS_ROOTINO + 1, INT_MAX, );
+}
+
+SYSINIT(devfs_devs, SI_SUB_DEVFS, SI_ORDER_FIRST, devfs_devs_init, NULL);
-- 
1.9.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 1/7] Adding pipe support

2016-12-09 Thread Kevin Kirspel
---
 freebsd/sys/kern/sys_pipe.c | 1689 +++
 1 file changed, 1689 insertions(+)
 create mode 100644 freebsd/sys/kern/sys_pipe.c

diff --git a/freebsd/sys/kern/sys_pipe.c b/freebsd/sys/kern/sys_pipe.c
new file mode 100644
index 000..f1efd09
--- /dev/null
+++ b/freebsd/sys/kern/sys_pipe.c
@@ -0,0 +1,1689 @@
+#include 
+
+/*-
+ * Copyright (c) 1996 John S. Dyson
+ * All rights reserved.
+ *
+ * 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 immediately at the beginning of the file, without modification,
+ *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.
+ * 3. Absolutely no warranty of function or purpose is made by the author
+ *John S. Dyson.
+ * 4. Modifications may be freely made to this file if the above conditions
+ *are met.
+ */
+
+/*
+ * This file contains a high-performance replacement for the socket-based
+ * pipes scheme originally used in FreeBSD/4.4Lite.  It does not support
+ * all features of sockets, but does do everything that pipes normally
+ * do.
+ */
+
+/*
+ * This code has two modes of operation, a small write mode and a large
+ * write mode.  The small write mode acts like conventional pipes with
+ * a kernel buffer.  If the buffer is less than PIPE_MINDIRECT, then the
+ * "normal" pipe buffering is done.  If the buffer is between PIPE_MINDIRECT
+ * and PIPE_SIZE in size, the sending process pins the underlying pages in
+ * memory, and the receiving process copies directly from these pinned pages
+ * in the sending process.
+ *
+ * If the sending process receives a signal, it is possible that it will
+ * go away, and certainly its address space can change, because control
+ * is returned back to the user-mode side.  In that case, the pipe code
+ * arranges to copy the buffer supplied by the user process, to a pageable
+ * kernel buffer, and the receiving process will grab the data from the
+ * pageable kernel buffer.  Since signals don't happen all that often,
+ * the copy operation is normally eliminated.
+ *
+ * The constant PIPE_MINDIRECT is chosen to make sure that buffering will
+ * happen for small transfers so that the system will not spend all of
+ * its time context switching.
+ *
+ * In order to limit the resource use of pipes, two sysctls exist:
+ *
+ * kern.ipc.maxpipekva - This is a hard limit on the amount of pageable
+ * address space available to us in pipe_map. This value is normally
+ * autotuned, but may also be loader tuned.
+ *
+ * kern.ipc.pipekva - This read-only sysctl tracks the current amount of
+ * memory in use by pipes.
+ *
+ * Based on how large pipekva is relative to maxpipekva, the following
+ * will happen:
+ *
+ * 0% - 50%:
+ * New pipes are given 16K of memory backing, pipes may dynamically
+ * grow to as large as 64K where needed.
+ * 50% - 75%:
+ * New pipes are given 4K (or PAGE_SIZE) of memory backing,
+ * existing pipes may NOT grow.
+ * 75% - 100%:
+ * New pipes are given 4K (or PAGE_SIZE) of memory backing,
+ * existing pipes will be shrunk down to 4K whenever possible.
+ *
+ * Resizing may be disabled by setting kern.ipc.piperesizeallowed=0.  If
+ * that is set,  the only resize that will occur is the 0 -> SMALL_PIPE_SIZE
+ * resize which MUST occur for reverse-direction pipes when they are
+ * first used.
+ *
+ * Additional information about the current state of pipes may be obtained
+ * from kern.ipc.pipes, kern.ipc.pipefragretry, kern.ipc.pipeallocfail,
+ * and kern.ipc.piperesizefail.
+ *
+ * Locking rules:  There are two locks present here:  A mutex, used via
+ * PIPE_LOCK, and a flag, used via pipelock().  All locking is done via
+ * the flag, as mutexes can not persist over uiomove.  The mutex
+ * exists only to guard access to the flag, and is not in itself a
+ * locking mechanism.  Also note that there is only a single mutex for
+ * both directions of a pipe.
+ *
+ * As pipelock() may have to sleep before it can acquire the flag, it
+ * is important to reread all data after a call to pipelock(); everything
+ * in the structure may have changed.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* XXX */
+intdo_pipe(struct thread *td, int fildes[2], int flags);
+
+/*
+ * 

[PATCH 4/7] Adding pipe support

2016-12-09 Thread Kevin Kirspel
---
 freebsd/sys/sys/pipe.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 freebsd/sys/sys/pipe.h

diff --git a/freebsd/sys/sys/pipe.h b/freebsd/sys/sys/pipe.h
old mode 100644
new mode 100755
index 20b1092..c59ecc7
--- a/freebsd/sys/sys/pipe.h
+++ b/freebsd/sys/sys/pipe.h
@@ -54,7 +54,7 @@
 #define PIPENPAGES (BIG_PIPE_SIZE / PAGE_SIZE + 1)
 
 /*
- * See sys_pipe.c for info on what these limits mean. 
+ * See sys_pipe.c for info on what these limits mean.
  */
 extern longmaxpipekva;
 
@@ -78,7 +78,9 @@ struct pipemapping {
vm_size_t   cnt;/* number of chars in buffer */
vm_size_t   pos;/* current position of transfer */
int npages; /* number of pages */
+#ifndef __rtems__
vm_page_t   ms[PIPENPAGES]; /* pages in source process */
+#endif /* __rtems__ */
 };
 
 /*
-- 
1.9.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/7] Adding pipe support

2016-12-09 Thread Kevin Kirspel
---
 freebsd/sys/sys/pipe.h | 142 +
 1 file changed, 142 insertions(+)
 create mode 100644 freebsd/sys/sys/pipe.h

diff --git a/freebsd/sys/sys/pipe.h b/freebsd/sys/sys/pipe.h
new file mode 100644
index 000..20b1092
--- /dev/null
+++ b/freebsd/sys/sys/pipe.h
@@ -0,0 +1,142 @@
+/*-
+ * Copyright (c) 1996 John S. Dyson
+ * All rights reserved.
+ *
+ * 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 immediately at the beginning of the file, without modification,
+ *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.
+ * 3. Absolutely no warranty of function or purpose is made by the author
+ *John S. Dyson.
+ * 4. This work was done expressly for inclusion into FreeBSD.  Other use
+ *is allowed if this notation is included.
+ * 5. Modifications may be freely made to this file if the above conditions
+ *are met.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_PIPE_H_
+#define _SYS_PIPE_H_
+
+#ifndef _KERNEL
+#error "no user-servicable parts inside"
+#endif
+
+/*
+ * Pipe buffer size, keep moderate in value, pipes take kva space.
+ */
+#ifndef PIPE_SIZE
+#define PIPE_SIZE  16384
+#endif
+
+#ifndef BIG_PIPE_SIZE
+#define BIG_PIPE_SIZE  (64*1024)
+#endif
+
+#ifndef SMALL_PIPE_SIZE
+#define SMALL_PIPE_SIZEPAGE_SIZE
+#endif
+
+/*
+ * PIPE_MINDIRECT MUST be smaller than PIPE_SIZE and MUST be bigger
+ * than PIPE_BUF.
+ */
+#ifndef PIPE_MINDIRECT
+#define PIPE_MINDIRECT 8192
+#endif
+
+#define PIPENPAGES (BIG_PIPE_SIZE / PAGE_SIZE + 1)
+
+/*
+ * See sys_pipe.c for info on what these limits mean. 
+ */
+extern longmaxpipekva;
+
+/*
+ * Pipe buffer information.
+ * Separate in, out, cnt are used to simplify calculations.
+ * Buffered write is active when the buffer.cnt field is set.
+ */
+struct pipebuf {
+   u_int   cnt;/* number of chars currently in buffer */
+   u_int   in; /* in pointer */
+   u_int   out;/* out pointer */
+   u_int   size;   /* size of buffer */
+   caddr_t buffer; /* kva of buffer */
+};
+
+/*
+ * Information to support direct transfers between processes for pipes.
+ */
+struct pipemapping {
+   vm_size_t   cnt;/* number of chars in buffer */
+   vm_size_t   pos;/* current position of transfer */
+   int npages; /* number of pages */
+   vm_page_t   ms[PIPENPAGES]; /* pages in source process */
+};
+
+/*
+ * Bits in pipe_state.
+ */
+#define PIPE_ASYNC 0x004   /* Async? I/O. */
+#define PIPE_WANTR 0x008   /* Reader wants some characters. */
+#define PIPE_WANTW 0x010   /* Writer wants space to put characters. */
+#define PIPE_WANT  0x020   /* Pipe is wanted to be run-down. */
+#define PIPE_SEL   0x040   /* Pipe has a select active. */
+#define PIPE_EOF   0x080   /* Pipe is in EOF condition. */
+#define PIPE_LOCKFL0x100   /* Process has exclusive access to 
pointers/data. */
+#define PIPE_LWANT 0x200   /* Process wants exclusive access to 
pointers/data. */
+#define PIPE_DIRECTW   0x400   /* Pipe direct write active. */
+#define PIPE_DIRECTOK  0x800   /* Direct mode ok. */
+
+/*
+ * Per-pipe data structure.
+ * Two of these are linked together to produce bi-directional pipes.
+ */
+struct pipe {
+   struct  pipebuf pipe_buffer;/* data storage */
+   struct  pipemapping pipe_map;   /* pipe mapping for direct I/O */
+   struct  selinfo pipe_sel;   /* for compat with select */
+   struct  timespec pipe_atime;/* time of last access */
+   struct  timespec pipe_mtime;/* time of last modify */
+   struct  timespec pipe_ctime;/* time of status change */
+   struct  sigio *pipe_sigio;  /* information for async I/O */
+   struct  pipe *pipe_peer;/* link with other direction */
+   struct  pipepair *pipe_pair;/* container structure pointer */
+   u_int   pipe_state; /* pipe status info */
+   int pipe_busy;  /* busy flag, mostly to handle rundown 
sanely */
+   int pipe_present;   /* still present? */
+   ino_t   pipe_ino;   /* fake inode for stat(2) */
+};
+
+/*
+ * Values for the pipe_present.
+ */
+#define PIPE_ACTIVE1
+#definePIPE_CLOSING2
+#definePIPE_FINALIZED  3
+
+/*
+ * Container structure to hold the two pipe endpoints, mutex, and label
+ * pointer.
+ */
+struct pipepair {
+   struct pipe pp_rpipe;
+   struct pipe pp_wpipe;
+   struct 

[PATCH 3/7] Adding pipe support

2016-12-09 Thread Kevin Kirspel
---
 libbsd.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libbsd.py b/libbsd.py
index 3685191..d7a0a5f 100755
--- a/libbsd.py
+++ b/libbsd.py
@@ -258,6 +258,7 @@ def base(mm):
 'sys/sys/_null.h',
 'sys/sys/osd.h',
 'sys/sys/pcpu.h',
+'sys/sys/pipe.h',
 'sys/sys/priv.h',
 'sys/sys/proc.h',
 'sys/sys/protosw.h',
@@ -348,6 +349,7 @@ def base(mm):
 'sys/kern/subr_uio.c',
 'sys/kern/subr_unit.c',
 'sys/kern/sys_generic.c',
+'sys/kern/sys_pipe.c',
 'sys/kern/uipc_accf.c',
 'sys/kern/uipc_domain.c',
 'sys/kern/uipc_mbuf2.c',
-- 
1.9.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 5/7] Adding pipe support

2016-12-09 Thread Kevin Kirspel
---
 freebsd/sys/kern/sys_pipe.c | 273 +++-
 1 file changed, 272 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 freebsd/sys/kern/sys_pipe.c

diff --git a/freebsd/sys/kern/sys_pipe.c b/freebsd/sys/kern/sys_pipe.c
old mode 100644
new mode 100755
index f1efd09..45d3ed1
--- a/freebsd/sys/kern/sys_pipe.c
+++ b/freebsd/sys/kern/sys_pipe.c
@@ -131,6 +131,9 @@ __FBSDID("$FreeBSD$");
 #include 
 
 /* XXX */
+#ifdef __rtems__
+static
+#endif /* __rtems__ */
 intdo_pipe(struct thread *td, int fildes[2], int flags);
 
 /*
@@ -143,6 +146,7 @@ int do_pipe(struct thread *td, int fildes[2], int flags);
 /*
  * interfaces to the outside world
  */
+#ifndef __rtems__
 static fo_rdwr_t   pipe_read;
 static fo_rdwr_t   pipe_write;
 static fo_truncate_t   pipe_truncate;
@@ -165,6 +169,39 @@ static struct fileops pipeops = {
.fo_chown = invfo_chown,
.fo_flags = DFLAG_PASSABLE
 };
+#else /* __rtems__ */
+#define PIPE_NODIRECT
+#definePRIBIO  (0)
+
+static int rtems_bsd_pipe_open(rtems_libio_t *iop, const char *path, int 
oflag, mode_t mode);
+static int rtems_bsd_pipe_close(rtems_libio_t *iop);
+static ssize_t rtems_bsd_pipe_read(rtems_libio_t *iop, void *buffer, size_t 
count);
+static ssize_t rtems_bsd_pipe_write(rtems_libio_t *iop, const void *buffer, 
size_t count);
+static int rtems_bsd_pipe_ioctl(rtems_libio_t *iop, ioctl_command_t request, 
void *buffer);
+static int rtems_bsd_pipe_stat(const rtems_filesystem_location_info_t *loc,
struct stat *buf);
+static int rtems_bsd_pipe_fcntl(rtems_libio_t *iop, int cmd);
+static int rtems_bsd_pipe_poll(rtems_libio_t *iop, int events);
+int rtems_bsd_pipe_kqfilter(rtems_libio_t *iop, struct knote *kn);
+
+static const rtems_filesystem_file_handlers_r pipeops = {
+   .open_h = rtems_bsd_pipe_open,
+   .close_h = rtems_bsd_pipe_close,
+   .read_h = rtems_bsd_pipe_read,
+   .write_h = rtems_bsd_pipe_write,
+   .ioctl_h = rtems_bsd_pipe_ioctl,
+   .lseek_h = rtems_filesystem_default_lseek,
+   .fstat_h = rtems_bsd_pipe_stat,
+   .ftruncate_h = rtems_filesystem_default_ftruncate,
+   .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
+   .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
+   .fcntl_h = rtems_bsd_pipe_fcntl,
+   .poll_h = rtems_bsd_pipe_poll,
+   .kqfilter_h = rtems_bsd_pipe_kqfilter
+};
+
+long   maxpipekva; /* Limit on pipe KVA */
+
+#endif /* __rtems__ */
 
 static voidfilt_pipedetach(struct knote *kn);
 static int filt_piperead(struct knote *kn, long hint);
@@ -266,7 +303,11 @@ pipe_zone_ctor(void *mem, int size, void *arg, int flags)
 */
rpipe = >pp_rpipe;
bzero(rpipe, sizeof(*rpipe));
+#ifndef __rtems__
vfs_timestamp(>pipe_ctime);
+#else /* __rtems__ */
+   rpipe->pipe_ctime.tv_sec = time(NULL);
+#endif /* __rtems__ */
rpipe->pipe_atime = rpipe->pipe_mtime = rpipe->pipe_ctime;
 
wpipe = >pp_wpipe;
@@ -336,7 +377,11 @@ kern_pipe(struct thread *td, int fildes[2])
 int
 do_pipe(struct thread *td, int fildes[2], int flags)
 {
+#ifndef __rtems__
struct filedesc *fdp = td->td_proc->p_fd;
+#else /* __rtems__ */
+   struct filedesc *fdp = NULL;
+#endif /* __rtems__ */
struct file *rf, *wf;
struct pipepair *pp;
struct pipe *rpipe, *wpipe;
@@ -416,12 +461,34 @@ sys_pipe(struct thread *td, struct pipe_args *uap)
error = kern_pipe(td, fildes);
if (error)
return (error);
-   
+
td->td_retval[0] = fildes[0];
td->td_retval[1] = fildes[1];
 
return (0);
 }
+#ifdef __rtems__
+int
+pipe(int fildes[2])
+{
+   struct thread *td = rtems_bsd_get_curthread_or_null();
+   int error;
+
+   if (td != NULL) {
+   error = sys_pipe(td, NULL);
+   } else {
+   error = ENOMEM;
+   }
+
+   if (error == 0) {
+   fildes[0] = td->td_retval[0];
+   fildes[1] = td->td_retval[1];
+   return error;
+   } else {
+   rtems_set_errno_and_return_minus_one(error);
+   }
+}
+#endif /* __rtems__ */
 
 /*
  * Allocate kva for pipe circular buffer, the space is pageable
@@ -448,12 +515,17 @@ retry:
size = cnt;
 
size = round_page(size);
+#ifndef __rtems__
buffer = (caddr_t) vm_map_min(pipe_map);
 
error = vm_map_find(pipe_map, NULL, 0,
(vm_offset_t *) , size, 1,
VM_PROT_ALL, VM_PROT_ALL, 0);
if (error != KERN_SUCCESS) {
+#else /* __rtems__ */
+   buffer = malloc(size, M_TEMP, M_WAITOK | M_ZERO);
+   if (buffer == NULL) {
+#endif /* __rtems__ */
if ((cpipe->pipe_buffer.buffer == NULL) &&
(size > SMALL_PIPE_SIZE)) {
size = SMALL_PIPE_SIZE;
@@ -716,7 +788,11 @@ pipe_read(fp, uio, active_cred, flags, td)
  

Flight Software Workshop Next Week

2016-12-09 Thread Joel Sherrill
Hi

Just a note that I will be at the Flight Software Workshop in Pasadena next
week.

FlightSoftware.org for details.

Thanks.

--joel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH] EDF scheduler overrun handling example

2016-12-09 Thread Kuan-Hsun Chen
---
 testsuites/sptests/Makefile.am   |   2 +-
 testsuites/sptests/configure.ac  |   1 +
 testsuites/sptests/spedfsched04/Makefile.am  |  21 +
 testsuites/sptests/spedfsched04/init.c   |  70 
 testsuites/sptests/spedfsched04/spedfsched04.doc |  34 
 testsuites/sptests/spedfsched04/spedfsched04.scn |  24 ++
 testsuites/sptests/spedfsched04/system.h |  66 +++
 testsuites/sptests/spedfsched04/tasks.c  | 101 +++
 8 files changed, 318 insertions(+), 1 deletion(-)
 create mode 100644 testsuites/sptests/spedfsched04/Makefile.am
 create mode 100644 testsuites/sptests/spedfsched04/init.c
 create mode 100644 testsuites/sptests/spedfsched04/spedfsched04.doc
 create mode 100644 testsuites/sptests/spedfsched04/spedfsched04.scn
 create mode 100644 testsuites/sptests/spedfsched04/system.h
 create mode 100644 testsuites/sptests/spedfsched04/tasks.c

diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 4281abb..c62cbef 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -37,7 +37,7 @@ _SUBDIRS += spfatal29
 _SUBDIRS += spmutex01
 _SUBDIRS += spextensions01
 _SUBDIRS += spsysinit01
-_SUBDIRS += sprmsched01
+_SUBDIRS += sprmsched01 spedfsched04
 if HAS_SMP
 else
 _SUBDIRS += sp29
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 8a55aef..6713754 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -166,6 +166,7 @@ spcoverage/Makefile
 spedfsched01/Makefile
 spedfsched02/Makefile
 spedfsched03/Makefile
+spedfsched04/Makefile
 sperror01/Makefile
 sperror02/Makefile
 sperror03/Makefile
diff --git a/testsuites/sptests/spedfsched04/Makefile.am 
b/testsuites/sptests/spedfsched04/Makefile.am
new file mode 100644
index 000..21293de
--- /dev/null
+++ b/testsuites/sptests/spedfsched04/Makefile.am
@@ -0,0 +1,21 @@
+
+rtems_tests_PROGRAMS = spedfsched04
+spedfsched04_SOURCES = init.c tasks.c system.h
+   
+dist_rtems_tests_DATA = spedfsched04.scn 
+dist_rtems_tests_DATA += spedfsched04.doc
+
+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)/../support/include
+
+LINK_OBJS = $(spedfsched04_OBJECTS)
+LINK_LIBS = $(spedfsched04_LDLIBS)
+
+spedfsched04$(EXEEXT): $(spedfsched04_OBJECTS) $(spedfsched04_DEPENDENCIES)
+   @rm -f spedfsched04$(EXEEXT)
+   $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spedfsched04/init.c 
b/testsuites/sptests/spedfsched04/init.c
new file mode 100644
index 000..e0847db
--- /dev/null
+++ b/testsuites/sptests/spedfsched04/init.c
@@ -0,0 +1,70 @@
+/**
+ * @file spedfsched04/init.c
+ *
+ * @brief A init task body for spedfsched04 example.
+ *
+ */
+
+/*
+ *  COPYRIGHT (c) 2016 Kuan-Hsun Chen, TU Dortmund University (TUDo).
+ *
+ *  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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+#include 
+#include 
+#include 
+
+const char rtems_test_name[] = "SPEDFSCHED 4";
+
+/* Global variables */
+rtems_id   Task_id[ 2 ]; /* array of task ids */
+rtems_name Task_name[ 2 ];   /* array of task names */
+uint32_t tick_per_second;/* time reference */
+int testnumber = 5;  /* stop condition */
+
+rtems_task_priority Prio[3] = {0, 2, 5};
+
+rtems_task Init(
+   rtems_task_argument argument
+)
+{
+  uint32_tindex;
+  TEST_BEGIN();
+  rtems_status_code status;
+
+
+  tick_per_second = rtems_clock_get_ticks_per_second();
+  printf("\nTicks per second in your system: %" PRIu32 "\n", tick_per_second);
+
+  Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
+  Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
+
+  /* Create two tasks */
+  for ( index = 1; index <= 2; index++ ){
+status = rtems_task_create(
+  Task_name[ index ], Prio[ index ], RTEMS_MINIMUM_STACK_SIZE, 
RTEMS_DEFAULT_MODES,
+  RTEMS_DEFAULT_ATTRIBUTES, _id[ index ]
+);
+directive_failed( status, "rtems_task_create loop" );
+  }
+
+  /* After creating the periods for tasks, start to run them sequencially. */
+  for ( index = 1; index <=2; index++ ){
+status = rtems_task_start( Task_id[ index ], Task_1, index);
+directive_failed( status, "rtems_task_start loop" );
+  }
+
+  status = rtems_task_delete( RTEMS_SELF );
+  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
+}
+
diff --git a/testsuites/sptests/spedfsched04/spedfsched04.doc 
b/testsuites/sptests/spedfsched04/spedfsched04.doc
new file mode 100644
index 000..6c34b31
--- /dev/null
+++ b/testsuites/sptests/spedfsched04/spedfsched04.doc
@@ -0,0 +1,34 @@
+#
+#   COPYRIGHT (c) 

[PATCH] RMS scheduler overrun handling example

2016-12-09 Thread Kuan-Hsun Chen
---
 testsuites/sptests/Makefile.am |   2 +
 testsuites/sptests/configure.ac|   1 +
 testsuites/sptests/sprmsched01/Makefile.am |  21 +
 testsuites/sptests/sprmsched01/init.c  |  69 
 testsuites/sptests/sprmsched01/sprmsched01.doc |  33 
 testsuites/sptests/sprmsched01/sprmsched01.scn |  48 
 testsuites/sptests/sprmsched01/system.h|  64 +++
 testsuites/sptests/sprmsched01/tasks.c | 104 +
 8 files changed, 342 insertions(+)
 create mode 100644 testsuites/sptests/sprmsched01/Makefile.am
 create mode 100644 testsuites/sptests/sprmsched01/init.c
 create mode 100644 testsuites/sptests/sprmsched01/sprmsched01.doc
 create mode 100644 testsuites/sptests/sprmsched01/sprmsched01.scn
 create mode 100644 testsuites/sptests/sprmsched01/system.h
 create mode 100644 testsuites/sptests/sprmsched01/tasks.c

diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 54a4de7..4281abb 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -37,6 +37,7 @@ _SUBDIRS += spfatal29
 _SUBDIRS += spmutex01
 _SUBDIRS += spextensions01
 _SUBDIRS += spsysinit01
+_SUBDIRS += sprmsched01
 if HAS_SMP
 else
 _SUBDIRS += sp29
@@ -56,6 +57,7 @@ _SUBDIRS += sptimecounter03
 _SUBDIRS += spatomic01
 _SUBDIRS += spintrcritical22
 _SUBDIRS += spsem03
+_SUBDIRS += spresource01
 _SUBDIRS += spmrsp01
 _SUBDIRS += spscheduler01
 _SUBDIRS += spprofiling01
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 76d60e3..8a55aef 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -255,5 +255,6 @@ sptimer_err02/Makefile
 spcpuset01/Makefile
 spregion_err01/Makefile
 sppartition_err01/Makefile
+sprmsched01/Makefile
 ])
 AC_OUTPUT
diff --git a/testsuites/sptests/sprmsched01/Makefile.am 
b/testsuites/sptests/sprmsched01/Makefile.am
new file mode 100644
index 000..f837b52
--- /dev/null
+++ b/testsuites/sptests/sprmsched01/Makefile.am
@@ -0,0 +1,21 @@
+
+rtems_tests_PROGRAMS = sprmsched01
+sprmsched01_SOURCES = init.c tasks.c system.h
+   
+dist_rtems_tests_DATA = sprmsched01.scn 
+dist_rtems_tests_DATA += sprmsched01.doc
+
+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)/../support/include
+
+LINK_OBJS = $(sprmsched01_OBJECTS)
+LINK_LIBS = $(sprmsched01_LDLIBS)
+
+sprmsched01$(EXEEXT): $(sprmsched01_OBJECTS) $(sprmsched01_DEPENDENCIES)
+   @rm -f sprmsched01$(EXEEXT)
+   $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/sprmsched01/init.c 
b/testsuites/sptests/sprmsched01/init.c
new file mode 100644
index 000..7fd3e87
--- /dev/null
+++ b/testsuites/sptests/sprmsched01/init.c
@@ -0,0 +1,69 @@
+/**
+ * @file sprmsched01/init.c
+ *
+ * @brief A init task body for sprmsched01 example.
+ *
+ */
+
+/*
+ *  COPYRIGHT (c) 2016 Kuan-Hsun Chen, TU Dortmund University (TUDo).
+ *
+ *  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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+#include 
+#include 
+#include 
+
+const char rtems_test_name[] = "Rate Monotonic 01";
+
+/* Global variables */
+rtems_id   Task_id[ 2 ]; /* array of task ids */
+rtems_name Task_name[ 2 ];   /* array of task names */
+uint32_t tick_per_second;/* time reference */
+int testnumber = 11;  /* stop condition */
+
+rtems_task_priority Prio[3] = {0, 2, 5};
+
+rtems_task Init(
+   rtems_task_argument argument
+)
+{
+  rtems_status_code status;
+  TEST_BEGIN();
+
+
+  tick_per_second = rtems_clock_get_ticks_per_second();
+  printf("\nTicks per second in your system: %" PRIu32 "\n", tick_per_second);
+
+  Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
+  Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
+
+  /* Create two tasks */
+  for ( int index = 1; index <= 2; index++){
+status = rtems_task_create(
+  Task_name[ index ], Prio[index], RTEMS_MINIMUM_STACK_SIZE, 
RTEMS_DEFAULT_MODES,
+  RTEMS_DEFAULT_ATTRIBUTES, _id[ index ]
+);
+directive_failed( status, "rtems_task_create loop");
+  }
+
+
+  /* After creating the periods for tasks, start to run them sequencially. */
+  for ( int index = 1; index <= 2; index++){
+status = rtems_task_start( Task_id[ index ], Task_1, index);
+directive_failed( status, "rtems_task_start loop");
+  }
+  status = rtems_task_delete( RTEMS_SELF );
+  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
+}
+
diff --git a/testsuites/sptests/sprmsched01/sprmsched01.doc 
b/testsuites/sptests/sprmsched01/sprmsched01.doc
new file mode 100644
index 000..7153af8
--- /dev/null
+++ 

[PATCH] Update RMS documentation

2016-12-09 Thread Kuan-Hsun Chen
---
 c-user/rate_monotonic_manager.rst | 30 +-
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/c-user/rate_monotonic_manager.rst 
b/c-user/rate_monotonic_manager.rst
index 8ad74e5..292e4bc 100644
--- a/c-user/rate_monotonic_manager.rst
+++ b/c-user/rate_monotonic_manager.rst
@@ -132,7 +132,7 @@ milliseconds every 100 (10 percent of the CPU).  As a 
general rule of thumb,
 the higher frequency at which a task executes, the more important it is to
 optimize that task.
 
-Rate Monotonic Manager Definitions
+Periodicity Definitions
 --
 .. index:: periodic task, definition
 
@@ -170,7 +170,7 @@ Rate Monotonic Scheduling Algorithm
 .. index:: RMS Algorithm, definition
 
 The Rate Monotonic Scheduling Algorithm (RMS) is important to real-time systems
-designers because it allows one to guarantee that a set of tasks is
+designers because it allows one to sufficiently guarantee that a set of tasks 
is
 schedulable.  A set of tasks is said to be schedulable if all of the tasks can
 meet their deadlines.  RMS provides a set of rules which can be used to perform
 a guaranteed schedulability analysis for a task set.  This analysis determines
@@ -179,11 +179,11 @@ the predictability of the system's behavior.  It has been 
proven that:
 
 .. sidebar:: *RMS*
 
-  RMS is an optimal static priority algorithm for scheduling independent,
+  RMS is an optimal fixed-priority algorithm for scheduling independent,
   preemptible, periodic tasks on a single processor.
 
 RMS is optimal in the sense that if a set of tasks can be scheduled by any
-static priority algorithm, then RMS will be able to schedule that task set.
+fixed-priority algorithm, then RMS will be able to schedule that task set.
 RMS bases it schedulability analysis on the processor utilization level below
 which all deadlines can be met.
 
@@ -230,7 +230,7 @@ Schedulability Analysis
 
 .. index:: RMS schedulability analysis
 
-RMS allows application designers to ensure that tasks can meet all deadlines,
+RMS allows application designers to ensure that tasks can meet all deadlines 
under fixed-priority assignment,
 even under transient overload, without knowing exactly when any given task will
 execute by applying proven schedulability analysis rules.
 
@@ -468,9 +468,10 @@ monotonic period results in one of the following scenarios:
   immediately.
 
 - If the rate monotonic period has expired before the task invokes the
-  ``rtems_rate_monotonic_period`` directive, the period will be initiated with
-  a length of period ticks and the calling task returns immediately with a
-  timeout error status.
+  ``rtems_rate_monotonic_period`` directive, the postponed job will be 
released 
+  until there is no more postponed jobs. The calling task returns immediately 
+  with a timeout error status. In the watchdog routine, the period will still 
+  be updated periodically and track the number of the postponed periods.
 
 Obtaining the Status of a Period
 
@@ -560,8 +561,8 @@ Subsequent invocations of the 
``rtems_rate_monotonic_period`` directive will
 result in the task blocking for the remainder of the 100 tick period.  If, for
 any reason, the body of the loop takes more than 100 ticks to execute, the
 ``rtems_rate_monotonic_period`` directive will return the ``RTEMS_TIMEOUT``
-status.  If the above task misses its deadline, it will delete the rate
-monotonic period and itself.
+status and the postponed job will be released.  If the above task misses 
+its deadline, it will delete the rate monotonic period and itself.
 
 Task with Multiple Periods
 --
@@ -629,8 +630,8 @@ will not block.
 
 If, for any reason, the task misses any deadline, the
 ``rtems_rate_monotonic_period`` directive will return the ``RTEMS_TIMEOUT``
-directive status.  If the above task misses its deadline, it will delete the
-rate monotonic periods and itself.
+directive status and the postponed job will be released. If the above task 
misses 
+its deadline, it will delete the rate monotonic periods and itself.
 
 Directives
 ==
@@ -839,7 +840,10 @@ DESCRIPTION:
 period ticks.  If id is running, then the calling task will block for the
 remainder of the period before reinitiating the period with the specified
 period.  If id was not running (either expired or never initiated), the
-period is immediately initiated and the directive returns immediately.
+period is immediately initiated and the directive returns immediately. 
+   If id has expired its period, the postponed job will be released 
immediately 
+   and the following calls of this directive will keep release those 
postponed 
+   jobs until there is no more deadline miss.
 
 If invoked with a period of ``RTEMS_PERIOD_STATUS`` ticks, the current
 state of id will be returned.  The directive status indicates the current
-- 
1.9.1


[PATCH] Enhancement of the RMS manager for the overrun handling.

2016-12-09 Thread Kuan-Hsun Chen
Three additional functions:
RM_Postponed_num, RM_Renew_deadline, and RM_Release_postponedjob.

Four refined functions:
RM_Activate, RM_Block_while_expired, rtems_rate_monotonic_period, RM_Timeout.

Rate_monotonic_Control contains one counter for counting the postponed jobs and 
one for recording the recent deadline.
---
 cpukit/rtems/include/rtems/rtems/ratemon.h |  42 ++--
 cpukit/rtems/include/rtems/rtems/ratemonimpl.h |  25 +++--
 cpukit/rtems/src/ratemonperiod.c   | 144 +
 cpukit/rtems/src/ratemontimeout.c  |  13 ++-
 4 files changed, 183 insertions(+), 41 deletions(-)

diff --git a/cpukit/rtems/include/rtems/rtems/ratemon.h 
b/cpukit/rtems/include/rtems/rtems/ratemon.h
index 50b8478..71a99dc 100644
--- a/cpukit/rtems/include/rtems/rtems/ratemon.h
+++ b/cpukit/rtems/include/rtems/rtems/ratemon.h
@@ -22,6 +22,7 @@
 
 /* COPYRIGHT (c) 1989-2009, 2016.
  * On-Line Applications Research Corporation (OAR).
+ * COPYRIGHT (c) 2016 Kuan-Hsun Chen, TU Dortmund University (TUDo).
  *
  * The license and distribution terms for this file may be
  * found in the file LICENSE in this distribution or at
@@ -194,11 +195,6 @@ typedef struct {
   /** This field is the object management portion of a Period instance. */
   Objects_Control Object;
 
-  /**
-   * @brief Protects the rate monotonic period state.
-   */
-  ISR_LOCK_MEMBER(Lock )
-
   /** This is the timer used to provide the unblocking mechanism. */
   Watchdog_ControlTimer;
 
@@ -206,12 +202,6 @@ typedef struct {
   rtems_rate_monotonic_period_states  state;
 
   /**
-   * @brief A priority node for use by the scheduler job release and cancel
-   * operations.
-   */
-  Priority_Node   Priority;
-
-  /**
* This field contains the length of the next period to be
* executed.
*/
@@ -240,6 +230,19 @@ typedef struct {
* This field contains the statistics maintained for the period.
*/
   Rate_monotonic_Statistics   Statistics;
+
+  /**
+   * This field contains the number of postponed jobs. When the watchdog 
timeout, 
+   * this variable will be increased immediately.
+   */
+  uint32_tpostponed_jobs;
+
+  /**
+   *  This field contains the tick of the latest deadline decided by the period
+   *  watchdog. 
+   */
+  uint64_tlatest_deadline;
+
 }   Rate_monotonic_Control;
 
 /**
@@ -386,6 +389,23 @@ void rtems_rate_monotonic_report_statistics_with_plugin(
 void rtems_rate_monotonic_report_statistics( void );
 
 /**
+ * @brief RTEMS Return the number of postponed jobs
+ * 
+ * This is a helper function to return the number of postponed jobs by this
+ * given period. This number is only increased by the corresponding watchdog,
+ * and is decreased by RMS manager with the postponed job releasing.
+ *
+ * @param[in] id is the period id
+ *
+ * @retval This helper function returns the number of postponed 
+ * jobs with given period_id.
+ *
+ */
+uint32_t rtems_rate_monotonic_Postponed_num(
+  rtems_idperiod_id
+);
+
+/**
  * @brief RTEMS Rate Monotonic Period
  *
  * This routine implements the rtems_rate_monotonic_period directive. When
diff --git a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h 
b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
index b6b3ffd..6cdaaeb 100644
--- a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
@@ -9,6 +9,7 @@
 /*  COPYRIGHT (c) 1989-2008.
  *  On-Line Applications Research Corporation (OAR).
  *  Copyright (c) 2016 embedded brains GmbH.
+ *  COPYRIGHT (c) 2016 Kuan-Hsun Chen, TU Dortmund University (TUDo).
  *
  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
@@ -69,19 +70,19 @@ RTEMS_INLINE_ROUTINE Rate_monotonic_Control 
*_Rate_monotonic_Allocate( void )
 }
 
 RTEMS_INLINE_ROUTINE void _Rate_monotonic_Acquire_critical(
-  Rate_monotonic_Control *the_period,
-  ISR_lock_Context   *lock_context
+  Thread_Control   *the_thread,
+  ISR_lock_Context *lock_context
 )
 {
-  _ISR_lock_Acquire( _period->Lock, lock_context );
+  _Thread_Wait_acquire_default_critical( the_thread, lock_context );
 }
 
 RTEMS_INLINE_ROUTINE void _Rate_monotonic_Release(
-  Rate_monotonic_Control *the_period,
-  ISR_lock_Context   *lock_context
+  Thread_Control   *the_thread,
+  ISR_lock_Context *lock_context
 )
 {
-  _ISR_lock_Release_and_ISR_enable( _period->Lock, lock_context );
+  _Thread_Wait_release_default( the_thread, lock_context );
 }
 
 RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get(
@@ -116,6 +117,18 @@ bool _Rate_monotonic_Get_status(
   Timestamp_Control*cpu_since_last_period
 );
 
+/**
+ * @brief Renew the watchdog deadline
+ *
+ * This routine is prepared for the watchdog timeout to renew its deadline
+ * without releasing jobs. 
+ 

Re: RTEMS LIBBSD Pipe Support

2016-12-09 Thread Sebastian Huber

On 09/12/16 13:51, Kirspel, Kevin wrote:


The attached patch pulls in FreeBSDs pipe functionality into RTEMS LIBBSD.



There are some guidelines for "|How to import code from FreeBSD|"

https://git.rtems.org/rtems-libbsd/tree/libbsd.txt#n784

Please send patches via git format-patch and git send-email.

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: QT 5.8 Port

2016-12-09 Thread Sebastian Huber

On 09/12/16 14:17, Kirspel, Kevin wrote:

LIBBSD has the poll() functionality.  In order for the pipe to be polled then 
it needs functionality that is only found in LIBBSD.  I started off using the 
pipe in the RTEMS tree.  I even added the poll handler to return the correct 
revents.  The problem was that the RTEMS pipe poll handler needs to call a 
function in LIBBSD (selrecord) so that it can work with poll().


Ok, this makes sense.

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


RE: QT 5.8 Port

2016-12-09 Thread Kirspel, Kevin
LIBBSD has the poll() functionality.  In order for the pipe to be polled then 
it needs functionality that is only found in LIBBSD.  I started off using the 
pipe in the RTEMS tree.  I even added the poll handler to return the correct 
revents.  The problem was that the RTEMS pipe poll handler needs to call a 
function in LIBBSD (selrecord) so that it can work with poll().

Kevin Kirspel
Electrical Engineer - Sr. Staff
Idexx Roswell
235 Hembree Park Drive
Roswell GA 30076
Tel: (770)-510- ext. 81642
Direct: (770)-688-1642
Fax: (770)-510-4445

-Original Message-
From: devel [mailto:devel-boun...@rtems.org] On Behalf Of Sebastian Huber
Sent: Friday, December 09, 2016 3:44 AM
To: devel@rtems.org
Subject: Re: QT 5.8 Port

Hello Kevin,

we already have a (broken) pipe support in RTEMS

https://urldefense.proofpoint.com/v2/url?u=https-3A__git.rtems.org_rtems_tree_cpukit_libcsupport_src_pipe.c=DgIF-g=2do6VJGs3LvEOe4OFFM1bA=dbavT-WIJ4nBfQFKYnKdAD52Vyq3ZXSzrL9TAm21lZI=JsBiBqByZuuh7FFKuLujX-9gC7BaNG4-3Xa1ytmRgcA=kS0AINMLfVS4Eoot_vf4iYhQwj3ENj3xMIyrqerJfIc=
 

What is the befit of using the FreeBSD pipe implementation?

On 07/12/16 19:49, Kirspel, Kevin wrote:
>
> I'm porting QT 5.8 to RTEMS 4.12 and rtems-libbsd.  I had to add pipe 
> support to rtems-libbsd.  I would like to submit the pipe patch but 
> the "git diff" is long due to the fact that the diff includes the 
> entire file contents of the modified sys_pipe.c and pipe.h files.  How 
> do you usually submit patches for review for rtems-libbsd?
>
> Kevin Kirspel
>
> Electrical Engineer - Sr. Staff
>
> Idexx Roswell
>
> 235 Hembree Park Drive
>
> Roswell GA 30076
>
> Tel: (770)-510- ext. 81642
>
> Direct: (770)-688-1642
>
> Fax: (770)-510-4445
>
>
>
> ___
> devel mailing list
> devel@rtems.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.rtems.org_ma
> ilman_listinfo_devel=DgIF-g=2do6VJGs3LvEOe4OFFM1bA=dbavT-WIJ4nBf
> QFKYnKdAD52Vyq3ZXSzrL9TAm21lZI=JsBiBqByZuuh7FFKuLujX-9gC7BaNG4-3Xa1y
> tmRgcA=DmB5g2XWSfm8YAS-McegW2BaDcYR_4LLkQkY5liYzKI=

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

___
devel mailing list
devel@rtems.org
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.rtems.org_mailman_listinfo_devel=DgIF-g=2do6VJGs3LvEOe4OFFM1bA=dbavT-WIJ4nBfQFKYnKdAD52Vyq3ZXSzrL9TAm21lZI=JsBiBqByZuuh7FFKuLujX-9gC7BaNG4-3Xa1ytmRgcA=DmB5g2XWSfm8YAS-McegW2BaDcYR_4LLkQkY5liYzKI=
 
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


RTEMS LIBBSD Pipe Support

2016-12-09 Thread Kirspel, Kevin
The attached patch pulls in FreeBSDs pipe functionality into RTEMS LIBBSD.

Kevin Kirspel
Electrical Engineer - Sr. Staff
Idexx Roswell
235 Hembree Park Drive
Roswell GA 30076
Tel: (770)-510- ext. 81642
Direct: (770)-688-1642
Fax: (770)-510-4445



rtems-libbsd-pipe-submit.diff
Description: rtems-libbsd-pipe-submit.diff
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH] Update Initialization Manager chapter

2016-12-09 Thread Sebastian Huber
Update #2408.
---
 c-user/fatal_error.rst|  36 ++
 c-user/initialization.rst | 288 ++
 c-user/linker_sets.rst|   2 +-
 3 files changed, 226 insertions(+), 100 deletions(-)

diff --git a/c-user/fatal_error.rst b/c-user/fatal_error.rst
index df8294b..8deb3db 100644
--- a/c-user/fatal_error.rst
+++ b/c-user/fatal_error.rst
@@ -4,6 +4,8 @@
 .. COMMENT: On-Line Applications Research Corporation (OAR).
 .. COMMENT: All rights reserved.
 
+.. _fatal_error_manager:
+
 Fatal Error Manager
 ***
 
@@ -19,6 +21,8 @@ provided by the fatal error manager are:
 
 - rtems_fatal_ - Invoke the fatal error handler
 
+- rtems_shutdown_executive_ - Shutdown RTEMS
+
 - rtems_exception_frame_print_ - Print the CPU exception frame
 
 - rtems_fatal_source_text_ - Return the fatal source text
@@ -468,6 +472,38 @@ NOTE:
 
\clearpage
 
+.. _rtems_shutdown_executive:
+
+SHUTDOWN_EXECUTIVE - Shutdown RTEMS
+---
+.. index:: shutdown RTEMS
+
+.. index:: rtems_shutdown_executive
+CALLING SEQUENCE:
+.. code-block:: c
+
+void rtems_shutdown_executive(
+uint32_t result
+);
+
+DIRECTIVE STATUS CODES:
+NONE - This function will not return to the caller.
+
+DESCRIPTION:
+This directive is called when the application wishes to shutdown RTEMS.
+The system is terminated with a fatal source of ``RTEMS_FATAL_SOURCE_EXIT``
+and the specified ``result`` code.
+
+NOTES:
+This directive *must* be the last RTEMS directive invoked by an application
+and it *does not return* to the caller.
+
+This directive may be called any time.
+
+.. raw:: latex
+
+   \clearpage
+
 .. _rtems_exception_frame_print:
 
 EXCEPTION_FRAME_PRINT - Prints the exception frame
diff --git a/c-user/initialization.rst b/c-user/initialization.rst
index 4be322a..ae3f6d8 100644
--- a/c-user/initialization.rst
+++ b/c-user/initialization.rst
@@ -10,16 +10,14 @@ Initialization Manager
 Introduction
 
 
-The Initialization Manager is responsible for initiating and shutting down
-RTEMS.  Initiating RTEMS involves creating and starting all configured
-initialization tasks, and for invoking the initialization routine for each
-user-supplied device driver.  In a multiprocessor configuration, this manager
-also initializes the interprocessor communications layer.  The directives
-provided by the Initialization Manager are:
+The Initialization Manager is responsible for initializing the Board Support
+Package, RTEMS, device drivers, the root filesystem and the application.  The
+:ref:`Fatal Error Manager ` is responsible for the system
+shutdown.
 
-- rtems_initialize_executive_ - Initialize RTEMS
+The Initialization Manager provides only one directive:
 
-- rtems_shutdown_executive_ - Shutdown RTEMS
+- rtems_initialize_executive_ - Initialize RTEMS
 
 Background
 ==
@@ -47,25 +45,11 @@ Initialization tasks may transform themselves into a 
"normal" application task.
 This transformation typically involves changing priority and execution mode.
 RTEMS does not automatically delete the initialization tasks.
 
-System Initialization
--
-
-System Initialization begins with board reset and continues through RTEMS
-initialization, initialization of all device drivers, and eventually a context
-switch to the first user task.  Remember, that interrupts are disabled during
-initialization and the *initialization context* is not a task in any sense and
-the user should be very careful during initialization.
-
-The BSP must ensure that the there is enough stack space reserved for the
-initialization context to successfully execute the initialization routines for
-all device drivers and, in multiprocessor configurations, the Multiprocessor
-Communications Interface Layer initialization routine.
-
 The Idle Task
 -
 
 The Idle Task is the lowest priority task in a system and executes only when no
-other task is ready to execute.  This default implementation of this task
+other task is ready to execute.  The default implementation of this task
 consists of an infinite loop. RTEMS allows the Idle Task body to be replaced by
 a CPU specific implementation, a BSP specific implementation or an application
 specific implementation.
@@ -85,10 +69,10 @@ Operations
 Initializing RTEMS
 --
 
-The Initialization Manager ``rtems_initialize_executive`` directives is called
-by the ``boot_card`` routine.  The ``boot_card`` routine is invoked by the
-Board Support Package once a basic C run-time environment is set up.  This
-consists of
+The Initialization Manager :c:func:`rtems_initialize_executive()` directives is
+called by the :c:ref:`boot_card()` routine which is invoked by the Board
+Support Package once a basic C run-time environment is set up.  This consists
+of
 
 - a valid and accessible text section, read-only data, read-write data and
   zero-initialized data,
@@ -100,25 +84,33 

[PATCH] Improve fatal error chapter

2016-12-09 Thread Sebastian Huber
Update #2825.
---
 c-user/fatal_error.rst| 148 +++---
 c-user/initialization.rst |  31 +-
 2 files changed, 116 insertions(+), 63 deletions(-)

diff --git a/c-user/fatal_error.rst b/c-user/fatal_error.rst
index e401db2..df8294b 100644
--- a/c-user/fatal_error.rst
+++ b/c-user/fatal_error.rst
@@ -128,70 +128,120 @@ fatal source.  Each symbolic name has the corresponding 
numeric error code in
 parenthesis.
 
 INTERNAL_ERROR_TOO_LITTLE_WORKSPACE (2)
-Document me.
+There is not enough memory for the workspace.  This fatal error may occur
+during system initialization.  It is an application configuration error.
 
 INTERNAL_ERROR_WORKSPACE_ALLOCATION (3)
-Document me.
+An allocation from the workspace failed.  This fatal error may occur during
+system initialization.  It is an application configuration error.
 
 INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL (4)
-Document me.
+The configured interrupt stack size is too small.  This fatal error may
+occur during system initialization.  It is an application configuration
+error.
 
 INTERNAL_ERROR_THREAD_EXITTED (5)
-Document me.
+A non-POSIX thread entry function returned.  This is an API usage error.
+
+An example code to provoke this fatal error is:
+
+.. code-block:: c
+
+void task( rtems_arg arg )
+{
+  /* Classic API tasks must not return */
+}
+
+void create_bad_task( void )
+{
+  rtems_status_code sc;
+  rtems_id  task_id;
+
+  sc = rtems_task_create(
+rtems_build_name('T', 'A', 'S', 'K'),
+1,
+RTEMS_DEFAULT_MODES,
+RTEMS_DEFAULT_ATTRIBUTES,
+_id
+  );
+  assert( sc == RTEMS_SUCCESSFUL );
+
+  sc = rtems_task_start( task_id, task, 0 );
+  assert( sc == RTEMS_SUCCESSFUL );
+}
 
 INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION (6)
-Document me.
+This fatal error can only occur on MPCI configurations.  The MPCI nodes or
+global objects configuration is inconsistent.  This fatal error may occur
+during system initialization.  It is an application configuration error.
 
 INTERNAL_ERROR_INVALID_NODE (7)
-Document me.
+This fatal error can only occur on MPCI configurations.  The own MPCI node
+number is invalid.  This fatal error may occur during system
+initialization.  It is an application configuration error.
 
 INTERNAL_ERROR_NO_MPCI (8)
-Document me.
+This fatal error can only occur on MPCI configurations.  There is no MPCI
+configuration table.  This fatal error may occur during system
+initialization.  It is an application configuration error.
 
 INTERNAL_ERROR_BAD_PACKET (9)
-Document me.
+This fatal error can only occur on MPCI configurations.  The MPCI server
+thread received a bad packet.
 
 INTERNAL_ERROR_OUT_OF_PACKETS (10)
-Document me.
+This fatal error can only occur on MPCI configurations.  The MPCI packet
+pool is empty.  It is an application configuration error.
 
 INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS (11)
-Document me.
+This fatal error can only occur on MPCI configurations.  The MPCI global
+objects pool is empty.  It is an application configuration error.
 
 INTERNAL_ERROR_OUT_OF_PROXIES (12)
-Document me.
+This fatal error can only occur on MPCI configurations.  The MPCI thread
+proxy pool is empty.  It is an application configuration error.
 
 INTERNAL_ERROR_INVALID_GLOBAL_ID (13)
-Document me.
+This fatal error can only occur on MPCI configurations.  The system cannot
+find the global object for a specific object identifier.  In case this
+happens, then this is probably an operating system bug.
 
 INTERNAL_ERROR_BAD_STACK_HOOK (14)
-Document me.
+The stack allocator hook or stack free hook is NULL.  This fatal error may
+occur during system initialization.  It is an application configuration
+error.
 
 INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0 (19)
-Document me.
-
-INTERNAL_ERROR_GXX_KEY_ADD_FAILED (21)
-Document me.
-
-INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED (22)
-Document me.
+An object class is configured to use the unlimited objects option, however,
+the count of objects for each extension is zero.  This fatal error may
+occur during system initialization.  It is an application configuration
+error.
 
 INTERNAL_ERROR_NO_MEMORY_FOR_HEAP (23)
-Document me.
+There is not enough memory for the C program heap.  This fatal error may
+occur during system initialization.  It is an application configuration
+error.
 
 INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR (24)
-Document me.
+The use of :c:func:`_CPU_ISR_install_vector()` is illegal on this system.
 
 INTERNAL_ERROR_RESOURCE_IN_USE (25)
-Document me.
+This fatal error can only occur on debug configurations.  It happens in
+case a thread 

[PATCH] Rename is_internal to always_false

2016-12-09 Thread Sebastian Huber
Update #2825.
---
 c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspclean.c| 2 +-
 c/src/lib/libbsp/lm32/milkymist/startup/bspclean.c  | 2 +-
 c/src/lib/libbsp/m68k/mcf5225x/startup/bspclean.c   | 2 +-
 c/src/lib/libbsp/m68k/mrm332/misc/interr.c  | 2 +-
 c/src/lib/libbsp/m68k/mvme147/startup/bspclean.c| 2 +-
 c/src/lib/libbsp/m68k/mvme162/startup/bspclean.c| 2 +-
 c/src/lib/libbsp/m68k/mvme167/startup/bspclean.c| 2 +-
 c/src/lib/libbsp/m68k/uC5282/startup/bspclean.c | 2 +-
 c/src/lib/libbsp/powerpc/beatnik/startup/bspclean.c | 2 +-
 c/src/lib/libbsp/powerpc/mvme5500/startup/bspclean.c| 2 +-
 c/src/lib/libbsp/powerpc/virtex4/startup/bspclean.c | 2 +-
 c/src/lib/libbsp/powerpc/virtex5/startup/bspclean.c | 2 +-
 c/src/lib/libbsp/shared/bspclean.c  | 2 +-
 c/src/lib/libbsp/shared/include/default-initial-extension.h | 2 +-
 c/src/lib/libbsp/sparc/leon3/startup/bspclean.c | 2 +-
 c/src/lib/libbsp/sparc64/niagara/startup/bspclean.c | 2 +-
 c/src/libchip/shmdr/fatal.c | 2 +-
 cpukit/libmisc/stackchk/check.c | 2 +-
 cpukit/libmisc/testsupport/test.h   | 2 +-
 cpukit/libmisc/testsupport/testextension.c  | 4 ++--
 cpukit/score/include/rtems/score/userext.h  | 4 ++--
 testsuites/libtests/exit01/init.c   | 4 ++--
 testsuites/libtests/exit02/init.c   | 4 ++--
 testsuites/libtests/stackchk/init.c | 4 ++--
 testsuites/libtests/stackchk/system.h   | 2 +-
 testsuites/psxtests/psxfatal_support/init.c | 6 +++---
 testsuites/psxtests/psxfatal_support/system.h   | 2 +-
 testsuites/smptests/smpfatal01/init.c   | 4 ++--
 testsuites/smptests/smpfatal02/init.c   | 4 ++--
 testsuites/smptests/smpfatal03/init.c   | 4 ++--
 testsuites/smptests/smpfatal04/init.c   | 4 ++--
 testsuites/smptests/smpfatal05/init.c   | 4 ++--
 testsuites/smptests/smpfatal06/init.c   | 4 ++--
 testsuites/smptests/smpfatal08/init.c   | 4 ++--
 testsuites/sptests/sperror01/init.c | 4 ++--
 testsuites/sptests/sperror02/init.c | 4 ++--
 testsuites/sptests/sperror03/init.c | 4 ++--
 testsuites/sptests/spextensions01/init.c| 8 
 testsuites/sptests/spfatal26/init.c | 4 ++--
 testsuites/sptests/spfatal_support/init.c   | 6 +++---
 testsuites/sptests/spfatal_support/system.h | 2 +-
 testsuites/sptests/spinternalerror01/init.c | 4 ++--
 testsuites/sptests/spmutex01/init.c | 4 ++--
 testsuites/sptests/spsyslock01/init.c   | 4 ++--
 44 files changed, 70 insertions(+), 70 deletions(-)

diff --git a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspclean.c 
b/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspclean.c
index 5504ed6..a14ee74 100644
--- a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspclean.c
+++ b/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspclean.c
@@ -19,7 +19,7 @@
 
 void bsp_fatal_extension(
   rtems_fatal_source src,
-  bool is_internal,
+  bool always_false,
   rtems_fatal_code code
 )
 {
diff --git a/c/src/lib/libbsp/lm32/milkymist/startup/bspclean.c 
b/c/src/lib/libbsp/lm32/milkymist/startup/bspclean.c
index d4ff09b..548ade8 100644
--- a/c/src/lib/libbsp/lm32/milkymist/startup/bspclean.c
+++ b/c/src/lib/libbsp/lm32/milkymist/startup/bspclean.c
@@ -50,7 +50,7 @@ static void reconf(void)
 
 void bsp_fatal_extension(
   rtems_fatal_source source,
-  bool is_internal,
+  bool always_false,
   rtems_fatal_code error
 )
 {
diff --git a/c/src/lib/libbsp/m68k/mcf5225x/startup/bspclean.c 
b/c/src/lib/libbsp/m68k/mcf5225x/startup/bspclean.c
index 562b19a..26e263f 100644
--- a/c/src/lib/libbsp/m68k/mcf5225x/startup/bspclean.c
+++ b/c/src/lib/libbsp/m68k/mcf5225x/startup/bspclean.c
@@ -19,7 +19,7 @@
 
 void bsp_fatal_extension(
   rtems_fatal_source source,
-  bool is_internal,
+  bool always_false,
   rtems_fatal_code error
 )
 {
diff --git a/c/src/lib/libbsp/m68k/mrm332/misc/interr.c 
b/c/src/lib/libbsp/m68k/mrm332/misc/interr.c
index c0a8650..f6656e8 100644
--- a/c/src/lib/libbsp/m68k/mrm332/misc/interr.c
+++ b/c/src/lib/libbsp/m68k/mrm332/misc/interr.c
@@ -33,7 +33,7 @@
 
 void bsp_fatal_extension(
   rtems_fatal_source source,
-  bool is_internal,
+  bool always_false,
   rtems_fatal_code the_error
 )
 {
diff --git a/c/src/lib/libbsp/m68k/mvme147/startup/bspclean.c 
b/c/src/lib/libbsp/m68k/mvme147/startup/bspclean.c
index 36c3317..0148f6c 100644
--- a/c/src/lib/libbsp/m68k/mvme147/startup/bspclean.c
+++ 

[PATCH 6/9] Add INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED

2016-12-09 Thread Sebastian Huber
Update #2825.
---
 cpukit/libcsupport/src/libio_init.c | 5 +++--
 cpukit/sapi/src/interrtext.c| 3 ++-
 cpukit/score/include/rtems/score/interr.h   | 3 ++-
 testsuites/sptests/spinternalerror02/init.c | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/cpukit/libcsupport/src/libio_init.c 
b/cpukit/libcsupport/src/libio_init.c
index a265290..3fa9e09 100644
--- a/cpukit/libcsupport/src/libio_init.c
+++ b/cpukit/libcsupport/src/libio_init.c
@@ -79,8 +79,9 @@ static void rtems_libio_init( void )
 RTEMS_NO_PRIORITY,
 _libio_semaphore
   );
-  if ( rc != RTEMS_SUCCESSFUL )
-rtems_fatal_error_occurred( rc );
+  if ( rc != RTEMS_SUCCESSFUL ) {
+_Internal_error( INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED );
+  }
 }
 
 RTEMS_SYSINIT_ITEM(
diff --git a/cpukit/sapi/src/interrtext.c b/cpukit/sapi/src/interrtext.c
index 916d582..2285cd3 100644
--- a/cpukit/sapi/src/interrtext.c
+++ b/cpukit/sapi/src/interrtext.c
@@ -61,7 +61,8 @@ static const char *const internal_error_text[] = {
   "INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT",
   "INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED",
   "INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED",
-  "INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED"
+  "INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED",
+  "INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED"
 };
 
 const char *rtems_internal_error_text( rtems_fatal_code error )
diff --git a/cpukit/score/include/rtems/score/interr.h 
b/cpukit/score/include/rtems/score/interr.h
index 3bcece0..d6a961e 100644
--- a/cpukit/score/include/rtems/score/interr.h
+++ b/cpukit/score/include/rtems/score/interr.h
@@ -174,7 +174,8 @@ typedef enum {
   INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT = 31,
   INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED = 32,
   INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED = 33,
-  INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED = 34
+  INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED = 34,
+  INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED = 35
 } Internal_errors_Core_list;
 
 typedef CPU_Uint32ptr Internal_errors_t;
diff --git a/testsuites/sptests/spinternalerror02/init.c 
b/testsuites/sptests/spinternalerror02/init.c
index 1d24863..69bc89f 100644
--- a/testsuites/sptests/spinternalerror02/init.c
+++ b/testsuites/sptests/spinternalerror02/init.c
@@ -36,7 +36,7 @@ static void test_internal_error_text(void)
   } while ( text != text_last );
 
   rtems_test_assert(
-error - 3 == INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED
+error - 3 == INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED
   );
 }
 
-- 
1.8.4.5

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 7/9] libio: Ensure proper std file descriptors

2016-12-09 Thread Sebastian Huber
---
 cpukit/libcsupport/src/open_dev_console.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/cpukit/libcsupport/src/open_dev_console.c 
b/cpukit/libcsupport/src/open_dev_console.c
index 2e111cc..14257e8 100644
--- a/cpukit/libcsupport/src/open_dev_console.c
+++ b/cpukit/libcsupport/src/open_dev_console.c
@@ -17,20 +17,17 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  *  This is a replaceable stub which opens the console, if present.
  */
 void rtems_libio_post_driver(void)
 {
-  int  stdin_fd;
-  int  stdout_fd;
-  int  stderr_fd;
-
   /*
* Attempt to open /dev/console.
*/
-  if ((stdin_fd = open("/dev/console", O_RDONLY, 0)) == -1) {
+  if (open("/dev/console", O_RDONLY, 0) != STDIN_FILENO) {
 /*
  * There may not be a console driver so this is OK.
  */
@@ -41,11 +38,13 @@ void rtems_libio_post_driver(void)
*  But if we find /dev/console once, we better find it twice more
*  or something is REALLY wrong.
*/
-  if ((stdout_fd = open("/dev/console", O_WRONLY, 0)) == -1)
-rtems_fatal_error_occurred( 0x55544431 );  /* error STD1 */
+  if (open("/dev/console", O_WRONLY, 0) != STDOUT_FILENO) {
+rtems_fatal_error_occurred( 0x55544431 );
+  }
 
-  if ((stderr_fd = open("/dev/console", O_WRONLY, 0)) == -1)
-rtems_fatal_error_occurred( 0x55544432 );  /* error STD2 */
+  if (open("/dev/console", O_WRONLY, 0) != STDERR_FILENO) {
+rtems_fatal_error_occurred( 0x55544432 );
+  }
 
   atexit(rtems_libio_exit);
 }
-- 
1.8.4.5

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 8/9] Add INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED

2016-12-09 Thread Sebastian Huber
Update #2825.
---
 cpukit/libcsupport/src/open_dev_console.c   | 2 +-
 cpukit/sapi/src/interrtext.c| 3 ++-
 cpukit/score/include/rtems/score/interr.h   | 3 ++-
 testsuites/sptests/spfatal14/testcase.h | 4 ++--
 testsuites/sptests/spinternalerror02/init.c | 2 +-
 5 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/cpukit/libcsupport/src/open_dev_console.c 
b/cpukit/libcsupport/src/open_dev_console.c
index 14257e8..50c1e08 100644
--- a/cpukit/libcsupport/src/open_dev_console.c
+++ b/cpukit/libcsupport/src/open_dev_console.c
@@ -39,7 +39,7 @@ void rtems_libio_post_driver(void)
*  or something is REALLY wrong.
*/
   if (open("/dev/console", O_WRONLY, 0) != STDOUT_FILENO) {
-rtems_fatal_error_occurred( 0x55544431 );
+_Internal_error( INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED );
   }
 
   if (open("/dev/console", O_WRONLY, 0) != STDERR_FILENO) {
diff --git a/cpukit/sapi/src/interrtext.c b/cpukit/sapi/src/interrtext.c
index 2285cd3..f15c82b 100644
--- a/cpukit/sapi/src/interrtext.c
+++ b/cpukit/sapi/src/interrtext.c
@@ -62,7 +62,8 @@ static const char *const internal_error_text[] = {
   "INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED",
   "INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED",
   "INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED",
-  "INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED"
+  "INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED",
+  "INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED"
 };
 
 const char *rtems_internal_error_text( rtems_fatal_code error )
diff --git a/cpukit/score/include/rtems/score/interr.h 
b/cpukit/score/include/rtems/score/interr.h
index d6a961e..61a4153 100644
--- a/cpukit/score/include/rtems/score/interr.h
+++ b/cpukit/score/include/rtems/score/interr.h
@@ -175,7 +175,8 @@ typedef enum {
   INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED = 32,
   INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED = 33,
   INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED = 34,
-  INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED = 35
+  INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED = 35,
+  INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED = 36
 } Internal_errors_Core_list;
 
 typedef CPU_Uint32ptr Internal_errors_t;
diff --git a/testsuites/sptests/spfatal14/testcase.h 
b/testsuites/sptests/spfatal14/testcase.h
index 3dcd030..d280a17 100644
--- a/testsuites/sptests/spfatal14/testcase.h
+++ b/testsuites/sptests/spfatal14/testcase.h
@@ -11,8 +11,8 @@
 
 #define FATAL_ERROR_TEST_NAME"14"
 #define FATAL_ERROR_DESCRIPTION  "fail to open stdout"
-#define FATAL_ERROR_EXPECTED_SOURCE  INTERNAL_ERROR_RTEMS_API
-#define FATAL_ERROR_EXPECTED_ERROR   0x55544431
+#define FATAL_ERROR_EXPECTED_SOURCE  INTERNAL_ERROR_CORE
+#define FATAL_ERROR_EXPECTED_ERROR   
INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED
 
 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 1
 
diff --git a/testsuites/sptests/spinternalerror02/init.c 
b/testsuites/sptests/spinternalerror02/init.c
index 69bc89f..aa5f12e 100644
--- a/testsuites/sptests/spinternalerror02/init.c
+++ b/testsuites/sptests/spinternalerror02/init.c
@@ -36,7 +36,7 @@ static void test_internal_error_text(void)
   } while ( text != text_last );
 
   rtems_test_assert(
-error - 3 == INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED
+error - 3 == INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED
   );
 }
 
-- 
1.8.4.5

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 5/9] INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED

2016-12-09 Thread Sebastian Huber
Update #2825.
---
 cpukit/libcsupport/src/libio_init.c | 2 +-
 cpukit/sapi/src/interrtext.c| 3 ++-
 cpukit/score/include/rtems/score/interr.h   | 3 ++-
 testsuites/sptests/spfatal27/testcase.h | 4 ++--
 testsuites/sptests/spinternalerror02/init.c | 2 +-
 5 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/cpukit/libcsupport/src/libio_init.c 
b/cpukit/libcsupport/src/libio_init.c
index 3ac2e3b..a265290 100644
--- a/cpukit/libcsupport/src/libio_init.c
+++ b/cpukit/libcsupport/src/libio_init.c
@@ -64,7 +64,7 @@ static void rtems_libio_init( void )
 rtems_libio_free_user_env
   );
   if (eno != 0) {
-rtems_fatal_error_occurred( RTEMS_UNSATISFIED );
+_Internal_error( INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED );
   }
 
   /*
diff --git a/cpukit/sapi/src/interrtext.c b/cpukit/sapi/src/interrtext.c
index b2211ea..916d582 100644
--- a/cpukit/sapi/src/interrtext.c
+++ b/cpukit/sapi/src/interrtext.c
@@ -60,7 +60,8 @@ static const char *const internal_error_text[] = {
   "INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL",
   "INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT",
   "INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED",
-  "INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED"
+  "INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED",
+  "INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED"
 };
 
 const char *rtems_internal_error_text( rtems_fatal_code error )
diff --git a/cpukit/score/include/rtems/score/interr.h 
b/cpukit/score/include/rtems/score/interr.h
index 254d1f5..3bcece0 100644
--- a/cpukit/score/include/rtems/score/interr.h
+++ b/cpukit/score/include/rtems/score/interr.h
@@ -173,7 +173,8 @@ typedef enum {
   INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL = 30,
   INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT = 31,
   INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED = 32,
-  INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED = 33
+  INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED = 33,
+  INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED = 34
 } Internal_errors_Core_list;
 
 typedef CPU_Uint32ptr Internal_errors_t;
diff --git a/testsuites/sptests/spfatal27/testcase.h 
b/testsuites/sptests/spfatal27/testcase.h
index a7b26bd..9845959 100644
--- a/testsuites/sptests/spfatal27/testcase.h
+++ b/testsuites/sptests/spfatal27/testcase.h
@@ -14,8 +14,8 @@
 
 #define FATAL_ERROR_TEST_NAME"27"
 #define FATAL_ERROR_DESCRIPTION  "libio init no posix key left"
-#define FATAL_ERROR_EXPECTED_SOURCE  INTERNAL_ERROR_RTEMS_API
-#define FATAL_ERROR_EXPECTED_ERROR   RTEMS_UNSATISFIED
+#define FATAL_ERROR_EXPECTED_SOURCE  INTERNAL_ERROR_CORE
+#define FATAL_ERROR_EXPECTED_ERROR   
INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED
 
 #define CONFIGURE_MAXIMUM_POSIX_KEYS (-1)
 #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS (0)
diff --git a/testsuites/sptests/spinternalerror02/init.c 
b/testsuites/sptests/spinternalerror02/init.c
index 011a7fe..1d24863 100644
--- a/testsuites/sptests/spinternalerror02/init.c
+++ b/testsuites/sptests/spinternalerror02/init.c
@@ -36,7 +36,7 @@ static void test_internal_error_text(void)
   } while ( text != text_last );
 
   rtems_test_assert(
-error - 3 == INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED
+error - 3 == INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED
   );
 }
 
-- 
1.8.4.5

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 9/9] Add INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED

2016-12-09 Thread Sebastian Huber
Update #2825.
---
 cpukit/libcsupport/src/open_dev_console.c   | 2 +-
 cpukit/sapi/src/interrtext.c| 3 ++-
 cpukit/score/include/rtems/score/interr.h   | 3 ++-
 testsuites/sptests/spfatal15/testcase.h | 4 ++--
 testsuites/sptests/spinternalerror02/init.c | 2 +-
 5 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/cpukit/libcsupport/src/open_dev_console.c 
b/cpukit/libcsupport/src/open_dev_console.c
index 50c1e08..5bba0fb 100644
--- a/cpukit/libcsupport/src/open_dev_console.c
+++ b/cpukit/libcsupport/src/open_dev_console.c
@@ -43,7 +43,7 @@ void rtems_libio_post_driver(void)
   }
 
   if (open("/dev/console", O_WRONLY, 0) != STDERR_FILENO) {
-rtems_fatal_error_occurred( 0x55544432 );
+_Internal_error( INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED );
   }
 
   atexit(rtems_libio_exit);
diff --git a/cpukit/sapi/src/interrtext.c b/cpukit/sapi/src/interrtext.c
index f15c82b..c92f922 100644
--- a/cpukit/sapi/src/interrtext.c
+++ b/cpukit/sapi/src/interrtext.c
@@ -63,7 +63,8 @@ static const char *const internal_error_text[] = {
   "INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED",
   "INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED",
   "INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED",
-  "INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED"
+  "INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED",
+  "INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED"
 };
 
 const char *rtems_internal_error_text( rtems_fatal_code error )
diff --git a/cpukit/score/include/rtems/score/interr.h 
b/cpukit/score/include/rtems/score/interr.h
index 61a4153..7dd6168 100644
--- a/cpukit/score/include/rtems/score/interr.h
+++ b/cpukit/score/include/rtems/score/interr.h
@@ -176,7 +176,8 @@ typedef enum {
   INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED = 33,
   INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED = 34,
   INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED = 35,
-  INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED = 36
+  INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED = 36,
+  INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED = 37
 } Internal_errors_Core_list;
 
 typedef CPU_Uint32ptr Internal_errors_t;
diff --git a/testsuites/sptests/spfatal15/testcase.h 
b/testsuites/sptests/spfatal15/testcase.h
index 742b5b9..fc3d25f 100644
--- a/testsuites/sptests/spfatal15/testcase.h
+++ b/testsuites/sptests/spfatal15/testcase.h
@@ -10,8 +10,8 @@
 /* generate fatal errors in open_dev_console.c */
 #define FATAL_ERROR_TEST_NAME"15"
 #define FATAL_ERROR_DESCRIPTION  "fail to open stderr"
-#define FATAL_ERROR_EXPECTED_SOURCE  INTERNAL_ERROR_RTEMS_API
-#define FATAL_ERROR_EXPECTED_ERROR   0x55544432
+#define FATAL_ERROR_EXPECTED_SOURCE  INTERNAL_ERROR_CORE
+#define FATAL_ERROR_EXPECTED_ERROR   
INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED
 
 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 2
 
diff --git a/testsuites/sptests/spinternalerror02/init.c 
b/testsuites/sptests/spinternalerror02/init.c
index aa5f12e..4126755 100644
--- a/testsuites/sptests/spinternalerror02/init.c
+++ b/testsuites/sptests/spinternalerror02/init.c
@@ -36,7 +36,7 @@ static void test_internal_error_text(void)
   } while ( text != text_last );
 
   rtems_test_assert(
-error - 3 == INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED
+error - 3 == INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED
   );
 }
 
-- 
1.8.4.5

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/9] Add INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED

2016-12-09 Thread Sebastian Huber
Update #2825.
---
 cpukit/rtems/src/taskinitusers.c| 8 ++--
 cpukit/sapi/src/interrtext.c| 3 ++-
 cpukit/score/include/rtems/score/interr.h   | 3 ++-
 testsuites/sptests/spfatal01/testcase.h | 4 ++--
 testsuites/sptests/spinternalerror02/init.c | 2 +-
 5 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/cpukit/rtems/src/taskinitusers.c b/cpukit/rtems/src/taskinitusers.c
index 5104639..4a851d4 100644
--- a/cpukit/rtems/src/taskinitusers.c
+++ b/cpukit/rtems/src/taskinitusers.c
@@ -88,8 +88,12 @@ void _RTEMS_tasks_Initialize_user_tasks_body( void )
   user_tasks[ index ].attribute_set,
   
 );
-if ( !rtems_is_status_successful( return_value ) )
-  _Terminate( INTERNAL_ERROR_RTEMS_API, return_value );
+if ( !rtems_is_status_successful( return_value ) ) {
+  _Terminate(
+INTERNAL_ERROR_CORE,
+INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED
+  );
+}
 
 entry_point = user_tasks[ index ].entry_point;
 if ( entry_point == NULL ) {
diff --git a/cpukit/sapi/src/interrtext.c b/cpukit/sapi/src/interrtext.c
index 860513b..55b79d1 100644
--- a/cpukit/sapi/src/interrtext.c
+++ b/cpukit/sapi/src/interrtext.c
@@ -58,7 +58,8 @@ static const char *const internal_error_text[] = {
   "INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK",
   "INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE",
   "INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL",
-  "INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT"
+  "INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT",
+  "INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED"
 };
 
 const char *rtems_internal_error_text( rtems_fatal_code error )
diff --git a/cpukit/score/include/rtems/score/interr.h 
b/cpukit/score/include/rtems/score/interr.h
index b030a22..cd72dea 100644
--- a/cpukit/score/include/rtems/score/interr.h
+++ b/cpukit/score/include/rtems/score/interr.h
@@ -171,7 +171,8 @@ typedef enum {
   INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK = 28,
   INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE = 29,
   INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL = 30,
-  INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT = 31
+  INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT = 31,
+  INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED = 32
 } Internal_errors_Core_list;
 
 typedef CPU_Uint32ptr Internal_errors_t;
diff --git a/testsuites/sptests/spfatal01/testcase.h 
b/testsuites/sptests/spfatal01/testcase.h
index 01710dc..19cd16e 100644
--- a/testsuites/sptests/spfatal01/testcase.h
+++ b/testsuites/sptests/spfatal01/testcase.h
@@ -24,8 +24,8 @@ rtems_initialization_tasks_table Initialization_tasks[] = {
 
 #define FATAL_ERROR_TEST_NAME"1"
 #define FATAL_ERROR_DESCRIPTION  "Classic API Init task create failure"
-#define FATAL_ERROR_EXPECTED_SOURCE  INTERNAL_ERROR_RTEMS_API
-#define FATAL_ERROR_EXPECTED_ERROR   RTEMS_UNSATISFIED
+#define FATAL_ERROR_EXPECTED_SOURCE  INTERNAL_ERROR_CORE
+#define FATAL_ERROR_EXPECTED_ERROR   
INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED
 
 void force_error()
 {
diff --git a/testsuites/sptests/spinternalerror02/init.c 
b/testsuites/sptests/spinternalerror02/init.c
index 8c1ab36..5bea4f1 100644
--- a/testsuites/sptests/spinternalerror02/init.c
+++ b/testsuites/sptests/spinternalerror02/init.c
@@ -36,7 +36,7 @@ static void test_internal_error_text(void)
   } while ( text != text_last );
 
   rtems_test_assert(
-error - 3 == INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT
+error - 3 == INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED
   );
 }
 
-- 
1.8.4.5

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 3/9] Add INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED

2016-12-09 Thread Sebastian Huber
Update #2825.
---
 cpukit/posix/src/pthreadinitthreads.c   | 8 ++--
 cpukit/sapi/src/interrtext.c| 3 ++-
 cpukit/score/include/rtems/score/interr.h   | 3 ++-
 testsuites/psxtests/psxfatal02/testcase.h   | 4 ++--
 testsuites/sptests/spinternalerror02/init.c | 2 +-
 5 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/cpukit/posix/src/pthreadinitthreads.c 
b/cpukit/posix/src/pthreadinitthreads.c
index 3cfb92d..2fdfa53 100644
--- a/cpukit/posix/src/pthreadinitthreads.c
+++ b/cpukit/posix/src/pthreadinitthreads.c
@@ -102,7 +102,11 @@ void _POSIX_Threads_Initialize_user_threads_body(void)
   thread_entry,
   NULL
 );
-if ( eno )
-  _POSIX_Fatal_error( POSIX_FD_PTHREAD, eno );
+if ( eno != 0 ) {
+  _Terminate(
+INTERNAL_ERROR_CORE,
+INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED
+  );
+}
   }
 }
diff --git a/cpukit/sapi/src/interrtext.c b/cpukit/sapi/src/interrtext.c
index 55b79d1..b2211ea 100644
--- a/cpukit/sapi/src/interrtext.c
+++ b/cpukit/sapi/src/interrtext.c
@@ -59,7 +59,8 @@ static const char *const internal_error_text[] = {
   "INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE",
   "INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL",
   "INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT",
-  "INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED"
+  "INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED",
+  "INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED"
 };
 
 const char *rtems_internal_error_text( rtems_fatal_code error )
diff --git a/cpukit/score/include/rtems/score/interr.h 
b/cpukit/score/include/rtems/score/interr.h
index cd72dea..cf5 100644
--- a/cpukit/score/include/rtems/score/interr.h
+++ b/cpukit/score/include/rtems/score/interr.h
@@ -172,7 +172,8 @@ typedef enum {
   INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE = 29,
   INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL = 30,
   INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT = 31,
-  INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED = 32
+  INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED = 32,
+  INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED = 33
 } Internal_errors_Core_list;
 
 typedef CPU_Uint32ptr Internal_errors_t;
diff --git a/testsuites/psxtests/psxfatal02/testcase.h 
b/testsuites/psxtests/psxfatal02/testcase.h
index facf731..7f97a67 100644
--- a/testsuites/psxtests/psxfatal02/testcase.h
+++ b/testsuites/psxtests/psxfatal02/testcase.h
@@ -32,8 +32,8 @@ posix_initialization_threads_table 
POSIX_Initialization_threads[] = {
 #define FATAL_ERROR_TEST_NAME"2"
 #define FATAL_ERROR_DESCRIPTION \
 "POSIX API Init thread create failure -- no memory for stack"
-#define FATAL_ERROR_EXPECTED_SOURCE  INTERNAL_ERROR_POSIX_API
-#define FATAL_ERROR_EXPECTED_ERROR   ((POSIX_FD_PTHREAD << 8) | EAGAIN)
+#define FATAL_ERROR_EXPECTED_SOURCE  INTERNAL_ERROR_CORE
+#define FATAL_ERROR_EXPECTED_ERROR   
INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED
 
 void force_error(void)
 {
diff --git a/testsuites/sptests/spinternalerror02/init.c 
b/testsuites/sptests/spinternalerror02/init.c
index 5bea4f1..011a7fe 100644
--- a/testsuites/sptests/spinternalerror02/init.c
+++ b/testsuites/sptests/spinternalerror02/init.c
@@ -36,7 +36,7 @@ static void test_internal_error_text(void)
   } while ( text != text_last );
 
   rtems_test_assert(
-error - 3 == INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED
+error - 3 == INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED
   );
 }
 
-- 
1.8.4.5

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 4/9] score: Introduce _Internal_error()

2016-12-09 Thread Sebastian Huber
---
 cpukit/libcsupport/src/gxx_wrappers.c |  4 ++--
 cpukit/libcsupport/src/malloc_initialize.c|  2 +-
 cpukit/posix/src/pthreadinitthreads.c | 10 ++
 cpukit/rtems/src/taskinitusers.c  | 10 ++
 cpukit/score/cpu/powerpc/ppc-isr-vector-install.c |  2 +-
 cpukit/score/include/rtems/score/interr.h | 10 ++
 cpukit/score/src/interr.c |  5 +
 cpukit/score/src/isr.c|  5 +
 cpukit/score/src/mpci.c   | 11 ---
 cpukit/score/src/objectinitializeinformation.c|  5 +
 cpukit/score/src/objectmp.c   |  6 +++---
 cpukit/score/src/thread.c |  2 +-
 cpukit/score/src/threaddispatch.c | 10 ++
 cpukit/score/src/threadhandler.c  |  2 +-
 cpukit/score/src/threadmp.c   |  2 +-
 cpukit/score/src/threadqenqueue.c |  5 ++---
 cpukit/score/src/threadrestart.c  |  2 +-
 cpukit/score/src/wkspace.c|  4 ++--
 18 files changed, 42 insertions(+), 55 deletions(-)

diff --git a/cpukit/libcsupport/src/gxx_wrappers.c 
b/cpukit/libcsupport/src/gxx_wrappers.c
index 545c3af..d30b570 100644
--- a/cpukit/libcsupport/src/gxx_wrappers.c
+++ b/cpukit/libcsupport/src/gxx_wrappers.c
@@ -137,7 +137,7 @@ int rtems_gxx_setspecific(__gthread_key_t key, const void 
*ptr)
   #endif
 
   if ( eno != 0 ) {
-_Terminate( INTERNAL_ERROR_CORE, INTERNAL_ERROR_GXX_KEY_ADD_FAILED );
+_Internal_error( INTERNAL_ERROR_GXX_KEY_ADD_FAILED );
   }
 
   return 0;
@@ -171,7 +171,7 @@ void rtems_gxx_mutex_init (__gthread_mutex_t *mutex)
 status
   );
 #endif
-_Terminate( INTERNAL_ERROR_CORE, INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED );
+_Internal_error( INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED );
   }
   #ifdef DEBUG_GXX_WRAPPERS
 printk( "gxx_wrappers: mutex init complete =%X\n", *mutex );
diff --git a/cpukit/libcsupport/src/malloc_initialize.c 
b/cpukit/libcsupport/src/malloc_initialize.c
index e262c0f..dc94b48 100644
--- a/cpukit/libcsupport/src/malloc_initialize.c
+++ b/cpukit/libcsupport/src/malloc_initialize.c
@@ -50,7 +50,7 @@ void RTEMS_Malloc_Initialize(
 }
 
 if ( init_or_extend == _Heap_Initialize ) {
-  _Terminate( INTERNAL_ERROR_CORE, INTERNAL_ERROR_NO_MEMORY_FOR_HEAP );
+  _Internal_error( INTERNAL_ERROR_NO_MEMORY_FOR_HEAP );
 }
   }
 }
diff --git a/cpukit/posix/src/pthreadinitthreads.c 
b/cpukit/posix/src/pthreadinitthreads.c
index 2fdfa53..7695879 100644
--- a/cpukit/posix/src/pthreadinitthreads.c
+++ b/cpukit/posix/src/pthreadinitthreads.c
@@ -85,10 +85,7 @@ void _POSIX_Threads_Initialize_user_threads_body(void)
 
 thread_entry = user_threads[ index ].thread_entry;
 if ( thread_entry == NULL ) {
-  _Terminate(
-INTERNAL_ERROR_CORE,
-INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL
-  );
+  _Internal_error( INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL );
 }
 
 if ( register_global_construction ) {
@@ -103,10 +100,7 @@ void _POSIX_Threads_Initialize_user_threads_body(void)
   NULL
 );
 if ( eno != 0 ) {
-  _Terminate(
-INTERNAL_ERROR_CORE,
-INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED
-  );
+  _Internal_error( INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED );
 }
   }
 }
diff --git a/cpukit/rtems/src/taskinitusers.c b/cpukit/rtems/src/taskinitusers.c
index 4a851d4..41b7edc 100644
--- a/cpukit/rtems/src/taskinitusers.c
+++ b/cpukit/rtems/src/taskinitusers.c
@@ -89,18 +89,12 @@ void _RTEMS_tasks_Initialize_user_tasks_body( void )
   
 );
 if ( !rtems_is_status_successful( return_value ) ) {
-  _Terminate(
-INTERNAL_ERROR_CORE,
-INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED
-  );
+  _Internal_error( INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED );
 }
 
 entry_point = user_tasks[ index ].entry_point;
 if ( entry_point == NULL ) {
-  _Terminate(
-INTERNAL_ERROR_CORE,
-INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL
-  );
+  _Internal_error( INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL );
 }
 
 if ( register_global_construction ) {
diff --git a/cpukit/score/cpu/powerpc/ppc-isr-vector-install.c 
b/cpukit/score/cpu/powerpc/ppc-isr-vector-install.c
index 7d75fd8..c42c2e2 100644
--- a/cpukit/score/cpu/powerpc/ppc-isr-vector-install.c
+++ b/cpukit/score/cpu/powerpc/ppc-isr-vector-install.c
@@ -31,5 +31,5 @@ void _CPU_ISR_install_vector(
   proc_ptr *old_handler
 )
 {
-  _Terminate( INTERNAL_ERROR_CORE, INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR );
+  _Internal_error( INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR );
 }
diff --git a/cpukit/score/include/rtems/score/interr.h 
b/cpukit/score/include/rtems/score/interr.h
index cf5..254d1f5 100644
--- a/cpukit/score/include/rtems/score/interr.h
+++ 

[PATCH 1/9] score: Remove fatal is internal indicator

2016-12-09 Thread Sebastian Huber
The fatal is internal indicator is redundant since the fatal source and
error code uniquely identify a fatal error.  Keep the fatal user
extension is internal parameter for backward compatibility and set it to
false always.

Update #2825.
---
 c/src/lib/libbsp/powerpc/shared/startup/panic.c   |  2 --
 cpukit/libcsupport/src/gxx_wrappers.c | 12 ++--
 cpukit/libcsupport/src/malloc_initialize.c|  6 +---
 cpukit/posix/src/pthreadinitthreads.c |  1 -
 cpukit/rtems/src/taskinitusers.c  |  3 +-
 cpukit/sapi/Makefile.am   |  2 +-
 cpukit/sapi/include/rtems/fatal.h | 17 ++-
 cpukit/sapi/src/exshutdown.c  |  2 +-
 cpukit/sapi/src/fatal.c   |  2 +-
 cpukit/sapi/src/fatal2.c  | 35 ---
 cpukit/sapi/src/posixapi.c|  2 +-
 cpukit/score/cpu/nios2/nios2-context-initialize.c |  2 +-
 cpukit/score/cpu/nios2/nios2-isr-get-level.c  |  2 +-
 cpukit/score/cpu/nios2/nios2-isr-set-level.c  |  2 +-
 cpukit/score/cpu/powerpc/ppc-isr-vector-install.c |  6 +---
 cpukit/score/include/rtems/score/interr.h |  7 +
 cpukit/score/include/rtems/score/smpimpl.h|  2 +-
 cpukit/score/include/rtems/score/userext.h|  4 +--
 cpukit/score/include/rtems/score/userextimpl.h|  4 +--
 cpukit/score/src/heap.c   |  2 +-
 cpukit/score/src/interr.c | 12 
 cpukit/score/src/isr.c|  1 -
 cpukit/score/src/mpci.c   | 19 ++--
 cpukit/score/src/objectinitializeinformation.c|  1 -
 cpukit/score/src/objectmp.c   | 19 ++--
 cpukit/score/src/thread.c |  6 +---
 cpukit/score/src/threaddispatch.c |  2 --
 cpukit/score/src/threadhandler.c  |  6 +---
 cpukit/score/src/threadmp.c   |  6 +---
 cpukit/score/src/threadqenqueue.c |  7 +
 cpukit/score/src/threadrestart.c  |  6 +---
 cpukit/score/src/userextiterate.c |  2 +-
 cpukit/score/src/wkspace.c| 12 ++--
 testsuites/libtests/devnullfatal01/testcase.h |  1 -
 testsuites/psxtests/psxfatal01/testcase.h |  1 -
 testsuites/psxtests/psxfatal02/testcase.h |  1 -
 testsuites/psxtests/psxfatal_support/init.c   | 11 ++-
 testsuites/sptests/spfatal01/testcase.h   |  1 -
 testsuites/sptests/spfatal02/testcase.h   |  1 -
 testsuites/sptests/spfatal03/testcase.h   |  1 -
 testsuites/sptests/spfatal04/testcase.h   |  1 -
 testsuites/sptests/spfatal05/testcase.h   |  1 -
 testsuites/sptests/spfatal06/testcase.h   |  1 -
 testsuites/sptests/spfatal07/testcase.h   |  1 -
 testsuites/sptests/spfatal08/testcase.h   |  1 -
 testsuites/sptests/spfatal09/testcase.h   |  1 -
 testsuites/sptests/spfatal10/testcase.h   |  1 -
 testsuites/sptests/spfatal11/testcase.h   |  1 -
 testsuites/sptests/spfatal12/testcase.h   |  1 -
 testsuites/sptests/spfatal13/testcase.h   |  1 -
 testsuites/sptests/spfatal14/testcase.h   |  1 -
 testsuites/sptests/spfatal15/testcase.h   |  1 -
 testsuites/sptests/spfatal16/testcase.h   |  1 -
 testsuites/sptests/spfatal17/testcase.h   |  1 -
 testsuites/sptests/spfatal18/testcase.h   |  1 -
 testsuites/sptests/spfatal19/testcase.h   |  1 -
 testsuites/sptests/spfatal20/testcase.h   |  1 -
 testsuites/sptests/spfatal24/testcase.h   |  1 -
 testsuites/sptests/spfatal25/testcase.h   |  1 -
 testsuites/sptests/spfatal27/testcase.h   |  1 -
 testsuites/sptests/spfatal28/testcase.h   |  3 +-
 testsuites/sptests/spfatal29/testcase.h   |  1 -
 testsuites/sptests/spfatal_support/init.c | 17 ---
 testsuites/sptests/spinternalerror01/init.c   | 10 ++-
 testsuites/sptests/sptimecounter01/init.c |  2 +-
 65 files changed, 59 insertions(+), 225 deletions(-)
 delete mode 100644 cpukit/sapi/src/fatal2.c

diff --git a/c/src/lib/libbsp/powerpc/shared/startup/panic.c 
b/c/src/lib/libbsp/powerpc/shared/startup/panic.c
index bff7aeb..9b0aa75 100644
--- a/c/src/lib/libbsp/powerpc/shared/startup/panic.c
+++ b/c/src/lib/libbsp/powerpc/shared/startup/panic.c
@@ -23,7 +23,6 @@ void BSP_panic(char *s)
 }
 
 #define THESRC _Internal_errors_What_happened.the_source
-#define ISITNL _Internal_errors_What_happened.is_internal
 #define THEERR _Internal_errors_What_happened.the_error
 
 void _BSP_Fatal_error(unsigned int v)
@@ -36,7 +35,6 @@ void _BSP_Fatal_error(unsigned int v)
 
   printk("%s\n",_RTEMS_version);
   printk("FATAL ERROR:\n");
-  printk("Internal error: %s\n", ISITNL? "Yes":"No");
   printk("Environment:");
   switch (THESRC) {
 

Re: QT 5.8 Port

2016-12-09 Thread Sebastian Huber

Hello Kevin,

we already have a (broken) pipe support in RTEMS

https://git.rtems.org/rtems/tree/cpukit/libcsupport/src/pipe.c

What is the befit of using the FreeBSD pipe implementation?

On 07/12/16 19:49, Kirspel, Kevin wrote:


I’m porting QT 5.8 to RTEMS 4.12 and rtems-libbsd.  I had to add pipe 
support to rtems-libbsd.  I would like to submit the pipe patch but 
the “git diff” is long due to the fact that the diff includes the 
entire file contents of the modified sys_pipe.c and pipe.h files.  How 
do you usually submit patches for review for rtems-libbsd?


Kevin Kirspel

Electrical Engineer - Sr. Staff

Idexx Roswell

235 Hembree Park Drive

Roswell GA 30076

Tel: (770)-510- ext. 81642

Direct: (770)-688-1642

Fax: (770)-510-4445



___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel