1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup RTEMSAPIKernelCharIO |
---|
7 | * |
---|
8 | * @brief This header file provides the kernel character input/output support |
---|
9 | * API. |
---|
10 | */ |
---|
11 | |
---|
12 | /* |
---|
13 | * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG |
---|
14 | * Copyright (C) 2015 On-Line Applications Research Corporation (OAR) |
---|
15 | * |
---|
16 | * Redistribution and use in source and binary forms, with or without |
---|
17 | * modification, are permitted provided that the following conditions |
---|
18 | * are met: |
---|
19 | * 1. Redistributions of source code must retain the above copyright |
---|
20 | * notice, this list of conditions and the following disclaimer. |
---|
21 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
22 | * notice, this list of conditions and the following disclaimer in the |
---|
23 | * documentation and/or other materials provided with the distribution. |
---|
24 | * |
---|
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
35 | * POSSIBILITY OF SUCH DAMAGE. |
---|
36 | */ |
---|
37 | |
---|
38 | /* |
---|
39 | * This file is part of the RTEMS quality process and was automatically |
---|
40 | * generated. If you find something that needs to be fixed or |
---|
41 | * worded better please post a report or patch to an RTEMS mailing list |
---|
42 | * or raise a bug report: |
---|
43 | * |
---|
44 | * https://www.rtems.org/bugs.html |
---|
45 | * |
---|
46 | * For information on updating and regenerating please refer to the How-To |
---|
47 | * section in the Software Requirements Engineering chapter of the |
---|
48 | * RTEMS Software Engineering manual. The manual is provided as a part of |
---|
49 | * a release. For development sources please refer to the online |
---|
50 | * documentation at: |
---|
51 | * |
---|
52 | * https://docs.rtems.org |
---|
53 | */ |
---|
54 | |
---|
55 | /* Generated from spec:/rtems/io/if/header-3 */ |
---|
56 | |
---|
57 | #ifndef _RTEMS_BSPIO_H |
---|
58 | #define _RTEMS_BSPIO_H |
---|
59 | |
---|
60 | #include <stdarg.h> |
---|
61 | #include <rtems/score/basedefs.h> |
---|
62 | |
---|
63 | #ifdef __cplusplus |
---|
64 | extern "C" { |
---|
65 | #endif |
---|
66 | |
---|
67 | /* Generated from spec:/rtems/io/if/group-3 */ |
---|
68 | |
---|
69 | /** |
---|
70 | * @defgroup RTEMSAPIKernelCharIO Kernel Character I/O Support |
---|
71 | * |
---|
72 | * @ingroup RTEMSAPIClassicIO |
---|
73 | * |
---|
74 | * @brief The kernel character input/output support is an extension of the @ref |
---|
75 | * RTEMSAPIClassicIO to output characters to the kernel character output |
---|
76 | * device and receive characters from the kernel character input device using |
---|
77 | * a polled and non-blocking implementation. |
---|
78 | * |
---|
79 | * The directives may be used to print debug and test information. The kernel |
---|
80 | * character input/output support should work even if no Console Driver is |
---|
81 | * configured, see @ref CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER. The kernel |
---|
82 | * character input and output device is provided by the BSP. Applications may |
---|
83 | * change the device. |
---|
84 | */ |
---|
85 | |
---|
86 | /* Generated from spec:/rtems/io/if/bsp-output-char-function-type */ |
---|
87 | |
---|
88 | /** |
---|
89 | * @ingroup RTEMSAPIKernelCharIO |
---|
90 | * |
---|
91 | * @brief Polled character output functions shall have this type. |
---|
92 | */ |
---|
93 | typedef void ( *BSP_output_char_function_type )( char ); |
---|
94 | |
---|
95 | /* Generated from spec:/rtems/io/if/bsp-output-char */ |
---|
96 | |
---|
97 | /** |
---|
98 | * @ingroup RTEMSAPIKernelCharIO |
---|
99 | * |
---|
100 | * @brief This function pointer references the kernel character output |
---|
101 | * implementation. |
---|
102 | * |
---|
103 | * This function pointer shall never be NULL. It shall be provided by the BSP |
---|
104 | * and statically initialized. The referenced function shall output exactly |
---|
105 | * the character specified by the parameter. In particular, it shall not |
---|
106 | * perform character translations, for example ``NL`` to ``CR`` followed by |
---|
107 | * ``NR``. The function shall not block. |
---|
108 | */ |
---|
109 | extern BSP_output_char_function_type BSP_output_char; |
---|
110 | |
---|
111 | /* Generated from spec:/rtems/io/if/putc */ |
---|
112 | |
---|
113 | /** |
---|
114 | * @ingroup RTEMSAPIKernelCharIO |
---|
115 | * |
---|
116 | * @brief Outputs the character to the kernel character output device. |
---|
117 | * |
---|
118 | * @param c is the character to output. |
---|
119 | * |
---|
120 | * The directive outputs the character specified by ``c`` to the kernel |
---|
121 | * character output device using the polled character output implementation |
---|
122 | * provided by #BSP_output_char. The directive performs a character |
---|
123 | * translation from ``NL`` to ``CR`` followed by ``NR``. |
---|
124 | * |
---|
125 | * If the kernel character output device is concurrently accessed, then |
---|
126 | * interleaved output may occur. |
---|
127 | * |
---|
128 | * @par Constraints |
---|
129 | * @parblock |
---|
130 | * The following constraints apply to this directive: |
---|
131 | * |
---|
132 | * * The directive may be called from within any runtime context. |
---|
133 | * |
---|
134 | * * The directive will not cause the calling task to be preempted. |
---|
135 | * @endparblock |
---|
136 | */ |
---|
137 | void rtems_putc( char c ); |
---|
138 | |
---|
139 | /* Generated from spec:/rtems/io/if/put-char */ |
---|
140 | |
---|
141 | /** |
---|
142 | * @ingroup RTEMSAPIKernelCharIO |
---|
143 | * |
---|
144 | * @brief Puts the character using rtems_putc() |
---|
145 | * |
---|
146 | * @param c is the character to output. |
---|
147 | * |
---|
148 | * @param unused is an unused argument. |
---|
149 | * |
---|
150 | * @par Notes |
---|
151 | * The directive is provided to support the RTEMS Testing Framework. |
---|
152 | * |
---|
153 | * @par Constraints |
---|
154 | * @parblock |
---|
155 | * The following constraints apply to this directive: |
---|
156 | * |
---|
157 | * * The directive may be called from within any runtime context. |
---|
158 | * |
---|
159 | * * The directive will not cause the calling task to be preempted. |
---|
160 | * @endparblock |
---|
161 | */ |
---|
162 | void rtems_put_char( int c, void *unused ); |
---|
163 | |
---|
164 | /* Generated from spec:/rtems/io/if/putk */ |
---|
165 | |
---|
166 | /** |
---|
167 | * @ingroup RTEMSAPIKernelCharIO |
---|
168 | * |
---|
169 | * @brief Outputs the characters of the string and a newline character to the |
---|
170 | * kernel character output device. |
---|
171 | * |
---|
172 | * @param s is the string to output. |
---|
173 | * |
---|
174 | * @return Returns the number of characters output to the kernel character |
---|
175 | * output device. |
---|
176 | * |
---|
177 | * @par Notes |
---|
178 | * @parblock |
---|
179 | * The directive may be used to print debug and test information. It uses |
---|
180 | * rtems_putc() to output the characters. This directive performs a character |
---|
181 | * translation from ``NL`` to ``CR`` followed by ``NR``. |
---|
182 | * |
---|
183 | * If the kernel character output device is concurrently accessed, then |
---|
184 | * interleaved output may occur. |
---|
185 | * @endparblock |
---|
186 | * |
---|
187 | * @par Constraints |
---|
188 | * @parblock |
---|
189 | * The following constraints apply to this directive: |
---|
190 | * |
---|
191 | * * The directive may be called from within any runtime context. |
---|
192 | * |
---|
193 | * * The directive will not cause the calling task to be preempted. |
---|
194 | * @endparblock |
---|
195 | */ |
---|
196 | int putk( const char *s ); |
---|
197 | |
---|
198 | /* Generated from spec:/rtems/io/if/printk */ |
---|
199 | |
---|
200 | /** |
---|
201 | * @ingroup RTEMSAPIKernelCharIO |
---|
202 | * |
---|
203 | * @brief Outputs the characters defined by the format string and the arguments |
---|
204 | * to the kernel character output device. |
---|
205 | * |
---|
206 | * @param fmt is a printf()-style format string. |
---|
207 | * |
---|
208 | * @param ... is a list of optional parameters required by the format string. |
---|
209 | * |
---|
210 | * @return Returns the number of characters output to the kernel character |
---|
211 | * output device. |
---|
212 | * |
---|
213 | * @par Notes |
---|
214 | * @parblock |
---|
215 | * The directive may be used to print debug and test information. It uses |
---|
216 | * rtems_putc() to output the characters. This directive performs a character |
---|
217 | * translation from ``NL`` to ``CR`` followed by ``NR``. |
---|
218 | * |
---|
219 | * If the kernel character output device is concurrently accessed, then |
---|
220 | * interleaved output may occur. |
---|
221 | * @endparblock |
---|
222 | * |
---|
223 | * @par Constraints |
---|
224 | * @parblock |
---|
225 | * The following constraints apply to this directive: |
---|
226 | * |
---|
227 | * * The directive may be called from within any runtime context. |
---|
228 | * |
---|
229 | * * The directive will not cause the calling task to be preempted. |
---|
230 | * |
---|
231 | * * Formatting of floating point numbers is not supported. |
---|
232 | * @endparblock |
---|
233 | */ |
---|
234 | RTEMS_PRINTFLIKE( 1, 2 ) int printk( const char *fmt, ... ); |
---|
235 | |
---|
236 | /* Generated from spec:/rtems/io/if/vprintk */ |
---|
237 | |
---|
238 | /** |
---|
239 | * @ingroup RTEMSAPIKernelCharIO |
---|
240 | * |
---|
241 | * @brief Outputs the characters defined by the format string and the variable |
---|
242 | * argument list to the kernel character output device. |
---|
243 | * |
---|
244 | * @param fmt is a printf()-style format string. |
---|
245 | * |
---|
246 | * @param ap is the variable argument list required by the format string. |
---|
247 | * |
---|
248 | * @return Returns the number of characters output to the kernel character |
---|
249 | * output device. |
---|
250 | * |
---|
251 | * @par Notes |
---|
252 | * @parblock |
---|
253 | * The directive may be used to print debug and test information. It uses |
---|
254 | * rtems_putc() to output the characters. This directive performs a character |
---|
255 | * translation from ``NL`` to ``CR`` followed by ``NR``. |
---|
256 | * |
---|
257 | * If the kernel character output device is concurrently accessed, then |
---|
258 | * interleaved output may occur. |
---|
259 | * @endparblock |
---|
260 | * |
---|
261 | * @par Constraints |
---|
262 | * @parblock |
---|
263 | * The following constraints apply to this directive: |
---|
264 | * |
---|
265 | * * The directive may be called from within any runtime context. |
---|
266 | * |
---|
267 | * * The directive will not cause the calling task to be preempted. |
---|
268 | * |
---|
269 | * * Formatting of floating point numbers is not supported. |
---|
270 | * @endparblock |
---|
271 | */ |
---|
272 | int vprintk( const char *fmt, va_list ap ); |
---|
273 | |
---|
274 | /* Generated from spec:/rtems/io/if/printk-printer */ |
---|
275 | |
---|
276 | /** |
---|
277 | * @ingroup RTEMSAPIKernelCharIO |
---|
278 | * |
---|
279 | * @brief Outputs the characters defined by the format string and the variable |
---|
280 | * argument list to the kernel character output device. |
---|
281 | * |
---|
282 | * @param unused is an unused argument. |
---|
283 | * |
---|
284 | * @param fmt is a printf()-style format string. |
---|
285 | * |
---|
286 | * @param ap is the variable argument list required by the format string. |
---|
287 | * |
---|
288 | * @return Returns the number of characters output to the kernel character |
---|
289 | * output device. |
---|
290 | * |
---|
291 | * @par Notes |
---|
292 | * @parblock |
---|
293 | * The directive may be used to print debug and test information. It uses |
---|
294 | * rtems_putc() to output the characters. This directive performs a character |
---|
295 | * translation from ``NL`` to ``CR`` followed by ``NR``. |
---|
296 | * |
---|
297 | * If the kernel character output device is concurrently accessed, then |
---|
298 | * interleaved output may occur. |
---|
299 | * @endparblock |
---|
300 | * |
---|
301 | * @par Constraints |
---|
302 | * @parblock |
---|
303 | * The following constraints apply to this directive: |
---|
304 | * |
---|
305 | * * The directive may be called from within any runtime context. |
---|
306 | * |
---|
307 | * * The directive will not cause the calling task to be preempted. |
---|
308 | * |
---|
309 | * * Formatting of floating point numbers is not supported. |
---|
310 | * @endparblock |
---|
311 | */ |
---|
312 | int rtems_printk_printer( void *unused, const char *fmt, va_list ap ); |
---|
313 | |
---|
314 | /* Generated from spec:/rtems/io/if/bsp-polling-getchar-function-type */ |
---|
315 | |
---|
316 | /** |
---|
317 | * @ingroup RTEMSAPIKernelCharIO |
---|
318 | * |
---|
319 | * @brief Polled character input functions shall have this type. |
---|
320 | */ |
---|
321 | typedef int (* BSP_polling_getchar_function_type )( void ); |
---|
322 | |
---|
323 | /* Generated from spec:/rtems/io/if/bsp-poll-char */ |
---|
324 | |
---|
325 | /** |
---|
326 | * @ingroup RTEMSAPIKernelCharIO |
---|
327 | * |
---|
328 | * @brief This function pointer may reference the kernel character input |
---|
329 | * implementation. |
---|
330 | * |
---|
331 | * This function pointer may be NULL. It may reference a function provided by |
---|
332 | * the BSP. Referenced functions shall dequeue the least recently received |
---|
333 | * character from the device and return it as an unsigned character. If no |
---|
334 | * character is enqueued on the device, then the function shall immediately |
---|
335 | * return the value minus one. |
---|
336 | */ |
---|
337 | extern BSP_polling_getchar_function_type BSP_poll_char; |
---|
338 | |
---|
339 | /* Generated from spec:/rtems/io/if/getchark */ |
---|
340 | |
---|
341 | /** |
---|
342 | * @ingroup RTEMSAPIKernelCharIO |
---|
343 | * |
---|
344 | * @brief Tries to dequeue a character from the kernel character input device. |
---|
345 | * |
---|
346 | * The directive tries to dequeue a character from the kernel character input |
---|
347 | * device using the polled character input implementation referenced by |
---|
348 | * #BSP_poll_char if it is available. |
---|
349 | * |
---|
350 | * @retval -1 The #BSP_poll_char pointer was equal to NULL. |
---|
351 | * |
---|
352 | * @retval -1 There was no character enqueued on the kernel character input |
---|
353 | * device. |
---|
354 | * |
---|
355 | * @return Returns the character least recently enqueued on the kernel |
---|
356 | * character input device as an unsigned character value. |
---|
357 | * |
---|
358 | * @par Constraints |
---|
359 | * @parblock |
---|
360 | * The following constraints apply to this directive: |
---|
361 | * |
---|
362 | * * The directive may be called from within any runtime context. |
---|
363 | * |
---|
364 | * * The directive will not cause the calling task to be preempted. |
---|
365 | * @endparblock |
---|
366 | */ |
---|
367 | int getchark( void ); |
---|
368 | |
---|
369 | #ifdef __cplusplus |
---|
370 | } |
---|
371 | #endif |
---|
372 | |
---|
373 | #endif /* _RTEMS_BSPIO_H */ |
---|