RTEMS 6.1-rc2
Loading...
Searching...
No Matches
printer.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
13/*
14 * Copyright (c) 2016 Chris Johns <chrisj@rtems.org>
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#ifndef _RTEMS_PRINTER_H
40#define _RTEMS_PRINTER_H
41
42#include <rtems/print.h>
43#include <rtems/chain.h>
44#include <rtems/rtems/intr.h>
45#include <rtems/rtems/tasks.h>
46
47#include <stdio.h>
48#include <string.h>
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
70typedef int (*rtems_print_printer)(void *, const char *format, va_list ap);
71
77 void *context;
78 rtems_print_printer printer;
79};
80
88static inline bool rtems_print_printer_valid(const rtems_printer *printer)
89{
90 return printer != NULL && printer->printer != NULL;
91}
92
101static inline void rtems_print_printer_empty(rtems_printer *printer)
102{
103 printer->context = NULL;
104 printer->printer = NULL;
105}
106
113
120
128
136
137typedef struct {
138 rtems_id task;
140 rtems_chain_control free_buffers;
141 rtems_chain_control todo_buffers;
142 size_t task_stack_size;
143 rtems_task_priority task_priority;
144 int fd;
145 void *buffer_table;
146 size_t buffer_count;
147 size_t buffer_size;
149
150static inline void rtems_printer_task_initialize(
152)
153{
154 /*
155 * Some C++ compiler think that the structure is complex enough to need a
156 * proper constructor. Cast to void * to silence a warning.
157 */
158 memset( (void *) context, 0, sizeof( *context ) );
159}
160
161static inline void rtems_printer_task_set_stack_size(
163 size_t stack_size
164)
165{
166 context->task_stack_size = stack_size;
167}
168
169static inline void rtems_printer_task_set_priority(
171 rtems_task_priority priority
172)
173{
174 context->task_priority = priority;
175}
176
177static inline void rtems_printer_task_set_file_descriptor(
179 int fd
180)
181{
182 context->fd = fd;
183}
184
185static inline void rtems_printer_task_set_buffer_table(
187 void *buffer_table
188)
189{
190 context->buffer_table = buffer_table;
191}
192
193static inline void rtems_printer_task_set_buffer_count(
195 size_t buffer_count
196)
197{
198 context->buffer_count = buffer_count;
199}
200
201static inline void rtems_printer_task_set_buffer_size(
203 size_t buffer_size
204)
205{
206 context->buffer_size = buffer_size;
207}
208
226 rtems_printer *printer,
228);
229
243
246#ifdef __cplusplus
247}
248#endif
249
250#endif /* _RTEMS_PRINTER_H */
This header file provides the Chains API.
#define RTEMS_INTERRUPT_LOCK_MEMBER(_designator)
Defines an ISR lock member.
Definition: intr.h:867
uint32_t rtems_task_priority
This integer type represents task priorities of the Classic API.
Definition: types.h:257
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition: types.h:94
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:47
int(* rtems_print_printer)(void *, const char *format, va_list ap)
Definition: printer.h:70
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:75
void rtems_print_printer_printk(rtems_printer *printer)
Initializes the printer to print via printk().
Definition: printk_plugin.c:56
int rtems_print_printer_task(rtems_printer *printer, rtems_printer_task_context *context)
Creates a printer task.
Definition: printertask.c:169
void rtems_print_printer_printf(rtems_printer *printer)
Initializes the printer to print via printf().
Definition: printf_plugin.c:47
void rtems_printer_task_drain(rtems_printer_task_context *context)
Drains the work queue of the printer task.
Definition: printertask.c:211
#define NULL
Requests a GPIO pin group configuration.
Definition: xil_types.h:54
This header file defines the Interrupt Manager API.
User print interface to the bspIO print plug in.
rtems_termios_device_context * context
Definition: console-config.c:62
Definition: mongoose.c:448
Definition: mknod-pack_dev.c:254
Definition: printer.h:137
Definition: printer.h:76
This header file defines the main parts of the Tasks Manager API.
This union represents a chain control block.
Definition: chain.h:96