Changeset 0c3d6f58 in rtems


Ignore:
Timestamp:
05/23/23 08:44:04 (10 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
a83dc4a4
Parents:
63415655
git-author:
Sebastian Huber <sebastian.huber@…> (05/23/23 08:44:04)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/31/23 08:07:17)
Message:

termios: Add <rtems/termiosdevice.h>

Add <rtems/termiosdevice.h> which does not depend on <rtems/libio.h> to
provide rtems_termios_device_context and rtems_termios_device_handler.
For polled serial device drivers, this removes a header file dependency
to the full file system support.

Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • bsps/arm/xilinx-zynq/console/console-init.c

    r63415655 r0c3d6f58  
    2727
    2828#include <rtems/console.h>
     29#include <rtems/termiostypes.h>
    2930
    3031#include <bsp.h>
  • bsps/include/dev/serial/zynq-uart.h

    r63415655 r0c3d6f58  
    3535#define LIBBSP_ARM_XILINX_ZYNQ_UART_H
    3636
    37 #include <rtems/termiostypes.h>
     37#include <rtems/termiosdevice.h>
    3838
    3939#ifdef __cplusplus
  • bsps/shared/dev/serial/zynq-uart.c

    r63415655 r0c3d6f58  
    2929#include <dev/serial/zynq-uart-regs.h>
    3030#include <bsp/irq.h>
     31#include <rtems/termiostypes.h>
    3132
    3233#include <bspopts.h>
  • cpukit/include/rtems/libio.h

    r63415655 r0c3d6f58  
    13611361 * @brief Parameter block for open/close.
    13621362 */
    1363 typedef struct {
     1363typedef struct rtems_libio_open_close_args {
    13641364  rtems_libio_t          *iop;
    13651365  uint32_t                flags;
  • cpukit/include/rtems/termiostypes.h

    r63415655 r0c3d6f58  
    4040#include <rtems/assoc.h>
    4141#include <rtems/chain.h>
    42 #include <rtems/thread.h>
    43 #include <sys/ioccom.h>
     42#include <rtems/termiosdevice.h>
    4443#include <stdint.h>
    4544#include <termios.h>
     
    5049
    5150/**
    52  *  @defgroup TermiostypesSupport RTEMS Termios Device Support
    53  *
    54  *  @ingroup libcsupport
    55  *
    56  *  @brief RTEMS Termios Device Support Internal Data Structures
     51 * @addtogroup TermiostypesSupport
     52 *
     53 * @{
    5754 */
    5855
     
    7572  rtems_binary_semaphore Semaphore;
    7673};
    77 
    78 typedef enum {
    79   TERMIOS_POLLED,
    80   TERMIOS_IRQ_DRIVEN,
    81   TERMIOS_TASK_DRIVEN,
    82   TERMIOS_IRQ_SERVER_DRIVEN
    83 } rtems_termios_device_mode;
    84 
    85 struct rtems_termios_tty;
    86 
    87 /**
    88  * @brief Termios device context.
    89  *
    90  * @see RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER(),
    91  * rtems_termios_device_context_initialize() and
    92  * rtems_termios_device_install().
    93  */
    94 typedef struct rtems_termios_device_context {
    95   union {
    96     /* Used for TERMIOS_POLLED and TERMIOS_IRQ_DRIVEN */
    97     rtems_interrupt_lock interrupt;
    98 
    99     /* Used for TERMIOS_IRQ_SERVER_DRIVEN or TERMIOS_TASK_DRIVEN */
    100     rtems_mutex mutex;
    101   } lock;
    102 
    103   void ( *lock_acquire )(
    104     struct rtems_termios_device_context *,
    105     rtems_interrupt_lock_context *
    106   );
    107 
    108   void ( *lock_release )(
    109     struct rtems_termios_device_context *,
    110     rtems_interrupt_lock_context *
    111   );
    112 } rtems_termios_device_context;
    113 
    114 void rtems_termios_device_lock_acquire_default(
    115   rtems_termios_device_context *ctx,
    116   rtems_interrupt_lock_context *lock_context
    117 );
    118 
    119 void rtems_termios_device_lock_release_default(
    120   rtems_termios_device_context *ctx,
    121   rtems_interrupt_lock_context *lock_context
    122 );
    123 
    124 /**
    125  * @brief Initializes a device context.
    126  *
    127  * @param[in] context The Termios device context.
    128  * @param[in] name The name for the interrupt lock.  This name must be a
    129  *   string persistent throughout the life time of this lock.  The name is only
    130  *   used if profiling is enabled.
    131  */
    132 static inline void rtems_termios_device_context_initialize(
    133   rtems_termios_device_context *context,
    134   const char                   *name
    135 )
    136 {
    137   rtems_interrupt_lock_initialize( &context->lock.interrupt, name );
    138   context->lock_acquire = rtems_termios_device_lock_acquire_default;
    139   context->lock_release = rtems_termios_device_lock_release_default;
    140 }
    141 
    142 /**
    143  * @brief Initializer for static initialization of Termios device contexts.
    144  *
    145  * @param name The name for the interrupt lock.  It must be a string.  The name
    146  *   is only used if profiling is enabled.
    147  */
    148 #define RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( name ) \
    149   { \
    150     { RTEMS_INTERRUPT_LOCK_INITIALIZER( name ) }, \
    151     rtems_termios_device_lock_acquire_default, \
    152     rtems_termios_device_lock_release_default \
    153   }
    154 
    155 /**
    156  * @brief Termios device handler.
    157  *
    158  * @see rtems_termios_device_install().
    159  */
    160 typedef struct {
    161   /**
    162    * @brief First open of this device.
    163    *
    164    * @param[in] tty The Termios control.  This parameter may be passed to
    165    *   interrupt service routines since it must be provided for the
    166    *   rtems_termios_enqueue_raw_characters() and
    167    *   rtems_termios_dequeue_characters() functions.
    168    * @param[in] context The Termios device context.
    169    * @param[in] term The current Termios attributes.
    170    * @param[in] args The open/close arguments.  This is parameter provided to
    171    *   support legacy drivers.  It must not be used by new drivers.
    172    *
    173    * @retval true Successful operation.
    174    * @retval false Cannot open device.
    175    *
    176    * @see rtems_termios_get_device_context() and rtems_termios_set_best_baud().
    177    */
    178   bool (*first_open)(
    179     struct rtems_termios_tty      *tty,
    180     rtems_termios_device_context  *context,
    181     struct termios                *term,
    182     rtems_libio_open_close_args_t *args
    183   );
    184 
    185   /**
    186    * @brief Last close of this device.
    187    *
    188    * @param[in] tty The Termios control.
    189    * @param[in] context The Termios device context.
    190    * @param[in] args The open/close arguments.  This is parameter provided to
    191    *   support legacy drivers.  It must not be used by new drivers.
    192    */
    193   void (*last_close)(
    194     struct rtems_termios_tty      *tty,
    195     rtems_termios_device_context  *context,
    196     rtems_libio_open_close_args_t *args
    197   );
    198 
    199   /**
    200    * @brief Polled read.
    201    *
    202    * In case mode is TERMIOS_IRQ_DRIVEN, TERMIOS_IRQ_SERVER_DRIVEN or
    203    * TERMIOS_TASK_DRIVEN, then data is received via
    204    * rtems_termios_enqueue_raw_characters().
    205    *
    206    * @param[in] context The Termios device context.
    207    *
    208    * @retval char The received data encoded as unsigned char.
    209    * @retval -1 No data currently available.
    210    */
    211   int (*poll_read)(rtems_termios_device_context *context);
    212 
    213   /**
    214    * @brief Polled write in case mode is TERMIOS_POLLED or write support
    215    * otherwise.
    216    *
    217    * @param[in] context The Termios device context.
    218    * @param[in] buf The output buffer.
    219    * @param[in] len The output buffer length in characters.
    220    */
    221   void (*write)(
    222     rtems_termios_device_context *context,
    223     const char *buf,
    224     size_t len
    225   );
    226 
    227   /**
    228    * @brief Set attributes after a Termios settings change.
    229    *
    230    * @param[in] context The Termios device context.
    231    * @param[in] term The new Termios attributes.
    232    *
    233    * @retval true Successful operation.
    234    * @retval false Invalid attributes.
    235    */
    236   bool (*set_attributes)(
    237     rtems_termios_device_context *context,
    238     const struct termios         *term
    239   );
    240 
    241   /**
    242    * @brief IO control handler.
    243    *
    244    * Invoked in case the Termios layer cannot deal with the IO request.
    245    *
    246    * @param[in] context The Termios device context.
    247    * @param[in] request The IO control request.
    248    * @param[in] buffer The IO control buffer.
    249    */
    250   int (*ioctl)(
    251     rtems_termios_device_context *context,
    252     ioctl_command_t               request,
    253     void                         *buffer
    254   );
    255 
    256   /**
    257    * @brief Termios device mode.
    258    */
    259   rtems_termios_device_mode mode;
    260 } rtems_termios_device_handler;
    261 
    262 /**
    263  * @brief Termios device flow control handler.
    264  *
    265  * @see rtems_termios_device_install().
    266  */
    267 typedef struct {
    268   /**
    269    * @brief Indicate to stop remote transmitter.
    270    *
    271    * @param[in] context The Termios device context.
    272    */
    273   void (*stop_remote_tx)(rtems_termios_device_context *context);
    274 
    275   /**
    276    * @brief Indicate to start remote transmitter.
    277    *
    278    * @param[in] context The Termios device context.
    279    */
    280   void (*start_remote_tx)(rtems_termios_device_context *context);
    281 } rtems_termios_device_flow;
    28274
    28375/**
     
    454246{
    455247  return tty->device_context;
    456 }
    457 
    458 /**
    459  * @brief Acquires the device lock.
    460  *
    461  * @param[in] context The device context.
    462  * @param[in] lock_context The local interrupt lock context for an acquire and
    463  *   release pair.
    464  */
    465 static inline void rtems_termios_device_lock_acquire(
    466   rtems_termios_device_context *context,
    467   rtems_interrupt_lock_context *lock_context
    468 )
    469 {
    470   ( *context->lock_acquire )( context, lock_context );
    471 }
    472 
    473 /**
    474  * @brief Releases the device lock.
    475  *
    476  * @param[in] context The device context.
    477  * @param[in] lock_context The local interrupt lock context for an acquire and
    478  *   release pair.
    479  */
    480 static inline void rtems_termios_device_lock_release(
    481   rtems_termios_device_context *context,
    482   rtems_interrupt_lock_context *lock_context
    483 )
    484 {
    485   ( *context->lock_release )( context, lock_context );
    486248}
    487249
  • cpukit/libcsupport/src/termiosinitialize.c

    r63415655 r0c3d6f58  
    11/**
    2  *  @file
     2 * @file
    33 *
    4  *  @brief Termios Initialization
    5  *  @ingroup Termios
     4 * @ingroup TermiostypesSupport
     5 *
     6 * @brief This source file contains the implementation of
     7 *   rtems_termios_device_lock_acquire_default() and
     8 *   rtems_termios_device_lock_release_default().
    69 */
    710
     
    1821#endif
    1922
    20 #include <rtems/termiostypes.h>
     23#include <rtems/termiosdevice.h>
    2124
    2225void
Note: See TracChangeset for help on using the changeset viewer.