[rtems commit] cpukit, testsuite: Add rtems_printf and rtems_printer support.

Chris Johns chrisj at rtems.org
Wed May 25 06:56:44 UTC 2016


Module:    rtems
Branch:    master
Commit:    24d0ee57a4d95f99be6e7e60bd162a30daf0638d
Changeset: http://git.rtems.org/rtems/commit/?id=24d0ee57a4d95f99be6e7e60bd162a30daf0638d

Author:    Chris Johns <chrisj at rtems.org>
Date:      Fri May 20 18:39:50 2016 +1000

cpukit, testsuite: Add rtems_printf and rtems_printer support.

This change adds rtems_printf and related functions and wraps the
RTEMS print plugin support into a user API. All references to the
plugin are removed and replaced with the rtems_printer interface.

Printk and related functions are made to return a valid number of
characters formatted and output.

The function attribute to check printf functions has been added
to rtems_printf and printk. No changes to remove warrnings are part
of this patch set.

The testsuite has been moved over to the rtems_printer. The testsuite
has a mix of rtems_printer access and direct print control via the
tmacros.h header file. The support for begink/endk has been removed
as it served no purpose and only confused the code base. The testsuite
has not been refactored to use rtems_printf. This is future work.

---

 c/src/lib/libbsp/shared/include/irq-info.h    |   5 +-
 c/src/lib/libbsp/shared/src/irq-info.c        |  29 ++---
 c/src/lib/libbsp/shared/src/irq-shell.c       |   4 +-
 cpukit/Makefile.am                            |   1 +
 cpukit/include/rtems/bspIo.h                  |  33 ++++--
 cpukit/include/rtems/print.h                  | 134 +++++++++++++++++++++++
 cpukit/libblock/include/rtems/blkdev.h        |   7 +-
 cpukit/libblock/src/blkdev-blkstats.c         |  17 ++-
 cpukit/libblock/src/blkdev-print-stats.c      |   7 +-
 cpukit/libcsupport/Makefile.am                |   2 +
 cpukit/libcsupport/src/print_fprintf.c        |  29 +++++
 cpukit/libcsupport/src/print_printf.c         |  52 +++++++++
 cpukit/libcsupport/src/printf_plugin.c        |  18 ++--
 cpukit/libcsupport/src/printk.c               |   9 +-
 cpukit/libcsupport/src/printk_plugin.c        |  22 ++--
 cpukit/libcsupport/src/putk.c                 |   8 +-
 cpukit/libcsupport/src/vprintk.c              |  28 +++--
 cpukit/libmisc/cpuuse/cpuusagereport.c        |  28 +++--
 cpukit/libmisc/cpuuse/cpuusagetop.c           | 147 ++++++++++----------------
 cpukit/libmisc/cpuuse/cpuuse.h                |  14 +--
 cpukit/libmisc/fb/mw_print.c                  |  23 ++--
 cpukit/libmisc/fb/mw_uid.h                    |   9 +-
 cpukit/libmisc/shell/main_blkstats.c          |   7 +-
 cpukit/libmisc/shell/main_cpuuse.c            |   4 +-
 cpukit/libmisc/shell/main_perioduse.c         |   5 +-
 cpukit/libmisc/shell/main_profreport.c        |   5 +-
 cpukit/libmisc/shell/main_stackuse.c          |   7 +-
 cpukit/libmisc/shell/main_top.c               |   4 +-
 cpukit/libmisc/stackchk/check.c               |  36 +++----
 cpukit/libmisc/stackchk/stackchk.h            |   5 +-
 cpukit/libmisc/testsupport/test.h             |  60 +++--------
 cpukit/libmisc/testsupport/testbeginend.c     |  39 ++++---
 cpukit/libmisc/testsupport/testextension.c    |   6 +-
 cpukit/preinstall.am                          |   4 +
 cpukit/rtems/include/rtems/rtems/ratemon.h    |  13 ++-
 cpukit/rtems/src/ratemonreportstatistics.c    |  27 +++--
 cpukit/sapi/include/rtems/profiling.h         |  21 +---
 cpukit/sapi/src/profilingreportxml.c          | 106 +++++++++----------
 cpukit/score/src/cpusetprintsupport.c         |  30 +++---
 testsuites/fstests/fsnofs01/init.c            |   4 +-
 testsuites/libtests/block02/init.c            |   5 +-
 testsuites/libtests/block03/init.c            |   5 +-
 testsuites/libtests/block04/init.c            |   5 +-
 testsuites/libtests/block05/init.c            |   5 +-
 testsuites/libtests/block06/init.c            |   2 +-
 testsuites/libtests/block07/init.c            |   6 +-
 testsuites/libtests/block08/init.c            |   7 +-
 testsuites/libtests/block09/init.c            |   7 +-
 testsuites/libtests/block10/init.c            |   7 +-
 testsuites/libtests/block14/init.c            |   5 +-
 testsuites/libtests/capture01/init.c          |   3 +
 testsuites/libtests/complex/init.c            |   4 +-
 testsuites/libtests/devnullfatal01/testcase.h |   3 +-
 testsuites/libtests/exit01/init.c             |   8 +-
 testsuites/libtests/exit02/init.c             |   8 +-
 testsuites/libtests/math/init.c               |   7 +-
 testsuites/libtests/mathf/init.c              |   5 +-
 testsuites/libtests/mathl/init.c              |   4 +-
 testsuites/libtests/mouse01/init.c            |  13 +--
 testsuites/libtests/stackchk/init.c           |   2 +-
 testsuites/libtests/stackchk/system.h         |   1 +
 testsuites/libtests/uid01/init.c              |   9 +-
 testsuites/psxtests/psxfatal_support/init.c   |   8 +-
 testsuites/samples/capture/init.c             |   2 +
 testsuites/samples/hello/init.c               |   2 +
 testsuites/samples/paranoia/init.c            |   2 +
 testsuites/smptests/smp05/init.c              |   4 +-
 testsuites/smptests/smp07/init.c              |  14 +--
 testsuites/smptests/smpfatal01/init.c         |  10 +-
 testsuites/smptests/smpfatal02/init.c         |  10 +-
 testsuites/smptests/smpfatal04/init.c         |   8 +-
 testsuites/smptests/smpfatal05/init.c         |   8 +-
 testsuites/smptests/smpfatal08/init.c         |   8 +-
 testsuites/sptests/sperror01/init.c           |   4 +-
 testsuites/sptests/sperror02/init.c           |   6 +-
 testsuites/sptests/sperror03/init.c           |   5 +-
 testsuites/sptests/spextensions01/init.c      |   9 +-
 testsuites/sptests/spfatal07/testcase.h       |   2 +-
 testsuites/sptests/spfatal16/testcase.h       |   4 +-
 testsuites/sptests/spfatal26/init.c           |   5 +-
 testsuites/sptests/spfatal_support/init.c     |   5 +-
 testsuites/sptests/spfatal_support/system.h   |   6 +-
 testsuites/sptests/spinternalerror01/init.c   |   9 +-
 testsuites/sptests/spprintk/init.c            |  17 ++-
 testsuites/sptests/spprofiling01/init.c       |   4 +-
 testsuites/sptests/spsysinit01/init.c         |   8 +-
 testsuites/sptests/sptimecounter01/init.c     |   9 +-
 testsuites/support/include/buffer_test_io.h   |  16 ++-
 testsuites/support/include/test_support.h     |   2 -
 testsuites/support/src/locked_print.c         |  42 +++++---
 90 files changed, 802 insertions(+), 557 deletions(-)

diff --git a/c/src/lib/libbsp/shared/include/irq-info.h b/c/src/lib/libbsp/shared/include/irq-info.h
index df85c8e..ea6d629 100644
--- a/c/src/lib/libbsp/shared/include/irq-info.h
+++ b/c/src/lib/libbsp/shared/include/irq-info.h
@@ -23,7 +23,7 @@
 #define LIBBSP_SHARED_IRQ_INFO_H
 
 #include <rtems/shell.h>
-#include <rtems/bspIo.h>
+#include <rtems/print.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -34,8 +34,7 @@ extern "C" {
  * context @a context.
  */
 void bsp_interrupt_report_with_plugin(
-  void *context,
-  rtems_printk_plugin_t print
+  const rtems_printer *printer
 );
 
 /**
diff --git a/c/src/lib/libbsp/shared/src/irq-info.c b/c/src/lib/libbsp/shared/src/irq-info.c
index 7967ee5..f5f2323 100644
--- a/c/src/lib/libbsp/shared/src/irq-info.c
+++ b/c/src/lib/libbsp/shared/src/irq-info.c
@@ -21,12 +21,13 @@
 
 #include <inttypes.h>
 
+#include <rtems/print.h>
+
 #include <bsp/irq-generic.h>
 #include <bsp/irq-info.h>
 
 typedef struct {
-  void *context;
-  rtems_printk_plugin_t print;
+  const rtems_printer *printer;
   rtems_vector_number vector;
 } bsp_interrupt_report_entry;
 
@@ -41,9 +42,9 @@ static void bsp_interrupt_report_per_handler_routine(
   bsp_interrupt_report_entry *e = (bsp_interrupt_report_entry *) arg;
   const char *opt = options == RTEMS_INTERRUPT_UNIQUE ? "UNIQUE" : "SHARED";
 
-  e->print(
-    e->context,
-    "%7" PRIu32 " | %-32s | %7s | %010p | %010p\n",
+  rtems_printf(
+    e->printer,
+    "%7" PRIu32 " | %-32s | %7s | %p | %p\n",
     e->vector,
     info,
     opt,
@@ -53,19 +54,17 @@ static void bsp_interrupt_report_per_handler_routine(
 }
 
 void bsp_interrupt_report_with_plugin(
-  void *context,
-  rtems_printk_plugin_t print
+  const rtems_printer *printer
 )
 {
   rtems_vector_number v = 0;
   bsp_interrupt_report_entry e = {
-    .context = context,
-    .print = print,
+    .printer = printer,
     .vector = 0
   };
 
-  print(
-    context,
+  rtems_printf(
+    printer,
     "-------------------------------------------------------------------------------\n"
     "                             INTERRUPT INFORMATION\n"
     "--------+----------------------------------+---------+------------+------------\n"
@@ -82,13 +81,15 @@ void bsp_interrupt_report_with_plugin(
     );
   }
 
-  print(
-    context,
+  rtems_printf(
+    printer,
     "--------+----------------------------------+---------+------------+------------\n"
   );
 }
 
 void bsp_interrupt_report(void)
 {
-  bsp_interrupt_report_with_plugin(NULL, printk_plugin);
+  rtems_printer printer;
+  rtems_print_printer_printk(&printer);
+  bsp_interrupt_report_with_plugin(&printer);
 }
diff --git a/c/src/lib/libbsp/shared/src/irq-shell.c b/c/src/lib/libbsp/shared/src/irq-shell.c
index 0bd63f2..512594c 100644
--- a/c/src/lib/libbsp/shared/src/irq-shell.c
+++ b/c/src/lib/libbsp/shared/src/irq-shell.c
@@ -27,7 +27,9 @@
 
 static int bsp_interrupt_shell_main(int argc, char **argv)
 {
-  bsp_interrupt_report_with_plugin(stdout, (rtems_printk_plugin_t) fprintf);
+  rtems_printer printer;
+  rtems_print_printer_printf(&printer);
+  bsp_interrupt_report_with_plugin(&printer);
 
   return 0;
 }
diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index c84ccc3..aa1111e 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -97,6 +97,7 @@ include_rtems_rtl_HEADERS += libdl/rap.h libdl/rap-shell.h
 endif
 
 include_rtems_HEADERS += include/rtems/bspIo.h
+include_rtems_HEADERS += include/rtems/print.h
 include_rtems_HEADERS += include/rtems/userenv.h
 include_rtems_HEADERS += include/rtems/fs.h
 if !LIBPCI
diff --git a/cpukit/include/rtems/bspIo.h b/cpukit/include/rtems/bspIo.h
index dde8d94..403b857 100644
--- a/cpukit/include/rtems/bspIo.h
+++ b/cpukit/include/rtems/bspIo.h
@@ -37,6 +37,15 @@ extern "C" {
  */
 
 /**
+ * Print format function attribute for warning checks. Can be defined if
+ * checking needs to be disabled.
+ */
+#ifndef RTEMS_PRINTF_ATTRIBUTE
+#define RTEMS_PRINTF_ATTRIBUTE(_format_pos, _ap_pos) \
+  __attribute__((format(__printf__, _format_pos, _ap_pos)))
+#endif
+
+/**
  * This type defines the prototype for the BSP provided method to
  * print a single character. It is assumed to be polled.
  */
@@ -84,8 +93,10 @@ extern int getchark(void);
  *
  * @param[in] fmt is a printf()-style format string
  * @param[in] ap is a va_list pointer to arguments
+ *
+ * @return The number of characters output.
  */
-extern void vprintk(const char *fmt, va_list ap);
+extern int vprintk(const char *fmt, va_list ap);
 
 /**
  * @brief Kernel Print
@@ -93,8 +104,10 @@ extern void vprintk(const char *fmt, va_list ap);
  * This method allows the user to perform a debug printk().
  *
  * @param[in] fmt is a printf()-style format string
+ *
+ * @return The number of characters output.
  */
-extern void printk(const char *fmt, ...);
+extern int printk(const char *fmt, ...) RTEMS_PRINTF_ATTRIBUTE(1, 2);
 
 /**
  * @brief Kernel Put String
@@ -102,8 +115,10 @@ extern void printk(const char *fmt, ...);
  * This method allows the user to perform a debug puts().
  *
  * @param[in] s is the string to print
+ *
+ * @return The number of characters output.
  */
-extern void putk(const char *s);
+extern int putk(const char *s);
 
 /**
  * @brief Kernel Put Character
@@ -118,15 +133,13 @@ extern void rtems_putc(char c);
  * Type definition for function which can be plugged in to
  * certain reporting routines to redirect the output.
  *
- * Methods following this prototype may be passed into RTEMS reporting
- * functions that allow their output to be redirected.  In particular,
- * the cpu usage, period usage, and stack usage reporting
- * functions use this.
+ * Use the RTEMS Print interface to call these functions. Do not
+ * directly use them.
  *
  * If the user provides their own "printf plugin", then they may
  * redirect those reports as they see fit.
  */
-typedef int (*rtems_printk_plugin_t)(void *, const char *format, ...);
+typedef int (*rtems_print_plugin_t)(void *, const char *format, va_list ap);
 
 /**
  * @brief Reporting Methods printk() Plugin
@@ -136,7 +149,7 @@ typedef int (*rtems_printk_plugin_t)(void *, const char *format, ...);
  *
  * @return The number of characters printed.
  */
-extern int printk_plugin(void *context, const char *fmt, ...);
+extern int printk_plugin(void *context, const char *fmt, va_list ap);
 
 /**
  * @brief Reporting Methods printf() Plugin
@@ -149,7 +162,7 @@ extern int printk_plugin(void *context, const char *fmt, ...);
  *
  * @return The number of characters printed.
  */
-extern int rtems_printf_plugin(void *context, const char *fmt, ...);
+extern int rtems_printf_plugin(void *context, const char *fmt, va_list ap);
 
 /**@}*/
 
