Index: c/src/lib/libbsp/arm/shared/startup/linkcmds.base
===================================================================
--- c/src/lib/libbsp/arm/shared/startup/linkcmds.base	(revision 2cc4f3ca45e5cb20649c2733330977a2307e2e19)
+++ c/src/lib/libbsp/arm/shared/startup/linkcmds.base	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
@@ -311,4 +311,13 @@
 		*(_bsd_set_sysctl_set);
 		_bsd__stop_set_sysctl_set = .;
+		__start_pcpu_set = .;
+		*(set_pcpu);
+		__stop_pcpu_set = .;
+		_bsd__start_set_ieee80211_ioctl_getset = .;
+		*(_bsd_set_ieee80211_ioctl_getset);
+		_bsd__stop_set_ieee80211_ioctl_getset = .;
+		_bsd__start_set_ieee80211_ioctl_setset = .;
+		*(_bsd_set_ieee80211_ioctl_setset);
+		_bsd__stop_set_ieee80211_ioctl_setset = .;
 
 		bsp_section_rodata_end = .;
Index: c/src/lib/libbsp/sparc/erc32/make/custom/erc32.cfg
===================================================================
--- c/src/lib/libbsp/sparc/erc32/make/custom/erc32.cfg	(revision 2cc4f3ca45e5cb20649c2733330977a2307e2e19)
+++ c/src/lib/libbsp/sparc/erc32/make/custom/erc32.cfg	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
@@ -13,3 +13,3 @@
 
 # optimize flag: typically -O2
-CFLAGS_OPTIMIZE_V = -O2 -g
+CFLAGS_OPTIMIZE_V = -O0 -g
Index: c/src/lib/libbsp/sparc/shared/startup/linkcmds.base
===================================================================
--- c/src/lib/libbsp/sparc/shared/startup/linkcmds.base	(revision 2cc4f3ca45e5cb20649c2733330977a2307e2e19)
+++ c/src/lib/libbsp/sparc/shared/startup/linkcmds.base	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
@@ -121,4 +121,7 @@
   .rela.dyn       :
     {
+      data_start = .;
+      _data_start = .;
+      _sdata = . ;
       *(.rela.init)
       *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
@@ -133,9 +136,35 @@
       *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
     } >ram
