forked from Imagelibrary/rtems
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.
This commit is contained in:
@@ -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
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -36,6 +36,15 @@ extern "C" {
|
||||
* - BSP_poll_char
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
||||
134
cpukit/include/rtems/print.h
Normal file
134
cpukit/include/rtems/print.h
Normal file
@@ -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@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
|
||||
@@ -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
|
||||
);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 \
|
||||
|
||||
29
cpukit/libcsupport/src/print_fprintf.c
Normal file
29
cpukit/libcsupport/src/print_fprintf.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief RTEMS Print Support
|
||||
* @ingroup libcsupport
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Chris Johns <chrisj@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;
|
||||
}
|
||||
52
cpukit/libcsupport/src/print_printf.c
Normal file
52
cpukit/libcsupport/src/print_printf.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief RTEMS Print Support
|
||||
* @ingroup libcsupport
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Chris Johns <chrisj@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;
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
return rv;
|
||||
printer->context = NULL;
|
||||
printer->printer = rtems_printf_plugin;
|
||||
}
|
||||
|
||||
int rtems_printf_plugin(void *context, const char *format, va_list ap)
|
||||
{
|
||||
(void) context;
|
||||
return vprintf(format, ap);
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -47,9 +46,6 @@ void rtems_cpu_usage_report_with_plugin(
|
||||
Timestamp_Control uptime, total, used, uptime_at_last_reset;
|
||||
uint32_t seconds, nanoseconds;
|
||||
|
||||
if ( !print )
|
||||
return;
|
||||
|
||||
/*
|
||||
* When not using nanosecond CPU usage resolution, we have to count
|
||||
* the number of "ticks" we gave credit for to give the user a rough
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -40,15 +40,6 @@
|
||||
#include <rtems/score/watchdogimpl.h>
|
||||
#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,35 +379,35 @@ 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,
|
||||
rtems_printf(data->printer,
|
||||
"\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, "\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,
|
||||
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,
|
||||
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,
|
||||
rtems_printf(data->printer,
|
||||
" Idle: %4" PRIu32 ".%03" PRIu32 "%%", ival, fval);
|
||||
|
||||
/*
|
||||
@@ -432,7 +415,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
|
||||
*/
|
||||
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,7 +470,7 @@ 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,
|
||||
rtems_printf(data->printer,
|
||||
" 0x%08" PRIx32 " | %-19s | %3" PRId32 " | %3" PRId32 " | ",
|
||||
thread->Object.id,
|
||||
name,
|
||||
@@ -502,10 +485,10 @@ 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,
|
||||
rtems_printf(data->printer,
|
||||
" |%4" PRIu32 ".%03" PRIu32, ival, fval);
|
||||
_Timestamp_Divide(¤t_usage, &data->period, &ival, &fval);
|
||||
(*data->plugin.print)(data->plugin.context,
|
||||
rtems_printf(data->printer,
|
||||
" |%4" PRIu32 ".%03" PRIu32 "\n", ival, fval);
|
||||
}
|
||||
|
||||
@@ -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,7 +508,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
|
||||
&out);
|
||||
if ((sc != RTEMS_SUCCESSFUL) && (sc != RTEMS_TIMEOUT))
|
||||
{
|
||||
(*data->plugin.print)(data->plugin.context,
|
||||
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 == '<')
|
||||
@@ -678,5 +645,7 @@ void rtems_cpu_usage_top_with_plugin(
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
" "
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
/*************************************************************
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -37,6 +37,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.
|
||||
*/
|
||||
@@ -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().
|
||||
* @brief Begin of test message format string.
|
||||
*/
|
||||
int rtems_test_begin_with_plugin(
|
||||
rtems_printk_plugin_t printf_func,
|
||||
void *printf_arg
|
||||
);
|
||||
#define TEST_BEGIN_STRING "\n\n*** BEGIN OF TEST %s ***\n", rtems_test_name
|
||||
|
||||
/**
|
||||
* @brief End of test message format string.
|
||||
*/
|
||||
#define TEST_END_STRING "*** END OF TEST %s ***\n", rtems_test_name
|
||||
|
||||
/**
|
||||
* @brief Prints a begin of test message using printf().
|
||||
*
|
||||
* @returns As specified by printf().
|
||||
*/
|
||||
static inline int rtems_test_begin(void)
|
||||
{
|
||||
return rtems_test_begin_with_plugin(rtems_printf_plugin, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Prints a begin of test message using printk().
|
||||
*
|
||||
* @returns As specified by printf().
|
||||
*/
|
||||
static inline int rtems_test_begink(void)
|
||||
{
|
||||
return rtems_test_begin_with_plugin(printk_plugin, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*
|
||||
* @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.
|
||||
|
||||
@@ -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 (*printf_func)(
|
||||
printf_arg,
|
||||
"\n\n*** BEGIN OF TEST %s ***\n",
|
||||
rtems_test_name
|
||||
return rtems_printf(
|
||||
&rtems_test_printer,
|
||||
TEST_BEGIN_STRING
|
||||
);
|
||||
}
|
||||
|
||||
int rtems_test_end_with_plugin(
|
||||
rtems_printk_plugin_t printf_func,
|
||||
void *printf_arg
|
||||
)
|
||||
int rtems_test_end(void)
|
||||
{
|
||||
return (*printf_func)(
|
||||
printf_arg,
|
||||
"*** END OF TEST %s ***\n",
|
||||
rtems_test_name
|
||||
return rtems_printf(
|
||||
&rtems_test_printer,
|
||||
TEST_END_STRING
|
||||
);
|
||||
}
|
||||
|
||||
int rtems_test_print(
|
||||
const char* format,
|
||||
...
|
||||
)
|
||||
{
|
||||
va_list ap;
|
||||
int len;
|
||||
va_start(ap, format);
|
||||
len = rtems_vprintf(
|
||||
&rtems_test_printer,
|
||||
format,
|
||||
ap
|
||||
);
|
||||
va_end(ap);
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
" "
|
||||
);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <rtems/print.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
@@ -305,25 +307,11 @@ void rtems_profiling_iterate(
|
||||
void *visitor_arg
|
||||
);
|
||||
|
||||
/**
|
||||
* @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
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -23,14 +23,13 @@
|
||||
#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 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 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 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include <bsp.h>
|
||||
|
||||
#include <tmacros.h>
|
||||
#include "tmacros.h"
|
||||
|
||||
const char rtems_test_name[] = "BLOCK 6";
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <rtems/test.h>
|
||||
|
||||
const char rtems_test_name[] = "COMPLEX";
|
||||
rtems_printer rtems_test_printer;
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -60,6 +61,7 @@ int main( void )
|
||||
#endif
|
||||
{
|
||||
#if __rtems__
|
||||
rtems_print_printer_printf(&rtems_test_printer);
|
||||
rtems_test_begin();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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 */
|
||||
}
|
||||
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <rtems/test.h>
|
||||
|
||||
const char rtems_test_name[] = "MATHF";
|
||||
rtems_printer rtems_test_printer;
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -58,6 +59,7 @@ int main( void )
|
||||
#endif
|
||||
{
|
||||
#if __rtems__
|
||||
rtems_print_printer_printf(&rtems_test_printer);
|
||||
rtems_test_begin();
|
||||
#endif
|
||||
|
||||
@@ -68,4 +70,3 @@ int main( void )
|
||||
#endif
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <rtems/test.h>
|
||||
|
||||
const char rtems_test_name[] = "MATHL";
|
||||
rtems_printer rtems_test_printer;
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -58,6 +59,7 @@ int main( void )
|
||||
#endif
|
||||
{
|
||||
#if __rtems__
|
||||
rtems_print_printer_printf(&rtems_test_printer);
|
||||
rtems_test_begin();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#define TESTS_USE_PRINTK
|
||||
#include <tmacros.h>
|
||||
|
||||
/* macros */
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -16,6 +16,22 @@
|
||||
|
||||
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)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user