diff --git a/cpukit/include/rtems/print.h b/cpukit/include/rtems/print.h
new file mode 100644
index 0000000..5268e8c
--- /dev/null
+++ b/cpukit/include/rtems/print.h
@@ -0,0 +1,134 @@
+/**
+ * @file rtems/print.h
+ *
+ * @brief User print interface to the bspIO print plug in.
+ *
+ * This include file defines the user interface to kernel print methods.
+ */
+
+/*
+ *  Copyright (c) 2016 Chris Johns <chrisj at rtems.org>
+ *  All rights reserved.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_PRINT_H
+#define _RTEMS_PRINT_H
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdio.h>
+
+#include <rtems/bspIo.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup RTEMS Print Support
+ *
+ * This module contains all methods and support related to providing the user
+ * with an interface to the kernel level print support.
+ */
+
+/**
+ * Type definition for the printer structure used to access the kernel print
+ * support.
+ */
+typedef struct {
+  void                *context;
+  rtems_print_plugin_t printer;
+}rtems_printer;
+
+/**
+ * @brief check if the printer is valid.
+ *
+ * @param[in] printer Pointer to the printer structure.
+ *
+ * @return true The printer is valid else false is returned.
+ */
+static inline bool rtems_print_printer_valid(const rtems_printer *printer)
+{
+  return printer != NULL && printer->printer != NULL;
+}
+
+/**
+ * @brief Print to the kernel plugin handler. This has to be a macro because
+ * there is no vprint version of the plug in handlers.
+ *
+ * @param[in] printer Pointer to the printer structure.
+ * @param[in] fmt Print format string.
+ * @param[in] ... Print variable argument list.
+ *
+ * @return int Number of characters printed.
+ */
+extern int rtems_printf(const rtems_printer *printer,
+                        const char          *format,
+                        ...) RTEMS_PRINTF_ATTRIBUTE(2, 3);
+
+/**
+ * @brief Print to the kernel plugin handler. This has to be a macro because
+ * there is no vprint version of the plug in handlers.
+ *
+ * @param[in] printer Pointer to the printer structure.
+ * @param[in] fmt Print format string.
+ * @param[in] ap Print variable argument list pointer.
+ *
+ * @return int Number of characters printed.
+ */
+extern int rtems_vprintf(const rtems_printer *printer,
+                         const char          *format,
+                         va_list              ap);
+
+/**
+ * @brief Intiialise the rtems_printer struct to empty.
+ *
+ * An empty printer prints nothing. You can use this to implement an enable and
+ * disable type print implementation.
+ *
+ * @param[in] printer Pointer to the printer structure.
+ */
+static inline void rtems_print_printer_empty(rtems_printer *printer)
+{
+  printer->context = NULL;
+  printer->printer = NULL;
+}
+
+/**
+ * @brief Intiialise the rtems_printer struct to printk
+ *
+ * The printer will output to the kernel printk support.
+ *
+ * @param[in] printer Pointer to the printer structure.
+ */
+void rtems_print_printer_printk(rtems_printer *printer);
+
+/**
+ * @brief Intiialise the rtems_printer struct to printf
+ *
+ * The printer will output to the libc printf support.
+ *
+ * @param[in] printer Pointer to the printer structure.
+ */
+extern void rtems_print_printer_printf(rtems_printer *printer);
+
+/**
+ * @brief Intiialise the rtems_printer struct to a fprintf device.
+ *
+ * The printer will output to the libc fprintf file provided.
+ *
+ * @param[in] printer Pointer to the printer structure.
+ */
+extern void rtems_print_printer_fprintf(rtems_printer *printer, FILE *file);
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/cpukit/libblock/include/rtems/blkdev.h b/cpukit/libblock/include/rtems/blkdev.h
index 81e2dfa..99f8573 100644
--- a/cpukit/libblock/include/rtems/blkdev.h
+++ b/cpukit/libblock/include/rtems/blkdev.h
@@ -16,7 +16,7 @@
 
 #include <rtems.h>
 #include <rtems/diskdevs.h>
-#include <rtems/bspIo.h>
+#include <rtems/print.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
 
@@ -348,15 +348,14 @@ void rtems_blkdev_print_stats(
   uint32_t media_block_size,
   uint32_t media_block_count,
   uint32_t block_size,
-  rtems_printk_plugin_t print,
-  void *print_arg
+  const rtems_printer* printer
 );
 
 /**
  * @brief Block device statistics command.
  */
 void rtems_blkstats(
-  FILE *output,
+  const rtems_printer *printer,
   const char *device,
   bool reset
 );
diff --git a/cpukit/libblock/src/blkdev-blkstats.c b/cpukit/libblock/src/blkdev-blkstats.c
index 1e773cf..ca1e0e4 100644
--- a/cpukit/libblock/src/blkdev-blkstats.c
+++ b/cpukit/libblock/src/blkdev-blkstats.c
@@ -31,7 +31,7 @@
 #include <errno.h>
 #include <string.h>
 
-void rtems_blkstats(FILE *output, const char *device, bool reset)
+void rtems_blkstats(const rtems_printer* printer, const char *device, bool reset)
 {
   int fd = open(device, O_RDONLY);
 
@@ -45,7 +45,7 @@ void rtems_blkstats(FILE *output, const char *device, bool reset)
         if (reset) {
           rv = rtems_disk_fd_reset_device_stats(fd);
           if (rv != 0) {
-            fprintf(output, "error: reset stats: %s\n", strerror(errno));
+            rtems_printf(printer, "error: reset stats: %s\n", strerror(errno));
           }
         } else {
           uint32_t media_block_size = 0;
@@ -64,25 +64,24 @@ void rtems_blkstats(FILE *output, const char *device, bool reset)
               media_block_size,
               media_block_count,
               block_size,
-              (rtems_printk_plugin_t) fprintf,
-              output
+              printer
             );
           } else {
-            fprintf(output, "error: get stats: %s\n", strerror(errno));
+            rtems_printf(printer, "error: get stats: %s\n", strerror(errno));
           }
         }
       } else {
-        fprintf(output, "error: not a block device\n");
+        rtems_printf(printer, "error: not a block device\n");
       }
     } else {
-      fprintf(output, "error: get file stats: %s\n", strerror(errno));
+      rtems_printf(printer, "error: get file stats: %s\n", strerror(errno));
     }
 
     rv = close(fd);
     if (rv != 0) {
-      fprintf(output, "error: close device: %s\n", strerror(errno));
+      rtems_printf(printer, "error: close device: %s\n", strerror(errno));
     }
   } else {
-    fprintf(output, "error: open device: %s\n", strerror(errno));
+    rtems_printf(printer, "error: open device: %s\n", strerror(errno));
   }
 }