+  .robsdsets : {
+    /* Special FreeBSD linker set sections */
+    __start_set_sysctl_set = .;
+    *(set_sysctl_*);
+    __stop_set_sysctl_set = .;
+    *(set_domain_*);
+    *(set_pseudo_*);
+    _bsd__start_set_modmetadata_set = .;
+    *(_bsd_set_modmetadata_set);
+    _bsd__stop_set_modmetadata_set = .;
+    _bsd__start_set_sysctl_set = .;
+    *(_bsd_set_sysctl_set);
+    _bsd__stop_set_sysctl_set = .;
+    __start_pcpu_set = .;
+    *(set_pcpu);
+    __stop_pcpu_set = .;
+    _bsd__start_set_ieee80211_ioctl_getset = .;
+    *(_bsd_set_ieee80211_ioctl_getset);
+    _bsd__stop_set_ieee80211_ioctl_getset = .;
+    _bsd__start_set_ieee80211_ioctl_setset = .;
+    *(_bsd_set_ieee80211_ioctl_setset);
+    _bsd__stop_set_ieee80211_ioctl_setset = .;
+  } >ram
+  .rwbsdsets : {
+    /* Special FreeBSD linker set sections */
+    _bsd__start_set_sysinit_set = .;
+    *(_bsd_set_sysinit_set);
+    _bsd__stop_set_sysinit_set = .;
+  } >ram
   .data :
   {
-    data_start = .;
-    _data_start = .;
-    _sdata = . ;
     *(.data*)
     *(.gnu.linkonce.d*)
Index: c/src/make/Makefile.am
===================================================================
--- c/src/make/Makefile.am	(revision 2cc4f3ca45e5cb20649c2733330977a2307e2e19)
+++ c/src/make/Makefile.am	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
@@ -19,5 +19,5 @@
 
 rtems_bsp_makedir = $(rtems_bspdir)/make
-rtems_bsp_make_DATA = bsp.cfg target.cfg
+rtems_bsp_make_DATA = bsp.cfg target.cfg bsp.mk
 
 bsp.cfg: bsp.cfg.in Makefile
Index: c/src/make/bsp.mk.in
===================================================================
--- c/src/make/bsp.mk.in	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
+++ c/src/make/bsp.mk.in	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
@@ -0,0 +1,59 @@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+RTEMS_API = @RTEMS_API@
+RTEMS_BSP = @RTEMS_BSP@
+RTEMS_ROOT = @prefix@
+RTEMS_SHARE = $(RTEMS_ROOT)/share/rtems$(RTEMS_API)
+PROJECT_ROOT = @exec_prefix@/@RTEMS_BSP@
+PROJECT_INCLUDE = $(PROJECT_ROOT)/lib/include
+PROJECT_LIB = $(PROJECT_ROOT)/lib
+BUILDDIR = build-$(RTEMS_BSP)
+
+include $(RTEMS_ROOT)/make/custom/$(RTEMS_BSP).cfg
+
+DEPFLAGS = -MT $@ -MD -MP -MF $(basename $@).d
+SYSFLAGS = -B $(PROJECT_LIB) -specs bsp_specs -qrtems
+WARNFLAGS = -Wall -Wextra -Wformat=2 -Wcast-qual -Wconversion -Wno-unused
+OPTFLAGS = $(CFLAGS_OPTIMIZE_V)
+
+CFLAGS = $(DEPFLAGS) $(SYSFLAGS) $(WARNFLAGS) $(CPU_CFLAGS) $(OPTFLAGS)
+CXXFLAGS = $(DEPFLAGS) $(SYSFLAGS) $(WARNFLAGS) $(CPU_CFLAGS) $(OPTFLAGS)
+LINKFLAGS = $(SYSFLAGS) $(CPU_CFLAGS) $(LDFLAGS) $(OPTFLAGS)
+ASFLAGS = $(CPU_CFLAGS)
+
+CCLINK = $(CC) $(LINKFLAGS) -Wl,-Map,$(basename $@).map
+CXXLINK = $(CXX) $(LINKFLAGS) -Wl,-Map,$(basename $@).map
+
+$(BUILDDIR)/%.o: %.c
+	$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
+
+$(BUILDDIR)/%.o: %.S
+	$(CC) $(CPPFLAGS) -DASM $(CFLAGS) -c $< -o $@
+
+$(BUILDDIR)/%.o: %.cc
+	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
+
+$(BUILDDIR)/%.o: %.s
+	$(AS) $(ASFLAGS) $< -o $@
+
+AR = @AR@
+AS = @AS@
+CC = @CC@
+CXX = @CXX@
+LD = @LD@
+NM = @NM@
+OBJCOPY = @OBJCOPY@
+RANLIB = @RANLIB@
+SIZE = @SIZE@
+STRIP = @STRIP@
+export AR
+export AS
+export CC
+export CXX
+export LD
+export NM
+export OBJCOPY
+export RANLIB
+export SIZE
+export STRIP
Index: c/src/make/configure.ac
===================================================================
--- c/src/make/configure.ac	(revision 2cc4f3ca45e5cb20649c2733330977a2307e2e19)
+++ c/src/make/configure.ac	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
@@ -79,4 +79,5 @@
 # Explicitly list all Makefiles here
 AC_CONFIG_FILES([Makefile
+bsp.mk
 ])
 AC_OUTPUT
Index: cpukit/libcsupport/include/sys/ioccom.h
===================================================================
--- cpukit/libcsupport/include/sys/ioccom.h	(revision 2cc4f3ca45e5cb20649c2733330977a2307e2e19)
+++ cpukit/libcsupport/include/sys/ioccom.h	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
@@ -34,6 +34,5 @@
 #define	_SYS_IOCCOM_H_
 
-#include <sys/types.h>
-#include <stdint.h>
+#include <rtems.h>
 
 /*
@@ -75,4 +74,27 @@
 #define       RTEMS_IO_SNDWAKEUP      5
 
+typedef enum {
+  RTEMS_IOCTL_SELECT_OTHER,
+  RTEMS_IOCTL_SELECT_READ,
+  RTEMS_IOCTL_SELECT_WRITE
+} rtems_ioctl_select_kind;
+
+/**
+ * @brief IO control request for select() support.
+ *
+ * The driver shall return
+ *   - 1, when the request can be fullfilled immediately,
+ *   - 0, when the request task must wait, and
+ *   - -1, in case of an error.
+ */
+typedef struct {
+  rtems_ioctl_select_kind kind;
+  rtems_id request_task_id;
+} rtems_ioctl_select_request;
+
+#define RTEMS_IOCTL_SELECT _IOW('R', 0, rtems_ioctl_select_request)
+
+#define RTEMS_IOCTL_SELECT_EVENT RTEMS_EVENT_24
+
 /* copied from libnetworking/sys/filio.h and commented out there */
 /* Generic file-descriptor ioctl's. */
Index: cpukit/libcsupport/src/termios.c
===================================================================
--- cpukit/libcsupport/src/termios.c	(revision 2cc4f3ca45e5cb20649c2733330977a2307e2e19)
+++ cpukit/libcsupport/src/termios.c	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
@@ -508,4 +508,71 @@
 }
 
