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
|
#define LIBBSP_SHARED_IRQ_INFO_H
|
||||||
|
|
||||||
#include <rtems/shell.h>
|
#include <rtems/shell.h>
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/print.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -34,8 +34,7 @@ extern "C" {
|
|||||||
* context @a context.
|
* context @a context.
|
||||||
*/
|
*/
|
||||||
void bsp_interrupt_report_with_plugin(
|
void bsp_interrupt_report_with_plugin(
|
||||||
void *context,
|
const rtems_printer *printer
|
||||||
rtems_printk_plugin_t print
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,12 +21,13 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#include <rtems/print.h>
|
||||||
|
|
||||||
#include <bsp/irq-generic.h>
|
#include <bsp/irq-generic.h>
|
||||||
#include <bsp/irq-info.h>
|
#include <bsp/irq-info.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *context;
|
const rtems_printer *printer;
|
||||||
rtems_printk_plugin_t print;
|
|
||||||
rtems_vector_number vector;
|
rtems_vector_number vector;
|
||||||
} bsp_interrupt_report_entry;
|
} 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;
|
bsp_interrupt_report_entry *e = (bsp_interrupt_report_entry *) arg;
|
||||||
const char *opt = options == RTEMS_INTERRUPT_UNIQUE ? "UNIQUE" : "SHARED";
|
const char *opt = options == RTEMS_INTERRUPT_UNIQUE ? "UNIQUE" : "SHARED";
|
||||||
|
|
||||||
e->print(
|
rtems_printf(
|
||||||
e->context,
|
e->printer,
|
||||||
"%7" PRIu32 " | %-32s | %7s | %010p | %010p\n",
|
"%7" PRIu32 " | %-32s | %7s | %p | %p\n",
|
||||||
e->vector,
|
e->vector,
|
||||||
info,
|
info,
|
||||||
opt,
|
opt,
|
||||||
@@ -53,19 +54,17 @@ static void bsp_interrupt_report_per_handler_routine(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void bsp_interrupt_report_with_plugin(
|
void bsp_interrupt_report_with_plugin(
|
||||||
void *context,
|
const rtems_printer *printer
|
||||||
rtems_printk_plugin_t print
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_vector_number v = 0;
|
rtems_vector_number v = 0;
|
||||||
bsp_interrupt_report_entry e = {
|
bsp_interrupt_report_entry e = {
|
||||||
.context = context,
|
.printer = printer,
|
||||||
.print = print,
|
|
||||||
.vector = 0
|
.vector = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
print(
|
rtems_printf(
|
||||||
context,
|
printer,
|
||||||
"-------------------------------------------------------------------------------\n"
|
"-------------------------------------------------------------------------------\n"
|
||||||
" INTERRUPT INFORMATION\n"
|
" INTERRUPT INFORMATION\n"
|
||||||
"--------+----------------------------------+---------+------------+------------\n"
|
"--------+----------------------------------+---------+------------+------------\n"
|
||||||
@@ -82,13 +81,15 @@ void bsp_interrupt_report_with_plugin(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
print(
|
rtems_printf(
|
||||||
context,
|
printer,
|
||||||
"--------+----------------------------------+---------+------------+------------\n"
|
"--------+----------------------------------+---------+------------+------------\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bsp_interrupt_report(void)
|
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)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ include_rtems_rtl_HEADERS += libdl/rap.h libdl/rap-shell.h
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
include_rtems_HEADERS += include/rtems/bspIo.h
|
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/userenv.h
|
||||||
include_rtems_HEADERS += include/rtems/fs.h
|
include_rtems_HEADERS += include/rtems/fs.h
|
||||||
if !LIBPCI
|
if !LIBPCI
|
||||||
|
|||||||
@@ -36,6 +36,15 @@ extern "C" {
|
|||||||
* - BSP_poll_char
|
* - 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
|
* This type defines the prototype for the BSP provided method to
|
||||||
* print a single character. It is assumed to be polled.
|
* 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] fmt is a printf()-style format string
|
||||||
* @param[in] ap is a va_list pointer to arguments
|
* @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
|
* @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().
|
* This method allows the user to perform a debug printk().
|
||||||
*
|
*
|
||||||
* @param[in] fmt is a printf()-style format string
|
* @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
|
* @brief Kernel Put String
|
||||||
@@ -102,8 +115,10 @@ extern void printk(const char *fmt, ...);
|
|||||||
* This method allows the user to perform a debug puts().
|
* This method allows the user to perform a debug puts().
|
||||||
*
|
*
|
||||||
* @param[in] s is the string to print
|
* @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
|
* @brief Kernel Put Character
|
||||||
@@ -118,15 +133,13 @@ extern void rtems_putc(char c);
|
|||||||
* Type definition for function which can be plugged in to
|
* Type definition for function which can be plugged in to
|
||||||
* certain reporting routines to redirect the output.
|
* certain reporting routines to redirect the output.
|
||||||
*
|
*
|
||||||
* Methods following this prototype may be passed into RTEMS reporting
|
* Use the RTEMS Print interface to call these functions. Do not
|
||||||
* functions that allow their output to be redirected. In particular,
|
* directly use them.
|
||||||
* the cpu usage, period usage, and stack usage reporting
|
|
||||||
* functions use this.
|
|
||||||
*
|
*
|
||||||
* If the user provides their own "printf plugin", then they may
|
* If the user provides their own "printf plugin", then they may
|
||||||
* redirect those reports as they see fit.
|
* 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
|
* @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.
|
* @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
|
* @brief Reporting Methods printf() Plugin
|
||||||
@@ -149,7 +162,7 @@ extern int printk_plugin(void *context, const char *fmt, ...);
|
|||||||
*
|
*
|
||||||
* @return The number of characters printed.
|
* @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.h>
|
||||||
#include <rtems/diskdevs.h>
|
#include <rtems/diskdevs.h>
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/print.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -348,15 +348,14 @@ void rtems_blkdev_print_stats(
|
|||||||
uint32_t media_block_size,
|
uint32_t media_block_size,
|
||||||
uint32_t media_block_count,
|
uint32_t media_block_count,
|
||||||
uint32_t block_size,
|
uint32_t block_size,
|
||||||
rtems_printk_plugin_t print,
|
const rtems_printer* printer
|
||||||
void *print_arg
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Block device statistics command.
|
* @brief Block device statistics command.
|
||||||
*/
|
*/
|
||||||
void rtems_blkstats(
|
void rtems_blkstats(
|
||||||
FILE *output,
|
const rtems_printer *printer,
|
||||||
const char *device,
|
const char *device,
|
||||||
bool reset
|
bool reset
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.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);
|
int fd = open(device, O_RDONLY);
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ void rtems_blkstats(FILE *output, const char *device, bool reset)
|
|||||||
if (reset) {
|
if (reset) {
|
||||||
rv = rtems_disk_fd_reset_device_stats(fd);
|
rv = rtems_disk_fd_reset_device_stats(fd);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
fprintf(output, "error: reset stats: %s\n", strerror(errno));
|
rtems_printf(printer, "error: reset stats: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uint32_t media_block_size = 0;
|
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_size,
|
||||||
media_block_count,
|
media_block_count,
|
||||||
block_size,
|
block_size,
|
||||||
(rtems_printk_plugin_t) fprintf,
|
printer
|
||||||
output
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
fprintf(output, "error: get stats: %s\n", strerror(errno));
|
rtems_printf(printer, "error: get stats: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(output, "error: not a block device\n");
|
rtems_printf(printer, "error: not a block device\n");
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
rv = close(fd);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
fprintf(output, "error: close device: %s\n", strerror(errno));
|
rtems_printf(printer, "error: close device: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
} else {
|
} 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_size,
|
||||||
uint32_t media_block_count,
|
uint32_t media_block_count,
|
||||||
uint32_t block_size,
|
uint32_t block_size,
|
||||||
rtems_printk_plugin_t print,
|
const rtems_printer* printer
|
||||||
void *print_arg
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
(*print)(
|
rtems_printf(
|
||||||
print_arg,
|
printer,
|
||||||
"-------------------------------------------------------------------------------\n"
|
"-------------------------------------------------------------------------------\n"
|
||||||
" DEVICE STATISTICS\n"
|
" DEVICE STATISTICS\n"
|
||||||
"----------------------+--------------------------------------------------------\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 \
|
libcsupport_a_SOURCES = src/gxx_wrappers.c src/getchark.c src/printk.c \
|
||||||
src/printk_plugin.c src/putk.c src/vprintk.c \
|
src/printk_plugin.c src/putk.c src/vprintk.c \
|
||||||
src/rtems_putc.c \
|
src/rtems_putc.c \
|
||||||
|
src/print_fprintf.c \
|
||||||
|
src/print_printf.c \
|
||||||
src/printf_plugin.c \
|
src/printf_plugin.c \
|
||||||
src/sup_fs_location.c \
|
src/sup_fs_location.c \
|
||||||
src/sup_fs_eval_path.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"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/print.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int rtems_printf_plugin(void *context, const char *format, ...)
|
void rtems_print_printer_printf(rtems_printer *printer)
|
||||||
{
|
{
|
||||||
int rv;
|
printer->context = NULL;
|
||||||
va_list ap;
|
printer->printer = rtems_printf_plugin;
|
||||||
|
}
|
||||||
va_start(ap, format);
|
|
||||||
rv = vprintf(format, ap);
|
int rtems_printf_plugin(void *context, const char *format, va_list ap)
|
||||||
va_end(ap);
|
{
|
||||||
|
(void) context;
|
||||||
return rv;
|
return vprintf(format, ap);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,11 +32,12 @@
|
|||||||
/**
|
/**
|
||||||
* Kernel printf function requiring minimal infrastructure.
|
* Kernel printf function requiring minimal infrastructure.
|
||||||
*/
|
*/
|
||||||
void printk(const char *fmt, ...)
|
int printk(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap; /* points to each unnamed argument in turn */
|
va_list ap; /* points to each unnamed argument in turn */
|
||||||
|
int len;
|
||||||
va_start(ap, fmt); /* make ap point to 1st unnamed arg */
|
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 */
|
va_end(ap); /* clean up when done */
|
||||||
|
return len;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,23 +19,23 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdarg.h>
|
#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(
|
int printk_plugin(
|
||||||
void *ignored,
|
void *ignored,
|
||||||
const char *format,
|
const char *format,
|
||||||
...
|
va_list ap
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
va_list arg_pointer;
|
|
||||||
|
|
||||||
(void) ignored;
|
(void) ignored;
|
||||||
|
vprintk( format, ap );
|
||||||
va_start (arg_pointer, format);
|
|
||||||
|
|
||||||
vprintk( format, arg_pointer );
|
|
||||||
|
|
||||||
va_end(arg_pointer); /* clean up when done */
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,11 +23,13 @@
|
|||||||
/**
|
/**
|
||||||
* Kernel putk (e.g. puts) function requiring minimal infrastrure.
|
* Kernel putk (e.g. puts) function requiring minimal infrastrure.
|
||||||
*/
|
*/
|
||||||
void putk(const char *s)
|
int putk(const char *s)
|
||||||
{
|
{
|
||||||
const char *p;
|
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(*p);
|
||||||
BSP_output_char('\n');
|
BSP_output_char('\n');
|
||||||
|
return len_out + 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/bspIo.h>
|
||||||
|
|
||||||
static void printNum(
|
static int printNum(
|
||||||
long long num,
|
long long num,
|
||||||
unsigned base,
|
unsigned base,
|
||||||
bool sign,
|
bool sign,
|
||||||
@@ -45,11 +45,12 @@ static void printNum(
|
|||||||
* Arguments:
|
* Arguments:
|
||||||
* as in printf: fmt - format string, ... - unnamed arguments.
|
* as in printf: fmt - format string, ... - unnamed arguments.
|
||||||
*/
|
*/
|
||||||
void vprintk(
|
int vprintk(
|
||||||
const char *fmt,
|
const char *fmt,
|
||||||
va_list ap
|
va_list ap
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
int len_out = 0;
|
||||||
for (; *fmt != '\0'; fmt++) {
|
for (; *fmt != '\0'; fmt++) {
|
||||||
unsigned base = 0;
|
unsigned base = 0;
|
||||||
unsigned width = 0;
|
unsigned width = 0;
|
||||||
@@ -66,6 +67,7 @@ void vprintk(
|
|||||||
|
|
||||||
if (c != '%') {
|
if (c != '%') {
|
||||||
rtems_putc(c);
|
rtems_putc(c);
|
||||||
|
++len_out;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +103,7 @@ void vprintk(
|
|||||||
/* need a cast here since va_arg() only takes fully promoted types */
|
/* need a cast here since va_arg() only takes fully promoted types */
|
||||||
char chr = (char) va_arg(ap, int);
|
char chr = (char) va_arg(ap, int);
|
||||||
rtems_putc(chr);
|
rtems_putc(chr);
|
||||||
|
++len_out;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +123,7 @@ void vprintk(
|
|||||||
|
|
||||||
/* leading spaces */
|
/* leading spaces */
|
||||||
if ( !minus )
|
if ( !minus )
|
||||||
for ( i=len ; i<width ; i++ )
|
for ( i=len ; i<width ; i++, len_out++ )
|
||||||
rtems_putc(' ');
|
rtems_putc(' ');
|
||||||
|
|
||||||
/* no width option */
|
/* no width option */
|
||||||
@@ -129,12 +132,12 @@ void vprintk(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* output the string */
|
/* output the string */
|
||||||
for ( i=0 ; i<width && *str ; str++ )
|
for ( i=0 ; i<width && *str ; str++, len_out++ )
|
||||||
rtems_putc(*str);
|
rtems_putc(*str);
|
||||||
|
|
||||||
/* trailing spaces */
|
/* trailing spaces */
|
||||||
if ( minus )
|
if ( minus )
|
||||||
for ( i=len ; i<width ; i++ )
|
for ( i=len ; i<width ; i++, len_out++ )
|
||||||
rtems_putc(' ');
|
rtems_putc(' ');
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@@ -154,6 +157,7 @@ void vprintk(
|
|||||||
base = 16; sign = false; lflag = LFLAG_LONG;
|
base = 16; sign = false; lflag = LFLAG_LONG;
|
||||||
} else {
|
} else {
|
||||||
rtems_putc(c);
|
rtems_putc(c);
|
||||||
|
++len_out;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,8 +176,10 @@ void vprintk(
|
|||||||
break;
|
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] num is the number to print
|
||||||
* @param[in] base is the base used to print the number
|
* @param[in] base is the base used to print the number
|
||||||
*/
|
*/
|
||||||
static void printNum(
|
static int printNum(
|
||||||
long long num,
|
long long num,
|
||||||
unsigned base,
|
unsigned base,
|
||||||
bool sign,
|
bool sign,
|
||||||
@@ -194,9 +200,11 @@ static void printNum(
|
|||||||
unsigned count;
|
unsigned count;
|
||||||
#define UINT64_MAX_IN_OCTAL_FORMAT "1777777777777777777777"
|
#define UINT64_MAX_IN_OCTAL_FORMAT "1777777777777777777777"
|
||||||
char toPrint[sizeof(UINT64_MAX_IN_OCTAL_FORMAT)];
|
char toPrint[sizeof(UINT64_MAX_IN_OCTAL_FORMAT)];
|
||||||
|
int len_out = 0;
|
||||||
|
|
||||||
if ( sign && (num < 0) ) {
|
if ( sign && (num < 0) ) {
|
||||||
rtems_putc('-');
|
rtems_putc('-');
|
||||||
|
++len_out;
|
||||||
unsigned_num = (unsigned long long) -num;
|
unsigned_num = (unsigned long long) -num;
|
||||||
if (maxwidth) maxwidth--;
|
if (maxwidth) maxwidth--;
|
||||||
} else {
|
} else {
|
||||||
@@ -210,10 +218,12 @@ static void printNum(
|
|||||||
}
|
}
|
||||||
toPrint[count++] = (char) unsigned_num;
|
toPrint[count++] = (char) unsigned_num;
|
||||||
|
|
||||||
for (n=maxwidth ; n > count; n-- )
|
for (n=maxwidth ; n > count; n--, len_out++ )
|
||||||
rtems_putc(lead);
|
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)])]);
|
rtems_putc("0123456789ABCDEF"[(int)(toPrint[count-(n+1)])]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return len_out;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,7 @@
|
|||||||
* rtems_cpu_usage_report
|
* rtems_cpu_usage_report
|
||||||
*/
|
*/
|
||||||
void rtems_cpu_usage_report_with_plugin(
|
void rtems_cpu_usage_report_with_plugin(
|
||||||
void *context,
|
const rtems_printer *printer
|
||||||
rtems_printk_plugin_t print
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
@@ -44,11 +43,8 @@ void rtems_cpu_usage_report_with_plugin(
|
|||||||
Objects_Information *information;
|
Objects_Information *information;
|
||||||
char name[13];
|
char name[13];
|
||||||
uint32_t ival, fval;
|
uint32_t ival, fval;
|
||||||
Timestamp_Control uptime, total, used, uptime_at_last_reset;
|
Timestamp_Control uptime, total, used, uptime_at_last_reset;
|
||||||
uint32_t seconds, nanoseconds;
|
uint32_t seconds, nanoseconds;
|
||||||
|
|
||||||
if ( !print )
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When not using nanosecond CPU usage resolution, we have to count
|
* When not using nanosecond CPU usage resolution, we have to count
|
||||||
@@ -58,8 +54,8 @@ void rtems_cpu_usage_report_with_plugin(
|
|||||||
_Timestamp_Set_to_zero( &total );
|
_Timestamp_Set_to_zero( &total );
|
||||||
uptime_at_last_reset = CPU_usage_Uptime_at_last_reset;
|
uptime_at_last_reset = CPU_usage_Uptime_at_last_reset;
|
||||||
|
|
||||||
(*print)(
|
rtems_printf(
|
||||||
context,
|
printer,
|
||||||
"-------------------------------------------------------------------------------\n"
|
"-------------------------------------------------------------------------------\n"
|
||||||
" CPU USAGE BY THREAD\n"
|
" CPU USAGE BY THREAD\n"
|
||||||
"------------+----------------------------------------+---------------+---------\n"
|
"------------+----------------------------------------+---------------+---------\n"
|
||||||
@@ -83,8 +79,8 @@ void rtems_cpu_usage_report_with_plugin(
|
|||||||
|
|
||||||
rtems_object_get_name( the_thread->Object.id, sizeof(name), name );
|
rtems_object_get_name( the_thread->Object.id, sizeof(name), name );
|
||||||
|
|
||||||
(*print)(
|
rtems_printf(
|
||||||
context,
|
printer,
|
||||||
" 0x%08" PRIx32 " | %-38s |",
|
" 0x%08" PRIx32 " | %-38s |",
|
||||||
the_thread->Object.id,
|
the_thread->Object.id,
|
||||||
name
|
name
|
||||||
@@ -102,7 +98,7 @@ void rtems_cpu_usage_report_with_plugin(
|
|||||||
seconds = _Timestamp_Get_seconds( &used );
|
seconds = _Timestamp_Get_seconds( &used );
|
||||||
nanoseconds = _Timestamp_Get_nanoseconds( &used ) /
|
nanoseconds = _Timestamp_Get_nanoseconds( &used ) /
|
||||||
TOD_NANOSECONDS_PER_MICROSECOND;
|
TOD_NANOSECONDS_PER_MICROSECOND;
|
||||||
(*print)( context,
|
rtems_printf( printer,
|
||||||
"%7" PRIu32 ".%06" PRIu32 " |%4" PRIu32 ".%03" PRIu32 "\n",
|
"%7" PRIu32 ".%06" PRIu32 " |%4" PRIu32 ".%03" PRIu32 "\n",
|
||||||
seconds, nanoseconds,
|
seconds, nanoseconds,
|
||||||
ival, fval
|
ival, fval
|
||||||
@@ -114,8 +110,8 @@ void rtems_cpu_usage_report_with_plugin(
|
|||||||
seconds = _Timestamp_Get_seconds( &total );
|
seconds = _Timestamp_Get_seconds( &total );
|
||||||
nanoseconds = _Timestamp_Get_nanoseconds( &total ) /
|
nanoseconds = _Timestamp_Get_nanoseconds( &total ) /
|
||||||
TOD_NANOSECONDS_PER_MICROSECOND;
|
TOD_NANOSECONDS_PER_MICROSECOND;
|
||||||
(*print)(
|
rtems_printf(
|
||||||
context,
|
printer,
|
||||||
"------------+----------------------------------------+---------------+---------\n"
|
"------------+----------------------------------------+---------------+---------\n"
|
||||||
" TIME SINCE LAST CPU USAGE RESET IN SECONDS: %7" PRIu32 ".%06" PRIu32 "\n"
|
" TIME SINCE LAST CPU USAGE RESET IN SECONDS: %7" PRIu32 ".%06" PRIu32 "\n"
|
||||||
"-------------------------------------------------------------------------------\n",
|
"-------------------------------------------------------------------------------\n",
|
||||||
@@ -125,5 +121,7 @@ void rtems_cpu_usage_report_with_plugin(
|
|||||||
|
|
||||||
void rtems_cpu_usage_report( void )
|
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/watchdogimpl.h>
|
||||||
#include <rtems/score/wkspace.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
|
* Use a struct for all data to allow more than one top and to support the
|
||||||
* thread iterator.
|
* thread iterator.
|
||||||
@@ -61,7 +52,7 @@ typedef struct
|
|||||||
volatile uint32_t sort_order;
|
volatile uint32_t sort_order;
|
||||||
volatile uint32_t poll_rate_usecs;
|
volatile uint32_t poll_rate_usecs;
|
||||||
volatile uint32_t show;
|
volatile uint32_t show;
|
||||||
rtems_cpu_usage_plugin plugin;
|
const rtems_printer* printer;
|
||||||
Timestamp_Control zero;
|
Timestamp_Control zero;
|
||||||
Timestamp_Control uptime;
|
Timestamp_Control uptime;
|
||||||
Timestamp_Control last_uptime;
|
Timestamp_Control last_uptime;
|
||||||
@@ -144,27 +135,19 @@ static inline bool less_than_uint32_t( uint32_t * lhs, uint32_t * rhs )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CPU_usage_Equal_to( _lhs, _rhs ) \
|
#define CPU_usage_Equal_to( _lhs, _rhs ) _Timestamp_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_Set_to_zero( _time ) \
|
|
||||||
_Timestamp_Set_to_zero( _time )
|
|
||||||
|
|
||||||
#define CPU_usage_Less_than( _lhs, _rhs ) \
|
|
||||||
_Timestamp_Less_than( _lhs, _rhs )
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_memsize(rtems_cpu_usage_data* data, const uint32_t size, const char* label)
|
print_memsize(rtems_cpu_usage_data* data, const uint32_t size, const char* label)
|
||||||
{
|
{
|
||||||
if (size > (1024 * 1024))
|
if (size > (1024 * 1024))
|
||||||
(*data->plugin.print)(data->plugin.context, "%4" PRIu32 "M %s",
|
rtems_printf(data->printer, "%4" PRIu32 "M %s", size / (1024 * 1024), label);
|
||||||
size / (1024 * 1024), label);
|
|
||||||
else if (size > 1024)
|
else if (size > 1024)
|
||||||
(*data->plugin.print)(data->plugin.context, "%4" PRIu32 "K %s",
|
rtems_printf(data->printer, "%4" PRIu32 "K %s", size / 1024, label);
|
||||||
size / 1024, label);
|
|
||||||
else
|
else
|
||||||
(*data->plugin.print)(data->plugin.context, "%4" PRIu32 " %s",
|
rtems_printf(data->printer, "%4" PRIu32 " %s", size, label);
|
||||||
size, label);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -184,19 +167,19 @@ print_time(rtems_cpu_usage_data* data,
|
|||||||
uint32_t hours = mins / 60;
|
uint32_t hours = mins / 60;
|
||||||
if (hours > 24)
|
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;
|
hours %= 24;
|
||||||
}
|
}
|
||||||
len += (*data->plugin.print)(data->plugin.context, "%" PRIu32 "hr", hours);
|
len += rtems_printf(data->printer, "%" PRIu32 "hr", hours);
|
||||||
mins %= 60;
|
mins %= 60;
|
||||||
}
|
}
|
||||||
len += (*data->plugin.print)(data->plugin.context, "%" PRIu32 "m", mins);
|
len += rtems_printf(data->printer, "%" PRIu32 "m", mins);
|
||||||
secs %= 60;
|
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)
|
if (len < length)
|
||||||
(*data->plugin.print)(data->plugin.context, "%*c", length - len, ' ');
|
rtems_printf(data->printer, "%*c", length - len, ' ');
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
@@ -344,7 +327,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
|
|||||||
data->current_usage = realloc(data->current_usage, usage_size);
|
data->current_usage = realloc(data->current_usage, usage_size);
|
||||||
if ((data->tasks == NULL) || (data->usage == NULL) || (data->current_usage == NULL))
|
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;
|
data->thread_run = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -371,7 +354,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
|
|||||||
data->last_usage = realloc(data->last_usage, usage_size);
|
data->last_usage = realloc(data->last_usage, usage_size);
|
||||||
if ((data->last_tasks == NULL) || (data->last_usage == NULL))
|
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;
|
data->thread_run = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -396,43 +379,43 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
|
|||||||
_Protected_heap_Get_information(&_Workspace_Area, &wksp);
|
_Protected_heap_Get_information(&_Workspace_Area, &wksp);
|
||||||
|
|
||||||
if (data->single_page)
|
if (data->single_page)
|
||||||
(*data->plugin.print)(data->plugin.context,
|
rtems_printf(data->printer,
|
||||||
"\x1b[H\x1b[J"
|
"\x1b[H\x1b[J"
|
||||||
" ENTER:Exit SPACE:Refresh"
|
" ENTER:Exit SPACE:Refresh"
|
||||||
" S:Scroll A:All <>:Order +/-:Lines\n");
|
" 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.
|
* Uptime and period of this sample.
|
||||||
*/
|
*/
|
||||||
(*data->plugin.print)(data->plugin.context, "Uptime: ");
|
rtems_printf(data->printer, "Uptime: ");
|
||||||
print_time(data, &data->uptime, 20);
|
print_time(data, &data->uptime, 20);
|
||||||
(*data->plugin.print)(data->plugin.context, " Period: ");
|
rtems_printf(data->printer, " Period: ");
|
||||||
print_time(data, &data->period, 20);
|
print_time(data, &data->period, 20);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Task count, load and idle levels.
|
* 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_Subtract(&data->idle, &data->total, &load);
|
||||||
_Timestamp_Divide(&load, &data->uptime, &ival, &fval);
|
_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);
|
"Load Average: %4" PRIu32 ".%03" PRIu32 "%%", ival, fval);
|
||||||
_Timestamp_Subtract(&data->current_idle, &data->current, &load);
|
_Timestamp_Subtract(&data->current_idle, &data->current, &load);
|
||||||
_Timestamp_Divide(&load, &data->period, &ival, &fval);
|
_Timestamp_Divide(&load, &data->period, &ival, &fval);
|
||||||
(*data->plugin.print)(data->plugin.context,
|
rtems_printf(data->printer,
|
||||||
" Load: %4" PRIu32 ".%03" PRIu32 "%%", ival, fval);
|
" Load: %4" PRIu32 ".%03" PRIu32 "%%", ival, fval);
|
||||||
_Timestamp_Divide(&data->current_idle, &data->period, &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);
|
" Idle: %4" PRIu32 ".%03" PRIu32 "%%", ival, fval);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Memory usage.
|
* Memory usage.
|
||||||
*/
|
*/
|
||||||
if (rtems_configuration_get_unified_work_area())
|
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.Free.total, "free");
|
||||||
print_memsize(data, wksp.Used.total, "used");
|
print_memsize(data, wksp.Used.total, "used");
|
||||||
}
|
}
|
||||||
@@ -440,7 +423,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
|
|||||||
{
|
{
|
||||||
region_information_block libc_heap;
|
region_information_block libc_heap;
|
||||||
malloc_info(&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.Free.total, "free");
|
||||||
print_memsize(data, wksp.Used.total, "used Heap: ");
|
print_memsize(data, wksp.Used.total, "used Heap: ");
|
||||||
print_memsize(data, libc_heap.Free.total, "free");
|
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");
|
print_memsize(data, data->stack_size, "stack\n");
|
||||||
|
|
||||||
(*data->plugin.print)(data->plugin.context,
|
rtems_printf(data->printer,
|
||||||
"\n"
|
"\n"
|
||||||
" ID | NAME | RPRI | CPRI | TIME | TOTAL | CURRENT\n"
|
" ID | NAME | RPRI | CPRI | TIME | TOTAL | CURRENT\n"
|
||||||
"-%s---------+---------------------+-%s-----%s-----+---------------------+-%s------+--%s----\n",
|
"-%s---------+---------------------+-%s-----%s-----+---------------------+-%s------+--%s----\n",
|
||||||
@@ -487,12 +470,12 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
|
|||||||
if (name[0] == '\0')
|
if (name[0] == '\0')
|
||||||
snprintf(name, sizeof(name) - 1, "(%p)", thread->Start.Entry.Kinds.Numeric.entry);
|
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 " | ",
|
" 0x%08" PRIx32 " | %-19s | %3" PRId32 " | %3" PRId32 " | ",
|
||||||
thread->Object.id,
|
thread->Object.id,
|
||||||
name,
|
name,
|
||||||
thread->real_priority,
|
thread->real_priority,
|
||||||
thread->current_priority);
|
thread->current_priority);
|
||||||
|
|
||||||
usage = data->usage[i];
|
usage = data->usage[i];
|
||||||
current_usage = data->current_usage[i];
|
current_usage = data->current_usage[i];
|
||||||
@@ -502,11 +485,11 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
|
|||||||
*/
|
*/
|
||||||
print_time(data, &usage, 19);
|
print_time(data, &usage, 19);
|
||||||
_Timestamp_Divide(&usage, &data->total, &ival, &fval);
|
_Timestamp_Divide(&usage, &data->total, &ival, &fval);
|
||||||
(*data->plugin.print)(data->plugin.context,
|
rtems_printf(data->printer,
|
||||||
" |%4" PRIu32 ".%03" PRIu32, ival, fval);
|
" |%4" PRIu32 ".%03" PRIu32, ival, fval);
|
||||||
_Timestamp_Divide(¤t_usage, &data->period, &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);
|
" |%4" PRIu32 ".%03" PRIu32 "\n", ival, fval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->single_page && (data->show != 0) && (task_count < data->show))
|
if (data->single_page && (data->show != 0) && (task_count < data->show))
|
||||||
@@ -514,7 +497,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
|
|||||||
i = data->show - task_count;
|
i = data->show - task_count;
|
||||||
while (i > 0)
|
while (i > 0)
|
||||||
{
|
{
|
||||||
(*data->plugin.print)(data->plugin.context, "\x1b[K\n");
|
rtems_printf(data->printer, "\x1b[K\n");
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -525,8 +508,8 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
|
|||||||
&out);
|
&out);
|
||||||
if ((sc != RTEMS_SUCCESSFUL) && (sc != RTEMS_TIMEOUT))
|
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));
|
"error: event receive: %s\n", rtems_status_text(sc));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -542,8 +525,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void rtems_cpu_usage_top_with_plugin(
|
void rtems_cpu_usage_top_with_plugin(
|
||||||
void *context,
|
const rtems_printer *printer
|
||||||
rtems_printk_plugin_t print
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
@@ -553,9 +535,6 @@ void rtems_cpu_usage_top_with_plugin(
|
|||||||
rtems_cpu_usage_data data;
|
rtems_cpu_usage_data data;
|
||||||
int show_lines = 25;
|
int show_lines = 25;
|
||||||
|
|
||||||
if ( !print )
|
|
||||||
return;
|
|
||||||
|
|
||||||
memset(&data, 0, sizeof(data));
|
memset(&data, 0, sizeof(data));
|
||||||
|
|
||||||
data.thread_run = true;
|
data.thread_run = true;
|
||||||
@@ -563,18 +542,14 @@ void rtems_cpu_usage_top_with_plugin(
|
|||||||
data.sort_order = RTEMS_TOP_SORT_CURRENT;
|
data.sort_order = RTEMS_TOP_SORT_CURRENT;
|
||||||
data.poll_rate_usecs = 3000;
|
data.poll_rate_usecs = 3000;
|
||||||
data.show = show_lines;
|
data.show = show_lines;
|
||||||
data.plugin.context = context;
|
data.printer = printer;
|
||||||
data.plugin.print = print;
|
|
||||||
|
|
||||||
sc = rtems_task_set_priority (RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority);
|
sc = rtems_task_set_priority (RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority);
|
||||||
|
|
||||||
if (sc != RTEMS_SUCCESSFUL)
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
{
|
{
|
||||||
(*print)(
|
rtems_printf (printer,
|
||||||
context,
|
"error: cannot obtain the current priority: %s\n", rtems_status_text (sc));
|
||||||
"error: cannot obtain the current priority: %s\n",
|
|
||||||
rtems_status_text (sc)
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,24 +562,16 @@ void rtems_cpu_usage_top_with_plugin(
|
|||||||
|
|
||||||
if (sc != RTEMS_SUCCESSFUL)
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
{
|
{
|
||||||
(*print)(
|
rtems_printf (printer,
|
||||||
context,
|
"error: cannot create helper thread: %s\n", rtems_status_text (sc));
|
||||||
"error: cannot create helper thread: %s\n",
|
|
||||||
rtems_status_text (sc)
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc = rtems_task_start (
|
sc = rtems_task_start (id, rtems_cpuusage_top_thread, (rtems_task_argument) &data);
|
||||||
id, rtems_cpuusage_top_thread, (rtems_task_argument) &data
|
|
||||||
);
|
|
||||||
if (sc != RTEMS_SUCCESSFUL)
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
{
|
{
|
||||||
(*print)(
|
rtems_printf (printer,
|
||||||
context,
|
"error: cannot start helper thread: %s\n", rtems_status_text (sc));
|
||||||
"error: cannot start helper thread: %s\n",
|
|
||||||
rtems_status_text (sc)
|
|
||||||
);
|
|
||||||
rtems_task_delete (id);
|
rtems_task_delete (id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -624,7 +591,7 @@ void rtems_cpu_usage_top_with_plugin(
|
|||||||
while (loops && data.thread_active)
|
while (loops && data.thread_active)
|
||||||
rtems_task_wake_after (RTEMS_MICROSECONDS_TO_TICKS (100000));
|
rtems_task_wake_after (RTEMS_MICROSECONDS_TO_TICKS (100000));
|
||||||
|
|
||||||
(*print)(context, "load monitoring stopped.\n");
|
rtems_printf (printer, "load monitoring stopped.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (c == '<')
|
else if (c == '<')
|
||||||
@@ -676,7 +643,9 @@ void rtems_cpu_usage_top_with_plugin(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rtems_cpu_usage_top( void )
|
void rtems_cpu_usage_top (void)
|
||||||
{
|
{
|
||||||
rtems_cpu_usage_top_with_plugin( NULL, printk_plugin );
|
rtems_printer printer;
|
||||||
|
rtems_print_printer_printk (&printer);
|
||||||
|
rtems_cpu_usage_top_with_plugin (&printer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#define __RTEMS_CPUUSE_h
|
#define __RTEMS_CPUUSE_h
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/print.h>
|
||||||
|
|
||||||
#include <rtems/score/timestamp.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
|
* rtems_cpu_usage_report_with_handler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void rtems_cpu_usage_report_with_plugin(
|
void rtems_cpu_usage_report_with_plugin( const rtems_printer *printer );
|
||||||
void *context,
|
|
||||||
rtems_printk_plugin_t handler
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Report CPU usage.
|
* @brief Report CPU usage.
|
||||||
@@ -62,10 +59,7 @@ void rtems_cpu_usage_report( void );
|
|||||||
* Report CPU Usage in top format to
|
* Report CPU Usage in top format to
|
||||||
* to a print plugin.
|
* to a print plugin.
|
||||||
*/
|
*/
|
||||||
void rtems_cpu_usage_top_with_plugin(
|
void rtems_cpu_usage_top_with_plugin( const rtems_printer *printer );
|
||||||
void *context,
|
|
||||||
rtems_printk_plugin_t print
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CPU usage top.
|
* @brief CPU usage top.
|
||||||
|
|||||||
@@ -43,12 +43,13 @@ void uid_print_message(
|
|||||||
struct MW_UID_MESSAGE *uid
|
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 uid_print_message_with_plugin(
|
||||||
void *context,
|
const rtems_printer *printer,
|
||||||
rtems_printk_plugin_t handler,
|
|
||||||
struct MW_UID_MESSAGE *uid
|
struct MW_UID_MESSAGE *uid
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -56,11 +57,11 @@ void uid_print_message_with_plugin(
|
|||||||
|
|
||||||
switch (uid->type) {
|
switch (uid->type) {
|
||||||
case MV_UID_INVALID:
|
case MV_UID_INVALID:
|
||||||
(*handler)( context, "MV_UID_INVALID\n" );
|
rtems_printf( printer, "MV_UID_INVALID\n" );
|
||||||
break;
|
break;
|
||||||
case MV_UID_REL_POS:
|
case MV_UID_REL_POS:
|
||||||
(*handler)(
|
rtems_printf(
|
||||||
context,
|
printer,
|
||||||
"MV_UID_REL_POS - %s x=%d y=%d z=%d\n",
|
"MV_UID_REL_POS - %s x=%d y=%d z=%d\n",
|
||||||
uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)),
|
uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)),
|
||||||
uid->m.pos.x, /* x location */
|
uid->m.pos.x, /* x location */
|
||||||
@@ -69,8 +70,8 @@ void uid_print_message_with_plugin(
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case MV_UID_ABS_POS:
|
case MV_UID_ABS_POS:
|
||||||
(*handler)(
|
rtems_printf(
|
||||||
context,
|
printer,
|
||||||
"MV_UID_ABS_POS - %s x=%d y=%d z=%d\n",
|
"MV_UID_ABS_POS - %s x=%d y=%d z=%d\n",
|
||||||
uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)),
|
uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)),
|
||||||
uid->m.pos.x, /* x location */
|
uid->m.pos.x, /* x location */
|
||||||
@@ -79,7 +80,7 @@ void uid_print_message_with_plugin(
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case MV_UID_KBD:
|
case MV_UID_KBD:
|
||||||
(*handler)( context,
|
rtems_printf( printer,
|
||||||
"MV_UID_KBD - code=0x%04x modifiers=0x%02x mode=0x%02x\n",
|
"MV_UID_KBD - code=0x%04x modifiers=0x%02x mode=0x%02x\n",
|
||||||
uid->m.kbd.code, /* keycode or scancode */
|
uid->m.kbd.code, /* keycode or scancode */
|
||||||
uid->m.kbd.modifiers, /* key modifiers */
|
uid->m.kbd.modifiers, /* key modifiers */
|
||||||
@@ -87,10 +88,10 @@ void uid_print_message_with_plugin(
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case MV_UID_TIMER:
|
case MV_UID_TIMER:
|
||||||
(*handler)( context, "MV_UID_TIMER\n" );
|
rtems_printf( printer, "MV_UID_TIMER\n" );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
(*handler)( context, "Invalid device type\n" );
|
rtems_printf( printer, "Invalid device type\n" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#define _MW_UID_H
|
#define _MW_UID_H
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/print.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup libmisc_fb_mw Input Devices for MicroWindows
|
* @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
|
* This methods prints the specified UID message using your fprintf
|
||||||
* style method of choice.
|
* style method of choice.
|
||||||
*
|
*
|
||||||
* @param[in] context is a pointer to a data area which may be
|
* @param[in] RTEMS printer
|
||||||
* used by some print handlers
|
|
||||||
* @param[in] handler is the fprintf style method to invoke
|
|
||||||
* @param[in] uid points to the message to print
|
* @param[in] uid points to the message to print
|
||||||
*/
|
*/
|
||||||
void uid_print_message_with_plugin(
|
void uid_print_message_with_plugin(
|
||||||
void *context,
|
const rtems_printer *printer,
|
||||||
rtems_printk_plugin_t handler,
|
|
||||||
struct MW_UID_MESSAGE *uid
|
struct MW_UID_MESSAGE *uid
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ static int rtems_shell_main_blkstats(int argc, char **argv)
|
|||||||
bool ok = false;
|
bool ok = false;
|
||||||
bool reset = false;
|
bool reset = false;
|
||||||
const char *device;
|
const char *device;
|
||||||
|
rtems_printer printer;
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
ok = true;
|
ok = true;
|
||||||
@@ -41,10 +42,12 @@ static int rtems_shell_main_blkstats(int argc, char **argv)
|
|||||||
device = argv [2];
|
device = argv [2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtems_print_printer_printf(&printer);
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
rtems_blkstats(stdout, device, reset);
|
rtems_blkstats(&printer, device, reset);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stdout, "usage: %s\n", rtems_shell_BLKSTATS_Command.usage);
|
rtems_printf(&printer, "usage: %s\n", rtems_shell_BLKSTATS_Command.usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ static int rtems_shell_main_cpuuse(
|
|||||||
* When invoked with no arguments, print the report.
|
* When invoked with no arguments, print the report.
|
||||||
*/
|
*/
|
||||||
if ( argc == 1 ) {
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,10 @@ static int rtems_shell_main_perioduse(
|
|||||||
* When invoked with no arguments, print the report.
|
* When invoked with no arguments, print the report.
|
||||||
*/
|
*/
|
||||||
if ( argc == 1 ) {
|
if ( argc == 1 ) {
|
||||||
|
rtems_printer printer;
|
||||||
|
rtems_print_printer_printf(&printer);
|
||||||
rtems_rate_monotonic_report_statistics_with_plugin(
|
rtems_rate_monotonic_report_statistics_with_plugin(
|
||||||
stdout,
|
&printer
|
||||||
(rtems_printk_plugin_t)fprintf
|
|
||||||
);
|
);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,11 @@
|
|||||||
|
|
||||||
static int rtems_shell_main_profreport(int argc, char **argv)
|
static int rtems_shell_main_profreport(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
rtems_printer printer;
|
||||||
|
rtems_print_printer_printf(&printer);
|
||||||
rtems_profiling_report_xml(
|
rtems_profiling_report_xml(
|
||||||
"Shell",
|
"Shell",
|
||||||
(rtems_profiling_printf) fprintf,
|
&printer,
|
||||||
stdout,
|
|
||||||
0,
|
0,
|
||||||
" "
|
" "
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -25,10 +25,9 @@ static int rtems_shell_main_stackuse(
|
|||||||
char *argv[] RTEMS_UNUSED
|
char *argv[] RTEMS_UNUSED
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_stack_checker_report_usage_with_plugin(
|
rtems_printer printer;
|
||||||
stdout,
|
rtems_print_printer_printf(&printer);
|
||||||
(rtems_printk_plugin_t)fprintf
|
rtems_stack_checker_report_usage_with_plugin( &printer );
|
||||||
);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ static int rtems_shell_main_top(
|
|||||||
* When invoked with no arguments, print the report.
|
* When invoked with no arguments, print the report.
|
||||||
*/
|
*/
|
||||||
if ( argc == 1 ) {
|
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;
|
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.
|
* Try to print out how much stack was actually used by the task.
|
||||||
*/
|
*/
|
||||||
static void *print_context;
|
static const rtems_printer* printer;
|
||||||
static rtems_printk_plugin_t print_handler;
|
|
||||||
|
|
||||||
static void Stack_check_Dump_threads_usage(
|
static void Stack_check_Dump_threads_usage(
|
||||||
Thread_Control *the_thread
|
Thread_Control *the_thread
|
||||||
@@ -438,8 +437,8 @@ static void Stack_check_Dump_threads_usage(
|
|||||||
if ( the_thread )
|
if ( the_thread )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
(*print_handler)(
|
rtems_printf(
|
||||||
print_context,
|
printer,
|
||||||
"0x%08" PRIx32 " %4s",
|
"0x%08" PRIx32 " %4s",
|
||||||
the_thread->Object.id,
|
the_thread->Object.id,
|
||||||
rtems_object_get_name( the_thread->Object.id, sizeof(name), name )
|
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)
|
#if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE)
|
||||||
else {
|
else {
|
||||||
(*print_handler)( print_context, "0x%08" PRIx32 " INTR", ~0 );
|
rtems_printf( printer, "0x%08" PRIx32 " INTR", ~0 );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
(*print_handler)(
|
rtems_printf(
|
||||||
print_context,
|
printer,
|
||||||
" %010p - %010p %010p %8" PRId32 " ",
|
" %010p - %010p %010p %8" PRId32 " ",
|
||||||
stack->area,
|
stack->area,
|
||||||
stack->area + stack->size - 1,
|
stack->area + stack->size - 1,
|
||||||
@@ -461,9 +460,9 @@ static void Stack_check_Dump_threads_usage(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (Stack_check_Initialized == 0) {
|
if (Stack_check_Initialized == 0) {
|
||||||
(*print_handler)( print_context, "Unavailable\n" );
|
rtems_printf( printer, "Unavailable\n" );
|
||||||
} else {
|
} 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 rtems_stack_checker_report_usage_with_plugin(
|
||||||
void *context,
|
const rtems_printer* printer_
|
||||||
rtems_printk_plugin_t print
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ( !print )
|
if ( printer != NULL || ! rtems_print_printer_valid ( printer_ ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
print_context = context;
|
printer = printer_;
|
||||||
print_handler = print;
|
|
||||||
|
|
||||||
(*print)( context, "Stack usage by thread\n");
|
rtems_printf( printer, "Stack usage by thread\n");
|
||||||
(*print)( context,
|
rtems_printf( printer,
|
||||||
" ID NAME LOW HIGH CURRENT AVAILABLE USED\n"
|
" 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);
|
Stack_check_Dump_threads_usage((Thread_Control *) -1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
print_context = NULL;
|
printer = NULL;
|
||||||
print_handler = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rtems_stack_checker_report_usage( void )
|
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 <stdbool.h> /* bool */
|
||||||
|
|
||||||
#include <rtems/score/thread.h> /* Thread_Control */
|
#include <rtems/score/thread.h> /* Thread_Control */
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/print.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup libmisc_stackchk Stack Checker Mechanism
|
* @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.
|
* @note It uses the caller's routine to print the report.
|
||||||
*/
|
*/
|
||||||
void rtems_stack_checker_report_usage_with_plugin(
|
void rtems_stack_checker_report_usage_with_plugin(
|
||||||
void *context,
|
const rtems_printer *printer
|
||||||
rtems_printk_plugin_t print
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#define _RTEMS_TEST_H
|
#define _RTEMS_TEST_H
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/print.h>
|
||||||
#include <rtems/score/atomic.h>
|
#include <rtems/score/atomic.h>
|
||||||
#include <rtems/score/smpbarrier.h>
|
#include <rtems/score/smpbarrier.h>
|
||||||
|
|
||||||
@@ -37,6 +37,11 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
extern const char rtems_test_name[];
|
extern const char rtems_test_name[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Each test must define a printer.
|
||||||
|
*/
|
||||||
|
extern rtems_printer rtems_test_printer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fatal extension for tests.
|
* @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 }
|
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, rtems_test_fatal_extension }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints a begin of test message.
|
* @brief Begin of test message format string.
|
||||||
*
|
|
||||||
* @param[in] printf_func The formatted output function.
|
|
||||||
* @param[in, out] printf_arg The formatted output function argument.
|
|
||||||
*
|
|
||||||
* @returns As specified by printf().
|
|
||||||
*/
|
*/
|
||||||
int rtems_test_begin_with_plugin(
|
#define TEST_BEGIN_STRING "\n\n*** BEGIN OF TEST %s ***\n", rtems_test_name
|
||||||
rtems_printk_plugin_t printf_func,
|
|
||||||
void *printf_arg
|
/**
|
||||||
);
|
* @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().
|
* @brief Prints a begin of test message using printf().
|
||||||
*
|
*
|
||||||
* @returns As specified by printf().
|
* @returns As specified by printf().
|
||||||
*/
|
*/
|
||||||
static inline int rtems_test_begin(void)
|
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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints an end of test message using printf().
|
* @brief Prints an end of test message using printf().
|
||||||
*
|
*
|
||||||
* @returns As specified by printf().
|
* @returns As specified by printf().
|
||||||
*/
|
*/
|
||||||
static inline int rtems_test_end(void)
|
int rtems_test_end(void);
|
||||||
{
|
|
||||||
return rtems_test_end_with_plugin(rtems_printf_plugin, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints an end of test message using printk().
|
* @brief Prints via the RTEMS printer.
|
||||||
*
|
*
|
||||||
* @returns As specified by printf().
|
* @returns As specified by printf().
|
||||||
*/
|
*/
|
||||||
static inline int rtems_test_endk(void)
|
int rtems_test_print(const char* format, ...) RTEMS_PRINTF_ATTRIBUTE(1, 2);
|
||||||
{
|
|
||||||
return rtems_test_end_with_plugin(printk_plugin, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Internal context for parallel job execution.
|
* @brief Internal context for parallel job execution.
|
||||||
|
|||||||
@@ -18,26 +18,35 @@
|
|||||||
|
|
||||||
#include <rtems/test.h>
|
#include <rtems/test.h>
|
||||||
|
|
||||||
int rtems_test_begin_with_plugin(
|
int rtems_test_begin(void)
|
||||||
rtems_printk_plugin_t printf_func,
|
|
||||||
void *printf_arg
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return (*printf_func)(
|
return rtems_printf(
|
||||||
printf_arg,
|
&rtems_test_printer,
|
||||||
"\n\n*** BEGIN OF TEST %s ***\n",
|
TEST_BEGIN_STRING
|
||||||
rtems_test_name
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rtems_test_end_with_plugin(
|
int rtems_test_end(void)
|
||||||
rtems_printk_plugin_t printf_func,
|
|
||||||
void *printf_arg
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return (*printf_func)(
|
return rtems_printf(
|
||||||
printf_arg,
|
&rtems_test_printer,
|
||||||
"*** END OF TEST %s ***\n",
|
TEST_END_STRING
|
||||||
rtems_test_name
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
#if defined(RTEMS_PROFILING)
|
||||||
rtems_interrupt_lock_context lock_context;
|
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
|
* 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_profiling_report_xml(
|
||||||
rtems_test_name,
|
rtems_test_name,
|
||||||
printk_plugin,
|
&printer,
|
||||||
NULL,
|
|
||||||
1,
|
1,
|
||||||
" "
|
" "
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -224,6 +224,10 @@ $(PROJECT_INCLUDE)/rtems/bspIo.h: include/rtems/bspIo.h $(PROJECT_INCLUDE)/rtems
|
|||||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bspIo.h
|
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bspIo.h
|
||||||
PREINSTALL_FILES += $(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)
|
$(PROJECT_INCLUDE)/rtems/userenv.h: include/rtems/userenv.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
|
||||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/userenv.h
|
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/userenv.h
|
||||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/userenv.h
|
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/userenv.h
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
#include <rtems/rtems/status.h>
|
#include <rtems/rtems/status.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
#include <rtems/score/watchdog.h>
|
#include <rtems/score/watchdog.h>
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/print.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -356,14 +356,13 @@ void rtems_rate_monotonic_reset_all_statistics( void );
|
|||||||
* @brief RTEMS Report Rate Monotonic Statistics
|
* @brief RTEMS Report Rate Monotonic Statistics
|
||||||
*
|
*
|
||||||
* This routine allows a thread to print the statistics information
|
* This routine allows a thread to print the statistics information
|
||||||
* on ALL period instances which have non-zero counts using printk.
|
* on ALL period instances which have non-zero counts using the RTEMS
|
||||||
* The implementation of this directive straddles the fence between
|
* printer. The implementation of this directive straddles the fence
|
||||||
* inside and outside of RTEMS. It is presented as part of the Manager
|
* between inside and outside of RTEMS. It is presented as part of
|
||||||
* but actually uses other services of the Manager.
|
* the Manager but actually uses other services of the Manager.
|
||||||
*/
|
*/
|
||||||
void rtems_rate_monotonic_report_statistics_with_plugin(
|
void rtems_rate_monotonic_report_statistics_with_plugin(
|
||||||
void *context,
|
const rtems_printer *printer
|
||||||
rtems_printk_plugin_t print
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <rtems/rtems/ratemonimpl.h>
|
#include <rtems/rtems/ratemonimpl.h>
|
||||||
#include <rtems/rtems/object.h>
|
#include <rtems/rtems/object.h>
|
||||||
|
#include <rtems/print.h>
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
@@ -29,8 +30,7 @@
|
|||||||
#define NANOSECONDS_FMT "%06" PRId32
|
#define NANOSECONDS_FMT "%06" PRId32
|
||||||
|
|
||||||
void rtems_rate_monotonic_report_statistics_with_plugin(
|
void rtems_rate_monotonic_report_statistics_with_plugin(
|
||||||
void *context,
|
const rtems_printer *printer
|
||||||
rtems_printk_plugin_t print
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_status_code status;
|
rtems_status_code status;
|
||||||
@@ -39,12 +39,9 @@ void rtems_rate_monotonic_report_statistics_with_plugin(
|
|||||||
rtems_rate_monotonic_period_status the_status;
|
rtems_rate_monotonic_period_status the_status;
|
||||||
char name[5];
|
char name[5];
|
||||||
|
|
||||||
if ( !print )
|
rtems_printf( printer, "Period information by period\n" );
|
||||||
return;
|
rtems_printf( printer, "--- CPU times are in seconds ---\n" );
|
||||||
|
rtems_printf( printer, "--- Wall times are in seconds ---\n" );
|
||||||
(*print)( context, "Period information by period\n" );
|
|
||||||
(*print)( context, "--- CPU times are in seconds ---\n" );
|
|
||||||
(*print)( context, "--- Wall times are in seconds ---\n" );
|
|
||||||
/*
|
/*
|
||||||
Layout by columns -- in memory of Hollerith :)
|
Layout by columns -- in memory of Hollerith :)
|
||||||
|
|
||||||
@@ -58,7 +55,7 @@ ididididid NNNN ccccc mmmmmm X
|
|||||||
1234567890123456789012345678901234567890123456789012345678901234567890123456789\
|
1234567890123456789012345678901234567890123456789012345678901234567890123456789\
|
||||||
\n");
|
\n");
|
||||||
*/
|
*/
|
||||||
(*print)( context,
|
rtems_printf( printer,
|
||||||
" ID OWNER COUNT MISSED "
|
" ID OWNER COUNT MISSED "
|
||||||
" CPU TIME WALL TIME\n"
|
" 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 part of report line that is not dependent on granularity
|
||||||
*/
|
*/
|
||||||
(*print)( context,
|
rtems_printf( printer,
|
||||||
"0x%08" PRIx32 " %4s %5" PRId32 " %6" PRId32 " ",
|
"0x%08" PRIx32 " %4s %5" PRId32 " %6" PRId32 " ",
|
||||||
id, name,
|
id, name,
|
||||||
the_stats.count, the_stats.missed_count
|
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 count is zero, don't print statistics
|
||||||
*/
|
*/
|
||||||
if (the_stats.count == 0) {
|
if (the_stats.count == 0) {
|
||||||
(*print)( context, "\n" );
|
rtems_printf( printer, "\n" );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +111,7 @@ ididididid NNNN ccccc mmmmmm X
|
|||||||
struct timespec *total_cpu = &the_stats.total_cpu_time;
|
struct timespec *total_cpu = &the_stats.total_cpu_time;
|
||||||
|
|
||||||
_Timespec_Divide_by_integer( total_cpu, the_stats.count, &cpu_average );
|
_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 "/" /* min cpu time */
|
||||||
"%" PRId32 "." NANOSECONDS_FMT "/" /* max cpu time */
|
"%" PRId32 "." NANOSECONDS_FMT "/" /* max cpu time */
|
||||||
"%" PRId32 "." NANOSECONDS_FMT " ", /* avg 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;
|
struct timespec *total_wall = &the_stats.total_wall_time;
|
||||||
|
|
||||||
_Timespec_Divide_by_integer(total_wall, the_stats.count, &wall_average);
|
_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 "/" /* min wall time */
|
||||||
"%" PRId32 "." NANOSECONDS_FMT "/" /* max wall time */
|
"%" PRId32 "." NANOSECONDS_FMT "/" /* max wall time */
|
||||||
"%" PRId32 "." NANOSECONDS_FMT "\n", /* avg 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 )
|
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 <stdint.h>
|
||||||
|
|
||||||
|
#include <rtems/print.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
@@ -305,25 +307,11 @@ void rtems_profiling_iterate(
|
|||||||
void *visitor_arg
|
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.
|
* @brief Reports profiling data as XML.
|
||||||
*
|
*
|
||||||
* @param[in] name The name of the profiling report.
|
* @param[in] name The name of the profiling report.
|
||||||
* @param[in] printf_func The formatted output function.
|
* @param[in] printer The RTEMS printer to send the output too.
|
||||||
* @param[in, out] printf_arg The formatted output function argument.
|
|
||||||
* @param[in] indentation_level The current indentation level.
|
* @param[in] indentation_level The current indentation level.
|
||||||
* @param[in] indentation The string used for indentation.
|
* @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(
|
int rtems_profiling_report_xml(
|
||||||
const char *name,
|
const char *name,
|
||||||
rtems_profiling_printf printf_func,
|
const rtems_printer *printer,
|
||||||
void *printf_arg,
|
|
||||||
uint32_t indentation_level,
|
uint32_t indentation_level,
|
||||||
const char *indentation
|
const char *indentation
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
rtems_profiling_printf printf_func;
|
const rtems_printer *printer;
|
||||||
void *printf_arg;
|
|
||||||
uint32_t indentation_level;
|
uint32_t indentation_level;
|
||||||
const char *indentation;
|
const char *indentation;
|
||||||
int retval;
|
int retval;
|
||||||
@@ -43,7 +42,7 @@ static void indent(context *ctx, uint32_t indentation_level)
|
|||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
for (i = 0; i < n; ++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);
|
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)
|
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;
|
int rv;
|
||||||
|
|
||||||
indent(ctx, 1);
|
indent(ctx, 1);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<PerCPUProfilingReport processorIndex=\"%" PRIu32 "\">\n",
|
"<PerCPUProfilingReport processorIndex=\"%" PRIu32 "\">\n",
|
||||||
per_cpu->processor_index
|
per_cpu->processor_index
|
||||||
);
|
);
|
||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<MaxThreadDispatchDisabledTime unit=\"ns\">%" PRIu32
|
"<MaxThreadDispatchDisabledTime unit=\"ns\">%" PRIu32
|
||||||
"</MaxThreadDispatchDisabledTime>\n",
|
"</MaxThreadDispatchDisabledTime>\n",
|
||||||
per_cpu->max_thread_dispatch_disabled_time
|
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);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<MeanThreadDispatchDisabledTime unit=\"ns\">%" PRIu64
|
"<MeanThreadDispatchDisabledTime unit=\"ns\">%" PRIu64
|
||||||
"</MeanThreadDispatchDisabledTime>\n",
|
"</MeanThreadDispatchDisabledTime>\n",
|
||||||
arithmetic_mean(
|
arithmetic_mean(
|
||||||
@@ -90,8 +87,8 @@ static void report_per_cpu(context *ctx, const rtems_profiling_per_cpu *per_cpu)
|
|||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<TotalThreadDispatchDisabledTime unit=\"ns\">%" PRIu64
|
"<TotalThreadDispatchDisabledTime unit=\"ns\">%" PRIu64
|
||||||
"</TotalThreadDispatchDisabledTime>\n",
|
"</TotalThreadDispatchDisabledTime>\n",
|
||||||
per_cpu->total_thread_dispatch_disabled_time
|
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);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<ThreadDispatchDisabledCount>%" PRIu64 "</ThreadDispatchDisabledCount>\n",
|
"<ThreadDispatchDisabledCount>%" PRIu64 "</ThreadDispatchDisabledCount>\n",
|
||||||
per_cpu->thread_dispatch_disabled_count
|
per_cpu->thread_dispatch_disabled_count
|
||||||
);
|
);
|
||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<MaxInterruptDelay unit=\"ns\">%" PRIu32 "</MaxInterruptDelay>\n",
|
"<MaxInterruptDelay unit=\"ns\">%" PRIu32 "</MaxInterruptDelay>\n",
|
||||||
per_cpu->max_interrupt_delay
|
per_cpu->max_interrupt_delay
|
||||||
);
|
);
|
||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<MaxInterruptTime unit=\"ns\">%" PRIu32
|
"<MaxInterruptTime unit=\"ns\">%" PRIu32
|
||||||
"</MaxInterruptTime>\n",
|
"</MaxInterruptTime>\n",
|
||||||
per_cpu->max_interrupt_time
|
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);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<MeanInterruptTime unit=\"ns\">%" PRIu64
|
"<MeanInterruptTime unit=\"ns\">%" PRIu64
|
||||||
"</MeanInterruptTime>\n",
|
"</MeanInterruptTime>\n",
|
||||||
arithmetic_mean(
|
arithmetic_mean(
|
||||||
@@ -136,24 +133,24 @@ static void report_per_cpu(context *ctx, const rtems_profiling_per_cpu *per_cpu)
|
|||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<TotalInterruptTime unit=\"ns\">%" PRIu64 "</TotalInterruptTime>\n",
|
"<TotalInterruptTime unit=\"ns\">%" PRIu64 "</TotalInterruptTime>\n",
|
||||||
per_cpu->total_interrupt_time
|
per_cpu->total_interrupt_time
|
||||||
);
|
);
|
||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<InterruptCount>%" PRIu64 "</InterruptCount>\n",
|
"<InterruptCount>%" PRIu64 "</InterruptCount>\n",
|
||||||
per_cpu->interrupt_count
|
per_cpu->interrupt_count
|
||||||
);
|
);
|
||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 1);
|
indent(ctx, 1);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"</PerCPUProfilingReport>\n"
|
"</PerCPUProfilingReport>\n"
|
||||||
);
|
);
|
||||||
update_retval(ctx, rv);
|
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)
|
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;
|
int rv;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
indent(ctx, 1);
|
indent(ctx, 1);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<SMPLockProfilingReport name=\"%s\">\n",
|
"<SMPLockProfilingReport name=\"%s\">\n",
|
||||||
smp_lock->name
|
smp_lock->name
|
||||||
);
|
);
|
||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<MaxAcquireTime unit=\"ns\">%" PRIu32 "</MaxAcquireTime>\n",
|
"<MaxAcquireTime unit=\"ns\">%" PRIu32 "</MaxAcquireTime>\n",
|
||||||
smp_lock->max_acquire_time
|
smp_lock->max_acquire_time
|
||||||
);
|
);
|
||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<MaxSectionTime unit=\"ns\">%" PRIu32 "</MaxSectionTime>\n",
|
"<MaxSectionTime unit=\"ns\">%" PRIu32 "</MaxSectionTime>\n",
|
||||||
smp_lock->max_section_time
|
smp_lock->max_section_time
|
||||||
);
|
);
|
||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<MeanAcquireTime unit=\"ns\">%" PRIu64
|
"<MeanAcquireTime unit=\"ns\">%" PRIu64
|
||||||
"</MeanAcquireTime>\n",
|
"</MeanAcquireTime>\n",
|
||||||
arithmetic_mean(
|
arithmetic_mean(
|
||||||
@@ -203,8 +198,8 @@ static void report_smp_lock(context *ctx, const rtems_profiling_smp_lock *smp_lo
|
|||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<MeanSectionTime unit=\"ns\">%" PRIu64
|
"<MeanSectionTime unit=\"ns\">%" PRIu64
|
||||||
"</MeanSectionTime>\n",
|
"</MeanSectionTime>\n",
|
||||||
arithmetic_mean(
|
arithmetic_mean(
|
||||||
@@ -215,24 +210,24 @@ static void report_smp_lock(context *ctx, const rtems_profiling_smp_lock *smp_lo
|
|||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<TotalAcquireTime unit=\"ns\">%" PRIu64 "</TotalAcquireTime>\n",
|
"<TotalAcquireTime unit=\"ns\">%" PRIu64 "</TotalAcquireTime>\n",
|
||||||
smp_lock->total_acquire_time
|
smp_lock->total_acquire_time
|
||||||
);
|
);
|
||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<TotalSectionTime unit=\"ns\">%" PRIu64 "</TotalSectionTime>\n",
|
"<TotalSectionTime unit=\"ns\">%" PRIu64 "</TotalSectionTime>\n",
|
||||||
smp_lock->total_section_time
|
smp_lock->total_section_time
|
||||||
);
|
);
|
||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<UsageCount>%" PRIu64 "</UsageCount>\n",
|
"<UsageCount>%" PRIu64 "</UsageCount>\n",
|
||||||
smp_lock->usage_count
|
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) {
|
for (i = 0; i < RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS; ++i) {
|
||||||
indent(ctx, 2);
|
indent(ctx, 2);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"<ContentionCount initialQueueLength=\"%" PRIu32 "\">%"
|
"<ContentionCount initialQueueLength=\"%" PRIu32 "\">%"
|
||||||
PRIu64 "</ContentionCount>\n",
|
PRIu64 "</ContentionCount>\n",
|
||||||
i,
|
i,
|
||||||
@@ -251,8 +246,8 @@ static void report_smp_lock(context *ctx, const rtems_profiling_smp_lock *smp_lo
|
|||||||
}
|
}
|
||||||
|
|
||||||
indent(ctx, 1);
|
indent(ctx, 1);
|
||||||
rv = (*printf_func)(
|
rv = rtems_printf(
|
||||||
printf_arg,
|
ctx->printer,
|
||||||
"</SMPLockProfilingReport>\n"
|
"</SMPLockProfilingReport>\n"
|
||||||
);
|
);
|
||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
@@ -276,16 +271,14 @@ static void report(void *arg, const rtems_profiling_data *data)
|
|||||||
|
|
||||||
int rtems_profiling_report_xml(
|
int rtems_profiling_report_xml(
|
||||||
const char *name,
|
const char *name,
|
||||||
rtems_profiling_printf printf_func,
|
const rtems_printer *printer,
|
||||||
void *printf_arg,
|
|
||||||
uint32_t indentation_level,
|
uint32_t indentation_level,
|
||||||
const char *indentation
|
const char *indentation
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
#ifdef RTEMS_PROFILING
|
#ifdef RTEMS_PROFILING
|
||||||
context ctx_instance = {
|
context ctx_instance = {
|
||||||
.printf_func = printf_func,
|
.printer = printer,
|
||||||
.printf_arg = printf_arg,
|
|
||||||
.indentation_level = indentation_level,
|
.indentation_level = indentation_level,
|
||||||
.indentation = indentation,
|
.indentation = indentation,
|
||||||
.retval = 0
|
.retval = 0
|
||||||
@@ -294,20 +287,19 @@ int rtems_profiling_report_xml(
|
|||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
indent(ctx, 0);
|
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);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
rtems_profiling_iterate(report, ctx);
|
rtems_profiling_iterate(report, ctx);
|
||||||
|
|
||||||
indent(ctx, 0);
|
indent(ctx, 0);
|
||||||
rv = (*printf_func)(printf_arg, "</ProfilingReport>\n");
|
rv = rtems_printf(printer, "</ProfilingReport>\n");
|
||||||
update_retval(ctx, rv);
|
update_retval(ctx, rv);
|
||||||
|
|
||||||
return ctx->retval;
|
return ctx->retval;
|
||||||
#else /* RTEMS_PROFILING */
|
#else /* RTEMS_PROFILING */
|
||||||
(void) name;
|
(void) name;
|
||||||
(void) printf_func;
|
(void) printer;
|
||||||
(void) printf_arg;
|
|
||||||
(void) indentation_level;
|
(void) indentation_level;
|
||||||
(void) indentation;
|
(void) indentation;
|
||||||
|
|
||||||
|
|||||||
@@ -23,16 +23,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/print.h>
|
||||||
#include <rtems/score/cpusetimpl.h>
|
#include <rtems/score/cpusetimpl.h>
|
||||||
|
|
||||||
#ifdef __RTEMS_HAVE_SYS_CPUSET_H__
|
#ifdef __RTEMS_HAVE_SYS_CPUSET_H__
|
||||||
|
|
||||||
void _CPU_set_Show_with_plugin(
|
void _CPU_set_Show_with_plugin(
|
||||||
void *context,
|
const rtems_printer *printer,
|
||||||
rtems_printk_plugin_t print,
|
const char *description,
|
||||||
const char *description,
|
const cpu_set_t *cpuset
|
||||||
const cpu_set_t *cpuset
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -42,21 +41,16 @@
|
|||||||
* print plugin .
|
* print plugin .
|
||||||
*/
|
*/
|
||||||
void _CPU_set_Show_with_plugin(
|
void _CPU_set_Show_with_plugin(
|
||||||
void *context,
|
const rtems_printer *printer,
|
||||||
rtems_printk_plugin_t print,
|
const char *description,
|
||||||
const char *description,
|
const cpu_set_t *cpuset
|
||||||
const cpu_set_t *cpuset
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
rtems_printf(printer ,"%s: ", description);
|
||||||
if ( !print )
|
|
||||||
return;
|
|
||||||
|
|
||||||
(*print)(context ,"%s: ", description);
|
|
||||||
for(i=0; i<_NCPUWORDS; i++)
|
for(i=0; i<_NCPUWORDS; i++)
|
||||||
(*print)(context ,"%x", cpuset->__bits[i]);
|
rtems_printf(printer ,"%x", cpuset->__bits[i]);
|
||||||
(*print)(context ,"\n");
|
rtems_printf(printer ,"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -67,7 +61,9 @@
|
|||||||
*/
|
*/
|
||||||
void _CPU_set_Show( const char *description, const cpu_set_t *cpuset)
|
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)
|
static void Init(rtems_task_argument arg)
|
||||||
{
|
{
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
test_initial_values();
|
test_initial_values();
|
||||||
test_location_obtain();
|
test_location_obtain();
|
||||||
@@ -506,7 +506,7 @@ static void Init(rtems_task_argument arg)
|
|||||||
test_user_env();
|
test_user_env();
|
||||||
test_check_access();
|
test_check_access();
|
||||||
|
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
#include "tmacros.h"
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <rtems.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_assert(bd->dd == dd_a);
|
||||||
|
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -136,7 +137,7 @@ static rtems_task Init(rtems_task_argument argument)
|
|||||||
dev_t dev_a = 0;
|
dev_t dev_a = 0;
|
||||||
dev_t dev_b = 0;
|
dev_t dev_b = 0;
|
||||||
|
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
sc = rtems_disk_io_initialize();
|
sc = rtems_disk_io_initialize();
|
||||||
ASSERT_SC(sc);
|
ASSERT_SC(sc);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
#include "tmacros.h"
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
@@ -76,7 +77,7 @@ static void task_low(rtems_task_argument arg)
|
|||||||
|
|
||||||
rtems_test_assert(bd->block == 0);
|
rtems_test_assert(bd->block == 0);
|
||||||
|
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -129,7 +130,7 @@ static rtems_task Init(rtems_task_argument argument)
|
|||||||
rtems_bdbuf_buffer *bd = NULL;
|
rtems_bdbuf_buffer *bd = NULL;
|
||||||
dev_t dev = 0;
|
dev_t dev = 0;
|
||||||
|
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
sc = rtems_disk_io_initialize();
|
sc = rtems_disk_io_initialize();
|
||||||
ASSERT_SC(sc);
|
ASSERT_SC(sc);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
#include "tmacros.h"
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
@@ -101,7 +102,7 @@ static void task_high(rtems_task_argument arg)
|
|||||||
|
|
||||||
printk("H: release done: 0\n");
|
printk("H: release done: 0\n");
|
||||||
|
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -111,7 +112,7 @@ static rtems_task Init(rtems_task_argument argument)
|
|||||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||||
dev_t dev = 0;
|
dev_t dev = 0;
|
||||||
|
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
sc = rtems_disk_io_initialize();
|
sc = rtems_disk_io_initialize();
|
||||||
ASSERT_SC(sc);
|
ASSERT_SC(sc);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
#include "tmacros.h"
|
#include "tmacros.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -426,7 +427,7 @@ static rtems_task Init(rtems_task_argument argument)
|
|||||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
|
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
task_id_init = rtems_task_self();
|
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);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include <bsp.h>
|
#include <bsp.h>
|
||||||
|
|
||||||
#include <tmacros.h>
|
#include "tmacros.h"
|
||||||
|
|
||||||
const char rtems_test_name[] = "BLOCK 6";
|
const char rtems_test_name[] = "BLOCK 6";
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
#include "tmacros.h"
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
@@ -102,7 +104,7 @@ static void task_low(rtems_task_argument arg)
|
|||||||
|
|
||||||
printk("L: release done: 0\n");
|
printk("L: release done: 0\n");
|
||||||
|
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -164,7 +166,7 @@ static rtems_task Init(rtems_task_argument argument)
|
|||||||
rtems_bdbuf_buffer *bd = NULL;
|
rtems_bdbuf_buffer *bd = NULL;
|
||||||
dev_t dev = 0;
|
dev_t dev = 0;
|
||||||
|
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
sc = rtems_disk_io_initialize();
|
sc = rtems_disk_io_initialize();
|
||||||
ASSERT_SC(sc);
|
ASSERT_SC(sc);
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#define CONFIGURE_INIT
|
#define CONFIGURE_INIT
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
@@ -30,10 +32,9 @@ const char rtems_test_name[] = "BLOCK 8";
|
|||||||
|
|
||||||
rtems_task Init(rtems_task_argument argument)
|
rtems_task Init(rtems_task_argument argument)
|
||||||
{
|
{
|
||||||
rtems_test_begin();
|
TEST_BEGIN();
|
||||||
run_bdbuf_tests();
|
run_bdbuf_tests();
|
||||||
rtems_test_end();
|
TEST_END();
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,9 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -176,7 +179,7 @@ static rtems_task Init(rtems_task_argument argument)
|
|||||||
dev_t dev = 0;
|
dev_t dev = 0;
|
||||||
rtems_disk_device *dd = NULL;
|
rtems_disk_device *dd = NULL;
|
||||||
|
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
sc = rtems_disk_io_initialize();
|
sc = rtems_disk_io_initialize();
|
||||||
ASSERT_SC(sc);
|
ASSERT_SC(sc);
|
||||||
@@ -224,7 +227,7 @@ static rtems_task Init(rtems_task_argument argument)
|
|||||||
sc = rtems_disk_release(dd);
|
sc = rtems_disk_release(dd);
|
||||||
ASSERT_SC(sc);
|
ASSERT_SC(sc);
|
||||||
|
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,9 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -402,7 +405,7 @@ static rtems_task Init(rtems_task_argument argument)
|
|||||||
size_t i_rel = 0;
|
size_t i_rel = 0;
|
||||||
size_t i_p = 0;
|
size_t i_p = 0;
|
||||||
|
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
task_id_init = rtems_task_self();
|
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);
|
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)
|
static void test_actions(rtems_disk_device *dd)
|
||||||
{
|
{
|
||||||
|
rtems_printer printer;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
rtems_print_printer_printf(&printer);
|
||||||
|
|
||||||
for (i = 0; i < ACTION_COUNT; ++i) {
|
for (i = 0; i < ACTION_COUNT; ++i) {
|
||||||
const test_action *action = &actions [i];
|
const test_action *action = &actions [i];
|
||||||
rtems_status_code sc;
|
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)
|
static void test(void)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
rtems_task Init(rtems_task_argument argument);
|
rtems_task Init(rtems_task_argument argument);
|
||||||
|
|
||||||
const char rtems_test_name[] = "CAPTURE 1";
|
const char rtems_test_name[] = "CAPTURE 1";
|
||||||
|
rtems_printer rtems_test_printer;
|
||||||
|
|
||||||
rtems_task Init(
|
rtems_task Init(
|
||||||
rtems_task_argument ignored
|
rtems_task_argument ignored
|
||||||
@@ -46,6 +47,8 @@ rtems_task Init(
|
|||||||
rtems_mode old_mode;
|
rtems_mode old_mode;
|
||||||
rtems_name to_name = rtems_build_name('I', 'D', 'L', 'E');;
|
rtems_name to_name = rtems_build_name('I', 'D', 'L', 'E');;
|
||||||
|
|
||||||
|
rtems_print_printer_printf(&rtems_test_printer);
|
||||||
|
|
||||||
rtems_test_begin();
|
rtems_test_begin();
|
||||||
|
|
||||||
rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
|
rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <rtems/test.h>
|
#include <rtems/test.h>
|
||||||
|
|
||||||
const char rtems_test_name[] = "COMPLEX";
|
const char rtems_test_name[] = "COMPLEX";
|
||||||
|
rtems_printer rtems_test_printer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -60,6 +61,7 @@ int main( void )
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if __rtems__
|
#if __rtems__
|
||||||
|
rtems_print_printer_printf(&rtems_test_printer);
|
||||||
rtems_test_begin();
|
rtems_test_begin();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#define FATAL_ERROR_EXPECTED_IS_INTERNAL FALSE
|
#define FATAL_ERROR_EXPECTED_IS_INTERNAL FALSE
|
||||||
#define FATAL_ERROR_EXPECTED_ERROR RTEMS_TOO_MANY
|
#define FATAL_ERROR_EXPECTED_ERROR RTEMS_TOO_MANY
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
|
||||||
#include <rtems/devnull.h>
|
#include <rtems/devnull.h>
|
||||||
#include "tmacros.h"
|
#include "tmacros.h"
|
||||||
|
|
||||||
@@ -28,4 +30,3 @@ void force_error()
|
|||||||
/* A fatal error would be raised in previous call */
|
/* A fatal error would be raised in previous call */
|
||||||
/* we will not run this far */
|
/* we will not run this far */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,13 +16,15 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* Use assert() not rtems_test_assert() since it uses exit() */
|
/* Use assert() not rtems_test_assert() since it uses exit() */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/test.h>
|
|
||||||
|
|
||||||
const char rtems_test_name[] = "EXIT 1";
|
const char rtems_test_name[] = "EXIT 1";
|
||||||
|
|
||||||
@@ -60,7 +62,7 @@ static void fatal_extension(
|
|||||||
&& error == EXIT_STATUS
|
&& error == EXIT_STATUS
|
||||||
&& counter == 3
|
&& counter == 3
|
||||||
) {
|
) {
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +87,7 @@ static void Init(rtems_task_argument arg)
|
|||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
rtems_id id;
|
rtems_id id;
|
||||||
|
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
sc = rtems_task_create(
|
sc = rtems_task_create(
|
||||||
rtems_build_name('E', 'X', 'I', 'T'),
|
rtems_build_name('E', 'X', 'I', 'T'),
|
||||||
|
|||||||
@@ -16,13 +16,15 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* Use assert() not rtems_test_assert() since it uses exit() */
|
/* Use assert() not rtems_test_assert() since it uses exit() */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/test.h>
|
|
||||||
|
|
||||||
const char rtems_test_name[] = "EXIT 2";
|
const char rtems_test_name[] = "EXIT 2";
|
||||||
|
|
||||||
@@ -44,7 +46,7 @@ static void fatal_extension(
|
|||||||
&& !is_internal
|
&& !is_internal
|
||||||
&& error == EXIT_STATUS
|
&& error == EXIT_STATUS
|
||||||
) {
|
) {
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +65,7 @@ static void Init(rtems_task_argument arg)
|
|||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
rtems_id id;
|
rtems_id id;
|
||||||
|
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
sc = rtems_task_create(
|
sc = rtems_task_create(
|
||||||
rtems_build_name('E', 'X', 'I', 'T'),
|
rtems_build_name('E', 'X', 'I', 'T'),
|
||||||
|
|||||||
@@ -22,11 +22,16 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @fixme This test should use the test macros but the include paths are
|
||||||
|
* are wrong in the build system.
|
||||||
|
*/
|
||||||
#if __rtems__
|
#if __rtems__
|
||||||
#include <bsp.h> /* for device driver prototypes */
|
#include <bsp.h> /* for device driver prototypes */
|
||||||
#include <rtems/test.h>
|
#include <rtems/test.h>
|
||||||
|
|
||||||
const char rtems_test_name[] = "MATH";
|
const char rtems_test_name[] = "MATH";
|
||||||
|
rtems_printer rtems_test_printer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -58,6 +63,7 @@ int main( void )
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if __rtems__
|
#if __rtems__
|
||||||
|
rtems_print_printer_printf(&rtems_test_printer);
|
||||||
rtems_test_begin();
|
rtems_test_begin();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -68,4 +74,3 @@ int main( void )
|
|||||||
#endif
|
#endif
|
||||||
exit( 0 );
|
exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <rtems/test.h>
|
#include <rtems/test.h>
|
||||||
|
|
||||||
const char rtems_test_name[] = "MATHF";
|
const char rtems_test_name[] = "MATHF";
|
||||||
|
rtems_printer rtems_test_printer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -58,6 +59,7 @@ int main( void )
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if __rtems__
|
#if __rtems__
|
||||||
|
rtems_print_printer_printf(&rtems_test_printer);
|
||||||
rtems_test_begin();
|
rtems_test_begin();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -68,4 +70,3 @@ int main( void )
|
|||||||
#endif
|
#endif
|
||||||
exit( 0 );
|
exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <rtems/test.h>
|
#include <rtems/test.h>
|
||||||
|
|
||||||
const char rtems_test_name[] = "MATHL";
|
const char rtems_test_name[] = "MATHL";
|
||||||
|
rtems_printer rtems_test_printer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -58,6 +59,7 @@ int main( void )
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if __rtems__
|
#if __rtems__
|
||||||
|
rtems_print_printer_printf(&rtems_test_printer);
|
||||||
rtems_test_begin();
|
rtems_test_begin();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -95,9 +95,10 @@ void printf_uid_message(
|
|||||||
struct MW_UID_MESSAGE *uid
|
struct MW_UID_MESSAGE *uid
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
rtems_printer printer;
|
||||||
|
rtems_print_printer_printf( &printer );
|
||||||
uid_print_message_with_plugin(
|
uid_print_message_with_plugin(
|
||||||
stdout,
|
&printer,
|
||||||
(rtems_printk_plugin_t)fprintf,
|
|
||||||
uid
|
uid
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,6 +101,6 @@ void Fatal_extension(
|
|||||||
} else if ( error != rtems_build_name( 'T', 'A', '1', ' ' ) ) {
|
} else if ( error != rtems_build_name( 'T', 'A', '1', ' ' ) ) {
|
||||||
printk( "unexpected fatal error\n" );
|
printk( "unexpected fatal error\n" );
|
||||||
} else {
|
} else {
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
* http://www.rtems.org/license/LICENSE.
|
* http://www.rtems.org/license/LICENSE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
#include <tmacros.h>
|
#include <tmacros.h>
|
||||||
|
|
||||||
/* macros */
|
/* macros */
|
||||||
|
|||||||
@@ -69,9 +69,10 @@ void printf_uid_message(
|
|||||||
struct MW_UID_MESSAGE *uid
|
struct MW_UID_MESSAGE *uid
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
rtems_printer printer;
|
||||||
|
rtems_print_printer_printf( &printer );
|
||||||
uid_print_message_with_plugin(
|
uid_print_message_with_plugin(
|
||||||
stdout,
|
&printer,
|
||||||
(rtems_printk_plugin_t)fprintf,
|
|
||||||
uid
|
uid
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#define CONFIGURE_INIT
|
#define CONFIGURE_INIT
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
@@ -22,7 +25,7 @@ static void print_test_begin_message(void)
|
|||||||
|
|
||||||
if (!done) {
|
if (!done) {
|
||||||
done = true;
|
done = true;
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +98,6 @@ void Fatal_extension(
|
|||||||
&& is_internal == FATAL_ERROR_EXPECTED_IS_INTERNAL
|
&& is_internal == FATAL_ERROR_EXPECTED_IS_INTERNAL
|
||||||
&& error == FATAL_ERROR_EXPECTED_ERROR
|
&& 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);
|
static void notification(int fd, int seconds_remaining, void *arg);
|
||||||
|
|
||||||
const char rtems_test_name[] = "CAPTURE ENGINE";
|
const char rtems_test_name[] = "CAPTURE ENGINE";
|
||||||
|
rtems_printer rtems_test_printer;
|
||||||
|
|
||||||
volatile int can_proceed = 1;
|
volatile int can_proceed = 1;
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ rtems_task Init(
|
|||||||
rtems_task_priority old_priority;
|
rtems_task_priority old_priority;
|
||||||
rtems_mode old_mode;
|
rtems_mode old_mode;
|
||||||
|
|
||||||
|
rtems_print_printer_printf(&rtems_test_printer);
|
||||||
rtems_test_begin();
|
rtems_test_begin();
|
||||||
|
|
||||||
status = rtems_shell_wait_for_input(
|
status = rtems_shell_wait_for_input(
|
||||||
|
|||||||
@@ -22,11 +22,13 @@
|
|||||||
rtems_task Init(rtems_task_argument argument);
|
rtems_task Init(rtems_task_argument argument);
|
||||||
|
|
||||||
const char rtems_test_name[] = "HELLO WORLD";
|
const char rtems_test_name[] = "HELLO WORLD";
|
||||||
|
rtems_printer rtems_test_printer;
|
||||||
|
|
||||||
rtems_task Init(
|
rtems_task Init(
|
||||||
rtems_task_argument ignored
|
rtems_task_argument ignored
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
rtems_print_printer_printf(&rtems_test_printer);
|
||||||
rtems_test_begin();
|
rtems_test_begin();
|
||||||
printf( "Hello World\n" );
|
printf( "Hello World\n" );
|
||||||
rtems_test_end();
|
rtems_test_end();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
extern int paranoia(int, char **);
|
extern int paranoia(int, char **);
|
||||||
|
|
||||||
const char rtems_test_name[] = "PARANOIA";
|
const char rtems_test_name[] = "PARANOIA";
|
||||||
|
rtems_printer rtems_test_printer;
|
||||||
|
|
||||||
char *args[2] = { "paranoia", 0 };
|
char *args[2] = { "paranoia", 0 };
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ rtems_task Init(
|
|||||||
M68KFPSPInstallExceptionHandlers ();
|
M68KFPSPInstallExceptionHandlers ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
rtems_print_printer_printf(&rtems_test_printer);
|
||||||
rtems_test_begin();
|
rtems_test_begin();
|
||||||
paranoia(1, args);
|
paranoia(1, args);
|
||||||
rtems_test_end();
|
rtems_test_end();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ rtems_task Test_task(
|
|||||||
|
|
||||||
static void success(void)
|
static void success(void)
|
||||||
{
|
{
|
||||||
rtems_test_end_with_plugin(locked_printf_plugin, NULL);
|
rtems_test_end();
|
||||||
rtems_test_exit( 0 );
|
rtems_test_exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ rtems_task Init(
|
|||||||
rtems_status_code status;
|
rtems_status_code status;
|
||||||
|
|
||||||
locked_print_initialize();
|
locked_print_initialize();
|
||||||
rtems_test_begin_with_plugin(locked_printf_plugin, NULL);
|
rtems_test_begin();
|
||||||
|
|
||||||
if ( rtems_get_processor_count() == 1 ) {
|
if ( rtems_get_processor_count() == 1 ) {
|
||||||
success();
|
success();
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ rtems_task Test_task(
|
|||||||
|
|
||||||
static void success(void)
|
static void success(void)
|
||||||
{
|
{
|
||||||
rtems_test_end_with_plugin(locked_printf_plugin, NULL);
|
rtems_test_end( );
|
||||||
rtems_test_exit( 0 );
|
rtems_test_exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ rtems_task Init(
|
|||||||
rtems_id Timer;
|
rtems_id Timer;
|
||||||
|
|
||||||
locked_print_initialize();
|
locked_print_initialize();
|
||||||
rtems_test_begin_with_plugin(locked_printf_plugin, NULL);
|
rtems_test_begin();
|
||||||
|
|
||||||
if ( rtems_get_processor_count() == 1 ) {
|
if ( rtems_get_processor_count() == 1 ) {
|
||||||
success();
|
success();
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/test.h>
|
|
||||||
#include <rtems/score/percpu.h>
|
#include <rtems/score/percpu.h>
|
||||||
#include <rtems/score/smpimpl.h>
|
#include <rtems/score/smpimpl.h>
|
||||||
#include <rtems/score/smpbarrier.h>
|
#include <rtems/score/smpbarrier.h>
|
||||||
@@ -62,7 +64,7 @@ static void fatal_extension(
|
|||||||
assert(state == PER_CPU_STATE_SHUTDOWN);
|
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_count = rtems_get_processor_count();
|
||||||
uint32_t cpu;
|
uint32_t cpu;
|
||||||
|
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
assert(rtems_configuration_get_maximum_processors() == MAX_CPUS);
|
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;
|
per_cpu->state = PER_CPU_STATE_SHUTDOWN;
|
||||||
} else {
|
} else {
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/test.h>
|
|
||||||
#include <rtems/score/percpu.h>
|
#include <rtems/score/percpu.h>
|
||||||
#include <rtems/score/smpimpl.h>
|
#include <rtems/score/smpimpl.h>
|
||||||
#include <rtems/score/smpbarrier.h>
|
#include <rtems/score/smpbarrier.h>
|
||||||
@@ -67,7 +69,7 @@ static void fatal_extension(
|
|||||||
assert(state == PER_CPU_STATE_SHUTDOWN);
|
assert(state == PER_CPU_STATE_SHUTDOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
} else {
|
} else {
|
||||||
assert(source == RTEMS_FATAL_SOURCE_SMP);
|
assert(source == RTEMS_FATAL_SOURCE_SMP);
|
||||||
assert(code == SMP_FATAL_SHUTDOWN);
|
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_count = rtems_get_processor_count();
|
||||||
uint32_t cpu;
|
uint32_t cpu;
|
||||||
|
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
assert(rtems_configuration_get_maximum_processors() == MAX_CPUS);
|
assert(rtems_configuration_get_maximum_processors() == MAX_CPUS);
|
||||||
|
|
||||||
@@ -112,7 +114,7 @@ static rtems_status_code test_driver_init(
|
|||||||
if (cpu_count > 1) {
|
if (cpu_count > 1) {
|
||||||
rtems_fatal(RTEMS_FATAL_SOURCE_APPLICATION, 0xdeadbeef);
|
rtems_fatal(RTEMS_FATAL_SOURCE_APPLICATION, 0xdeadbeef);
|
||||||
} else {
|
} else {
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/test.h>
|
|
||||||
#include <rtems/score/smpimpl.h>
|
#include <rtems/score/smpimpl.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -36,14 +38,14 @@ static void fatal_extension(
|
|||||||
rtems_fatal_code code
|
rtems_fatal_code code
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
source == RTEMS_FATAL_SOURCE_SMP
|
source == RTEMS_FATAL_SOURCE_SMP
|
||||||
&& !is_internal
|
&& !is_internal
|
||||||
&& code == SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER
|
&& code == SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER
|
||||||
) {
|
) {
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/test.h>
|
|
||||||
#include <rtems/score/smpimpl.h>
|
#include <rtems/score/smpimpl.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -36,14 +38,14 @@ static void fatal_extension(
|
|||||||
rtems_fatal_code code
|
rtems_fatal_code code
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
source == RTEMS_FATAL_SOURCE_SMP
|
source == RTEMS_FATAL_SOURCE_SMP
|
||||||
&& !is_internal
|
&& !is_internal
|
||||||
&& code == SMP_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT
|
&& code == SMP_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT
|
||||||
) {
|
) {
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/test.h>
|
|
||||||
#include <rtems/score/smpimpl.h>
|
#include <rtems/score/smpimpl.h>
|
||||||
|
|
||||||
#include <bsp.h>
|
#include <bsp.h>
|
||||||
@@ -93,14 +95,14 @@ static void fatal_extension(
|
|||||||
rtems_fatal_code code
|
rtems_fatal_code code
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
source == RTEMS_FATAL_SOURCE_SMP
|
source == RTEMS_FATAL_SOURCE_SMP
|
||||||
&& !is_internal
|
&& !is_internal
|
||||||
&& code == SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED
|
&& code == SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED
|
||||||
) {
|
) {
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,9 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
#include <tmacros.h>
|
#include <tmacros.h>
|
||||||
|
|
||||||
#include "test_support.h"
|
#include "test_support.h"
|
||||||
#include "rtems/error.h"
|
#include "rtems/error.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -32,7 +34,7 @@ static void fatal_extension(
|
|||||||
&& !is_internal
|
&& !is_internal
|
||||||
&& error == ENOMEM
|
&& error == ENOMEM
|
||||||
) {
|
) {
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,9 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
#include <tmacros.h>
|
#include <tmacros.h>
|
||||||
|
|
||||||
#include "test_support.h"
|
#include "test_support.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <rtems/error.h>
|
#include <rtems/error.h>
|
||||||
@@ -32,7 +34,7 @@ static void fatal_extension(
|
|||||||
&& !is_internal
|
&& !is_internal
|
||||||
&& error == 1
|
&& error == 1
|
||||||
) {
|
) {
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <tmacros.h>
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
#include "test_support.h"
|
#include "test_support.h"
|
||||||
|
|
||||||
const char rtems_test_name[] = "SPERROR 3";
|
const char rtems_test_name[] = "SPERROR 3";
|
||||||
@@ -30,7 +31,7 @@ static void fatal_extension(
|
|||||||
&& !is_internal
|
&& !is_internal
|
||||||
&& error == 0
|
&& error == 0
|
||||||
) {
|
) {
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,13 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <rtems/test.h>
|
|
||||||
|
|
||||||
#include <bsp.h>
|
#include <bsp.h>
|
||||||
|
|
||||||
const char rtems_test_name[] = "SPEXTENSIONS 1";
|
const char rtems_test_name[] = "SPEXTENSIONS 1";
|
||||||
@@ -199,7 +200,7 @@ static void two_fatal(
|
|||||||
if (source == RTEMS_FATAL_SOURCE_EXIT) {
|
if (source == RTEMS_FATAL_SOURCE_EXIT) {
|
||||||
assert_reverse_order(2);
|
assert_reverse_order(2);
|
||||||
assert(counter == 72);
|
assert(counter == 72);
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,7 +425,7 @@ static void test(void)
|
|||||||
|
|
||||||
static void Init(rtems_task_argument arg)
|
static void Init(rtems_task_argument arg)
|
||||||
{
|
{
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
test();
|
test();
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ void force_error()
|
|||||||
"WARNING - Test not applicable on this target architecture.\n"
|
"WARNING - Test not applicable on this target architecture.\n"
|
||||||
"WARNING - Only applicable when CPU_ALLOCATE_INTERRUPT_STACK == TRUE.\n"
|
"WARNING - Only applicable when CPU_ALLOCATE_INTERRUPT_STACK == TRUE.\n"
|
||||||
);
|
);
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
rtems_test_exit(0);
|
rtems_test_exit(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,6 @@
|
|||||||
void force_error()
|
void force_error()
|
||||||
{
|
{
|
||||||
/* This fatal error depends on the Termios device configuration */
|
/* This fatal error depends on the Termios device configuration */
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
rtems_test_exit(0);
|
rtems_test_exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
#include "tmacros.h"
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@@ -51,7 +52,7 @@ static void provoke_aligment_or_data_access_exception( void )
|
|||||||
|
|
||||||
static void Init( rtems_task_argument arg )
|
static void Init( rtems_task_argument arg )
|
||||||
{
|
{
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
provoke_aligment_or_data_access_exception();
|
provoke_aligment_or_data_access_exception();
|
||||||
|
|
||||||
@@ -69,7 +70,7 @@ static void fatal_extension(
|
|||||||
|
|
||||||
rtems_exception_frame_print( (const rtems_exception_frame *) code );
|
rtems_exception_frame_print( (const rtems_exception_frame *) code );
|
||||||
|
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CONFIGURE_INITIAL_EXTENSIONS \
|
#define CONFIGURE_INITIAL_EXTENSIONS \
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ static void print_test_begin_message(void)
|
|||||||
|
|
||||||
if (!done) {
|
if (!done) {
|
||||||
done = true;
|
done = true;
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,6 @@ void Fatal_extension(
|
|||||||
&& is_internal == FATAL_ERROR_EXPECTED_IS_INTERNAL
|
&& is_internal == FATAL_ERROR_EXPECTED_IS_INTERNAL
|
||||||
&& is_expected_error( error )
|
&& 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
|
* 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.h>
|
||||||
#include <rtems/test.h>
|
|
||||||
#include <tmacros.h>
|
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,12 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <bsp.h>
|
#include <bsp.h>
|
||||||
#include <bsp/bootcard.h>
|
#include <bsp/bootcard.h>
|
||||||
|
|
||||||
#include <rtems/test.h>
|
|
||||||
|
|
||||||
const char rtems_test_name[] = "SPINTERNALERROR 1";
|
const char rtems_test_name[] = "SPINTERNALERROR 1";
|
||||||
|
|
||||||
#define FATAL_SOURCE 0xdeadbeef
|
#define FATAL_SOURCE 0xdeadbeef
|
||||||
@@ -40,14 +41,14 @@ static void fatal_extension(
|
|||||||
Internal_errors_t error
|
Internal_errors_t error
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
source == FATAL_SOURCE
|
source == FATAL_SOURCE
|
||||||
&& is_internal == FATAL_IS_INTERNAL
|
&& is_internal == FATAL_IS_INTERNAL
|
||||||
&& error == FATAL_ERROR
|
&& error == FATAL_ERROR
|
||||||
) {
|
) {
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,19 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
#include <tmacros.h>
|
#include <tmacros.h>
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/print.h>
|
||||||
|
|
||||||
const char rtems_test_name[] = "SPPRINTK";
|
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 */
|
/* forward declarations to avoid warnings */
|
||||||
rtems_task Init(rtems_task_argument argument);
|
rtems_task Init(rtems_task_argument argument);
|
||||||
int test_getchar(void);
|
int test_getchar(void);
|
||||||
@@ -124,7 +132,7 @@ rtems_task Init(
|
|||||||
rtems_task_argument argument
|
rtems_task_argument argument
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
do_putk();
|
do_putk();
|
||||||
putk("");
|
putk("");
|
||||||
@@ -134,7 +142,7 @@ rtems_task Init(
|
|||||||
|
|
||||||
do_getchark();
|
do_getchark();
|
||||||
|
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
rtems_test_exit( 0 );
|
rtems_test_exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,4 +159,3 @@ rtems_task Init(
|
|||||||
#define CONFIGURE_INIT
|
#define CONFIGURE_INIT
|
||||||
|
|
||||||
#include <rtems/confdefs.h>
|
#include <rtems/confdefs.h>
|
||||||
|
|
||||||
|
|||||||
@@ -115,13 +115,15 @@ static void test_iterate(void)
|
|||||||
|
|
||||||
static void test_report_xml(void)
|
static void test_report_xml(void)
|
||||||
{
|
{
|
||||||
|
rtems_printer printer;
|
||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
sc = rtems_task_wake_after(3);
|
sc = rtems_task_wake_after(3);
|
||||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
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);
|
printf("characters produced by rtems_profiling_report_xml(): %i\n", rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
@@ -29,7 +32,6 @@
|
|||||||
#include <rtems/ioimpl.h>
|
#include <rtems/ioimpl.h>
|
||||||
#include <rtems/libio_.h>
|
#include <rtems/libio_.h>
|
||||||
#include <rtems/sysinit.h>
|
#include <rtems/sysinit.h>
|
||||||
#include <rtems/test.h>
|
|
||||||
|
|
||||||
#include <rtems/extensionimpl.h>
|
#include <rtems/extensionimpl.h>
|
||||||
#ifdef RTEMS_POSIX_API
|
#ifdef RTEMS_POSIX_API
|
||||||
@@ -173,7 +175,7 @@ static void next_step(init_step expected)
|
|||||||
|
|
||||||
FIRST(RTEMS_SYSINIT_BSP_WORK_AREAS)
|
FIRST(RTEMS_SYSINIT_BSP_WORK_AREAS)
|
||||||
{
|
{
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
assert(_Workspace_Area.area_begin == 0);
|
assert(_Workspace_Area.area_begin == 0);
|
||||||
next_step(BSP_WORK_AREAS_PRE);
|
next_step(BSP_WORK_AREAS_PRE);
|
||||||
}
|
}
|
||||||
@@ -674,7 +676,7 @@ static void Init(rtems_task_argument arg)
|
|||||||
pthread_cleanup_pop(0);
|
pthread_cleanup_pop(0);
|
||||||
#endif /* RTEMS_POSIX_API */
|
#endif /* RTEMS_POSIX_API */
|
||||||
next_step(INIT_TASK);
|
next_step(INIT_TASK);
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,13 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TESTS_USE_PRINTK
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <bsp/bootcard.h>
|
#include <bsp/bootcard.h>
|
||||||
|
|
||||||
#include <rtems/test.h>
|
|
||||||
|
|
||||||
#include <rtems/score/timecounterimpl.h>
|
#include <rtems/score/timecounterimpl.h>
|
||||||
#include <rtems/score/todimpl.h>
|
#include <rtems/score/todimpl.h>
|
||||||
#include <rtems/timecounter.h>
|
#include <rtems/timecounter.h>
|
||||||
@@ -54,7 +55,7 @@ void boot_card(const char *cmdline)
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
rtems_test_begink();
|
TEST_BEGIN();
|
||||||
|
|
||||||
assert(time(NULL) == TOD_SECONDS_1970_THROUGH_1988);
|
assert(time(NULL) == TOD_SECONDS_1970_THROUGH_1988);
|
||||||
|
|
||||||
@@ -148,7 +149,7 @@ void boot_card(const char *cmdline)
|
|||||||
assert(bt.sec == 1);
|
assert(bt.sec == 1);
|
||||||
assert(bt.frac == 18446742522092);
|
assert(bt.frac == 18446742522092);
|
||||||
|
|
||||||
rtems_test_endk();
|
TEST_END();
|
||||||
|
|
||||||
_Terminate(RTEMS_FATAL_SOURCE_EXIT, false, 0);
|
_Terminate(RTEMS_FATAL_SOURCE_EXIT, false, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#if defined(TESTS_USE_PRINTK)
|
#if defined(TESTS_USE_PRINTK)
|
||||||
|
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/print.h>
|
||||||
|
|
||||||
#undef printf
|
#undef printf
|
||||||
#define printf(...) \
|
#define printf(...) \
|
||||||
@@ -54,9 +54,9 @@ extern "C" {
|
|||||||
do { \
|
do { \
|
||||||
} while (0)
|
} 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
|
* BUFFER TEST OUTPUT
|
||||||
@@ -156,9 +156,9 @@ extern "C" {
|
|||||||
fflush(stdout); \
|
fflush(stdout); \
|
||||||
} while (0)
|
} 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
|
* USE IPRINT
|
||||||
@@ -205,11 +205,9 @@ extern "C" {
|
|||||||
fflush(stdout); \
|
fflush(stdout); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TEST_BEGIN() \
|
#define TEST_BEGIN() fiprintf( stderr, TEST_BEGIN_STRING)
|
||||||
rtems_test_begin_with_plugin((rtems_printk_plugin_t) fiprintf, stderr)
|
|
||||||
|
|
||||||
#define TEST_END() \
|
#define TEST_END() fiprintf( stderr, TEST_END_STRING)
|
||||||
rtems_test_end_with_plugin((rtems_printk_plugin_t) fiprintf, stderr)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -74,8 +74,6 @@ int locked_printf(const char *fmt, ...);
|
|||||||
|
|
||||||
int locked_vprintf(const char *fmt, va_list ap);
|
int locked_vprintf(const char *fmt, va_list ap);
|
||||||
|
|
||||||
int locked_printf_plugin(void *context, const char *fmt, ...);
|
|
||||||
|
|
||||||
void locked_printk(const char *fmt, ...);
|
void locked_printk(const char *fmt, ...);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -16,6 +16,22 @@
|
|||||||
|
|
||||||
static rtems_id locked_print_semaphore; /* synchronisation semaphore */
|
static rtems_id locked_print_semaphore; /* synchronisation semaphore */
|
||||||
|
|
||||||
|
rtems_printer rtems_test_printer;
|
||||||
|
|
||||||
|
static int locked_printf_plugin(void *context, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
int rv;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
(void) context;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
rv = locked_vprintf(fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
void locked_print_initialize(void)
|
void locked_print_initialize(void)
|
||||||
{
|
{
|
||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
@@ -38,6 +54,12 @@ void locked_print_initialize(void)
|
|||||||
&locked_print_semaphore
|
&locked_print_semaphore
|
||||||
);
|
);
|
||||||
directive_failed( sc, "rtems_semaphore_create" );
|
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)
|
int locked_vprintf(const char *fmt, va_list ap)
|
||||||
@@ -60,20 +82,6 @@ int locked_vprintf(const char *fmt, va_list ap)
|
|||||||
return rv;
|
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 locked_printf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|||||||
Reference in New Issue
Block a user