RTEMS: cpukit/include/rtems/printer.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
printer.h
Go to the documentation of this file.
1
9/*
10 * Copyright (c) 2016 Chris Johns <chrisj@rtems.org>
11 * All rights reserved.
12 *
13 * The license and distribution terms for this file may be
14 * found in the file LICENSE in this distribution or at
15 * http://www.rtems.org/license/LICENSE.
16 */
17
18#ifndef _RTEMS_PRINTER_H
19#define _RTEMS_PRINTER_H
20
21#include <rtems/print.h>
22#include <rtems/chain.h>
23#include <rtems/rtems/intr.h>
24#include <rtems/rtems/tasks.h>
25
26#include <stdio.h>
27#include <string.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
49 typedef int (*rtems_print_printer)(void *, const char *format, va_list ap);
50
55 struct rtems_printer {
56 void *context;
57 rtems_print_printer printer;
58};
59
67static inline bool rtems_print_printer_valid(const rtems_printer *printer)
68{
69 return printer != NULL && printer->printer != NULL;
70}
71
80static inline void rtems_print_printer_empty(rtems_printer *printer)
81{
82 printer->context = NULL;
83 printer->printer = NULL;
84}
85
91void rtems_print_printer_printk(rtems_printer *printer);
92
98void rtems_print_printer_printf(rtems_printer *printer);
99
106void rtems_print_printer_fprintf(rtems_printer *printer, FILE *file);
107
114void rtems_print_printer_fprintf_putc(rtems_printer *printer);
115
116 typedef struct {
117 rtems_id task;
118 RTEMS_INTERRUPT_LOCK_MEMBER( lock )
119 rtems_chain_control free_buffers;
120 rtems_chain_control todo_buffers;
121 size_t task_stack_size;
122 rtems_task_priority task_priority;
123 int fd;
124 void *buffer_table;
125 size_t buffer_count;
126 size_t buffer_size;
127} rtems_printer_task_context;
128
129static inline void rtems_printer_task_initialize(
130 rtems_printer_task_context *context
131)
132{
133 memset( context, 0, sizeof( *context ) );
134}
135
136static inline void rtems_printer_task_set_stack_size(
137 rtems_printer_task_context *context,
138 size_t stack_size
139)
140{
141 context->task_stack_size = stack_size;
142}
143
144static inline void rtems_printer_task_set_priority(
145 rtems_printer_task_context *context,
146 rtems_task_priority priority
147)
148{
149 context->task_priority = priority;
150}
151
152static inline void rtems_printer_task_set_file_descriptor(
153 rtems_printer_task_context *context,
154 int fd
155)
156{
157 context->fd = fd;
158}
159
160static inline void rtems_printer_task_set_buffer_table(
161 rtems_printer_task_context *context,
162 void *buffer_table
163)
164{
165 context->buffer_table = buffer_table;
166}
167
168static inline void rtems_printer_task_set_buffer_count(
169 rtems_printer_task_context *context,
170 size_t buffer_count
171)
172{
173 context->buffer_count = buffer_count;
174}
175
176static inline void rtems_printer_task_set_buffer_size(
177 rtems_printer_task_context *context,
178 size_t buffer_size
179)
180{
181 context->buffer_size = buffer_size;
182}
183
200int rtems_print_printer_task(
201 rtems_printer *printer,
202 rtems_printer_task_context *context
203);
204
217void rtems_printer_task_drain(rtems_printer_task_context *context);
218
221#ifdef __cplusplus
222}
223#endif
224
225#endif /* _RTEMS_PRINTER_H */
NULL
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
chain.h
Chain API.
RTEMS_INTERRUPT_LOCK_MEMBER
#define RTEMS_INTERRUPT_LOCK_MEMBER(_designator)
Defines an interrupt lock member.
Definition: intr.h:209
rtems_task_priority
uint32_t rtems_task_priority
Definition: tasks.h:55
rtems_id
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:83
rtems_print_printer_fprintf
void rtems_print_printer_fprintf(rtems_printer *printer, FILE *file)
Initializes the printer to print via fprintf() using the specified file stream.
Definition: print_fprintf.c:28
rtems_print_printer
int(* rtems_print_printer)(void *, const char *format, va_list ap)
Definition: printer.h:49
rtems_print_printer_fprintf_putc
void rtems_print_printer_fprintf_putc(rtems_printer *printer)
Initializes the printer to print via fprintf() using an unbuffered FILE stream with output through rt...
Definition: printerfprintfputc.c:62
rtems_print_printer_printk
void rtems_print_printer_printk(rtems_printer *printer)
Initializes the printer to print via printk().
Definition: printk_plugin.c:34
rtems_print_printer_task
int rtems_print_printer_task(rtems_printer *printer, rtems_printer_task_context *context)
Creates a printer task.
Definition: printertask.c:152
rtems_print_printer_printf
void rtems_print_printer_printf(rtems_printer *printer)
Initializes the printer to print via printf().
Definition: printf_plugin.c:34
rtems_printer_task_drain
void rtems_printer_task_drain(rtems_printer_task_context *context)
Drains the work queue of the printer task.
Definition: printertask.c:193
intr.h
print.h
User print interface to the bspIO print plug in.
file
Definition: mongoose.c:442
format
Definition: mknod-pack_dev.c:254
rtems_printer_task_context
Definition: printer.h:116
rtems_printer
Definition: printer.h:55
tasks.h
Classic Task Manager API.
Chain_Control
Definition: chain.h:86