+static bool
+rtems_termios_can_read (const struct rtems_termios_tty *tty)
+{
+  if (tty->cindex == tty->ccount) {
+    if (tty->device.outputUsesInterrupts == TERMIOS_IRQ_DRIVEN) {
+      return tty->rawInBuf.Head != tty->rawInBuf.Tail;
+    } else {
+      return true;
+    }
+  } else {
+    return tty->cindex < tty->ccount;
+  }
+}
+
+static bool
+rtems_termios_can_write (const struct rtems_termios_tty *tty)
+{
+  /*
+   * Termios has no non-blocking writes.  In case the raw output buffer is
+   * full, we wait for the interrupt or poll.
+   */
+  return true;
+}
+
+static void
+rtems_termios_select_wakeup (struct termios *tty, void *arg)
+{
+  rtems_id task_id = (rtems_id) arg;
+  rtems_status_code sc = rtems_event_send (task_id, RTEMS_IOCTL_SELECT_EVENT);
+  if (sc != RTEMS_SUCCESSFUL)
+    rtems_fatal_error_occurred (sc);
+}
+
+static int
+rtems_termios_select (struct rtems_termios_tty *tty,
+                      const rtems_ioctl_select_request *request)
+{
+  int rv = 0;
+
+  rtems_interrupt_level level;
+  rtems_interrupt_disable(level);
+  switch (request->kind) {
+    case RTEMS_IOCTL_SELECT_READ:
+      if (rtems_termios_can_read (tty)) {
+        rv = 1;
+      } else {
+        tty->tty_rcvwakeup = 0;
+        tty->tty_rcv.sw_pfn = rtems_termios_select_wakeup;
+        tty->tty_rcv.sw_arg = (void *) request->request_task_id;
+      }
+      break;
+    case RTEMS_IOCTL_SELECT_WRITE:
+      if (rtems_termios_can_write (tty)) {
+        rv = 1;
+      } else {
+        tty->tty_snd.sw_pfn = rtems_termios_select_wakeup;
+        tty->tty_snd.sw_arg = (void *) request->request_task_id;
+      }
+      break;
+    default:
+      break;
+  }
+  rtems_interrupt_enable(level);
+
+  return rv;
+}
+
 rtems_status_code
 rtems_termios_ioctl (void *arg)
@@ -529,4 +596,8 @@
       sc = RTEMS_INVALID_NUMBER;
     }
+    break;
+
+  case RTEMS_IOCTL_SELECT:
+    args->ioctl_return = rtems_termios_select (tty, args->buffer);
     break;
 
Index: cpukit/libfs/src/pipe/fifo.c
===================================================================
--- cpukit/libfs/src/pipe/fifo.c	(revision 2cc4f3ca45e5cb20649c2733330977a2307e2e19)
+++ cpukit/libfs/src/pipe/fifo.c	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
@@ -67,4 +67,19 @@
 #include <rtems/score/thread.h>
 
+static void pipe_select_wakeup(rtems_id *id_ptr)
+{
+  rtems_id id = *id_ptr;
+
+  *id_ptr = 0;
+
+  if (id != 0) {
+    rtems_status_code sc = rtems_event_send(id, RTEMS_IOCTL_SELECT_EVENT);
+
+    if (sc != RTEMS_SUCCESSFUL) {
+      rtems_fatal_error_occurred(sc);
+    }
+  }
+}
+
 /* Set barriers to be interruptible by signals. */
 static void pipe_interruptible(pipe_control_t *pipe)