diff --git a/cpukit/libblock/src/blkdev-print-stats.c b/cpukit/libblock/src/blkdev-print-stats.c
index edeee90..aba2173 100644
--- a/cpukit/libblock/src/blkdev-print-stats.c
+++ b/cpukit/libblock/src/blkdev-print-stats.c
@@ -32,12 +32,11 @@ void rtems_blkdev_print_stats(
   uint32_t media_block_size,
   uint32_t media_block_count,
   uint32_t block_size,
-  rtems_printk_plugin_t print,
-  void *print_arg
+  const rtems_printer* printer
 )
 {
-  (*print)(
-     print_arg,
+  rtems_printf(
+     printer,
      "-------------------------------------------------------------------------------\n"
      "                               DEVICE STATISTICS\n"
      "----------------------+--------------------------------------------------------\n"
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am
index b3ad3db..f047cfc 100644
--- a/cpukit/libcsupport/Makefile.am
+++ b/cpukit/libcsupport/Makefile.am
@@ -112,6 +112,8 @@ BSD_LIBC_C_FILES = src/strlcpy.c src/strlcat.c src/issetugid.c
 libcsupport_a_SOURCES = src/gxx_wrappers.c src/getchark.c src/printk.c \
     src/printk_plugin.c src/putk.c src/vprintk.c \
     src/rtems_putc.c \
+    src/print_fprintf.c \
+    src/print_printf.c \
     src/printf_plugin.c \
     src/sup_fs_location.c \
     src/sup_fs_eval_path.c \
diff --git a/cpukit/libcsupport/src/print_fprintf.c b/cpukit/libcsupport/src/print_fprintf.c
new file mode 100644
index 0000000..5e46d1c
--- /dev/null
+++ b/cpukit/libcsupport/src/print_fprintf.c
@@ -0,0 +1,29 @@
+/**
+ *  @file
+ *
+ *  @brief RTEMS Print Support
+ *  @ingroup libcsupport
+ */
+
+/*
+ * Copyright (c) 2016 Chris Johns <chrisj at rtems.org>
+ * All rights reserved.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <rtems/print.h>
+
+#include <stdio.h>
+
+void rtems_print_printer_fprintf(rtems_printer *printer, FILE *file)
+{
+  printer->context = file;
+  printer->printer = (rtems_print_plugin_t) fprintf;
+}
diff --git a/cpukit/libcsupport/src/print_printf.c b/cpukit/libcsupport/src/print_printf.c
new file mode 100644
index 0000000..c869523
--- /dev/null
+++ b/cpukit/libcsupport/src/print_printf.c
@@ -0,0 +1,52 @@
+/**
+ *  @file
+ *
+ *  @brief RTEMS Print Support
+ *  @ingroup libcsupport
+ */
+
+/*
+ * Copyright (c) 2016 Chris Johns <chrisj at rtems.org>
+ * All rights reserved.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <rtems/print.h>
+
+#include <stdio.h>
+
+int rtems_vprintf(
+  const rtems_printer *printer,
+  const char          *format,
+  va_list              ap
+)
+{
+  int len = 0;
+  if ( rtems_print_printer_valid( printer ) ) {
+    len = printer->printer( printer->context, format, ap );
+  }
+  return len;
+}
+
+int rtems_printf(
+  const rtems_printer *printer,
+  const char          *format,
+  ...
+)
+{
+  int len = 0;
+  if ( rtems_print_printer_valid( printer ) ) {
+    va_list ap;
+    va_start( ap, format );
+    len = printer->printer( printer->context, format, ap );
+    va_end( ap );
+  }
+  return len;
+}
diff --git a/cpukit/libcsupport/src/printf_plugin.c b/cpukit/libcsupport/src/printf_plugin.c
index ab4f4a4..097e412 100644
--- a/cpukit/libcsupport/src/printf_plugin.c
+++ b/cpukit/libcsupport/src/printf_plugin.c
@@ -23,18 +23,18 @@
   #include "config.h"
 #endif
 
-#include <rtems/bspIo.h>
+#include <rtems/print.h>
 
 #include <stdio.h>
 
-int rtems_printf_plugin(void *context, const char *format, ...)
+void rtems_print_printer_printf(rtems_printer *printer)
 {
-  int rv;
-  va_list ap;
-
-  va_start(ap, format);
-  rv = vprintf(format, ap);
-  va_end(ap);
+  printer->context = NULL;
+  printer->printer = rtems_printf_plugin;
+}
 
-  return rv;
+int rtems_printf_plugin(void *context, const char *format, va_list ap)
+{
+  (void) context;
+  return vprintf(format, ap);
 }
diff --git a/cpukit/libcsupport/src/printk.c b/cpukit/libcsupport/src/printk.c
index badbd0d..88cd22a 100644
--- a/cpukit/libcsupport/src/printk.c
+++ b/cpukit/libcsupport/src/printk.c
@@ -32,11 +32,12 @@
 /**
  *  Kernel printf function requiring minimal infrastructure.
  */
-void printk(const char *fmt, ...)
+int printk(const char *fmt, ...)
 {
-  va_list  ap;       /* points to each unnamed argument in turn */
-
+  va_list ap;       /* points to each unnamed argument in turn */
+  int     len;
   va_start(ap, fmt); /* make ap point to 1st unnamed arg */
-  vprintk(fmt, ap);
+  len = vprintk(fmt, ap);
   va_end(ap);        /* clean up when done */
+  return len;
 }
diff --git a/cpukit/libcsupport/src/printk_plugin.c b/cpukit/libcsupport/src/printk_plugin.c
index b600378..3ecacb8 100644
--- a/cpukit/libcsupport/src/printk_plugin.c
+++ b/cpukit/libcsupport/src/printk_plugin.c
@@ -19,23 +19,23 @@
 #endif
 
 #include <stdarg.h>
-#include <rtems/bspIo.h>
+#include <rtems/print.h>
+
+void rtems_print_printer_printk(
+  rtems_printer *printer
+)
+{
+  printer->context = NULL;
+  printer->printer = printk_plugin;
+}
 
 int printk_plugin(
   void *ignored,
   const char *format,
-  ...
+  va_list ap
 )
 {
-  va_list arg_pointer;
-
   (void) ignored;
-
-  va_start (arg_pointer, format);
-
-  vprintk( format, arg_pointer );
-
-  va_end(arg_pointer); /* clean up when done */
-
+  vprintk( format, ap );
   return 0;
 }
diff --git a/cpukit/libcsupport/src/putk.c b/cpukit/libcsupport/src/putk.c
index 2532a64..76fa8b0 100644
--- a/cpukit/libcsupport/src/putk.c
+++ b/cpukit/libcsupport/src/putk.c
@@ -1,7 +1,7 @@
 /**
  *  @file
  *
- *  @brief Write Character to Stream 
+ *  @brief Write Character to Stream
  *  @ingroup libcsupport
  */
 
@@ -23,11 +23,13 @@
 /**
  * Kernel putk (e.g. puts) function requiring minimal infrastrure.
  */
-void putk(const char *s)
+int putk(const char *s)
 {
   const char *p;
+  int len_out = 0;
 
-  for (p=s ; *p ; p++ )
+  for (p=s ; *p ; p++, len_out++ )
     BSP_output_char(*p);
   BSP_output_char('\n');
+  return len_out + 1;
 }
diff --git a/cpukit/libcsupport/src/vprintk.c b/cpukit/libcsupport/src/vprintk.c
index 51e4947..a254934 100644
--- a/cpukit/libcsupport/src/vprintk.c
+++ b/cpukit/libcsupport/src/vprintk.c
@@ -30,7 +30,7 @@
 #include <stdbool.h>
 #include <rtems/bspIo.h>
 
-static void printNum(
+static int printNum(
   long long num,
   unsigned base,
   bool sign,
@@ -45,11 +45,12 @@ static void printNum(
  * Arguments:
  *    as in printf: fmt - format string, ... - unnamed arguments.
  */
-void vprintk(
+int vprintk(
   const char *fmt,
   va_list     ap
 )
 {
+  int len_out = 0;
   for (; *fmt != '\0'; fmt++) {
     unsigned base = 0;
     unsigned width = 0;
@@ -66,6 +67,7 @@ void vprintk(
 
     if (c != '%') {
       rtems_putc(c);
+      ++len_out;
       continue;
     }
 
@@ -101,6 +103,7 @@ void vprintk(
       /* need a cast here since va_arg() only takes fully promoted types */
       char chr = (char) va_arg(ap, int);
       rtems_putc(chr);
+      ++len_out;
       continue;
     }
 
@@ -120,7 +123,7 @@ void vprintk(
 
       /* leading spaces */
       if ( !minus )
-        for ( i=len ; i<width ; i++ )
+        for ( i=len ; i<width ; i++, len_out++ )
           rtems_putc(' ');
 
       /* no width option */
@@ -129,12 +132,12 @@ void vprintk(
       }
 
       /* output the string */
-      for ( i=0 ; i<width && *str ; str++ )
+      for ( i=0 ; i<width && *str ; str++, len_out++ )
         rtems_putc(*str);
 
       /* trailing spaces */
       if ( minus )
-        for ( i=len ; i<width ; i++ )
+        for ( i=len ; i<width ; i++, len_out++ )
           rtems_putc(' ');
 
       continue;
@@ -154,6 +157,7 @@ void vprintk(
       base = 16; sign = false; lflag = LFLAG_LONG;
     } else {
       rtems_putc(c);
+      ++len_out;
       continue;
     }
 
@@ -172,8 +176,10 @@ void vprintk(
         break;
     }
 
-    printNum(num, base, sign, width, lead);
+    len_out += printNum(num, base, sign, width, lead);
   }
+
+  return len_out;
 }
 
 /**
@@ -181,7 +187,7 @@ void vprintk(
  *  @param[in] num is the number to print
  *  @param[in] base is the base used to print the number
  */
-static void printNum(
+static int printNum(
   long long num,
   unsigned base,
   bool sign,
@@ -194,9 +200,11 @@ static void printNum(
   unsigned count;
   #define UINT64_MAX_IN_OCTAL_FORMAT "1777777777777777777777"
   char toPrint[sizeof(UINT64_MAX_IN_OCTAL_FORMAT)];
+  int len_out = 0;
 
   if ( sign && (num <  0) ) {
     rtems_putc('-');
+    ++len_out;
     unsigned_num = (unsigned long long) -num;
     if (maxwidth) maxwidth--;
   } else {
@@ -210,10 +218,12 @@ static void printNum(
   }
   toPrint[count++] = (char) unsigned_num;
 
-  for (n=maxwidth ; n > count; n-- )
+  for (n=maxwidth ; n > count; n--, len_out++ )
     rtems_putc(lead);
 
-  for (n = 0; n < count; n++) {
+  for (n = 0; n < count; n++, len_out++) {
     rtems_putc("0123456789ABCDEF"[(int)(toPrint[count-(n+1)])]);
   }
+
+  return len_out;
 }
diff --git a/cpukit/libmisc/cpuuse/cpuusagereport.c b/cpukit/libmisc/cpuuse/cpuusagereport.c
index 95d0648..5200352 100644
--- a/cpukit/libmisc/cpuuse/cpuusagereport.c
+++ b/cpukit/libmisc/cpuuse/cpuusagereport.c
@@ -34,8 +34,7 @@
  *  rtems_cpu_usage_report
  */
 void rtems_cpu_usage_report_with_plugin(
-  void                  *context,
-  rtems_printk_plugin_t  print
+  const rtems_printer *printer
 )
 {
   uint32_t             i;
@@ -44,11 +43,8 @@ void rtems_cpu_usage_report_with_plugin(
   Objects_Information *information;
   char                 name[13];
   uint32_t             ival, fval;
-  Timestamp_Control  uptime, total, used, uptime_at_last_reset;
-  uint32_t seconds, nanoseconds;
-
-  if ( !print )
-    return;
+  Timestamp_Control    uptime, total, used, uptime_at_last_reset;
+  uint32_t             seconds, nanoseconds;
 
   /*
    *  When not using nanosecond CPU usage resolution, we have to count
@@ -58,8 +54,8 @@ void rtems_cpu_usage_report_with_plugin(
   _Timestamp_Set_to_zero( &total );
   uptime_at_last_reset = CPU_usage_Uptime_at_last_reset;
 
-  (*print)(
-     context,
+  rtems_printf(
+     printer,
      "-------------------------------------------------------------------------------\n"
      "                              CPU USAGE BY THREAD\n"
      "------------+----------------------------------------+---------------+---------\n"
@@ -83,8 +79,8 @@ void rtems_cpu_usage_report_with_plugin(
 
         rtems_object_get_name( the_thread->Object.id, sizeof(name), name );
 
-        (*print)(
-          context,
+        rtems_printf(
+          printer,
           " 0x%08" PRIx32 " | %-38s |",
           the_thread->Object.id,
           name
@@ -102,7 +98,7 @@ void rtems_cpu_usage_report_with_plugin(
         seconds = _Timestamp_Get_seconds( &used );
         nanoseconds = _Timestamp_Get_nanoseconds( &used ) /
           TOD_NANOSECONDS_PER_MICROSECOND;
-        (*print)( context,
+        rtems_printf( printer,
           "%7" PRIu32 ".%06" PRIu32 " |%4" PRIu32 ".%03" PRIu32 "\n",
           seconds, nanoseconds,
           ival, fval
@@ -114,8 +110,8 @@ void rtems_cpu_usage_report_with_plugin(
   seconds = _Timestamp_Get_seconds( &total );
   nanoseconds = _Timestamp_Get_nanoseconds( &total ) /
     TOD_NANOSECONDS_PER_MICROSECOND;
-  (*print)(
-     context,
+  rtems_printf(
+     printer,
      "------------+----------------------------------------+---------------+---------\n"
      " TIME SINCE LAST CPU USAGE RESET IN SECONDS:                    %7" PRIu32 ".%06" PRIu32 "\n"
      "-------------------------------------------------------------------------------\n",
@@ -125,5 +121,7 @@ void rtems_cpu_usage_report_with_plugin(
 
 void rtems_cpu_usage_report( void )
 {
-  rtems_cpu_usage_report_with_plugin( NULL, printk_plugin );
+  rtems_printer printer;
+  rtems_print_printer_printk( &printer );
+  rtems_cpu_usage_report_with_plugin( &printer );
 }
diff --git a/cpukit/libmisc/cpuuse/cpuusagetop.c b/cpukit/libmisc/cpuuse/cpuusagetop.c
index cf896e3..2f48eb8 100644
--- a/cpukit/libmisc/cpuuse/cpuusagetop.c
+++ b/cpukit/libmisc/cpuuse/cpuusagetop.c
@@ -41,15 +41,6 @@
 #include <rtems/score/wkspace.h>
 
 /*
- * Common variable to sync the load monitor task.
- */
-typedef struct
-{
-  void*                  context;
-  rtems_printk_plugin_t  print;
-} rtems_cpu_usage_plugin;
-
-/*
  * Use a struct for all data to allow more than one top and to support the
  * thread iterator.
  */
@@ -61,7 +52,7 @@ typedef struct
   volatile uint32_t      sort_order;
   volatile uint32_t      poll_rate_usecs;
   volatile uint32_t      show;
-  rtems_cpu_usage_plugin plugin;
+  const rtems_printer*   printer;
   Timestamp_Control      zero;
   Timestamp_Control      uptime;
   Timestamp_Control      last_uptime;
@@ -144,27 +135,19 @@ static inline bool less_than_uint32_t( uint32_t * lhs, uint32_t * rhs )
     return false;
 }
 
-#define CPU_usage_Equal_to( _lhs, _rhs ) \
-	_Timestamp_Equal_to( _lhs, _rhs )
-
-#define CPU_usage_Set_to_zero( _time ) \
-       _Timestamp_Set_to_zero( _time )
-
-#define CPU_usage_Less_than( _lhs, _rhs ) \
-      _Timestamp_Less_than( _lhs, _rhs )
+#define CPU_usage_Equal_to( _lhs, _rhs )  _Timestamp_Equal_to( _lhs, _rhs )
+#define CPU_usage_Set_to_zero( _time )    _Timestamp_Set_to_zero( _time )
+#define CPU_usage_Less_than( _lhs, _rhs ) _Timestamp_Less_than( _lhs, _rhs )
 
 static void
 print_memsize(rtems_cpu_usage_data* data, const uint32_t size, const char* label)
 {
   if (size > (1024 * 1024))
-    (*data->plugin.print)(data->plugin.context, "%4" PRIu32 "M %s",
-                          size / (1024 * 1024), label);
+    rtems_printf(data->printer, "%4" PRIu32 "M %s", size / (1024 * 1024), label);
   else if (size > 1024)
-    (*data->plugin.print)(data->plugin.context, "%4" PRIu32 "K %s",
-                          size / 1024, label);
+    rtems_printf(data->printer, "%4" PRIu32 "K %s", size / 1024, label);
   else
-    (*data->plugin.print)(data->plugin.context, "%4" PRIu32 " %s",
-                          size, label);
+    rtems_printf(data->printer, "%4" PRIu32 " %s", size, label);
 }
 
 static int
@@ -184,19 +167,19 @@ print_time(rtems_cpu_usage_data*    data,
       uint32_t hours = mins / 60;
       if (hours > 24)
       {
-        len += (*data->plugin.print)(data->plugin.context, "%" PRIu32 "d", hours / 24);
+        len += rtems_printf(data->printer, "%" PRIu32 "d", hours / 24);
         hours %= 24;
       }
-      len += (*data->plugin.print)(data->plugin.context, "%" PRIu32 "hr", hours);
+      len += rtems_printf(data->printer, "%" PRIu32 "hr", hours);
       mins %= 60;
     }
-    len += (*data->plugin.print)(data->plugin.context, "%" PRIu32 "m", mins);
+    len += rtems_printf(data->printer, "%" PRIu32 "m", mins);
     secs %= 60;
   }
-  len += (*data->plugin.print)(data->plugin.context, "%" PRIu32 ".%06" PRIu32, secs, usecs);
+  len += rtems_printf(data->printer, "%" PRIu32 ".%06" PRIu32, secs, usecs);
 
   if (len < length)
-    (*data->plugin.print)(data->plugin.context, "%*c", length - len, ' ');
+    rtems_printf(data->printer, "%*c", length - len, ' ');
 
   return len;
 }
@@ -344,7 +327,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
       data->current_usage = realloc(data->current_usage, usage_size);
       if ((data->tasks == NULL) || (data->usage == NULL) || (data->current_usage == NULL))
       {
-        (*data->plugin.print)(data->plugin.context, "top worker: error: no memory\n");
+        rtems_printf(data->printer, "top worker: error: no memory\n");
         data->thread_run = false;
         break;
       }
@@ -371,7 +354,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
       data->last_usage = realloc(data->last_usage, usage_size);
       if ((data->last_tasks == NULL) || (data->last_usage == NULL))
       {
-        (*data->plugin.print)(data->plugin.context, "top worker: error: no memory\n");
+        rtems_printf(data->printer, "top worker: error: no memory\n");
         data->thread_run = false;
         break;
       }
@@ -396,43 +379,43 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
     _Protected_heap_Get_information(&_Workspace_Area, &wksp);
 
     if (data->single_page)
-      (*data->plugin.print)(data->plugin.context,
-                            "\x1b[H\x1b[J"
-                            " ENTER:Exit  SPACE:Refresh"
-                            "  S:Scroll  A:All  <>:Order  +/-:Lines\n");
-    (*data->plugin.print)(data->plugin.context,"\n");
+      rtems_printf(data->printer,
+                   "\x1b[H\x1b[J"
+                   " ENTER:Exit  SPACE:Refresh"
+                   "  S:Scroll  A:All  <>:Order  +/-:Lines\n");
+    rtems_printf(data->printer, "\n");
 
     /*
      * Uptime and period of this sample.
      */
-    (*data->plugin.print)(data->plugin.context, "Uptime: ");
+    rtems_printf(data->printer, "Uptime: ");
     print_time(data, &data->uptime, 20);
-    (*data->plugin.print)(data->plugin.context, " Period: ");
+    rtems_printf(data->printer, " Period: ");
     print_time(data, &data->period, 20);
 
     /*
      * Task count, load and idle levels.
      */
-    (*data->plugin.print)(data->plugin.context, "\nTasks: %4i  ", data->task_count);
+    rtems_printf(data->printer, "\nTasks: %4i  ", data->task_count);
 
     _Timestamp_Subtract(&data->idle, &data->total, &load);
     _Timestamp_Divide(&load, &data->uptime, &ival, &fval);
-    (*data->plugin.print)(data->plugin.context,
-                          "Load Average: %4" PRIu32 ".%03" PRIu32 "%%", ival, fval);
+    rtems_printf(data->printer,
+                 "Load Average: %4" PRIu32 ".%03" PRIu32 "%%", ival, fval);
     _Timestamp_Subtract(&data->current_idle, &data->current, &load);
     _Timestamp_Divide(&load, &data->period, &ival, &fval);
-    (*data->plugin.print)(data->plugin.context,
-                          "  Load: %4" PRIu32 ".%03" PRIu32 "%%", ival, fval);
+    rtems_printf(data->printer,
+                 "  Load: %4" PRIu32 ".%03" PRIu32 "%%", ival, fval);
     _Timestamp_Divide(&data->current_idle, &data->period, &ival, &fval);
-    (*data->plugin.print)(data->plugin.context,
-                          "  Idle: %4" PRIu32 ".%03" PRIu32 "%%", ival, fval);
+    rtems_printf(data->printer,
+                 "  Idle: %4" PRIu32 ".%03" PRIu32 "%%", ival, fval);
 
     /*
      * Memory usage.
      */
     if (rtems_configuration_get_unified_work_area())
     {
-      (*data->plugin.print)(data->plugin.context, "\nMem: ");
+      rtems_printf(data->printer, "\nMem: ");
       print_memsize(data, wksp.Free.total, "free");
       print_memsize(data, wksp.Used.total, "used");
     }
@@ -440,7 +423,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
     {
       region_information_block libc_heap;
       malloc_info(&libc_heap);
-      (*data->plugin.print)(data->plugin.context, "\nMem: Wksp: ");
+      rtems_printf(data->printer, "\nMem: Wksp: ");
       print_memsize(data, wksp.Free.total, "free");
       print_memsize(data, wksp.Used.total, "used  Heap: ");
       print_memsize(data, libc_heap.Free.total, "free");
@@ -449,7 +432,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
 
     print_memsize(data, data->stack_size, "stack\n");
 
-    (*data->plugin.print)(data->plugin.context,
+    rtems_printf(data->printer,
        "\n"
         " ID         | NAME                | RPRI | CPRI   | TIME                | TOTAL   | CURRENT\n"
         "-%s---------+---------------------+-%s-----%s-----+---------------------+-%s------+--%s----\n",
@@ -487,12 +470,12 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
       if (name[0] == '\0')
         snprintf(name, sizeof(name) - 1, "(%p)", thread->Start.Entry.Kinds.Numeric.entry);
 
-      (*data->plugin.print)(data->plugin.context,
-                            " 0x%08" PRIx32 " | %-19s |  %3" PRId32 " |  %3" PRId32 "   | ",
-                            thread->Object.id,
-                            name,
-                            thread->real_priority,
-                            thread->current_priority);
+      rtems_printf(data->printer,
+                   " 0x%08" PRIx32 " | %-19s |  %3" PRId32 " |  %3" PRId32 "   | ",
+                   thread->Object.id,
+                   name,
+                   thread->real_priority,
+                   thread->current_priority);
 
       usage = data->usage[i];
       current_usage = data->current_usage[i];
@@ -502,11 +485,11 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
        */
       print_time(data, &usage, 19);
       _Timestamp_Divide(&usage, &data->total, &ival, &fval);
-      (*data->plugin.print)(data->plugin.context,
-                            " |%4" PRIu32 ".%03" PRIu32, ival, fval);
+      rtems_printf(data->printer,
+                   " |%4" PRIu32 ".%03" PRIu32, ival, fval);
       _Timestamp_Divide(&current_usage, &data->period, &ival, &fval);
-      (*data->plugin.print)(data->plugin.context,
-                            " |%4" PRIu32 ".%03" PRIu32 "\n", ival, fval);
+      rtems_printf(data->printer,
+                   " |%4" PRIu32 ".%03" PRIu32 "\n", ival, fval);
     }
 
     if (data->single_page && (data->show != 0) && (task_count < data->show))
@@ -514,7 +497,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
       i = data->show - task_count;
       while (i > 0)
       {
-        (*data->plugin.print)(data->plugin.context, "\x1b[K\n");
+        rtems_printf(data->printer, "\x1b[K\n");
         i--;
       }
     }
@@ -525,8 +508,8 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
                              &out);
     if ((sc != RTEMS_SUCCESSFUL) && (sc != RTEMS_TIMEOUT))
     {
-      (*data->plugin.print)(data->plugin.context,
-                            "error: event receive: %s\n", rtems_status_text(sc));
+      rtems_printf(data->printer,
+                   "error: event receive: %s\n", rtems_status_text(sc));
       break;
     }
   }
@@ -542,8 +525,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
 }
 
 void rtems_cpu_usage_top_with_plugin(
-  void                  *context,
-  rtems_printk_plugin_t  print
+  const rtems_printer *printer
 )
 {
   rtems_status_code      sc;
@@ -553,9 +535,6 @@ void rtems_cpu_usage_top_with_plugin(
   rtems_cpu_usage_data   data;
   int                    show_lines = 25;
 
-  if ( !print )
-    return;
-
   memset(&data, 0, sizeof(data));
 
   data.thread_run = true;
@@ -563,18 +542,14 @@ void rtems_cpu_usage_top_with_plugin(
   data.sort_order = RTEMS_TOP_SORT_CURRENT;
   data.poll_rate_usecs = 3000;
   data.show = show_lines;
-  data.plugin.context = context;
-  data.plugin.print = print;
+  data.printer = printer;
 
   sc = rtems_task_set_priority (RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority);
 
   if (sc != RTEMS_SUCCESSFUL)
   {
-    (*print)(
-       context,
-       "error: cannot obtain the current priority: %s\n",
-       rtems_status_text (sc)
-    );
+    rtems_printf (printer,
+                  "error: cannot obtain the current priority: %s\n", rtems_status_text (sc));
     return;
   }
 
@@ -587,24 +562,16 @@ void rtems_cpu_usage_top_with_plugin(
 
   if (sc != RTEMS_SUCCESSFUL)
   {
-    (*print)(
-       context,
-       "error: cannot create helper thread: %s\n",
-       rtems_status_text (sc)
-    );
+    rtems_printf (printer,
+                  "error: cannot create helper thread: %s\n", rtems_status_text (sc));
     return;
   }
 
-  sc = rtems_task_start (
-    id, rtems_cpuusage_top_thread, (rtems_task_argument) &data
-  );
+  sc = rtems_task_start (id, rtems_cpuusage_top_thread, (rtems_task_argument) &data);
   if (sc != RTEMS_SUCCESSFUL)
   {
-    (*print)(
-       context,
-       "error: cannot start helper thread: %s\n",
-       rtems_status_text (sc)
-    );
+    rtems_printf (printer,
+                  "error: cannot start helper thread: %s\n", rtems_status_text (sc));
     rtems_task_delete (id);
     return;
   }
@@ -624,7 +591,7 @@ void rtems_cpu_usage_top_with_plugin(
       while (loops && data.thread_active)
         rtems_task_wake_after (RTEMS_MICROSECONDS_TO_TICKS (100000));
 
-      (*print)(context, "load monitoring stopped.\n");
+      rtems_printf (printer, "load monitoring stopped.\n");
       return;
     }
     else if (c == '<')
@@ -676,7 +643,9 @@ void rtems_cpu_usage_top_with_plugin(
   }
 }
 
-void rtems_cpu_usage_top( void )
+void rtems_cpu_usage_top (void)
 {
-  rtems_cpu_usage_top_with_plugin( NULL, printk_plugin );
+  rtems_printer printer;
+  rtems_print_printer_printk (&printer);
+  rtems_cpu_usage_top_with_plugin (&printer);
 }
diff --git a/cpukit/libmisc/cpuuse/cpuuse.h b/cpukit/libmisc/cpuuse/cpuuse.h
index 1e26019..1a3d2a7 100644
--- a/cpukit/libmisc/cpuuse/cpuuse.h
+++ b/cpukit/libmisc/cpuuse/cpuuse.h
@@ -1,6 +1,6 @@
 /**
  * @file rtems/cpuuse.h
- * 
+ *
  * @defgroup libmisc_cpuuse CPU Usage
  *
  * @ingroup libmisc
@@ -23,7 +23,7 @@
 #define __RTEMS_CPUUSE_h
 
 #include <rtems.h>
-#include <rtems/bspIo.h>
+#include <rtems/print.h>
 
 #include <rtems/score/timestamp.h>
 
@@ -43,10 +43,7 @@ extern Timestamp_Control  CPU_usage_Uptime_at_last_reset;
  * rtems_cpu_usage_report_with_handler
  */
 
-void rtems_cpu_usage_report_with_plugin(
-  void                  *context,
-  rtems_printk_plugin_t  handler
-);
+void rtems_cpu_usage_report_with_plugin( const rtems_printer *printer );
 
 /**
  *  @brief Report CPU usage.
@@ -62,10 +59,7 @@ void rtems_cpu_usage_report( void );
  *   Report CPU Usage in top format to
  *   to a print plugin.
  */
-void rtems_cpu_usage_top_with_plugin(
-  void                  *context,
-  rtems_printk_plugin_t  print
-);
+void rtems_cpu_usage_top_with_plugin( const rtems_printer *printer );
 
 /**
  *  @brief CPU usage top.
diff --git a/cpukit/libmisc/fb/mw_print.c b/cpukit/libmisc/fb/mw_print.c
index 8f4e465..25a3456 100644
--- a/cpukit/libmisc/fb/mw_print.c
+++ b/cpukit/libmisc/fb/mw_print.c
@@ -43,12 +43,13 @@ void uid_print_message(
   struct MW_UID_MESSAGE *uid
 )
 {
-  uid_print_message_with_plugin( NULL, printk_plugin, uid );
+  rtems_printer printer;
+  rtems_print_printer_printk(&printer);
+  uid_print_message_with_plugin( &printer, uid );
 }
 
 void uid_print_message_with_plugin(
-  void                  *context,
-  rtems_printk_plugin_t  handler,
+  const rtems_printer   *printer,
   struct MW_UID_MESSAGE *uid
 )
 {
@@ -56,11 +57,11 @@ void uid_print_message_with_plugin(
 
   switch (uid->type) {
     case MV_UID_INVALID:
-      (*handler)( context, "MV_UID_INVALID\n" );
+      rtems_printf( printer, "MV_UID_INVALID\n" );
       break;
     case MV_UID_REL_POS:
-      (*handler)(
-        context,
+      rtems_printf(
+        printer,
         "MV_UID_REL_POS - %s x=%d y=%d z=%d\n",
         uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)),
         uid->m.pos.x,    /* x location */
@@ -69,8 +70,8 @@ void uid_print_message_with_plugin(
       );
       break;
     case MV_UID_ABS_POS:
-      (*handler)(
-        context,
+      rtems_printf(
+        printer,
         "MV_UID_ABS_POS - %s x=%d y=%d z=%d\n",
         uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)),
         uid->m.pos.x,    /* x location */
@@ -79,7 +80,7 @@ void uid_print_message_with_plugin(
       );
       break;
     case MV_UID_KBD:
-      (*handler)( context,
+      rtems_printf( printer,
         "MV_UID_KBD - code=0x%04x modifiers=0x%02x mode=0x%02x\n",
         uid->m.kbd.code,        /* keycode or scancode        */
         uid->m.kbd.modifiers,   /* key modifiers              */
@@ -87,10 +88,10 @@ void uid_print_message_with_plugin(
       );
       break;
    case MV_UID_TIMER:
-      (*handler)( context, "MV_UID_TIMER\n" );
+      rtems_printf( printer, "MV_UID_TIMER\n" );
       break;
     default:
-      (*handler)( context, "Invalid device type\n" );
+      rtems_printf( printer, "Invalid device type\n" );
       break;
   }
 
diff --git a/cpukit/libmisc/fb/mw_uid.h b/cpukit/libmisc/fb/mw_uid.h
index 8a10a8f..aa88392 100644
--- a/cpukit/libmisc/fb/mw_uid.h
+++ b/cpukit/libmisc/fb/mw_uid.h
@@ -18,7 +18,7 @@
 #define _MW_UID_H
 
 #include <sys/types.h>
-#include <rtems/bspIo.h>
+#include <rtems/print.h>
 
 /**
  *  @defgroup libmisc_fb_mw Input Devices for MicroWindows
@@ -179,14 +179,11 @@ void uid_print_message(
  * This methods prints the specified UID message using your fprintf
  * style method of choice.
  *
- * @param[in] context is a pointer to a data area which may be
- *            used by some print handlers
- * @param[in] handler is the fprintf style method to invoke
+ * @param[in] RTEMS printer
  * @param[in] uid points to the message to print
  */
 void uid_print_message_with_plugin(
-  void                  *context,
-  rtems_printk_plugin_t  handler,
+  const rtems_printer   *printer,
   struct MW_UID_MESSAGE *uid
 );
 
diff --git a/cpukit/libmisc/shell/main_blkstats.c b/cpukit/libmisc/shell/main_blkstats.c
index 50d783d..d814df6 100644
--- a/cpukit/libmisc/shell/main_blkstats.c
+++ b/cpukit/libmisc/shell/main_blkstats.c
@@ -31,6 +31,7 @@ static int rtems_shell_main_blkstats(int argc, char **argv)
   bool ok = false;
   bool reset = false;
   const char *device;
+  rtems_printer printer;
 
   if (argc == 2) {
     ok = true;
@@ -41,10 +42,12 @@ static int rtems_shell_main_blkstats(int argc, char **argv)
     device = argv [2];
   }
 
+  rtems_print_printer_printf(&printer);
+
   if (ok) {
-    rtems_blkstats(stdout, device, reset);
+    rtems_blkstats(&printer, device, reset);
   } else {
-    fprintf(stdout, "usage: %s\n", rtems_shell_BLKSTATS_Command.usage);
+    rtems_printf(&printer, "usage: %s\n", rtems_shell_BLKSTATS_Command.usage);
   }
 
   return 0;
diff --git a/cpukit/libmisc/shell/main_cpuuse.c b/cpukit/libmisc/shell/main_cpuuse.c
index c1f991a..190fd03 100644
--- a/cpukit/libmisc/shell/main_cpuuse.c
+++ b/cpukit/libmisc/shell/main_cpuuse.c
@@ -30,7 +30,9 @@ static int rtems_shell_main_cpuuse(
    *  When invoked with no arguments, print the report.
    */
   if ( argc == 1 ) {
-    rtems_cpu_usage_report_with_plugin(stdout, (rtems_printk_plugin_t)fprintf);
+    rtems_printer printer;
+    rtems_print_printer_fprintf(&printer, stdout);
+    rtems_cpu_usage_report_with_plugin(&printer);
     return 0;
   }
 
diff --git a/cpukit/libmisc/shell/main_perioduse.c b/cpukit/libmisc/shell/main_perioduse.c
index 9b33a75..023e154 100644
--- a/cpukit/libmisc/shell/main_perioduse.c
+++ b/cpukit/libmisc/shell/main_perioduse.c
@@ -29,9 +29,10 @@ static int rtems_shell_main_perioduse(
    *  When invoked with no arguments, print the report.
    */
   if ( argc == 1 ) {
+    rtems_printer printer;
+    rtems_print_printer_printf(&printer);
     rtems_rate_monotonic_report_statistics_with_plugin(
-      stdout,
-      (rtems_printk_plugin_t)fprintf
+      &printer
     );
     return 0;
   }
diff --git a/cpukit/libmisc/shell/main_profreport.c b/cpukit/libmisc/shell/main_profreport.c
index d6e4c5a..a98b8ba 100644
--- a/cpukit/libmisc/shell/main_profreport.c
+++ b/cpukit/libmisc/shell/main_profreport.c
@@ -24,10 +24,11 @@
 
 static int rtems_shell_main_profreport(int argc, char **argv)
 {
+  rtems_printer printer;
+  rtems_print_printer_printf(&printer);
   rtems_profiling_report_xml(
     "Shell",
-    (rtems_profiling_printf) fprintf,
-    stdout,
+    &printer,
     0,
     "  "
   );
diff --git a/cpukit/libmisc/shell/main_stackuse.c b/cpukit/libmisc/shell/main_stackuse.c
index 74d47e1..40fc711 100644
--- a/cpukit/libmisc/shell/main_stackuse.c
+++ b/cpukit/libmisc/shell/main_stackuse.c
@@ -25,10 +25,9 @@ static int rtems_shell_main_stackuse(
   char *argv[] RTEMS_UNUSED
 )
 {
-  rtems_stack_checker_report_usage_with_plugin(
-    stdout,
-    (rtems_printk_plugin_t)fprintf
-  );
+  rtems_printer printer;
+  rtems_print_printer_printf(&printer);
+  rtems_stack_checker_report_usage_with_plugin( &printer );
   return 0;
 }
 
diff --git a/cpukit/libmisc/shell/main_top.c b/cpukit/libmisc/shell/main_top.c
index ad6223a..aea50d8 100644
--- a/cpukit/libmisc/shell/main_top.c
+++ b/cpukit/libmisc/shell/main_top.c
@@ -30,7 +30,9 @@ static int rtems_shell_main_top(
    *  When invoked with no arguments, print the report.
    */
   if ( argc == 1 ) {
-    rtems_cpu_usage_top_with_plugin(stdout, (rtems_printk_plugin_t)fprintf);
+    rtems_printer printer;
+    rtems_print_printer_fprintf(&printer, stdout);
+    rtems_cpu_usage_top_with_plugin(&printer);
     return 0;
   }
 
diff --git a/cpukit/libmisc/stackchk/check.c b/cpukit/libmisc/stackchk/check.c
index 9c6932e..93d45de 100644
--- a/cpukit/libmisc/stackchk/check.c
+++ b/cpukit/libmisc/stackchk/check.c
@@ -387,8 +387,7 @@ static inline void *Stack_check_find_high_water_mark(
  *
  *  Try to print out how much stack was actually used by the task.
  */
-static void                   *print_context;
-static rtems_printk_plugin_t   print_handler;
+static const rtems_printer* printer;
 
 static void Stack_check_Dump_threads_usage(
   Thread_Control *the_thread
@@ -438,8 +437,8 @@ static void Stack_check_Dump_threads_usage(
     if ( the_thread )
   #endif
     {
-      (*print_handler)(
-        print_context,
+      rtems_printf(
+        printer,
         "0x%08" PRIx32 "  %4s",
         the_thread->Object.id,
         rtems_object_get_name( the_thread->Object.id, sizeof(name), name )
@@ -447,12 +446,12 @@ static void Stack_check_Dump_threads_usage(
     }
     #if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE)
       else {
-        (*print_handler)( print_context, "0x%08" PRIx32 "  INTR", ~0 );
+        rtems_printf( printer, "0x%08" PRIx32 "  INTR", ~0 );
       }
     #endif
 
-  (*print_handler)(
-    print_context,
+  rtems_printf(
+    printer,
     " %010p - %010p %010p  %8" PRId32 "   ",
     stack->area,
     stack->area + stack->size - 1,
@@ -461,9 +460,9 @@ static void Stack_check_Dump_threads_usage(
   );
 
   if (Stack_check_Initialized == 0) {
-    (*print_handler)( print_context, "Unavailable\n" );
+    rtems_printf( printer, "Unavailable\n" );
   } else {
-    (*print_handler)( print_context, "%8" PRId32 "\n", used );
+    rtems_printf( printer, "%8" PRId32 "\n", used );
   }
 
 
@@ -489,18 +488,16 @@ static void Stack_check_Dump_threads_usage(
  */
 
 void rtems_stack_checker_report_usage_with_plugin(
-  void                  *context,
-  rtems_printk_plugin_t  print
+  const rtems_printer* printer_
 )
 {
-  if ( !print )
+  if ( printer != NULL || ! rtems_print_printer_valid ( printer_ ) )
     return;
 
-  print_context = context;
-  print_handler = print;
+  printer = printer_;
 
-  (*print)( context, "Stack usage by thread\n");
-  (*print)( context,
+  rtems_printf( printer, "Stack usage by thread\n");
+  rtems_printf( printer,
 "    ID      NAME    LOW          HIGH     CURRENT     AVAILABLE     USED\n"
   );
 
@@ -512,11 +509,12 @@ void rtems_stack_checker_report_usage_with_plugin(
     Stack_check_Dump_threads_usage((Thread_Control *) -1);
   #endif
 
-  print_context = NULL;
-  print_handler = NULL;
+  printer = NULL;
 }
 
 void rtems_stack_checker_report_usage( void )
 {
-  rtems_stack_checker_report_usage_with_plugin( NULL, printk_plugin );
+  rtems_printer printer;
+  rtems_print_printer_printk(&printer);
+  rtems_stack_checker_report_usage_with_plugin( &printer );
 }
diff --git a/cpukit/libmisc/stackchk/stackchk.h b/cpukit/libmisc/stackchk/stackchk.h
index b824057..f7f75b6 100644
--- a/cpukit/libmisc/stackchk/stackchk.h
+++ b/cpukit/libmisc/stackchk/stackchk.h
@@ -25,7 +25,7 @@
 #include <stdbool.h> /* bool */
 
 #include <rtems/score/thread.h> /* Thread_Control */
-#include <rtems/bspIo.h>
+#include <rtems/print.h>
 
 /**
  *  @defgroup libmisc_stackchk Stack Checker Mechanism
@@ -71,8 +71,7 @@ void rtems_stack_checker_report_usage( void );
  * @note It uses the caller's routine to print the report.
  */
 void rtems_stack_checker_report_usage_with_plugin(
-  void                  *context,
-  rtems_printk_plugin_t  print
+  const rtems_printer *printer
 );
 
 /*************************************************************
diff --git a/cpukit/libmisc/testsupport/test.h b/cpukit/libmisc/testsupport/test.h
index 497c4b6..980ab66 100644
--- a/cpukit/libmisc/testsupport/test.h
+++ b/cpukit/libmisc/testsupport/test.h
@@ -16,7 +16,7 @@
 #define _RTEMS_TEST_H
 
 #include <rtems.h>
-#include <rtems/bspIo.h>
+#include <rtems/print.h>
 #include <rtems/score/atomic.h>
 #include <rtems/score/smpbarrier.h>
 
@@ -38,6 +38,11 @@ extern "C" {
 extern const char rtems_test_name[];
 
 /**
+ * @brief Each test must define a printer.
+ */
+extern rtems_printer rtems_test_printer;
+
+/**
  * @brief Fatal extension for tests.
  */
 void rtems_test_fatal_extension(
@@ -53,70 +58,35 @@ void rtems_test_fatal_extension(
   { NULL, NULL, NULL, NULL, NULL, NULL, NULL, rtems_test_fatal_extension }
 
 /**
- * @brief Prints a begin of test message.
- *
- * @param[in] printf_func The formatted output function.
- * @param[in, out] printf_arg The formatted output function argument.
- *
- * @returns As specified by printf().
- */
-int rtems_test_begin_with_plugin(
-  rtems_printk_plugin_t printf_func,
-  void *printf_arg
-);
-
-/**
- * @brief Prints a begin of test message using printf().
- *
- * @returns As specified by printf().
+ * @brief Begin of test message format string.
  */
-static inline int rtems_test_begin(void)
-{
-  return rtems_test_begin_with_plugin(rtems_printf_plugin, NULL);
-}
+#define TEST_BEGIN_STRING "\n\n*** BEGIN OF TEST %s ***\n", rtems_test_name
 
 /**
- * @brief Prints a begin of test message using printk().
- *
- * @returns As specified by printf().
+ * @brief End of test message format string.
  */
-static inline int rtems_test_begink(void)
-{
-  return rtems_test_begin_with_plugin(printk_plugin, NULL);
-}
+#define TEST_END_STRING "*** END OF TEST %s ***\n", rtems_test_name
 
 /**
- * @brief Prints an end of test message.
- *
- * @param[in] printf_func The formatted output function.
- * @param[in, out] printf_arg The formatted output function argument.
+ * @brief Prints a begin of test message using printf().
  *
  * @returns As specified by printf().
  */
-int rtems_test_end_with_plugin(
-  rtems_printk_plugin_t printf_func,
-  void *printf_arg
-);
+int rtems_test_begin(void);
 
 /**
  * @brief Prints an end of test message using printf().
  *
  * @returns As specified by printf().
  */
-static inline int rtems_test_end(void)
-{
-  return rtems_test_end_with_plugin(rtems_printf_plugin, NULL);
-}
+int rtems_test_end(void);
 
 /**
- * @brief Prints an end of test message using printk().
+ * @brief Prints via the RTEMS printer.
  *
  * @returns As specified by printf().
  */
-static inline int rtems_test_endk(void)
-{
-  return rtems_test_end_with_plugin(printk_plugin, NULL);
-}
+int rtems_test_print(const char* format, ...) RTEMS_PRINTF_ATTRIBUTE(1, 2);
 
 /**
  * @brief Internal context for parallel job execution.
diff --git a/cpukit/libmisc/testsupport/testbeginend.c b/cpukit/libmisc/testsupport/testbeginend.c
index 6383b33..6bfc400 100644
--- a/cpukit/libmisc/testsupport/testbeginend.c
+++ b/cpukit/libmisc/testsupport/testbeginend.c
@@ -18,26 +18,35 @@
 
 #include <rtems/test.h>
 
-int rtems_test_begin_with_plugin(
-  rtems_printk_plugin_t printf_func,
-  void *printf_arg
-)
+int rtems_test_begin(void)
+{
+  return rtems_printf(
+    &rtems_test_printer,
+    TEST_BEGIN_STRING
+  );
+}
+
+int rtems_test_end(void)
 {
-  return (*printf_func)(
-    printf_arg,
-    "\n\n*** BEGIN OF TEST %s ***\n",
-    rtems_test_name
+  return rtems_printf(
+    &rtems_test_printer,
+    TEST_END_STRING
   );
 }
 
-int rtems_test_end_with_plugin(
-  rtems_printk_plugin_t printf_func,
-  void *printf_arg
+int rtems_test_print(
+  const char* format,
+  ...
 )
 {
-  return (*printf_func)(
-    printf_arg,
-    "*** END OF TEST %s ***\n",
-    rtems_test_name
+  va_list ap;
+  int len;
+  va_start(ap, format);
+  len = rtems_vprintf(
+    &rtems_test_printer,
+    format,
+    ap
   );
+  va_end(ap);
+  return len;
 }
diff --git a/cpukit/libmisc/testsupport/testextension.c b/cpukit/libmisc/testsupport/testextension.c
index a689e66..43f79bc 100644
--- a/cpukit/libmisc/testsupport/testextension.c
+++ b/cpukit/libmisc/testsupport/testextension.c
@@ -33,6 +33,9 @@ void rtems_test_fatal_extension(
 {
 #if defined(RTEMS_PROFILING)
   rtems_interrupt_lock_context lock_context;
+  rtems_printer printer;
+
+  rtems_print_printer_printk( &printer );
 
   /*
    * Ensures to report only once on SMP machines and ensures that the report is
@@ -50,8 +53,7 @@ void rtems_test_fatal_extension(
 
     rtems_profiling_report_xml(
       rtems_test_name,
-      printk_plugin,
-      NULL,
+      &printer,
       1,
       "  "
     );
diff --git a/cpukit/preinstall.am b/cpukit/preinstall.am
index c8f2cd3..fdf2016 100644
--- a/cpukit/preinstall.am
+++ b/cpukit/preinstall.am
@@ -224,6 +224,10 @@ $(PROJECT_INCLUDE)/rtems/bspIo.h: include/rtems/bspIo.h $(PROJECT_INCLUDE)/rtems
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bspIo.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/bspIo.h
 
+$(PROJECT_INCLUDE)/rtems/print.h: include/rtems/print.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/print.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/print.h
+
 $(PROJECT_INCLUDE)/rtems/userenv.h: include/rtems/userenv.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/userenv.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/userenv.h
diff --git a/cpukit/rtems/include/rtems/rtems/ratemon.h b/cpukit/rtems/include/rtems/rtems/ratemon.h
index 87bd064..6e8fab6 100644
--- a/cpukit/rtems/include/rtems/rtems/ratemon.h
+++ b/cpukit/rtems/include/rtems/rtems/ratemon.h
@@ -35,7 +35,7 @@
 #include <rtems/rtems/status.h>
 #include <rtems/score/thread.h>
 #include <rtems/score/watchdog.h>
-#include <rtems/bspIo.h>
+#include <rtems/print.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -356,14 +356,13 @@ void rtems_rate_monotonic_reset_all_statistics( void );
  *  @brief RTEMS Report Rate Monotonic Statistics
  *
  *  This routine allows a thread to print the statistics information
- *  on ALL period instances which have non-zero counts using printk.
- *  The implementation of this directive straddles the fence between
- *  inside and outside of RTEMS.  It is presented as part of the Manager
- *  but actually uses other services of the Manager.
+ *  on ALL period instances which have non-zero counts using the RTEMS
+ *  printer. The implementation of this directive straddles the fence
+ *  between inside and outside of RTEMS.  It is presented as part of
+ *  the Manager but actually uses other services of the Manager.
  */
 void rtems_rate_monotonic_report_statistics_with_plugin(
-  void                  *context,
-  rtems_printk_plugin_t  print
+  const rtems_printer *printer
 );
 
 /**
diff --git a/cpukit/rtems/src/ratemonreportstatistics.c b/cpukit/rtems/src/ratemonreportstatistics.c
index 856d431..3f264df 100644
--- a/cpukit/rtems/src/ratemonreportstatistics.c
+++ b/cpukit/rtems/src/ratemonreportstatistics.c
@@ -20,6 +20,7 @@
 
 #include <rtems/rtems/ratemonimpl.h>
 #include <rtems/rtems/object.h>
+#include <rtems/print.h>
 
 #include <inttypes.h>
 
@@ -29,8 +30,7 @@
 #define NANOSECONDS_FMT "%06" PRId32
 
 void rtems_rate_monotonic_report_statistics_with_plugin(
-  void                  *context,
-  rtems_printk_plugin_t  print
+  const rtems_printer *printer
 )
 {
   rtems_status_code                      status;
@@ -39,12 +39,9 @@ void rtems_rate_monotonic_report_statistics_with_plugin(
   rtems_rate_monotonic_period_status     the_status;
   char                                   name[5];
 
-  if ( !print )
-    return;
-
-  (*print)( context, "Period information by period\n" );
-  (*print)( context, "--- CPU times are in seconds ---\n" );
-  (*print)( context, "--- Wall times are in seconds ---\n" );
+  rtems_printf( printer, "Period information by period\n" );
+  rtems_printf( printer, "--- CPU times are in seconds ---\n" );
+  rtems_printf( printer, "--- Wall times are in seconds ---\n" );
 /*
 Layout by columns -- in memory of Hollerith :)
 
@@ -58,7 +55,7 @@ ididididid NNNN ccccc mmmmmm X
 1234567890123456789012345678901234567890123456789012345678901234567890123456789\
 \n");
 */
-  (*print)( context,
+  rtems_printf( printer,
       "   ID     OWNER COUNT MISSED     "
       "     CPU TIME                  WALL TIME\n"
       "                               "
@@ -90,7 +87,7 @@ ididididid NNNN ccccc mmmmmm X
     /*
      *  Print part of report line that is not dependent on granularity
      */
-    (*print)( context,
+    rtems_printf( printer,
       "0x%08" PRIx32 " %4s %5" PRId32 " %6" PRId32 " ",
       id, name,
       the_stats.count, the_stats.missed_count
@@ -100,7 +97,7 @@ ididididid NNNN ccccc mmmmmm X
      *  If the count is zero, don't print statistics
      */
     if (the_stats.count == 0) {
-      (*print)( context, "\n" );
+      rtems_printf( printer, "\n" );
       continue;
     }
 
@@ -114,7 +111,7 @@ ididididid NNNN ccccc mmmmmm X
       struct timespec *total_cpu = &the_stats.total_cpu_time;
 
       _Timespec_Divide_by_integer( total_cpu, the_stats.count, &cpu_average );
-      (*print)( context,
+      rtems_printf( printer,
         "%" PRId32 "."  NANOSECONDS_FMT "/"        /* min cpu time */
         "%" PRId32 "."  NANOSECONDS_FMT "/"        /* max cpu time */
         "%" PRId32 "."  NANOSECONDS_FMT " ",       /* avg cpu time */
@@ -137,7 +134,7 @@ ididididid NNNN ccccc mmmmmm X
       struct timespec *total_wall = &the_stats.total_wall_time;
 
       _Timespec_Divide_by_integer(total_wall, the_stats.count, &wall_average);
-      (*print)( context,
+      rtems_printf( printer,
         "%" PRId32 "." NANOSECONDS_FMT "/"        /* min wall time */
         "%" PRId32 "." NANOSECONDS_FMT "/"        /* max wall time */
         "%" PRId32 "." NANOSECONDS_FMT "\n",      /* avg wall time */
@@ -154,5 +151,7 @@ ididididid NNNN ccccc mmmmmm X
 
 void rtems_rate_monotonic_report_statistics( void )
 {
-  rtems_rate_monotonic_report_statistics_with_plugin( NULL, printk_plugin );
+  rtems_printer printer;
+  rtems_print_printer_printk( &printer );
+  rtems_rate_monotonic_report_statistics_with_plugin( &printer );
 }
diff --git a/cpukit/sapi/include/rtems/profiling.h b/cpukit/sapi/include/rtems/profiling.h
index 836e6d8..9e434b2 100644
--- a/cpukit/sapi/include/rtems/profiling.h
+++ b/cpukit/sapi/include/rtems/profiling.h
@@ -25,6 +25,8 @@
 
 #include <stdint.h>
 
+#include <rtems/print.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
@@ -306,24 +308,10 @@ void rtems_profiling_iterate(
 );
 
 /**
- * @brief Function for formatted output.
- *
- * @param[in, out] arg Some argument.
- * @param[in] format The output format as specified by printf().
- * @param[in] ... More parameters according to format.
- *
- * @returns As specified by printf().
- *
- * @see rtems_profiling_report_xml().
- */
-typedef int (*rtems_profiling_printf)(void *arg, const char *format, ...);
-
-/**
  * @brief Reports profiling data as XML.
  *
  * @param[in] name The name of the profiling report.
- * @param[in] printf_func The formatted output function.
- * @param[in, out] printf_arg The formatted output function argument.
+ * @param[in] printer The RTEMS printer to send the output too.
  * @param[in] indentation_level The current indentation level.
  * @param[in] indentation The string used for indentation.
  *
@@ -331,8 +319,7 @@ typedef int (*rtems_profiling_printf)(void *arg, const char *format, ...);
  */
 int rtems_profiling_report_xml(
   const char *name,
-  rtems_profiling_printf printf_func,
-  void *printf_arg,
+  const rtems_printer *printer,
   uint32_t indentation_level,
   const char *indentation
 );
diff --git a/cpukit/sapi/src/profilingreportxml.c b/cpukit/sapi/src/profilingreportxml.c
index 777d1f1..e643146 100644
--- a/cpukit/sapi/src/profilingreportxml.c
+++ b/cpukit/sapi/src/profilingreportxml.c
@@ -23,8 +23,7 @@
 #include <inttypes.h>
 
 typedef struct {
-  rtems_profiling_printf printf_func;
-  void *printf_arg;
+  const rtems_printer *printer;
   uint32_t indentation_level;
   const char *indentation;
   int retval;
@@ -43,7 +42,7 @@ static void indent(context *ctx, uint32_t indentation_level)
   uint32_t i;
 
   for (i = 0; i < n; ++i) {
-    int rv = (*ctx->printf_func)(ctx->printf_arg, "%s", ctx->indentation);
+    int rv = rtems_printf(ctx->printer, "%s", ctx->indentation);
 
     update_retval(ctx, rv);
   }
@@ -56,21 +55,19 @@ static uint64_t arithmetic_mean(uint64_t total, uint64_t count)
 
 static void report_per_cpu(context *ctx, const rtems_profiling_per_cpu *per_cpu)
 {
-  rtems_profiling_printf printf_func = ctx->printf_func;
-  void *printf_arg = ctx->printf_arg;
   int rv;
 
   indent(ctx, 1);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<PerCPUProfilingReport processorIndex=\"%" PRIu32 "\">\n",
     per_cpu->processor_index
   );
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<MaxThreadDispatchDisabledTime unit=\"ns\">%" PRIu32
       "</MaxThreadDispatchDisabledTime>\n",
     per_cpu->max_thread_dispatch_disabled_time
@@ -78,8 +75,8 @@ static void report_per_cpu(context *ctx, const rtems_profiling_per_cpu *per_cpu)
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<MeanThreadDispatchDisabledTime unit=\"ns\">%" PRIu64
       "</MeanThreadDispatchDisabledTime>\n",
     arithmetic_mean(
@@ -90,8 +87,8 @@ static void report_per_cpu(context *ctx, const rtems_profiling_per_cpu *per_cpu)
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<TotalThreadDispatchDisabledTime unit=\"ns\">%" PRIu64
       "</TotalThreadDispatchDisabledTime>\n",
     per_cpu->total_thread_dispatch_disabled_time
@@ -99,24 +96,24 @@ static void report_per_cpu(context *ctx, const rtems_profiling_per_cpu *per_cpu)
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<ThreadDispatchDisabledCount>%" PRIu64 "</ThreadDispatchDisabledCount>\n",
     per_cpu->thread_dispatch_disabled_count
   );
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<MaxInterruptDelay unit=\"ns\">%" PRIu32 "</MaxInterruptDelay>\n",
     per_cpu->max_interrupt_delay
   );
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<MaxInterruptTime unit=\"ns\">%" PRIu32
       "</MaxInterruptTime>\n",
     per_cpu->max_interrupt_time
@@ -124,8 +121,8 @@ static void report_per_cpu(context *ctx, const rtems_profiling_per_cpu *per_cpu)
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<MeanInterruptTime unit=\"ns\">%" PRIu64
       "</MeanInterruptTime>\n",
     arithmetic_mean(
@@ -136,24 +133,24 @@ static void report_per_cpu(context *ctx, const rtems_profiling_per_cpu *per_cpu)
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<TotalInterruptTime unit=\"ns\">%" PRIu64 "</TotalInterruptTime>\n",
     per_cpu->total_interrupt_time
   );
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<InterruptCount>%" PRIu64 "</InterruptCount>\n",
     per_cpu->interrupt_count
   );
   update_retval(ctx, rv);
 
   indent(ctx, 1);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "</PerCPUProfilingReport>\n"
   );
   update_retval(ctx, rv);
@@ -161,38 +158,36 @@ static void report_per_cpu(context *ctx, const rtems_profiling_per_cpu *per_cpu)
 
 static void report_smp_lock(context *ctx, const rtems_profiling_smp_lock *smp_lock)
 {
-  rtems_profiling_printf printf_func = ctx->printf_func;
-  void *printf_arg = ctx->printf_arg;
   int rv;
   uint32_t i;
 
   indent(ctx, 1);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<SMPLockProfilingReport name=\"%s\">\n",
     smp_lock->name
   );
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<MaxAcquireTime unit=\"ns\">%" PRIu32 "</MaxAcquireTime>\n",
     smp_lock->max_acquire_time
   );
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<MaxSectionTime unit=\"ns\">%" PRIu32 "</MaxSectionTime>\n",
     smp_lock->max_section_time
   );
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<MeanAcquireTime unit=\"ns\">%" PRIu64
       "</MeanAcquireTime>\n",
     arithmetic_mean(
@@ -203,8 +198,8 @@ static void report_smp_lock(context *ctx, const rtems_profiling_smp_lock *smp_lo
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<MeanSectionTime unit=\"ns\">%" PRIu64
       "</MeanSectionTime>\n",
     arithmetic_mean(
@@ -215,24 +210,24 @@ static void report_smp_lock(context *ctx, const rtems_profiling_smp_lock *smp_lo
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<TotalAcquireTime unit=\"ns\">%" PRIu64 "</TotalAcquireTime>\n",
     smp_lock->total_acquire_time
   );
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<TotalSectionTime unit=\"ns\">%" PRIu64 "</TotalSectionTime>\n",
     smp_lock->total_section_time
   );
   update_retval(ctx, rv);
 
   indent(ctx, 2);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "<UsageCount>%" PRIu64 "</UsageCount>\n",
     smp_lock->usage_count
   );
@@ -240,8 +235,8 @@ static void report_smp_lock(context *ctx, const rtems_profiling_smp_lock *smp_lo
 
   for (i = 0; i < RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS; ++i) {
     indent(ctx, 2);
-    rv = (*printf_func)(
-      printf_arg,
+    rv = rtems_printf(
+      ctx->printer,
       "<ContentionCount initialQueueLength=\"%" PRIu32 "\">%"
         PRIu64 "</ContentionCount>\n",
       i,
@@ -251,8 +246,8 @@ static void report_smp_lock(context *ctx, const rtems_profiling_smp_lock *smp_lo
   }
 
   indent(ctx, 1);
-  rv = (*printf_func)(
-    printf_arg,
+  rv = rtems_printf(
+    ctx->printer,
     "</SMPLockProfilingReport>\n"
   );
   update_retval(ctx, rv);
@@ -276,16 +271,14 @@ static void report(void *arg, const rtems_profiling_data *data)
 
 int rtems_profiling_report_xml(
   const char *name,
-  rtems_profiling_printf printf_func,
-  void *printf_arg,
+  const rtems_printer *printer,
   uint32_t indentation_level,
   const char *indentation
 )
 {
 #ifdef RTEMS_PROFILING
   context ctx_instance = {
-    .printf_func = printf_func,
-    .printf_arg = printf_arg,
+    .printer = printer,
     .indentation_level = indentation_level,
     .indentation = indentation,
     .retval = 0
@@ -294,20 +287,19 @@ int rtems_profiling_report_xml(
   int rv;
 
   indent(ctx, 0);
-  rv = (*printf_func)(printf_arg, "<ProfilingReport name=\"%s\">\n", name);
+  rv = rtems_printf(printer, "<ProfilingReport name=\"%s\">\n", name);
   update_retval(ctx, rv);
 
   rtems_profiling_iterate(report, ctx);
 
   indent(ctx, 0);
-  rv = (*printf_func)(printf_arg, "</ProfilingReport>\n");
+  rv = rtems_printf(printer, "</ProfilingReport>\n");
   update_retval(ctx, rv);
 
   return ctx->retval;
 #else /* RTEMS_PROFILING */
   (void) name;
-  (void) printf_func;
-  (void) printf_arg;
+  (void) printer;
   (void) indentation_level;
   (void) indentation;
 
diff --git a/cpukit/score/src/cpusetprintsupport.c b/cpukit/score/src/cpusetprintsupport.c
index 76851d3..83345d9 100644
--- a/cpukit/score/src/cpusetprintsupport.c
+++ b/cpukit/score/src/cpusetprintsupport.c
@@ -23,16 +23,15 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <inttypes.h>
-#include <rtems/bspIo.h>
+#include <rtems/print.h>
 #include <rtems/score/cpusetimpl.h>
 
 #ifdef __RTEMS_HAVE_SYS_CPUSET_H__
 
   void _CPU_set_Show_with_plugin(
-    void                  *context,
-    rtems_printk_plugin_t  print,
-    const char            *description,
-    const cpu_set_t       *cpuset
+    const rtems_printer *printer,
+    const char          *description,
+    const cpu_set_t     *cpuset
   );
 
   /*
@@ -42,21 +41,16 @@
    * print plugin .
    */
   void _CPU_set_Show_with_plugin(
-    void                  *context,
-    rtems_printk_plugin_t  print,
-    const char            *description,
-    const cpu_set_t       *cpuset
+    const rtems_printer *printer,
+    const char          *description,
+    const cpu_set_t     *cpuset
   )
   {
     int i;
-
-    if ( !print )
-      return;
-
-    (*print)(context ,"%s: ", description);
+    rtems_printf(printer ,"%s: ", description);
     for(i=0; i<_NCPUWORDS; i++)
-      (*print)(context ,"%x", cpuset->__bits[i]);
-    (*print)(context ,"\n");
+      rtems_printf(printer ,"%x", cpuset->__bits[i]);
+    rtems_printf(printer ,"\n");
   }
 
   /*
@@ -67,7 +61,9 @@
    */
   void _CPU_set_Show( const char *description, const cpu_set_t   *cpuset)
   {
-    _CPU_set_Show_with_plugin( NULL, printk_plugin, description, cpuset );
+    rtems_printer printer;
+    rtems_print_printer_printk( &printer );
+    _CPU_set_Show_with_plugin( &printer, description, cpuset );
   }
 
   /*
diff --git a/testsuites/fstests/fsnofs01/init.c b/testsuites/fstests/fsnofs01/init.c
index 298ba8d..ff2c2a8 100644
--- a/testsuites/fstests/fsnofs01/init.c
+++ b/testsuites/fstests/fsnofs01/init.c
@@ -495,7 +495,7 @@ static void test_check_access(void)
 
 static void Init(rtems_task_argument arg)
 {
-  rtems_test_begink();
+  TEST_BEGIN();
 
   test_initial_values();
   test_location_obtain();
@@ -506,7 +506,7 @@ static void Init(rtems_task_argument arg)
   test_user_env();
   test_check_access();
 
-  rtems_test_endk();
+  TEST_END();
   exit(0);
 }
 
diff --git a/testsuites/libtests/block02/init.c b/testsuites/libtests/block02/init.c
index f53dacc..8630641 100644
--- a/testsuites/libtests/block02/init.c
+++ b/testsuites/libtests/block02/init.c
@@ -24,6 +24,7 @@
 #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
 #include "tmacros.h"
 
 #include <rtems.h>
@@ -82,7 +83,7 @@ static void task_low(rtems_task_argument arg)
 
   rtems_test_assert(bd->dd == dd_a);
 
-  rtems_test_endk();
+  TEST_END();
 
   exit(0);
 }
@@ -136,7 +137,7 @@ static rtems_task Init(rtems_task_argument argument)
   dev_t dev_a = 0;
   dev_t dev_b = 0;
 
-  rtems_test_begink();
+  TEST_BEGIN();
 
   sc = rtems_disk_io_initialize();
   ASSERT_SC(sc);
diff --git a/testsuites/libtests/block03/init.c b/testsuites/libtests/block03/init.c
index 1da59f0..f2a18b9 100644
--- a/testsuites/libtests/block03/init.c
+++ b/testsuites/libtests/block03/init.c
@@ -24,6 +24,7 @@
 #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
 #include "tmacros.h"
 
 #include <rtems.h>
@@ -76,7 +77,7 @@ static void task_low(rtems_task_argument arg)
 
   rtems_test_assert(bd->block == 0);
 
-  rtems_test_endk();
+  TEST_END();
 
   exit(0);
 }
@@ -129,7 +130,7 @@ static rtems_task Init(rtems_task_argument argument)
   rtems_bdbuf_buffer *bd = NULL;
   dev_t dev = 0;
 
-  rtems_test_begink();
+  TEST_BEGIN();
 
   sc = rtems_disk_io_initialize();
   ASSERT_SC(sc);
diff --git a/testsuites/libtests/block04/init.c b/testsuites/libtests/block04/init.c
index 6731556..3f448c7 100644
--- a/testsuites/libtests/block04/init.c
+++ b/testsuites/libtests/block04/init.c
@@ -24,6 +24,7 @@
 #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
 #include "tmacros.h"
 
 #include <rtems.h>
@@ -101,7 +102,7 @@ static void task_high(rtems_task_argument arg)
 
   printk("H: release done: 0\n");
 
-  rtems_test_endk();
+  TEST_END();
 
   exit(0);
 }
@@ -111,7 +112,7 @@ static rtems_task Init(rtems_task_argument argument)
   rtems_status_code sc = RTEMS_SUCCESSFUL;
   dev_t dev = 0;
 
-  rtems_test_begink();
+  TEST_BEGIN();
 
   sc = rtems_disk_io_initialize();
   ASSERT_SC(sc);
diff --git a/testsuites/libtests/block05/init.c b/testsuites/libtests/block05/init.c
index 59889cc..7cce2ac 100644
--- a/testsuites/libtests/block05/init.c
+++ b/testsuites/libtests/block05/init.c
@@ -24,6 +24,7 @@
 #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
 #include "tmacros.h"
 #include <stdarg.h>
 #include <errno.h>
@@ -426,7 +427,7 @@ static rtems_task Init(rtems_task_argument argument)
   rtems_status_code sc = RTEMS_SUCCESSFUL;
   unsigned i = 0;
 
-  rtems_test_begink();
+  TEST_BEGIN();
 
   task_id_init = rtems_task_self();
 
@@ -505,7 +506,7 @@ static rtems_task Init(rtems_task_argument argument)
     }
   }
 
-  rtems_test_endk();
+  TEST_END();
 
   exit(0);
 }
diff --git a/testsuites/libtests/block06/init.c b/testsuites/libtests/block06/init.c
index 2234034..1b91ad7 100644
--- a/testsuites/libtests/block06/init.c
+++ b/testsuites/libtests/block06/init.c
@@ -32,7 +32,7 @@
 
 #include <bsp.h>
 
-#include <tmacros.h>
+#include "tmacros.h"
 
 const char rtems_test_name[] = "BLOCK 6";
 
diff --git a/testsuites/libtests/block07/init.c b/testsuites/libtests/block07/init.c
index f34e412..cd1b64a 100644
--- a/testsuites/libtests/block07/init.c
+++ b/testsuites/libtests/block07/init.c
@@ -27,6 +27,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+
+#define TESTS_USE_PRINTK
 #include "tmacros.h"
 
 #include <rtems.h>
@@ -102,7 +104,7 @@ static void task_low(rtems_task_argument arg)
 
   printk("L: release done: 0\n");
 
-  rtems_test_endk();
+  TEST_END();
 
   exit(0);
 }
@@ -164,7 +166,7 @@ static rtems_task Init(rtems_task_argument argument)
   rtems_bdbuf_buffer *bd = NULL;
   dev_t dev = 0;
 
-  rtems_test_begink();
+  TEST_BEGIN();
 
   sc = rtems_disk_io_initialize();
   ASSERT_SC(sc);
diff --git a/testsuites/libtests/block08/init.c b/testsuites/libtests/block08/init.c
index 84e755f..83eaf6d 100644
--- a/testsuites/libtests/block08/init.c
+++ b/testsuites/libtests/block08/init.c
@@ -19,6 +19,8 @@
 #include "config.h"
 #endif
 
+#include "tmacros.h"
+
 #define CONFIGURE_INIT
 #include "system.h"
 
@@ -30,10 +32,9 @@ const char rtems_test_name[] = "BLOCK 8";
 
 rtems_task Init(rtems_task_argument argument)
 {
-  rtems_test_begin();
+  TEST_BEGIN();
   run_bdbuf_tests();
-  rtems_test_end();
+  TEST_END();
 
   exit(0);
 }
-
diff --git a/testsuites/libtests/block09/init.c b/testsuites/libtests/block09/init.c
index 2d7cc7a..45e3b7a 100644
--- a/testsuites/libtests/block09/init.c
+++ b/testsuites/libtests/block09/init.c
@@ -24,6 +24,9 @@
 #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <assert.h>
 #include <errno.h>
 #include <stdlib.h>
@@ -176,7 +179,7 @@ static rtems_task Init(rtems_task_argument argument)
   dev_t dev = 0;
   rtems_disk_device *dd = NULL;
 
-  rtems_test_begink();
+  TEST_BEGIN();
 
   sc = rtems_disk_io_initialize();
   ASSERT_SC(sc);
@@ -224,7 +227,7 @@ static rtems_task Init(rtems_task_argument argument)
   sc = rtems_disk_release(dd);
   ASSERT_SC(sc);
 
-  rtems_test_endk();
+  TEST_END();
 
   exit(0);
 }
diff --git a/testsuites/libtests/block10/init.c b/testsuites/libtests/block10/init.c
index fac6781..1cdc91e 100644
--- a/testsuites/libtests/block10/init.c
+++ b/testsuites/libtests/block10/init.c
@@ -23,6 +23,9 @@
 #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <assert.h>
 #include <errno.h>
 #include <stdlib.h>
@@ -402,7 +405,7 @@ static rtems_task Init(rtems_task_argument argument)
   size_t i_rel = 0;
   size_t i_p = 0;
 
-  rtems_test_begink();
+  TEST_BEGIN();
 
   task_id_init = rtems_task_self();
 
@@ -466,7 +469,7 @@ static rtems_task Init(rtems_task_argument argument)
     }
   }
 
-  rtems_test_endk();
+  TEST_END();
 
   exit(0);
 }
diff --git a/testsuites/libtests/block14/init.c b/testsuites/libtests/block14/init.c
index 98282bc..889e853 100644
--- a/testsuites/libtests/block14/init.c
+++ b/testsuites/libtests/block14/init.c
@@ -118,8 +118,11 @@ static int test_disk_ioctl(rtems_disk_device *dd, uint32_t req, void *arg)
 
 static void test_actions(rtems_disk_device *dd)
 {
+  rtems_printer printer;
   int i;
 
+  rtems_print_printer_printf(&printer);
+
   for (i = 0; i < ACTION_COUNT; ++i) {
     const test_action *action = &actions [i];
     rtems_status_code sc;
@@ -155,7 +158,7 @@ static void test_actions(rtems_disk_device *dd)
     );
   }
 
-  rtems_blkdev_print_stats(&dd->stats, 0, 1, 2, rtems_printf_plugin, NULL);
+  rtems_blkdev_print_stats(&dd->stats, 0, 1, 2, &printer);
 }
 
 static void test(void)
diff --git a/testsuites/libtests/capture01/init.c b/testsuites/libtests/capture01/init.c
index 7957742..538583e 100644
--- a/testsuites/libtests/capture01/init.c
+++ b/testsuites/libtests/capture01/init.c
@@ -33,6 +33,7 @@
 rtems_task Init(rtems_task_argument argument);
 
 const char rtems_test_name[] = "CAPTURE 1";
+rtems_printer rtems_test_printer;
 
 rtems_task Init(
   rtems_task_argument ignored
@@ -46,6 +47,8 @@ rtems_task Init(
   rtems_mode          old_mode;
   rtems_name          to_name = rtems_build_name('I', 'D', 'L', 'E');;
 
+  rtems_print_printer_printf(&rtems_test_printer);
+
   rtems_test_begin();
 
   rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
diff --git a/testsuites/libtests/complex/init.c b/testsuites/libtests/complex/init.c
index 658af91..3d542fb 100644
--- a/testsuites/libtests/complex/init.c
+++ b/testsuites/libtests/complex/init.c
@@ -27,6 +27,7 @@
 #include <rtems/test.h>
 
 const char rtems_test_name[] = "COMPLEX";
+rtems_printer rtems_test_printer;
 #endif
 
 #include <stdio.h>
@@ -60,11 +61,12 @@ int main( void )
 #endif
 {
 #if __rtems__
+  rtems_print_printer_printf(&rtems_test_printer);
   rtems_test_begin();
 #endif
 
   docomplex();
-  docomplexf();  
+  docomplexf();
   docomplexl();
 #if __rtems__
   rtems_test_end();
diff --git a/testsuites/libtests/devnullfatal01/testcase.h b/testsuites/libtests/devnullfatal01/testcase.h
index 87a098e..14675da 100644
--- a/testsuites/libtests/devnullfatal01/testcase.h
+++ b/testsuites/libtests/devnullfatal01/testcase.h
@@ -13,6 +13,8 @@
 #define FATAL_ERROR_EXPECTED_IS_INTERNAL FALSE
 #define FATAL_ERROR_EXPECTED_ERROR       RTEMS_TOO_MANY
 
+#define TESTS_USE_PRINTK
+
 #include <rtems/devnull.h>
 #include "tmacros.h"
 
@@ -28,4 +30,3 @@ void force_error()
   /* A fatal error would be raised in previous call */
   /* we will not run this far */
 }
-
diff --git a/testsuites/libtests/exit01/init.c b/testsuites/libtests/exit01/init.c
index 6fbad6b..b677c3a 100644
--- a/testsuites/libtests/exit01/init.c
+++ b/testsuites/libtests/exit01/init.c
@@ -16,13 +16,15 @@
   #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <stdlib.h>
 
 /* Use assert() not rtems_test_assert() since it uses exit() */
 #include <assert.h>
 
 #include <rtems.h>
-#include <rtems/test.h>
 
 const char rtems_test_name[] = "EXIT 1";
 
@@ -60,7 +62,7 @@ static void fatal_extension(
       && error == EXIT_STATUS
       && counter == 3
   ) {
-    rtems_test_endk();
+    TEST_END();
   }
 }
 
@@ -85,7 +87,7 @@ static void Init(rtems_task_argument arg)
   rtems_status_code sc;
   rtems_id id;
 
-  rtems_test_begink();
+  TEST_BEGIN();
 
   sc = rtems_task_create(
     rtems_build_name('E', 'X', 'I', 'T'),
diff --git a/testsuites/libtests/exit02/init.c b/testsuites/libtests/exit02/init.c
index 88e0874..f185d0f 100644
--- a/testsuites/libtests/exit02/init.c
+++ b/testsuites/libtests/exit02/init.c
@@ -16,13 +16,15 @@
   #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <stdlib.h>
 
 /* Use assert() not rtems_test_assert() since it uses exit() */
 #include <assert.h>
 
 #include <rtems.h>
-#include <rtems/test.h>
 
 const char rtems_test_name[] = "EXIT 2";
 
@@ -44,7 +46,7 @@ static void fatal_extension(
       && !is_internal
       && error == EXIT_STATUS
   ) {
-    rtems_test_endk();
+    TEST_END();
   }
 }
 
@@ -63,7 +65,7 @@ static void Init(rtems_task_argument arg)
   rtems_status_code sc;
   rtems_id id;
 
-  rtems_test_begink();
+  TEST_BEGIN();
 
   sc = rtems_task_create(
     rtems_build_name('E', 'X', 'I', 'T'),
diff --git a/testsuites/libtests/math/init.c b/testsuites/libtests/math/init.c
index 0d4a97e..c045735 100644
--- a/testsuites/libtests/math/init.c
+++ b/testsuites/libtests/math/init.c
@@ -22,11 +22,16 @@
 #include "config.h"
 #endif
 
+/*
+ * @fixme This test should use the test macros but the include paths are
+ *        are wrong in the build system.
+ */
 #if __rtems__
 #include <bsp.h> /* for device driver prototypes */
 #include <rtems/test.h>
 
 const char rtems_test_name[] = "MATH";
+rtems_printer rtems_test_printer;
 #endif
 
 #include <stdio.h>
@@ -58,6 +63,7 @@ int main( void )
 #endif
 {
 #if __rtems__
+  rtems_print_printer_printf(&rtems_test_printer);
   rtems_test_begin();
 #endif
 
@@ -68,4 +74,3 @@ int main( void )
 #endif
   exit( 0 );
 }
-
diff --git a/testsuites/libtests/mathf/init.c b/testsuites/libtests/mathf/init.c
index 4cb1994..c91e6fe 100644
--- a/testsuites/libtests/mathf/init.c
+++ b/testsuites/libtests/mathf/init.c
@@ -27,6 +27,7 @@
 #include <rtems/test.h>
 
 const char rtems_test_name[] = "MATHF";
+rtems_printer rtems_test_printer;
 #endif
 
 #include <stdio.h>
@@ -58,14 +59,14 @@ int main( void )
 #endif
 {
 #if __rtems__
+  rtems_print_printer_printf(&rtems_test_printer);
   rtems_test_begin();
 #endif
 
-  domathf();  
+  domathf();
 
 #if __rtems__
   rtems_test_end();
 #endif
   exit( 0 );
 }
-
diff --git a/testsuites/libtests/mathl/init.c b/testsuites/libtests/mathl/init.c
index 0dab9da..ca26f11 100644
--- a/testsuites/libtests/mathl/init.c
+++ b/testsuites/libtests/mathl/init.c
@@ -27,6 +27,7 @@
 #include <rtems/test.h>
 
 const char rtems_test_name[] = "MATHL";
+rtems_printer rtems_test_printer;
 #endif
 
 #include <stdio.h>
@@ -58,10 +59,11 @@ int main( void )
 #endif
 {
 #if __rtems__
+  rtems_print_printer_printf(&rtems_test_printer);
   rtems_test_begin();
 #endif
 
-  domathl();  
+  domathl();
 
 #if __rtems__
   rtems_test_end();
diff --git a/testsuites/libtests/mouse01/init.c b/testsuites/libtests/mouse01/init.c
index a002f09..cc33630 100644
--- a/testsuites/libtests/mouse01/init.c
+++ b/testsuites/libtests/mouse01/init.c
@@ -60,7 +60,7 @@ bool enqueue_next_action(
     return false;
 
   termios_test_driver_set_rx_enqueue_now( true );
-  
+
   termios_test_driver_set_rx( &actions[Mouse_Index], to_enqueue );
   Mouse_Index += to_enqueue;
 
@@ -95,9 +95,10 @@ void printf_uid_message(
   struct MW_UID_MESSAGE *uid
 )
 {
+  rtems_printer printer;
+  rtems_print_printer_printf( &printer );
   uid_print_message_with_plugin(
-    stdout,
-    (rtems_printk_plugin_t)fprintf,
+    &printer,
     uid
   );
 }
@@ -135,16 +136,16 @@ rtems_task Init(
   TEST_BEGIN();
 
   open_it();
-  register_it(); 
+  register_it();
   do {
     more_data = enqueue_next_action(
       Mouse_Actions,
-      Mouse_Actions_Size, 
+      Mouse_Actions_Size,
       Mouse_Actions_Per_Iteration
     );
     receive_uid_message();
   } while (more_data);
-  close_it(); 
+  close_it();
   TEST_END();
   rtems_test_exit( 0 );
 }
diff --git a/testsuites/libtests/stackchk/init.c b/testsuites/libtests/stackchk/init.c
index cc54bf6..4e1e41c 100644
--- a/testsuites/libtests/stackchk/init.c
+++ b/testsuites/libtests/stackchk/init.c
@@ -101,6 +101,6 @@ void Fatal_extension(
   } else if ( error != rtems_build_name( 'T', 'A', '1', ' ' ) ) {
     printk( "unexpected fatal error\n" );
   } else {
-    rtems_test_endk();
+    TEST_END();
   }
 }
diff --git a/testsuites/libtests/stackchk/system.h b/testsuites/libtests/stackchk/system.h
index 6d9ce27..96f56fb 100644
--- a/testsuites/libtests/stackchk/system.h
+++ b/testsuites/libtests/stackchk/system.h
@@ -11,6 +11,7 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
+#define TESTS_USE_PRINTK
 #include <tmacros.h>
 
 /* macros */
diff --git a/testsuites/libtests/uid01/init.c b/testsuites/libtests/uid01/init.c
index 13ec8ba..f8ec4bd 100644
--- a/testsuites/libtests/uid01/init.c
+++ b/testsuites/libtests/uid01/init.c
@@ -69,9 +69,10 @@ void printf_uid_message(
   struct MW_UID_MESSAGE *uid
 )
 {
+  rtems_printer printer;
+  rtems_print_printer_printf( &printer );
   uid_print_message_with_plugin(
-    stdout,
-    (rtems_printk_plugin_t)fprintf,
+    &printer,
     uid
   );
 }
@@ -111,12 +112,12 @@ rtems_task Init(
   /* No message should ever be recieved. With a timeout val of 0, this
    * call will never return. We use this to check if patch was correct
    * by passing a number of ticks greater than 0 and less than 1. If
-   * patch was correct, this call will timeout instead of waiting 
+   * patch was correct, this call will timeout instead of waiting
    * indefinitely.
    */
   receive_uid_message();
 
-  close_it(); 
+  close_it();
   TEST_END();
   rtems_test_exit( 0 );
 }
diff --git a/testsuites/psxtests/psxfatal_support/init.c b/testsuites/psxtests/psxfatal_support/init.c
index 350b3a2..0f995dc 100644
--- a/testsuites/psxtests/psxfatal_support/init.c
+++ b/testsuites/psxtests/psxfatal_support/init.c
@@ -11,6 +11,9 @@
 #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #define CONFIGURE_INIT
 #include "system.h"
 
@@ -22,7 +25,7 @@ static void print_test_begin_message(void)
 
   if (!done) {
     done = true;
-    rtems_test_begink();
+    TEST_BEGIN();
   }
 }
 
@@ -95,7 +98,6 @@ void Fatal_extension(
       && is_internal == FATAL_ERROR_EXPECTED_IS_INTERNAL
       && error == FATAL_ERROR_EXPECTED_ERROR
   ) {
-    rtems_test_endk();
+    TEST_END();
   }
 }
-
diff --git a/testsuites/samples/capture/init.c b/testsuites/samples/capture/init.c
index a10ccc5..557e809 100644
--- a/testsuites/samples/capture/init.c
+++ b/testsuites/samples/capture/init.c
@@ -27,6 +27,7 @@ rtems_task Init(rtems_task_argument argument);
 static void notification(int fd, int seconds_remaining, void *arg);
 
 const char rtems_test_name[] = "CAPTURE ENGINE";
+rtems_printer rtems_test_printer;
 
 volatile int can_proceed = 1;
 
@@ -46,6 +47,7 @@ rtems_task Init(
   rtems_task_priority old_priority;
   rtems_mode          old_mode;
 
+  rtems_print_printer_printf(&rtems_test_printer);
   rtems_test_begin();
 
   status = rtems_shell_wait_for_input(
diff --git a/testsuites/samples/hello/init.c b/testsuites/samples/hello/init.c
index d8fe450..ea9af89 100644
--- a/testsuites/samples/hello/init.c
+++ b/testsuites/samples/hello/init.c
@@ -22,11 +22,13 @@
 rtems_task Init(rtems_task_argument argument);
 
 const char rtems_test_name[] = "HELLO WORLD";
+rtems_printer rtems_test_printer;
 
 rtems_task Init(
   rtems_task_argument ignored
 )
 {
+  rtems_print_printer_printf(&rtems_test_printer);
   rtems_test_begin();
   printf( "Hello World\n" );
   rtems_test_end();
diff --git a/testsuites/samples/paranoia/init.c b/testsuites/samples/paranoia/init.c
index 3718af4..ac7c214 100644
--- a/testsuites/samples/paranoia/init.c
+++ b/testsuites/samples/paranoia/init.c
@@ -19,6 +19,7 @@
 extern int paranoia(int, char **);
 
 const char rtems_test_name[] = "PARANOIA";
+rtems_printer rtems_test_printer;
 
 char *args[2] = { "paranoia", 0 };
 
@@ -35,6 +36,7 @@ rtems_task Init(
   M68KFPSPInstallExceptionHandlers ();
 #endif
 
+  rtems_print_printer_printf(&rtems_test_printer);
   rtems_test_begin();
   paranoia(1, args);
   rtems_test_end();
diff --git a/testsuites/smptests/smp05/init.c b/testsuites/smptests/smp05/init.c
index 424e9df..31f77a3 100644
--- a/testsuites/smptests/smp05/init.c
+++ b/testsuites/smptests/smp05/init.c
@@ -27,7 +27,7 @@ rtems_task Test_task(
 
 static void success(void)
 {
-  rtems_test_end_with_plugin(locked_printf_plugin, NULL);
+  rtems_test_end();
   rtems_test_exit( 0 );
 }
 
@@ -50,7 +50,7 @@ rtems_task Init(
   rtems_status_code  status;
 
   locked_print_initialize();
-  rtems_test_begin_with_plugin(locked_printf_plugin, NULL);
+  rtems_test_begin();
 
   if ( rtems_get_processor_count() == 1 ) {
     success();
diff --git a/testsuites/smptests/smp07/init.c b/testsuites/smptests/smp07/init.c
index c26669a..6acfe21 100644
--- a/testsuites/smptests/smp07/init.c
+++ b/testsuites/smptests/smp07/init.c
@@ -18,7 +18,7 @@ const char rtems_test_name[] = "SMP 7";
 
 volatile bool TaskRan = false;
 volatile bool TSRFired = false;
-rtems_id      Semaphore; 
+rtems_id      Semaphore;
 
 rtems_task Init(
   rtems_task_argument argument
@@ -30,7 +30,7 @@ rtems_task Test_task(
 
 static void success(void)
 {
-  rtems_test_end_with_plugin(locked_printf_plugin, NULL);
+  rtems_test_end( );
   rtems_test_exit( 0 );
 }
 
@@ -63,8 +63,8 @@ rtems_task Test_task(
 
   /* Print that the task is up and running. */
   locked_printf(
-    " CPU %" PRIu32 " running Task %s after semaphore release\n", 
-    cpu_num, 
+    " CPU %" PRIu32 " running Task %s after semaphore release\n",
+    cpu_num,
     name
   );
 
@@ -98,7 +98,7 @@ rtems_task Init(
   rtems_id           Timer;
 
   locked_print_initialize();
-  rtems_test_begin_with_plugin(locked_printf_plugin, NULL);
+  rtems_test_begin();
 
   if ( rtems_get_processor_count() == 1 ) {
     success();
@@ -107,7 +107,7 @@ rtems_task Init(
   /* Create/verify semaphore */
   status = rtems_semaphore_create(
     rtems_build_name ('S', 'E', 'M', '1'),
-    1,                                             
+    1,
     RTEMS_LOCAL                   |
     RTEMS_SIMPLE_BINARY_SEMAPHORE |
     RTEMS_PRIORITY,
@@ -157,7 +157,7 @@ rtems_task Init(
     if ( TSRFired && TaskRan )
       break;
   };
-  
+
   /* Validate the timer fired and that the task ran */
   if ( !TSRFired )
     locked_printf( "*** ERROR TSR DID NOT FIRE ***" );
diff --git a/testsuites/smptests/smpfatal01/init.c b/testsuites/smptests/smpfatal01/init.c
index 9346d87..e7f1597 100644
--- a/testsuites/smptests/smpfatal01/init.c
+++ b/testsuites/smptests/smpfatal01/init.c
@@ -16,8 +16,10 @@
   #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <rtems.h>
-#include <rtems/test.h>
 #include <rtems/score/percpu.h>
 #include <rtems/score/smpimpl.h>
 #include <rtems/score/smpbarrier.h>
@@ -62,7 +64,7 @@ static void fatal_extension(
         assert(state == PER_CPU_STATE_SHUTDOWN);
       }
 
-      rtems_test_endk();
+      TEST_END();
     }
   }
 
@@ -79,7 +81,7 @@ static rtems_status_code test_driver_init(
   uint32_t cpu_count = rtems_get_processor_count();
   uint32_t cpu;
 
-  rtems_test_begink();
+  TEST_BEGIN();
 
   assert(rtems_configuration_get_maximum_processors() == MAX_CPUS);
 
@@ -107,7 +109,7 @@ static rtems_status_code test_driver_init(
 
     per_cpu->state = PER_CPU_STATE_SHUTDOWN;
   } else {
-    rtems_test_endk();
+    TEST_END();
     exit(0);
   }
 
diff --git a/testsuites/smptests/smpfatal02/init.c b/testsuites/smptests/smpfatal02/init.c
index c98ff3c..71fff0c 100644
--- a/testsuites/smptests/smpfatal02/init.c
+++ b/testsuites/smptests/smpfatal02/init.c
@@ -16,8 +16,10 @@
   #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <rtems.h>
-#include <rtems/test.h>
 #include <rtems/score/percpu.h>
 #include <rtems/score/smpimpl.h>
 #include <rtems/score/smpbarrier.h>
@@ -67,7 +69,7 @@ static void fatal_extension(
         assert(state == PER_CPU_STATE_SHUTDOWN);
       }
 
-      rtems_test_endk();
+      TEST_END();
     } else {
       assert(source == RTEMS_FATAL_SOURCE_SMP);
       assert(code == SMP_FATAL_SHUTDOWN);
@@ -87,7 +89,7 @@ static rtems_status_code test_driver_init(
   uint32_t cpu_count = rtems_get_processor_count();
   uint32_t cpu;
 
-  rtems_test_begink();
+  TEST_BEGIN();
 
   assert(rtems_configuration_get_maximum_processors() == MAX_CPUS);
 
@@ -112,7 +114,7 @@ static rtems_status_code test_driver_init(
   if (cpu_count > 1) {
     rtems_fatal(RTEMS_FATAL_SOURCE_APPLICATION, 0xdeadbeef);
   } else {
-    rtems_test_endk();
+    TEST_END();
     exit(0);
   }
 
diff --git a/testsuites/smptests/smpfatal04/init.c b/testsuites/smptests/smpfatal04/init.c
index 39ceebf..ebfa849 100644
--- a/testsuites/smptests/smpfatal04/init.c
+++ b/testsuites/smptests/smpfatal04/init.c
@@ -16,8 +16,10 @@
   #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <rtems.h>
-#include <rtems/test.h>
 #include <rtems/score/smpimpl.h>
 
 #include <assert.h>
@@ -36,14 +38,14 @@ static void fatal_extension(
   rtems_fatal_code code
 )
 {
-  rtems_test_begink();
+  TEST_BEGIN();
 
   if (
     source == RTEMS_FATAL_SOURCE_SMP
       && !is_internal
       && code == SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER
   ) {
-    rtems_test_endk();
+    TEST_END();
   }
 }
 
diff --git a/testsuites/smptests/smpfatal05/init.c b/testsuites/smptests/smpfatal05/init.c
index 37b3dee..1e1e535 100644
--- a/testsuites/smptests/smpfatal05/init.c
+++ b/testsuites/smptests/smpfatal05/init.c
@@ -16,8 +16,10 @@
   #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <rtems.h>
-#include <rtems/test.h>
 #include <rtems/score/smpimpl.h>
 
 #include <assert.h>
@@ -36,14 +38,14 @@ static void fatal_extension(
   rtems_fatal_code code
 )
 {
-  rtems_test_begink();
+  TEST_BEGIN();
 
   if (
     source == RTEMS_FATAL_SOURCE_SMP
       && !is_internal
       && code == SMP_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT
   ) {
-    rtems_test_endk();
+    TEST_END();
   }
 }
 
diff --git a/testsuites/smptests/smpfatal08/init.c b/testsuites/smptests/smpfatal08/init.c
index 2de76e4..4b7aaf5 100644
--- a/testsuites/smptests/smpfatal08/init.c
+++ b/testsuites/smptests/smpfatal08/init.c
@@ -16,8 +16,10 @@
   #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <rtems.h>
-#include <rtems/test.h>
 #include <rtems/score/smpimpl.h>
 
 #include <bsp.h>
@@ -93,14 +95,14 @@ static void fatal_extension(
   rtems_fatal_code code
 )
 {
-  rtems_test_begink();
+  TEST_BEGIN();
 
   if (
     source == RTEMS_FATAL_SOURCE_SMP
       && !is_internal
       && code == SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED
   ) {
-    rtems_test_endk();
+    TEST_END();
   }
 }
 
diff --git a/testsuites/sptests/sperror01/init.c b/testsuites/sptests/sperror01/init.c
index 4c40be5..a84eaf9 100644
--- a/testsuites/sptests/sperror01/init.c
+++ b/testsuites/sptests/sperror01/init.c
@@ -11,7 +11,9 @@
 #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
 #include <tmacros.h>
+
 #include "test_support.h"
 #include "rtems/error.h"
 #include <errno.h>
@@ -32,7 +34,7 @@ static void fatal_extension(
       && !is_internal
       && error == ENOMEM
   ) {
-    rtems_test_endk();
+    TEST_END();
   }
 }
 
diff --git a/testsuites/sptests/sperror02/init.c b/testsuites/sptests/sperror02/init.c
index dca2219..0bb7cea 100644
--- a/testsuites/sptests/sperror02/init.c
+++ b/testsuites/sptests/sperror02/init.c
@@ -11,7 +11,9 @@
 #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
 #include <tmacros.h>
+
 #include "test_support.h"
 #include <errno.h>
 #include <rtems/error.h>
@@ -32,7 +34,7 @@ static void fatal_extension(
       && !is_internal
       && error == 1
   ) {
-    rtems_test_endk();
+    TEST_END();
   }
 }
 
@@ -44,7 +46,7 @@ rtems_task Init(
 
   errno = ENOMEM;
   rtems_error(
-    RTEMS_NO_MEMORY | RTEMS_ERROR_ABORT, 
+    RTEMS_NO_MEMORY | RTEMS_ERROR_ABORT,
     "Dummy: Resources unavailable\n"
   );
 
diff --git a/testsuites/sptests/sperror03/init.c b/testsuites/sptests/sperror03/init.c
index 818b907..aecdb79 100644
--- a/testsuites/sptests/sperror03/init.c
+++ b/testsuites/sptests/sperror03/init.c
@@ -11,7 +11,8 @@
 #include "config.h"
 #endif
 
-#include <tmacros.h>
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
 #include "test_support.h"
 
 const char rtems_test_name[] = "SPERROR 3";
@@ -30,7 +31,7 @@ static void fatal_extension(
       && !is_internal
       && error == 0
   ) {
-    rtems_test_endk();
+    TEST_END();
   }
 }
 
diff --git a/testsuites/sptests/spextensions01/init.c b/testsuites/sptests/spextensions01/init.c
index d8593b9..091d66f 100644
--- a/testsuites/sptests/spextensions01/init.c
+++ b/testsuites/sptests/spextensions01/init.c
@@ -16,12 +16,13 @@
   #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <assert.h>
 #include <limits.h>
 #include <stdlib.h>
 
-#include <rtems/test.h>
-
 #include <bsp.h>
 
 const char rtems_test_name[] = "SPEXTENSIONS 1";
@@ -199,7 +200,7 @@ static void two_fatal(
   if (source == RTEMS_FATAL_SOURCE_EXIT) {
     assert_reverse_order(2);
     assert(counter == 72);
-    rtems_test_endk();
+    TEST_END();
   }
 }
 
@@ -424,7 +425,7 @@ static void test(void)
 
 static void Init(rtems_task_argument arg)
 {
-  rtems_test_begink();
+  TEST_BEGIN();
 
   test();
 
diff --git a/testsuites/sptests/spfatal07/testcase.h b/testsuites/sptests/spfatal07/testcase.h
index 5ccaaa4..7cc9a5f 100644
--- a/testsuites/sptests/spfatal07/testcase.h
+++ b/testsuites/sptests/spfatal07/testcase.h
@@ -50,7 +50,7 @@ void force_error()
       "WARNING - Test not applicable on this target architecture.\n"
       "WARNING - Only applicable when CPU_ALLOCATE_INTERRUPT_STACK == TRUE.\n"
     );
-    rtems_test_endk();
+    TEST_END();
     rtems_test_exit(0);
   #endif
 }
diff --git a/testsuites/sptests/spfatal16/testcase.h b/testsuites/sptests/spfatal16/testcase.h
index 65af957..743b2be 100644
--- a/testsuites/sptests/spfatal16/testcase.h
+++ b/testsuites/sptests/spfatal16/testcase.h
@@ -7,7 +7,7 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
-/* generate fatal errors in termios.c 
+/* generate fatal errors in termios.c
  *    rtems_semaphore_create( rtems_build_name ('T', 'R', 'r', c),...);
  */
 
@@ -25,6 +25,6 @@
 void force_error()
 {
   /* This fatal error depends on the Termios device configuration */
-  rtems_test_endk();
+  TEST_END();
   rtems_test_exit(0);
 }
diff --git a/testsuites/sptests/spfatal26/init.c b/testsuites/sptests/spfatal26/init.c
index 7235f8d..4013b94 100644
--- a/testsuites/sptests/spfatal26/init.c
+++ b/testsuites/sptests/spfatal26/init.c
@@ -16,6 +16,7 @@
   #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
 #include "tmacros.h"
 
 #include <limits.h>
@@ -51,7 +52,7 @@ static void provoke_aligment_or_data_access_exception( void )
 
 static void Init( rtems_task_argument arg )
 {
-  rtems_test_begink();
+  TEST_BEGIN();
 
   provoke_aligment_or_data_access_exception();
 
@@ -69,7 +70,7 @@ static void fatal_extension(
 
   rtems_exception_frame_print( (const rtems_exception_frame *) code );
 
-  rtems_test_endk();
+  TEST_END();
 }
 
 #define CONFIGURE_INITIAL_EXTENSIONS \
diff --git a/testsuites/sptests/spfatal_support/init.c b/testsuites/sptests/spfatal_support/init.c
index 1052da4..f048d4b 100644
--- a/testsuites/sptests/spfatal_support/init.c
+++ b/testsuites/sptests/spfatal_support/init.c
@@ -22,7 +22,7 @@ static void print_test_begin_message(void)
 
   if (!done) {
     done = true;
-    rtems_test_begink();
+    TEST_BEGIN();
   }
 }
 
@@ -107,7 +107,6 @@ void Fatal_extension(
       && is_internal == FATAL_ERROR_EXPECTED_IS_INTERNAL
       && is_expected_error( error )
   ) {
-    rtems_test_endk();
+    TEST_END();
   }
 }
-
diff --git a/testsuites/sptests/spfatal_support/system.h b/testsuites/sptests/spfatal_support/system.h
index 19adb47..0a01e21 100644
--- a/testsuites/sptests/spfatal_support/system.h
+++ b/testsuites/sptests/spfatal_support/system.h
@@ -14,9 +14,11 @@
 /*
  *  Some of the fatal error cases require the ability to peek inside RTEMS
  */
+
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <rtems.h>
-#include <rtems/test.h>
-#include <tmacros.h>
 
 /* functions */
 
diff --git a/testsuites/sptests/spinternalerror01/init.c b/testsuites/sptests/spinternalerror01/init.c
index a1ddc14..e864db1 100644
--- a/testsuites/sptests/spinternalerror01/init.c
+++ b/testsuites/sptests/spinternalerror01/init.c
@@ -16,11 +16,12 @@
   #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <bsp.h>
 #include <bsp/bootcard.h>
 
-#include <rtems/test.h>
-
 const char rtems_test_name[] = "SPINTERNALERROR 1";
 
 #define FATAL_SOURCE 0xdeadbeef
@@ -40,14 +41,14 @@ static void fatal_extension(
   Internal_errors_t error
 )
 {
-  rtems_test_begink();
+  TEST_BEGIN();
 
   if (
     source == FATAL_SOURCE
       && is_internal == FATAL_IS_INTERNAL
       && error == FATAL_ERROR
   ) {
-    rtems_test_endk();
+    TEST_END();
   }
 }
 
diff --git a/testsuites/sptests/spprintk/init.c b/testsuites/sptests/spprintk/init.c
index eea17ad..8086a1a 100644
--- a/testsuites/sptests/spprintk/init.c
+++ b/testsuites/sptests/spprintk/init.c
@@ -13,11 +13,19 @@
 #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
 #include <tmacros.h>
-#include <rtems/bspIo.h>
+#include <rtems/print.h>
 
 const char rtems_test_name[] = "SPPRINTK";
 
+/*
+ * Undefined the RTEMS_PRINTF_ATTRIBUTE and make it nothing. The test code
+ * contained in the file is suppose to be wrong.
+ */
+#undef RTEMS_PRINTF_ATTRIBUTE
+#define RTEMS_PRINTF_ATTRIBUTE(_a, _b)
+
 /* forward declarations to avoid warnings */
 rtems_task Init(rtems_task_argument argument);
 int test_getchar(void);
@@ -38,7 +46,7 @@ void do_getchark(void)
   poll_char = BSP_poll_char;
 
   BSP_poll_char = NULL;
-  
+
   putk( "getchark - NULL getchar method - return -1" );
   sc = getchark();
   rtems_test_assert( sc == -1 );
@@ -124,7 +132,7 @@ rtems_task Init(
   rtems_task_argument argument
 )
 {
-  rtems_test_begink();
+  TEST_BEGIN();
 
   do_putk();
   putk("");
@@ -134,7 +142,7 @@ rtems_task Init(
 
   do_getchark();
 
-  rtems_test_endk();
+  TEST_END();
   rtems_test_exit( 0 );
 }
 
@@ -151,4 +159,3 @@ rtems_task Init(
 #define CONFIGURE_INIT
 
 #include <rtems/confdefs.h>
-
diff --git a/testsuites/sptests/spprofiling01/init.c b/testsuites/sptests/spprofiling01/init.c
index afbe2c7..60f6bd5 100644
--- a/testsuites/sptests/spprofiling01/init.c
+++ b/testsuites/sptests/spprofiling01/init.c
@@ -115,13 +115,15 @@ static void test_iterate(void)
 
 static void test_report_xml(void)
 {
+  rtems_printer printer;
   rtems_status_code sc;
   int rv;
 
   sc = rtems_task_wake_after(3);
   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
 
-  rv = rtems_profiling_report_xml("X", rtems_printf_plugin, NULL, 1, "  ");
+  rtems_print_printer_printf(&printer);
+  rv = rtems_profiling_report_xml("X", &printer, 1, "  ");
   printf("characters produced by rtems_profiling_report_xml(): %i\n", rv);
 }
 
diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c
index e12f7f3..c598ee5 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -16,6 +16,9 @@
   #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -29,7 +32,6 @@
 #include <rtems/ioimpl.h>
 #include <rtems/libio_.h>
 #include <rtems/sysinit.h>
-#include <rtems/test.h>
 
 #include <rtems/extensionimpl.h>
 #ifdef RTEMS_POSIX_API
@@ -173,7 +175,7 @@ static void next_step(init_step expected)
 
 FIRST(RTEMS_SYSINIT_BSP_WORK_AREAS)
 {
-  rtems_test_begink();
+  TEST_BEGIN();
   assert(_Workspace_Area.area_begin == 0);
   next_step(BSP_WORK_AREAS_PRE);
 }
@@ -674,7 +676,7 @@ static void Init(rtems_task_argument arg)
   pthread_cleanup_pop(0);
 #endif /* RTEMS_POSIX_API */
   next_step(INIT_TASK);
-  rtems_test_endk();
+  TEST_END();
   exit(0);
 }
 
diff --git a/testsuites/sptests/sptimecounter01/init.c b/testsuites/sptests/sptimecounter01/init.c
index d87ffec..9e396de 100644
--- a/testsuites/sptests/sptimecounter01/init.c
+++ b/testsuites/sptests/sptimecounter01/init.c
@@ -16,12 +16,13 @@
   #include "config.h"
 #endif
 
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
 #include <assert.h>
 
 #include <bsp/bootcard.h>
 
-#include <rtems/test.h>
-
 #include <rtems/score/timecounterimpl.h>
 #include <rtems/score/todimpl.h>
 #include <rtems/timecounter.h>
@@ -54,7 +55,7 @@ void boot_card(const char *cmdline)
   struct timeval tv;
   struct timespec ts;
 
-  rtems_test_begink();
+  TEST_BEGIN();
 
   assert(time(NULL) == TOD_SECONDS_1970_THROUGH_1988);
 
@@ -148,7 +149,7 @@ void boot_card(const char *cmdline)
   assert(bt.sec == 1);
   assert(bt.frac == 18446742522092);
 
-  rtems_test_endk();
+  TEST_END();
 
   _Terminate(RTEMS_FATAL_SOURCE_EXIT, false, 0);
 }
diff --git a/testsuites/support/include/buffer_test_io.h b/testsuites/support/include/buffer_test_io.h
index e5fbd2b..0ae3909 100644
--- a/testsuites/support/include/buffer_test_io.h
+++ b/testsuites/support/include/buffer_test_io.h
@@ -24,7 +24,7 @@ extern "C" {
  */
 #if defined(TESTS_USE_PRINTK)
 
-#include <rtems/bspIo.h>
+#include <rtems/print.h>
 
   #undef printf
   #define printf(...) \
@@ -54,9 +54,9 @@ extern "C" {
     do { \
     } while (0)
 
-  #define TEST_BEGIN() rtems_test_begink()
+  #define TEST_BEGIN() printk(TEST_BEGIN_STRING)
 
-  #define TEST_END() rtems_test_endk()
+  #define TEST_END() printk(TEST_END_STRING)
 
 /*
  *  BUFFER TEST OUTPUT
@@ -156,9 +156,9 @@ extern "C" {
       fflush(stdout); \
     } while (0)
 
-  #define TEST_BEGIN() rtems_test_begin()
+  #define TEST_BEGIN() printf(TEST_BEGIN_STRING)
 
-  #define TEST_END() rtems_test_end()
+  #define TEST_END() printf(TEST_END_STRING)
 
 /*
  *  USE IPRINT
@@ -205,11 +205,9 @@ extern "C" {
       fflush(stdout); \
     } while (0)
 
-  #define TEST_BEGIN() \
-    rtems_test_begin_with_plugin((rtems_printk_plugin_t) fiprintf, stderr)
+  #define TEST_BEGIN() fiprintf( stderr, TEST_BEGIN_STRING)
 
-  #define TEST_END() \
-    rtems_test_end_with_plugin((rtems_printk_plugin_t) fiprintf, stderr)
+  #define TEST_END()  fiprintf( stderr, TEST_END_STRING)
 
 #endif
 
diff --git a/testsuites/support/include/test_support.h b/testsuites/support/include/test_support.h
index 7c459ff..d6870b2 100644
--- a/testsuites/support/include/test_support.h
+++ b/testsuites/support/include/test_support.h
@@ -74,8 +74,6 @@ int locked_printf(const char *fmt, ...);
 
 int locked_vprintf(const char *fmt, va_list ap);
 
-int locked_printf_plugin(void *context, const char *fmt, ...);
-
 void locked_printk(const char *fmt, ...);
 
 #ifdef __cplusplus
diff --git a/testsuites/support/src/locked_print.c b/testsuites/support/src/locked_print.c
index 8414479..7c0df66 100644
--- a/testsuites/support/src/locked_print.c
+++ b/testsuites/support/src/locked_print.c
@@ -1,4 +1,4 @@
-/* 
+/*
  *  COPYRIGHT (c) 1989-2011.
  *  On-Line Applications Research Corporation (OAR).
  *
@@ -14,7 +14,23 @@
 #include "test_support.h"
 #include "tmacros.h"
 
-static rtems_id locked_print_semaphore;      /* synchronisation semaphore */ 
+static rtems_id locked_print_semaphore;      /* synchronisation semaphore */
+
+rtems_printer rtems_test_printer;
+
+static int locked_printf_plugin(void *context, const char *fmt, ...)
+{
+  int rv;
+  va_list ap;
+
+  (void) context;
+
+  va_start(ap, fmt);
+  rv = locked_vprintf(fmt, ap);
+  va_end(ap);
+
+  return rv;
+}
 
 void locked_print_initialize(void)
 {
@@ -29,7 +45,7 @@ void locked_print_initialize(void)
   /* Create/verify synchronisation semaphore */
   sc = rtems_semaphore_create(
     rtems_build_name ('S', 'E', 'M', '1'),
-    1,                                             
+    1,
     RTEMS_LOCAL                   |
     RTEMS_BINARY_SEMAPHORE |
     RTEMS_PRIORITY_CEILING |
@@ -38,6 +54,12 @@ void locked_print_initialize(void)
     &locked_print_semaphore
   );
   directive_failed( sc, "rtems_semaphore_create" );
+
+  /*
+   * Set up the printer to use the locked printf printer.
+   */
+  rtems_test_printer.context = NULL;
+  rtems_test_printer.context = locked_printf_plugin;
 }
 
 int locked_vprintf(const char *fmt, va_list ap)
@@ -60,20 +82,6 @@ int locked_vprintf(const char *fmt, va_list ap)
   return rv;
 }
 
-int locked_printf_plugin(void *context, const char *fmt, ...)
-{
-  int rv;
-  va_list ap;
-
-  (void) context;
-
-  va_start(ap, fmt);
-  rv = locked_vprintf(fmt, ap);
-  va_end(ap);
-
-  return rv;
-}
-
 int locked_printf(const char *fmt, ...)
 {
   int               rv;




More information about the vc mailing list