RTEMS  5.0.0
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
30 extern "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 
67 static inline bool rtems_print_printer_valid(const rtems_printer *printer)
68 {
69  return printer != NULL && printer->printer != NULL;
70 }
71 
80 static inline void rtems_print_printer_empty(rtems_printer *printer)
81 {
82  printer->context = NULL;
83  printer->printer = NULL;
84 }
85 
92 
99 
106 void rtems_print_printer_fprintf(rtems_printer *printer, FILE *file);
107 
115 
116 typedef struct {
117  rtems_id task;
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;
128 
129 static inline void rtems_printer_task_initialize(
131 )
132 {
133  memset( context, 0, sizeof( *context ) );
134 }
135 
136 static inline void rtems_printer_task_set_stack_size(
138  size_t stack_size
139 )
140 {
141  context->task_stack_size = stack_size;
142 }
143 
144 static inline void rtems_printer_task_set_priority(
146  rtems_task_priority priority
147 )
148 {
149  context->task_priority = priority;
150 }
151 
152 static inline void rtems_printer_task_set_file_descriptor(
154  int fd
155 )
156 {
157  context->fd = fd;
158 }
159 
160 static inline void rtems_printer_task_set_buffer_table(
162  void *buffer_table
163 )
164 {
165  context->buffer_table = buffer_table;
166 }
167 
168 static inline void rtems_printer_task_set_buffer_count(
170  size_t buffer_count
171 )
172 {
173  context->buffer_count = buffer_count;
174 }
175 
176 static inline void rtems_printer_task_set_buffer_size(
178  size_t buffer_size
179 )
180 {
181  context->buffer_size = buffer_size;
182 }
183 
201  rtems_printer *printer,
203 );
204 
218 
221 #ifdef __cplusplus
222 }
223 #endif
224 
225 #endif /* _RTEMS_PRINTER_H */
#define RTEMS_INTERRUPT_LOCK_MEMBER(_designator)
Defines an interrupt lock member.
Definition: intr.h:209
Definition: mknod-pack_dev.c:254
Definition: chain.h:83
Definition: printer.h:55
int rtems_print_printer_task(rtems_printer *printer, rtems_printer_task_context *context)
Creates a printer task.
Definition: printertask.c:152
void rtems_print_printer_printf(rtems_printer *printer)
Initializes the printer to print via printf().
Definition: printf_plugin.c:34
void rtems_printer_task_drain(rtems_printer_task_context *context)
Drains the work queue of the printer task.
Definition: printertask.c:193
int(* rtems_print_printer)(void *, const char *format, va_list ap)
Definition: printer.h:49
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
void rtems_print_printer_printk(rtems_printer *printer)
Initializes the printer to print via printk().
Definition: printk_plugin.c:35
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
Classic Task Manager API.
Chain API.
Definition: printer.h:116
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:83
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
Definition: mongoose.c:442
uint32_t rtems_task_priority
Definition: tasks.h:54