@@ -93,8 +108,7 @@
   int err = -ENOMEM;
 
-  pipe = malloc(sizeof(pipe_control_t));
+  pipe = calloc(1, sizeof(pipe_control_t));
   if (pipe == NULL)
     return err;
-  memset(pipe, 0, sizeof(pipe_control_t));
 
   pipe->Size = PIPE_BUF;
@@ -446,4 +460,5 @@
       pipe->Start = 0;
 
+    pipe_select_wakeup(&pipe->select_write_task_id);
     if (pipe->waitingWriters > 0)
       PIPE_WAKEUPWRITERS(pipe);
@@ -524,4 +539,5 @@
 
     pipe->Length += chunk;
+    pipe_select_wakeup(&pipe->select_read_task_id);
     if (pipe->waitingReaders > 0)
       PIPE_WAKEUPREADERS(pipe);
@@ -546,4 +562,51 @@
 }
 
+static int pipe_register_select_wakeup(
+  rtems_id *id_ptr,
+  const rtems_ioctl_select_request *request
+)
+{
+  int rv = 0;
+  rtems_id current_id = *id_ptr;
+  rtems_id request_id = request->request_task_id;
+
+  if (current_id == 0 || current_id == request_id) {
+    *id_ptr = request_id;
+  } else {
+    rv = -EINVAL;
+  }
+
+  return rv;
+}
+
+static int pipe_select(
+  pipe_control_t *pipe,
+  const rtems_ioctl_select_request *request
+)
+{
+  int rv = 0;
+
+  switch (request->kind) {
+    case RTEMS_IOCTL_SELECT_READ:
+      if (!PIPE_EMPTY(pipe)) {
+        rv = 1;
+      } else {
+        rv = pipe_register_select_wakeup(&pipe->select_read_task_id, request);
+      }
+      break;
+    case RTEMS_IOCTL_SELECT_WRITE:
+      if (PIPE_SPACE(pipe) > 0) {
+        rv = 1;
+      } else {
+        rv = pipe_register_select_wakeup(&pipe->select_write_task_id, request);
+      }
+      break;
+    default:
+      break;
+  }
+
+  return rv;
+}
+
 /*
  * Interface to file system ioctl.
@@ -556,17 +619,25 @@
 )
 {
-  if (cmd == FIONREAD) {
-    if (buffer == NULL)
-      return -EFAULT;
-
-    if (! PIPE_LOCK(pipe))
-      return -EINTR;
-
-    /* Return length of pipe */
-    *(unsigned int *)buffer = pipe->Length;
+  int rv = 0;
+
+  if (PIPE_LOCK(pipe)) {
+    switch (cmd) {
+      case RTEMS_IOCTL_SELECT:
+        rv = pipe_select(pipe, buffer);
+        break;
+      case FIONREAD:
+        /* Return length of pipe */
+        *(unsigned int *) buffer = pipe->Length;
+        break;
+      default:
+        rv = -EINVAL;
+        break;
+    }
+
     PIPE_UNLOCK(pipe);
-    return 0;
-  }
-
-  return -EINVAL;
-}
+  } else {
+    rv = -EINTR;
+  }
+
+  return rv;
+}
Index: cpukit/libfs/src/pipe/pipe.h
===================================================================
--- cpukit/libfs/src/pipe/pipe.h	(revision 2cc4f3ca45e5cb20649c2733330977a2307e2e19)
+++ cpukit/libfs/src/pipe/pipe.h	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
@@ -38,4 +38,6 @@
   rtems_id readBarrier;   /* wait queues */
   rtems_id writeBarrier;
+  rtems_id select_read_task_id;
+  rtems_id select_write_task_id;
 #if 0
   boolean Anonymous;      /* anonymous pipe or FIFO */
Index: cpukit/libnetworking/rtems/rtems_select.c
===================================================================
--- cpukit/libnetworking/rtems/rtems_select.c	(revision 2cc4f3ca45e5cb20649c2733330977a2307e2e19)
+++ cpukit/libnetworking/rtems/rtems_select.c	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
@@ -26,4 +26,9 @@
 #include <net/if.h>
 #include <net/route.h>
