Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:42

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  * Copyright (c) 2014 embedded brains GmbH & Co. KG
0005  *
0006  * Redistribution and use in source and binary forms, with or without
0007  * modification, are permitted provided that the following conditions
0008  * are met:
0009  * 1. Redistributions of source code must retain the above copyright
0010  *    notice, this list of conditions and the following disclaimer.
0011  * 2. Redistributions in binary form must reproduce the above copyright
0012  *    notice, this list of conditions and the following disclaimer in the
0013  *    documentation and/or other materials provided with the distribution.
0014  *
0015  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0016  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0017  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0018  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0019  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0020  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0021  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0024  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0025  * POSSIBILITY OF SUCH DAMAGE.
0026  */
0027 
0028 #ifndef BSP_CONSOLE_TERMIOS_H
0029 #define BSP_CONSOLE_TERMIOS_H
0030 
0031 #include <rtems/termiostypes.h>
0032 
0033 #ifdef __cplusplus
0034 extern "C" {
0035 #endif /* __cplusplus */
0036 
0037 /**
0038  * @defgroup ConsoleTermios Termios Console Driver
0039  *
0040  * @ingroup RTEMSBSPsSharedConsole
0041  *
0042  * @brief Console driver for Termios devices.
0043  *
0044  * In order to use this driver add the following lines to the Makefile.am of
0045  * the BSP:
0046  *
0047  * @code
0048  * libbsp_a_SOURCES += ../../shared/console-termios-init.c
0049  * libbsp_a_SOURCES += ../../shared/console-termios.c
0050  * libbsp_a_SOURCES += console/console-config.c
0051  * @endcode
0052  *
0053  * Define the console_device_table and console_device_count in the
0054  * console-config.c file of the BSP.
0055  *
0056  * @{
0057  */
0058 
0059 /**
0060  * @brief Console device probe function type.
0061  *
0062  * @param[in] context The Termios device context.
0063  *
0064  * @retval true Install this device.
0065  * @retval false Otherwise.
0066  */
0067 typedef bool (*console_device_probe)(rtems_termios_device_context *context);
0068 
0069 /**
0070  * @brief Console device information.
0071  */
0072 typedef struct {
0073   /**
0074    * @brief The device file path.
0075    *
0076    * The "/dev/console" device will be automatically installed as the first
0077    * device of console_device_table with a successful probe.
0078    */
0079   const char *device_file;
0080 
0081   /**
0082    * @brief The device probe function.
0083    */
0084   console_device_probe probe;
0085 
0086   /**
0087    * @brief The Termios device handler.
0088    */
0089   const rtems_termios_device_handler *handler;
0090 
0091   /**
0092    * @brief The Termios device flow control handler.
0093    */
0094   const rtems_termios_device_flow *flow;
0095 
0096   /**
0097    * @brief The Termios device context.
0098    */
0099   rtems_termios_device_context *context;
0100 } console_device;
0101 
0102 /**
0103  * @brief Returns true and does nothing else.
0104  */
0105 bool console_device_probe_default(rtems_termios_device_context *context);
0106 
0107 /**
0108  * @brief Table for console devices installed via console_initialize() during
0109  * system initialization.
0110  *
0111  * It must be provided by the BSP.
0112  *
0113  * @see console_device_count.
0114  */
0115 extern const console_device console_device_table[];
0116 
0117 /**
0118  * @brief Count of entries in the console_device_table.
0119  *
0120  * It must be provided by the BSP.
0121  */
0122 extern const size_t console_device_count;
0123 
0124 /** @{ */
0125 
0126 #ifdef __cplusplus
0127 }
0128 #endif /* __cplusplus */
0129 
0130 #endif /* BSP_CONSOLE_TERMIOS_H */