+
+RTEMS_STATIC_ASSERT(RTEMS_IOCTL_SELECT_OTHER == 0, other);
+RTEMS_STATIC_ASSERT(RTEMS_IOCTL_SELECT_READ == FREAD, fread);
+RTEMS_STATIC_ASSERT(RTEMS_IOCTL_SELECT_WRITE == FWRITE, fwrite);
+RTEMS_STATIC_ASSERT(RTEMS_IOCTL_SELECT_EVENT == SBWAIT_EVENT, sbwait_event);
 
 /*
@@ -85,4 +90,9 @@
 	int n = 0;
 	static int flag[3] = { FREAD, FWRITE, 0 };
+	int update_obits;
+	int rv;
+	rtems_ioctl_select_request select_request;
+
+	select_request.request_task_id = tid;
 
 	for (msk = 0; msk < 3; msk++) {
@@ -95,8 +105,24 @@
 					continue;
 				bits &= ~bit;
+				update_obits = 0;
 				so = rtems_bsdnet_fdToSocket (fd);
-				if (so == NULL)
-					return (EBADF);
-				if (socket_select (so, flag[msk], tid)) {
+				if (so != NULL) {
+					if (socket_select (so, flag[msk], tid)) {
+						update_obits = 1;
+					}
+				} else {
+					select_request.kind = flag[msk];
+
+					rtems_bsdnet_semaphore_release();
+					rv = ioctl (fd, RTEMS_IOCTL_SELECT, &select_request);
+					rtems_bsdnet_semaphore_obtain();
+					if (rv == 1) {
+						update_obits = 1;
+					} else if (rv != 0) {
+						return (EBADF);
+					}
+				}
+
+				if (update_obits) {
 					obits[msk][fd/NFDBITS] |=
 							(1 << (fd % NFDBITS));
Index: testsuites/libtests/flashdisk01/test-file-system.c
===================================================================
--- testsuites/libtests/flashdisk01/test-file-system.c	(revision 2cc4f3ca45e5cb20649c2733330977a2307e2e19)
+++ testsuites/libtests/flashdisk01/test-file-system.c	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
@@ -597,6 +597,7 @@
   if (pos != (off_t) -1) {
     size_t buf_size = sizeof(fs->buf);
+    size_t offset = HEADER_SIZE + 1;
     long random = lrand48();
-    size_t out = get_bucket_with_random(buf_size, random) + 1;
+    size_t out = get_bucket_with_random(buf_size - offset, random) + offset;
     ssize_t out_actual = 0;
     uint8_t *buf = fs->buf;
@@ -605,7 +606,4 @@
     size_t word_count = 0;
     size_t w = 0;
-
-    /* Must be big enough for the header */
-    out = out >= HEADER_SIZE ? out : HEADER_SIZE;
 
     /*
Index: testsuites/sptests/spfifo04/init.c
===================================================================
--- testsuites/sptests/spfifo04/init.c	(revision 2cc4f3ca45e5cb20649c2733330977a2307e2e19)
+++ testsuites/sptests/spfifo04/init.c	(revision 90bd18efe75be10c4d17be7a64f6f54686e7db2c)
@@ -54,9 +54,4 @@
   rtems_test_assert( errno == ESPIPE );
 
-  puts( "Init - ioctl: FIONBIO -- Expected EFAULT" );
-  status = ioctl( fd, FIONBIO, NULL );
-  rtems_test_assert( status == -1 );
-  rtems_test_assert( errno == EFAULT );
-
   puts( "Init - ioctl: FIONBIO -- OK" );
   status = ioctl( fd, FIONBIO, &flag );
@@ -69,12 +64,7 @@
 
   puts( "Init - ioctl: Dummy Command -- Expected EINVAL" );
-  status = ioctl( fd, -1, NULL );
+  status = ioctl( fd, -1 );
   rtems_test_assert( status == -1 );
   rtems_test_assert( errno == EINVAL );
-
-  puts( "Init - ioctl: FIONREAD -- Expected EFAULT" );
-  status = ioctl( fd, FIONREAD, NULL );
-  rtems_test_assert( status == -1 );
-  rtems_test_assert( errno == EFAULT );
 
   puts( "Init - ioctl: FIONREAD -- OK" );
