Changeset 7fd5e89 in rtems


Ignore:
Timestamp:
Oct 7, 2014, 2:28:04 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
d5cc923f
Parents:
a830cb8
git-author:
Sebastian Huber <sebastian.huber@…> (10/07/14 14:28:04)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/07/14 14:35:13)
Message:

termios: Partially hide rtems_termios_tty

Move interrupt lock to device context and expose only this structure to
the read, write and set attributes device handler. This makes these
device handler independent of the general Termios infrastructure
suitable for direct use in printk() support.

Files:
12 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/tms570/console/tms570-sci.c

    ra830cb8 r7fd5e89  
    2727#include <termios.h>
    2828#include <rtems/termiostypes.h>
    29 #include <libchip/sersupp.h>
    3029#include <bsp/tms570-sci.h>
    3130#include <bsp/tms570-sci-driver.h>
     
    4443const tms570_sci_context driver_context_table[] = {
    4544  {
     45    .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("TMS570 SCI1"),
    4646    .device_name = "/dev/console",
    4747    .regs = &TMS570_SCI,
     
    4949  },
    5050  {
     51    .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("TMS570 SCI2"),
    5152    .device_name = "/dev/ttyS1",
    5253    .regs = &TMS570_SCI2,
     
    105106        handler,
    106107        NULL,
    107         (void *) ctx
     108        RTEMS_DECONST(rtems_termios_device_context *, &ctx->base)
    108109    );
    109110    if ( sc != RTEMS_SUCCESSFUL ) {
     
    197198 * Sets attributes of the HW peripheral (parity, baud rate, etc.)
    198199 *
    199  * @param[in] tty rtems_termios_tty
     200 * @param[in] base context of the driver
    200201 * @param[in] t termios driver
    201202 * @retval true peripheral setting is changed
    202203 */
    203204static bool tms570_sci_set_attributes(
    204   rtems_termios_tty    *tty,
     205  rtems_termios_device_context *base,
    205206  const struct termios *t
    206207)
    207208{
    208   tms570_sci_context *ctx = rtems_termios_get_device_context(tty);
     209  tms570_sci_context *ctx = (tms570_sci_context *) base;
    209210  rtems_interrupt_lock_context lock_context;
    210211  int32_t bauddiv;
    211212  int32_t baudrate;
    212213
    213   rtems_termios_interrupt_lock_acquire(tty, &lock_context);
     214  rtems_termios_device_lock_acquire(base, &lock_context);
    214215
    215216  ctx->regs->SCIGCR1 &= ~( (1<<7) | (1<<25) | (1<<24) );
     
    246247  ctx->regs->SCIGCR1 |= (1<<7) | (1<<25) | (1<<24);
    247248
    248   rtems_termios_interrupt_lock_release(tty, &lock_context);
     249  rtems_termios_device_lock_release(base, &lock_context);
    249250
    250251  return true;
     
    301302 * so only one character can be written.
    302303 *
    303  * @param[in] tty rtems_termios_tty
     304 * @param[in] base context of the driver
    304305 * @param[in] buf buffer of characters pending to send
    305306 * @param[in] len size of the buffer
     
    307308 */
    308309static void tms570_sci_interrupt_write(
    309   rtems_termios_tty *tty,
     310  rtems_termios_device_context *base,
    310311  const char *buf,
    311312  size_t len
    312313)
    313314{
    314   tms570_sci_context *ctx = rtems_termios_get_device_context(tty);
     315  tms570_sci_context *ctx = (tms570_sci_context *) base;
    315316
    316317  if ( len > 0 ) {
     
    335336 * character to HW peripheral. Writes all characters in the buffer.
    336337 *
    337  * @param[in] tty rtems_termios_tty
     338 * @param[in] base context of the driver
    338339 * @param[in] buf buffer of characters pending to send
    339340 * @param[in] len size of the buffer
     
    341342 */
    342343static void tms570_sci_poll_write(
    343   rtems_termios_tty *tty,
    344   const char        *buf,
    345   size_t             n
    346 )
    347 {
    348   tms570_sci_context *ctx = rtems_termios_get_device_context(tty);
     344  rtems_termios_device_context *base,
     345  const char *buf,
     346  size_t n
     347)
     348{
     349  tms570_sci_context *ctx = (tms570_sci_context *) base;
    349350  size_t i;
    350351
     
    395396 * check if there is recieved character to be read and reads it.
    396397 *
    397  * @param[in] tty rtems_termios_tty (context of the driver)
     398 * @param[in] base context of the driver
    398399 * @retval -1 No character to be read
    399400 * @retval x Read character
    400401 */
    401 static int tms570_sci_poll_read(rtems_termios_tty *tty)
    402 {
    403   tms570_sci_context *ctx = rtems_termios_get_device_context(tty);
     402static int tms570_sci_poll_read(rtems_termios_device_context *base)
     403{
     404  tms570_sci_context *ctx = (tms570_sci_context *) base;
    404405
    405406  /* Check if a character is available */
     
    417418 * This function is called only once when opening the driver.
    418419 *
    419  * @param[in] tty context of the driver
     420 * @param[in] tty Termios control
     421 * @param[in] ctx context of the driver
     422 * @param[in] term Termios attributes
    420423 * @param[in] args
    421424 * @retval false Error occured during initialization
     
    424427static bool tms570_sci_poll_first_open(
    425428  rtems_termios_tty             *tty,
     429  rtems_termios_device_context  *ctx,
     430  struct termios                *term,
    426431  rtems_libio_open_close_args_t *args
    427432)
     
    429434  bool ok;
    430435
    431   rtems_termios_set_best_baud(tty, TMS570_SCI_BAUD_RATE);
    432   ok = tms570_sci_set_attributes(tty, rtems_termios_get_termios(tty));
     436  rtems_termios_set_best_baud(term, TMS570_SCI_BAUD_RATE);
     437  ok = tms570_sci_set_attributes(ctx, term);
    433438  if ( !ok ) {
    434439    return false;
     
    443448 * install and enables interrupts.
    444449 *
    445  * @param[in] tty context of the driver
     450 * @param[in] tty Termios control
     451 * @param[in] base context of the driver
    446452 * @param[in] args
    447453 * @retval false Error occured during initialization
     
    450456static bool tms570_sci_interrupt_first_open(
    451457  rtems_termios_tty             *tty,
     458  rtems_termios_device_context  *base,
     459  struct termios                *term,
    452460  rtems_libio_open_close_args_t *args
    453461)
    454462{
    455   tms570_sci_context *ctx = rtems_termios_get_device_context(tty);
     463  tms570_sci_context *ctx = (tms570_sci_context *) base;
    456464  rtems_status_code sc;
    457465  bool ret;
    458466
    459   ret = tms570_sci_poll_first_open(tty,args);
     467  ret = tms570_sci_poll_first_open(tty, base, term, args);
    460468  if ( ret == false ) {
    461469    return false;
     
    472480    return false;
    473481  }
    474   tms570_sci_enable_interrupts(rtems_termios_get_device_context(tty));
     482  tms570_sci_enable_interrupts(ctx);
    475483  return true;
    476484}
     
    479487 * @brief closes sci peripheral
    480488 *
    481  * @param[in] tty context of the driver
     489 * @param[in] tty Termios control
     490 * @param[in] base context of the driver
    482491 * @param[in] args
    483492 * @retval false Error occured during initialization
     
    486495static void tms570_sci_poll_last_close(
    487496  rtems_termios_tty             *tty,
     497  rtems_termios_device_context  *base,
    488498  rtems_libio_open_close_args_t *args
    489499)
     
    497507 * calls tms570_sci_poll_last_close and disables interrupts
    498508 *
    499  * @param[in] tty context of the driver
     509 * @param[in] tty Termios control
     510 * @param[in] base context of the driver
    500511 * @param[in] args
    501512 * @retval false Error occured during initialization
     
    504515static void tms570_sci_interrupt_last_close(
    505516  rtems_termios_tty             *tty,
     517  rtems_termios_device_context  *base,
    506518  rtems_libio_open_close_args_t *args
    507519)
    508520{
    509   tms570_sci_context *ctx = rtems_termios_get_device_context(tty);
     521  tms570_sci_context *ctx = (tms570_sci_context *) base;
    510522  rtems_interrupt_lock_context lock_context;
    511523
    512524  /* Turn off RX interrupts */
    513   rtems_termios_interrupt_lock_acquire(tty, &lock_context);
     525  rtems_termios_device_lock_acquire(base, &lock_context);
    514526  tms570_sci_disable_interrupts(ctx);
    515   rtems_termios_interrupt_lock_release(tty, &lock_context);
     527  rtems_termios_device_lock_release(base, &lock_context);
    516528
    517529  /* Flush device */
     
    523535  rtems_interrupt_handler_remove(ctx->irq, tms570_sci_interrupt_handler, tty);
    524536
    525   tms570_sci_poll_last_close(tty,args);
     537  tms570_sci_poll_last_close(tty, base, args);
    526538}
    527539
  • c/src/lib/libbsp/arm/tms570/include/tms570-sci-driver.h

    ra830cb8 r7fd5e89  
    3737/* Low-level driver specific data structure */
    3838typedef struct {
     39  rtems_termios_device_context base;
    3940  const char *device_name;
    4041  volatile tms570_sci_t *regs;
  • c/src/lib/libbsp/sparc/leon3/console/console.c

    ra830cb8 r7fd5e89  
    3737static int uarts = 0;
    3838
    39 static struct apbuart_context *leon3_console_get_uart(int minor)
     39static rtems_termios_device_context *leon3_console_get_context(int minor)
    4040{
    4141  struct apbuart_context *uart;
     
    4646    uart = &apbuarts[minor - 1];
    4747
    48   return uart;
     48  rtems_termios_device_context_initialize(&uart->base, "APBUART");
     49
     50  return &uart->base;
    4951}
    5052
     
    133135      handler,
    134136      NULL,
    135       leon3_console_get_uart(syscon_uart_index)
     137      leon3_console_get_context(syscon_uart_index)
    136138    );
    137139    if (status != RTEMS_SUCCESSFUL)
     
    150152      handler,
    151153      NULL,
    152       leon3_console_get_uart(syscon_uart_index)
     154      leon3_console_get_context(syscon_uart_index)
    153155    );
    154156  }
  • c/src/lib/libbsp/sparc/shared/include/apbuart_termios.h

    ra830cb8 r7fd5e89  
    2323
    2424struct apbuart_context {
     25  rtems_termios_device_context base;
    2526  struct apbuart_regs *regs;
    2627  unsigned int freq_hz;
  • c/src/lib/libbsp/sparc/shared/uart/apbuart_termios.c

    ra830cb8 r7fd5e89  
    4242
    4343static void apbuart_write_support(
    44   rtems_termios_tty *tty,
     44  rtems_termios_device_context *base,
    4545  const char *buf,
    4646  size_t len
    4747)
    4848{
    49   struct apbuart_context *uart = rtems_termios_get_device_context(tty);
     49  struct apbuart_context *uart = (struct apbuart_context *) base;
    5050  int sending;
    5151
     
    7070
    7171static void apbuart_write_polled(
    72   rtems_termios_tty *tty,
     72  rtems_termios_device_context *base,
    7373  const char *buf,
    7474  size_t len
    7575)
    7676{
    77   struct apbuart_context *uart = rtems_termios_get_device_context(tty);
     77  struct apbuart_context *uart = (struct apbuart_context *) base;
    7878  size_t nwrite = 0;
    7979
     
    8484}
    8585
    86 static int apbuart_poll_read(rtems_termios_tty *tty)
    87 {
    88   struct apbuart_context *uart = rtems_termios_get_device_context(tty);
     86static int apbuart_poll_read(rtems_termios_device_context *base)
     87{
     88  struct apbuart_context *uart = (struct apbuart_context *) base;
    8989
    9090  return apbuart_inbyte_nonblocking(uart->regs);
     
    9292
    9393static bool apbuart_set_attributes(
    94   rtems_termios_tty *tty,
     94  rtems_termios_device_context *base,
    9595  const struct termios *t
    9696)
    9797{
    98   struct apbuart_context *uart = rtems_termios_get_device_context(tty);
     98  struct apbuart_context *uart = (struct apbuart_context *) base;
    9999  rtems_interrupt_lock_context lock_context;
    100100  unsigned int scaler;
     
    113113  }
    114114
    115   rtems_termios_interrupt_lock_acquire(tty, &lock_context);
     115  rtems_termios_device_lock_acquire(base, &lock_context);
    116116
    117117  /* Read out current value */
     
    146146  uart->regs->ctrl = ctrl;
    147147
    148   rtems_termios_interrupt_lock_release(tty, &lock_context);
     148  rtems_termios_device_lock_release(base, &lock_context);
    149149
    150150  /* Baud rate */
     
    162162
    163163static void apbuart_set_best_baud(
    164   rtems_termios_tty *tty,
    165   const struct apbuart_context *uart
     164  const struct apbuart_context *uart,
     165  struct termios *term
    166166)
    167167{
    168168  uint32_t baud = (uart->freq_hz * 10) / ((uart->regs->scaler * 10 + 5) * 8);
    169169
    170   rtems_termios_set_best_baud(tty, baud);
     170  rtems_termios_set_best_baud(term, baud);
    171171}
    172172
    173173static bool apbuart_first_open_polled(
    174174  rtems_termios_tty *tty,
     175  rtems_termios_device_context *base,
     176  struct termios *term,
    175177  rtems_libio_open_close_args_t *args
    176178)
    177179{
    178   struct apbuart_context *uart = rtems_termios_get_device_context(tty);
    179 
    180   apbuart_set_best_baud(tty, uart);
     180  struct apbuart_context *uart = (struct apbuart_context *) base;
     181
     182  apbuart_set_best_baud(uart, term);
    181183
    182184  /* Initialize UART on opening */
     
    189191static bool apbuart_first_open_interrupt(
    190192  rtems_termios_tty *tty,
     193  rtems_termios_device_context *base,
     194  struct termios *term,
    191195  rtems_libio_open_close_args_t *args
    192196)
    193197{
    194   struct apbuart_context *uart = rtems_termios_get_device_context(tty);
     198  struct apbuart_context *uart = (struct apbuart_context *) base;
    195199  rtems_status_code sc;
    196200
    197   apbuart_set_best_baud(tty, uart);
     201  apbuart_set_best_baud(uart, term);
    198202
    199203  /* Register Interrupt handler */
     
    218222static void apbuart_last_close_interrupt(
    219223  rtems_termios_tty *tty,
     224  rtems_termios_device_context *base,
    220225  rtems_libio_open_close_args_t *args
    221226)
    222227{
    223   struct apbuart_context *uart = rtems_termios_get_device_context(tty);
     228  struct apbuart_context *uart = (struct apbuart_context *) base;
    224229  rtems_interrupt_lock_context lock_context;
    225230
    226231  /* Turn off RX interrupts */
    227   rtems_termios_interrupt_lock_acquire(tty, &lock_context);
     232  rtems_termios_device_lock_acquire(base, &lock_context);
    228233  uart->regs->ctrl &= ~(APBUART_CTRL_RI);
    229   rtems_termios_interrupt_lock_release(tty, &lock_context);
     234  rtems_termios_device_lock_release(base, &lock_context);
    230235
    231236  /**** Flush device ****/
  • cpukit/libcsupport/include/rtems/termiostypes.h

    ra830cb8 r7fd5e89  
    6464
    6565/**
     66 * @brief Termios device context.
     67 *
     68 * @see RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER(),
     69 * rtems_termios_device_context_initialize() and
     70 * rtems_termios_device_install().
     71 */
     72typedef struct rtems_termios_device_context {
     73  rtems_interrupt_lock interrupt_lock;
     74} rtems_termios_device_context;
     75
     76/**
     77 * @brief Initializes a device context.
     78 *
     79 * @param[in] context The Termios device context.
     80 * @param[in] name The name for the interrupt lock.  This name must be a
     81 *   string persistent throughout the life time of this lock.  The name is only
     82 *   used if profiling is enabled.
     83 */
     84RTEMS_INLINE_ROUTINE void rtems_termios_device_context_initialize(
     85  rtems_termios_device_context *context,
     86  const char                   *name
     87)
     88{
     89  rtems_interrupt_lock_initialize( &context->interrupt_lock, name );
     90}
     91
     92/**
     93 * @brief Initializer for static initialization of Termios device contexts.
     94 *
     95 * @param name The name for the interrupt lock.  It must be a string.  The name
     96 *   is only used if profiling is enabled.
     97 */
     98#define RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( name ) \
     99  { RTEMS_INTERRUPT_LOCK_INITIALIZER( name ) }
     100
     101/**
    66102 * @brief Termios device handler.
    67103 *
     
    72108   * @brief First open of this device.
    73109   *
    74    * @param[in] tty The Termios control.
     110   * @param[in] tty The Termios control.  This parameter may be passed to
     111   *   interrupt service routines since it must be provided for the
     112   *   rtems_termios_enqueue_raw_characters() and
     113   *   rtems_termios_dequeue_characters() functions.
     114   * @param[in] context The Termios device context.
     115   * @param[in] term The current Termios attributes.
    75116   * @param[in] args The open/close arguments.  This is parameter provided to
    76117   *   support legacy drivers.  It must not be used by new drivers.
     
    79120   * @retval false Cannot open device.
    80121   *
    81    * @see rtems_termios_get_device_context(), rtems_termios_set_best_baud() and
    82    *   rtems_termios_get_termios().
     122   * @see rtems_termios_get_device_context() and rtems_termios_set_best_baud().
    83123   */
    84124  bool (*first_open)(
    85125    struct rtems_termios_tty      *tty,
     126    rtems_termios_device_context  *context,
     127    struct termios                *term,
    86128    rtems_libio_open_close_args_t *args
    87129  );
     
    91133   *
    92134   * @param[in] tty The Termios control.
     135   * @param[in] context The Termios device context.
    93136   * @param[in] args The open/close arguments.  This is parameter provided to
    94137   *   support legacy drivers.  It must not be used by new drivers.
    95    *
    96    * @see rtems_termios_get_device_context().
    97138   */
    98139  void (*last_close)(
    99140    struct rtems_termios_tty      *tty,
     141    rtems_termios_device_context  *context,
    100142    rtems_libio_open_close_args_t *args
    101143  );
     
    107149   * received via rtems_termios_enqueue_raw_characters().
    108150   *
    109    * @param[in] tty The Termios control.
     151   * @param[in] context The Termios device context.
    110152   *
    111153   * @retval char The received data encoded as unsigned char.
    112154   * @retval -1 No data currently available.
    113    *
    114    * @see rtems_termios_get_device_context().
    115    */
    116   int (*poll_read)(struct rtems_termios_tty *tty);
     155   */
     156  int (*poll_read)(rtems_termios_device_context *context);
    117157
    118158  /**
     
    120160   * otherwise.
    121161   *
    122    * @param[in] tty The Termios control.
     162   * @param[in] context The Termios device context.
    123163   * @param[in] buf The output buffer.
    124164   * @param[in] len The output buffer length in characters.
    125    *
    126    * @see rtems_termios_get_device_context().
    127    */
    128   void (*write)(struct rtems_termios_tty *tty, const char *buf, size_t len);
     165   */
     166  void (*write)(
     167    rtems_termios_device_context *context,
     168    const char *buf,
     169    size_t len
     170  );
    129171
    130172  /**
    131173   * @brief Set attributes after a Termios settings change.
    132174   *
    133    * @param[in] tty The Termios control.
     175   * @param[in] context The Termios device context.
    134176   * @param[in] term The new Termios attributes.
    135177   *
    136178   * @retval true Successful operation.
    137179   * @retval false Invalid attributes.
    138    *
    139    * @see rtems_termios_get_device_context().
    140180   */
    141181  bool (*set_attributes)(
    142     struct rtems_termios_tty *tty,
    143     const struct termios     *term
     182    rtems_termios_device_context *context,
     183    const struct termios         *term
    144184  );
    145185
     
    159199   * @brief Indicate to stop remote transmitter.
    160200   *
    161    * @param[in] tty The Termios control.
    162    *
    163    * @see rtems_termios_get_device_context().
    164    */
    165   void (*stop_remote_tx)(struct rtems_termios_tty *tty);
     201   * @param[in] context The Termios device context.
     202   */
     203  void (*stop_remote_tx)(rtems_termios_device_context *context);
    166204
    167205  /**
    168206   * @brief Indicate to start remote transmitter.
    169207   *
    170    * @param[in] tty The Termios control.
    171    *
    172    * @see rtems_termios_get_device_context().
    173    */
    174   void (*start_remote_tx)(struct rtems_termios_tty *tty);
     208   * @param[in] context The Termios device context.
     209   */
     210  void (*start_remote_tx)(rtems_termios_device_context *context);
    175211} rtems_termios_device_flow;
    176212
     
    186222  const rtems_termios_device_handler *handler;
    187223  const rtems_termios_device_flow    *flow;
    188   void                               *context;
     224  rtems_termios_device_context       *context;
    189225  struct rtems_termios_tty           *tty;
    190226} rtems_termios_device_node;
     
    259295
    260296  /**
     297   * @brief Context for legacy devices using the callbacks.
     298   */
     299  rtems_termios_device_context legacy_device_context;
     300
     301  /**
    261302   * @brief The device handler.
    262303   */
     
    290331  int              tty_rcvwakeup;
    291332
    292   rtems_interrupt_lock interrupt_lock;
    293 
    294333  /**
    295334   * @brief Corresponding device node.
     
    299338  /**
    300339   * @brief Context for device driver.
    301    *
    302    * @see rtems_termios_get_device_context().
    303    */
    304   void *device_context;
     340   */
     341  rtems_termios_device_context *device_context;
    305342} rtems_termios_tty;
    306343
     
    336373  const rtems_termios_device_handler *handler,
    337374  const rtems_termios_device_flow    *flow,
    338   void                               *context
     375  rtems_termios_device_context       *context
    339376);
    340377
     
    383420/**
    384421 * @brief Returns the device context of an installed Termios device.
     422 *
     423 * @param[in] tty The Termios control.
    385424 */
    386425RTEMS_INLINE_ROUTINE void *rtems_termios_get_device_context(
     
    392431
    393432/**
    394  * @brief Returns the Termios structure.
    395  *
    396  * It can be used for example in the first open handler to adjust or obtain the
    397  * initial attributes.
    398  */
    399 RTEMS_INLINE_ROUTINE struct termios *rtems_termios_get_termios(
    400   rtems_termios_tty *tty
     433 * @brief Acquires the device lock.
     434 *
     435 * @param[in] context The device context.
     436 * @param[in] lock_context The local interrupt lock context for an acquire and
     437 *   release pair.
     438 */
     439RTEMS_INLINE_ROUTINE void rtems_termios_device_lock_acquire(
     440  rtems_termios_device_context *context,
     441  rtems_interrupt_lock_context *lock_context
    401442)
    402443{
    403   return &tty->termios;
     444  rtems_interrupt_lock_acquire( &context->interrupt_lock, lock_context );
     445}
     446
     447/**
     448 * @brief Releases the device lock.
     449 *
     450 * @param[in] context The device context.
     451 * @param[in] lock_context The local interrupt lock context for an acquire and
     452 *   release pair.
     453 */
     454RTEMS_INLINE_ROUTINE void rtems_termios_device_lock_release(
     455  rtems_termios_device_context *context,
     456  rtems_interrupt_lock_context *lock_context
     457)
     458{
     459  rtems_interrupt_lock_release( &context->interrupt_lock, lock_context );
    404460}
    405461
     
    410466 * value is chosen which minimizes the difference to the value specified.
    411467 *
    412  * @param[in] tty The Termios control.
     468 * @param[in] term The Termios attributes.
    413469 * @param[in] baud The current baud setting of the device.
    414470 */
    415471void rtems_termios_set_best_baud(
    416   rtems_termios_tty *tty,
    417   uint32_t           baud
     472  struct termios *term,
     473  uint32_t        baud
    418474);
    419475
     
    499555);
    500556
    501 #define rtems_termios_interrupt_lock_acquire(tty, level) \
    502   rtems_interrupt_lock_acquire(&tty->interrupt_lock, level)
    503 
    504 #define rtems_termios_interrupt_lock_release(tty, level) \
    505   rtems_interrupt_lock_release(&tty->interrupt_lock, level)
    506 
    507557#ifdef __cplusplus
    508558}
  • cpukit/libcsupport/src/termios.c

    ra830cb8 r7fd5e89  
    135135  const rtems_termios_device_handler *handler,
    136136  const rtems_termios_device_flow    *flow,
    137   void                               *context
     137  rtems_termios_device_context       *context
    138138)
    139139{
     
    228228}
    229229
     230static rtems_termios_tty *
     231legacyContextToTTY (rtems_termios_device_context *ctx)
     232{
     233  return RTEMS_CONTAINER_OF (ctx, rtems_termios_tty, legacy_device_context);
     234}
     235
    230236static bool
    231237rtems_termios_callback_firstOpen(
    232238  rtems_termios_tty             *tty,
     239  rtems_termios_device_context  *ctx,
     240  struct termios                *term,
    233241  rtems_libio_open_close_args_t *args
    234242)
    235243{
     244  (void) ctx;
     245  (void) term;
     246
    236247  (*tty->device.firstOpen) (tty->major, tty->minor, args);
    237248
     
    242253rtems_termios_callback_lastClose(
    243254  rtems_termios_tty             *tty,
     255  rtems_termios_device_context  *ctx,
    244256  rtems_libio_open_close_args_t *args
    245257)
    246258{
     259  (void) ctx;
     260
    247261  (*tty->device.lastClose) (tty->major, tty->minor, args);
    248262}
    249263
    250264static int
    251 rtems_termios_callback_pollRead (struct rtems_termios_tty *tty)
    252 {
     265rtems_termios_callback_pollRead (rtems_termios_device_context *ctx)
     266{
     267  rtems_termios_tty *tty = legacyContextToTTY (ctx);
     268
    253269  return (*tty->device.pollRead) (tty->minor);
    254270}
     
    256272static void
    257273rtems_termios_callback_write(
    258   rtems_termios_tty *tty,
    259   const char        *buf,
    260   size_t             len
     274  rtems_termios_device_context *ctx,
     275  const char                   *buf,
     276  size_t                        len
    261277)
    262278{
     279  rtems_termios_tty *tty = legacyContextToTTY (ctx);
     280
    263281  (*tty->device.write) (tty->minor, buf, len);
    264282}
     
    266284static bool
    267285rtems_termios_callback_setAttributes(
    268   rtems_termios_tty    *tty,
    269   const struct termios *term
     286  rtems_termios_device_context *ctx,
     287  const struct termios         *term
    270288)
    271289{
     290  rtems_termios_tty *tty = legacyContextToTTY (ctx);
     291
    272292  (*tty->device.setAttributes) (tty->minor, term);
    273293
     
    276296
    277297static void
    278 rtems_termios_callback_stopRemoteTx (rtems_termios_tty *tty)
    279 {
     298rtems_termios_callback_stopRemoteTx (rtems_termios_device_context *ctx)
     299{
     300  rtems_termios_tty *tty = legacyContextToTTY (ctx);
     301
    280302  (*tty->device.stopRemoteTx) (tty->minor);
    281303}
    282304
    283305static void
    284 rtems_termios_callback_startRemoteTx (rtems_termios_tty *tty)
    285 {
     306rtems_termios_callback_startRemoteTx (rtems_termios_device_context *ctx)
     307{
     308  rtems_termios_tty *tty = legacyContextToTTY (ctx);
     309
    286310  (*tty->device.startRemoteTx) (tty->minor);
    287311}
     
    293317drainOutput (struct rtems_termios_tty *tty)
    294318{
     319  rtems_termios_device_context *ctx = tty->device_context;
    295320  rtems_interrupt_lock_context lock_context;
    296321  rtems_status_code sc;
    297322
    298323  if (tty->handler.mode != TERMIOS_POLLED) {
    299     rtems_termios_interrupt_lock_acquire (tty, &lock_context);
     324    rtems_termios_device_lock_acquire (ctx, &lock_context);
    300325    while (tty->rawOutBuf.Tail != tty->rawOutBuf.Head) {
    301326      tty->rawOutBufState = rob_wait;
    302       rtems_termios_interrupt_lock_release (tty, &lock_context);
     327      rtems_termios_device_lock_release (ctx, &lock_context);
    303328      sc = rtems_semaphore_obtain(
    304329        tty->rawOutBuf.Semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
    305330      if (sc != RTEMS_SUCCESSFUL)
    306331        rtems_fatal_error_occurred (sc);
    307       rtems_termios_interrupt_lock_acquire (tty, &lock_context);
    308     }
    309     rtems_termios_interrupt_lock_release (tty, &lock_context);
     332      rtems_termios_device_lock_acquire (ctx, &lock_context);
     333    }
     334    rtems_termios_device_lock_release (ctx, &lock_context);
    310335  }
    311336}
     
    345370  }
    346371  if (last_close && tty->handler.last_close)
    347      (*tty->handler.last_close)(tty, arg);
     372     (*tty->handler.last_close)(tty, tty->device_context, arg);
    348373
    349374  if (tty->device_node != NULL)
     
    356381      (tty->handler.mode == TERMIOS_TASK_DRIVEN))
    357382    rtems_semaphore_delete (tty->rawInBuf.Semaphore);
    358   rtems_interrupt_lock_destroy (&tty->interrupt_lock);
     383
     384  if (tty->device_context == &tty->legacy_device_context)
     385    rtems_interrupt_lock_destroy (&tty->legacy_device_context.interrupt_lock);
     386
    359387  free (tty->rawInBuf.theBuf);
    360388  free (tty->rawOutBuf.theBuf);
     
    490518    }
    491519
    492     rtems_interrupt_lock_initialize (&tty->interrupt_lock, "Termios");
     520    if (tty->device_context == NULL) {
     521      tty->device_context = &tty->legacy_device_context;
     522      rtems_termios_device_context_initialize (tty->device_context, "Termios");
     523    }
    493524
    494525    /*
     
    570601  args->iop->data1 = tty;
    571602  if (!tty->refcount++) {
    572     if (tty->handler.first_open &&
    573         !(*tty->handler.first_open)(tty, args)) {
     603    if (tty->handler.first_open && !(*tty->handler.first_open)(
     604        tty, tty->device_context, &tty->termios, args)) {
    574605      rtems_termios_destroy_tty(tty, args, false);
    575606      return NULL;
     
    684715flushOutput (struct rtems_termios_tty *tty)
    685716{
     717  rtems_termios_device_context *ctx = tty->device_context;
    686718  rtems_interrupt_lock_context lock_context;
    687719
    688   rtems_termios_interrupt_lock_acquire (tty, &lock_context);
     720  rtems_termios_device_lock_acquire (ctx, &lock_context);
    689721  tty->rawOutBuf.Tail = 0;
    690722  tty->rawOutBuf.Head = 0;
    691723  tty->rawOutBufState = rob_idle;
    692   rtems_termios_interrupt_lock_release (tty, &lock_context);
     724  rtems_termios_device_lock_release (ctx, &lock_context);
    693725}
    694726
     
    696728flushInput (struct rtems_termios_tty *tty)
    697729{
     730  rtems_termios_device_context *ctx = tty->device_context;
    698731  rtems_interrupt_lock_context lock_context;
    699732
    700   rtems_termios_interrupt_lock_acquire (tty, &lock_context);
     733  rtems_termios_device_lock_acquire (ctx, &lock_context);
    701734  tty->rawInBuf.Tail = 0;
    702735  tty->rawInBuf.Head = 0;
    703   rtems_termios_interrupt_lock_release (tty, &lock_context);
     736  rtems_termios_device_lock_release (ctx, &lock_context);
    704737}
    705738
     
    785818termios_set_flowctrl(struct rtems_termios_tty *tty)
    786819{
     820  rtems_termios_device_context *ctx = tty->device_context;
    787821  rtems_interrupt_lock_context lock_context;
    788822  /*
     
    799833    if (tty->flow_ctrl & FL_OSTOP) {
    800834      /* disable interrupts    */
    801       rtems_termios_interrupt_lock_acquire (tty, &lock_context);
     835      rtems_termios_device_lock_acquire (ctx, &lock_context);
    802836      tty->flow_ctrl &= ~FL_OSTOP;
    803837      /* check for chars in output buffer (or rob_state?) */
     
    805839        /* if chars available, call write function... */
    806840        (*tty->handler.write)(
    807           tty, &tty->rawOutBuf.theBuf[tty->rawOutBuf.Tail],1);
     841          ctx, &tty->rawOutBuf.theBuf[tty->rawOutBuf.Tail],1);
    808842      }
    809843      /* reenable interrupts */
    810       rtems_termios_interrupt_lock_release (tty, &lock_context);
     844      rtems_termios_device_lock_release (ctx, &lock_context);
    811845    }
    812846  }
     
    827861    if ((tty->flow_ctrl & FL_IRTSOFF) &&
    828862        (tty->flow.start_remote_tx != NULL)) {
    829       tty->flow.start_remote_tx(tty);
     863      tty->flow.start_remote_tx(ctx);
    830864    }
    831865    tty->flow_ctrl &= ~(FL_IRTSOFF);
     
    907941    }
    908942    if (tty->handler.set_attributes) {
    909       sc = (*tty->handler.set_attributes)(tty, &tty->termios) ?
     943      sc = (*tty->handler.set_attributes)(tty->device_context, &tty->termios) ?
    910944        RTEMS_SUCCESSFUL : RTEMS_IO_ERROR;
    911945    }
     
    10041038    /* stop transmitter */
    10051039    if (transmitting) {
    1006       (*tty->handler.write) (tty, NULL, 0);
     1040      (*tty->handler.write) (tty->device_context, NULL, 0);
    10071041    }
    10081042  } else {
     
    10181052
    10191053    (*tty->handler.write)(
    1020         tty, &tty->rawOutBuf.theBuf[newTail], nToSend);
     1054        tty->device_context, &tty->rawOutBuf.theBuf[newTail], nToSend);
    10211055  }
    10221056
     
    10331067  const char *buf = _buf;
    10341068  unsigned int newHead;
     1069  rtems_termios_device_context *ctx = tty->device_context;
    10351070  rtems_interrupt_lock_context lock_context;
    10361071  rtems_status_code sc;
    10371072
    10381073  if (tty->handler.mode == TERMIOS_POLLED) {
    1039     (*tty->handler.write)(tty, buf, len);
     1074    (*tty->handler.write)(ctx, buf, len);
    10401075    return;
    10411076  }
     
    10501085      newHead -= tty->rawOutBuf.Size;
    10511086
    1052     rtems_termios_interrupt_lock_acquire (tty, &lock_context);
     1087    rtems_termios_device_lock_acquire (ctx, &lock_context);
    10531088    while (newHead == tty->rawOutBuf.Tail) {
    10541089      tty->rawOutBufState = rob_wait;
    1055       rtems_termios_interrupt_lock_release (tty, &lock_context);
     1090      rtems_termios_device_lock_release (ctx, &lock_context);
    10561091      sc = rtems_semaphore_obtain(
    10571092        tty->rawOutBuf.Semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
    10581093      if (sc != RTEMS_SUCCESSFUL)
    10591094        rtems_fatal_error_occurred (sc);
    1060       rtems_termios_interrupt_lock_acquire (tty, &lock_context);
     1095      rtems_termios_device_lock_acquire (ctx, &lock_context);
    10611096    }
    10621097
     
    10911126    }
    10921127
    1093     rtems_termios_interrupt_lock_release (tty, &lock_context);
     1128    rtems_termios_device_lock_release (ctx, &lock_context);
    10941129
    10951130    buf += nToCopy;
     
    13721407  if (tty->termios.c_lflag & ICANON) {
    13731408    for (;;) {
    1374       n = (*tty->handler.poll_read)(tty);
     1409      n = (*tty->handler.poll_read)(tty->device_context);
    13751410      if (n < 0) {
    13761411        rtems_task_wake_after (1);
     
    13851420    then = rtems_clock_get_ticks_since_boot();
    13861421    for (;;) {
    1387       n = (*tty->handler.poll_read)(tty);
     1422      n = (*tty->handler.poll_read)(tty->device_context);
    13881423      if (n < 0) {
    13891424        if (tty->termios.c_cc[VMIN]) {
     
    14481483          /* XON should be sent now... */
    14491484          (*tty->handler.write)(
    1450             tty, (void *)&(tty->termios.c_cc[VSTART]), 1);
     1485            tty->device_context, (void *)&(tty->termios.c_cc[VSTART]), 1);
    14511486        } else if (tty->flow_ctrl & FL_MDRTS) {
    14521487          tty->flow_ctrl &= ~FL_IRTSOFF;
    14531488          /* activate RTS line */
    14541489          if (tty->flow.start_remote_tx != NULL) {
    1455             tty->flow.start_remote_tx(tty);
     1490            tty->flow.start_remote_tx(tty->device_context);
    14561491          }
    14571492        }
     
    15511586  int dropped = 0;
    15521587  bool flow_rcv = false; /* true, if flow control char received */
     1588  rtems_termios_device_context *ctx = tty->device_context;
    15531589  rtems_interrupt_lock_context lock_context;
    15541590
     
    15991635      if ((tty->flow_ctrl & (FL_ORCVXOF | FL_OSTOP)) == FL_OSTOP) {
    16001636        /* disable interrupts    */
    1601         rtems_termios_interrupt_lock_acquire (tty, &lock_context);
     1637        rtems_termios_device_lock_acquire (ctx, &lock_context);
    16021638        tty->flow_ctrl &= ~FL_OSTOP;
    16031639        /* check for chars in output buffer (or rob_state?) */
     
    16051641          /* if chars available, call write function... */
    16061642          (*tty->handler.write)(
    1607             tty, &tty->rawOutBuf.theBuf[tty->rawOutBuf.Tail], 1);
     1643            ctx, &tty->rawOutBuf.theBuf[tty->rawOutBuf.Tail], 1);
    16081644        }
    16091645        /* reenable interrupts */
    1610         rtems_termios_interrupt_lock_release (tty, &lock_context);
     1646        rtems_termios_device_lock_release (ctx, &lock_context);
    16111647      }
    16121648    } else {
    16131649      newTail = (tty->rawInBuf.Tail + 1) % tty->rawInBuf.Size;
    16141650      /* if chars_in_buffer > highwater                */
    1615       rtems_termios_interrupt_lock_acquire (tty, &lock_context);
     1651      rtems_termios_device_lock_acquire (ctx, &lock_context);
    16161652      if ((((newTail - tty->rawInBuf.Head + tty->rawInBuf.Size)
    16171653            % tty->rawInBuf.Size) > tty->highwater) &&
     
    16261662            /*    call write function here                 */
    16271663            tty->flow_ctrl |= FL_ISNTXOF;
    1628             (*tty->handler.write)(tty,
     1664            (*tty->handler.write)(ctx,
    16291665                (void *)&(tty->termios.c_cc[VSTOP]), 1);
    16301666          }
     
    16331669          /* deactivate RTS line */
    16341670          if (tty->flow.stop_remote_tx != NULL) {
    1635             tty->flow.stop_remote_tx(tty);
     1671            tty->flow.stop_remote_tx(ctx);
    16361672          }
    16371673        }
     
    16391675
    16401676      /* reenable interrupts */
    1641       rtems_termios_interrupt_lock_release (tty, &lock_context);
     1677      rtems_termios_device_lock_release (ctx, &lock_context);
    16421678
    16431679      if (newTail == tty->rawInBuf.Head) {
     
    16731709  unsigned int newTail;
    16741710  int nToSend;
     1711  rtems_termios_device_context *ctx = tty->device_context;
    16751712  rtems_interrupt_lock_context lock_context;
    16761713  int len;
    16771714
    1678   rtems_termios_interrupt_lock_acquire (tty, &lock_context);
     1715  rtems_termios_device_lock_acquire (ctx, &lock_context);
    16791716
    16801717  /* check for XOF/XON to send */
     
    16821719      == (FL_MDXOF | FL_IREQXOF)) {
    16831720    /* XOFF should be sent now... */
    1684     (*tty->handler.write)(tty, (void *)&(tty->termios.c_cc[VSTOP]), 1);
     1721    (*tty->handler.write)(ctx, (void *)&(tty->termios.c_cc[VSTOP]), 1);
    16851722
    16861723    tty->t_dqlen--;
     
    16981735     * Therefore the dequeue "length" should be reduced by 1
    16991736     */
    1700     (*tty->handler.write)(tty, (void *)&(tty->termios.c_cc[VSTART]), 1);
     1737    (*tty->handler.write)(ctx, (void *)&(tty->termios.c_cc[VSTART]), 1);
    17011738
    17021739    tty->t_dqlen--;
     
    17151752    }
    17161753
    1717     (*tty->handler.write) (tty, NULL, 0);
     1754    (*tty->handler.write) (ctx, NULL, 0);
    17181755    nToSend = 0;
    17191756  } else {
     
    17351772       */
    17361773      tty->rawOutBufState = rob_idle;
    1737       (*tty->handler.write) (tty, NULL, 0);
     1774      (*tty->handler.write) (ctx, NULL, 0);
    17381775      nToSend = 0;
    17391776
     
    17521789  }
    17531790
    1754   rtems_termios_interrupt_lock_release (tty, &lock_context);
     1791  rtems_termios_device_lock_release (ctx, &lock_context);
    17551792
    17561793  if (wakeUpWriterTask) {
     
    18551892{
    18561893  struct rtems_termios_tty *tty = (struct rtems_termios_tty *)argument;
     1894  rtems_termios_device_context *ctx = tty->device_context;
    18571895  rtems_event_set the_event;
    18581896  int c;
     
    18771915     * do something
    18781916     */
    1879     c = tty->handler.poll_read(tty);
     1917    c = tty->handler.poll_read(ctx);
    18801918    if (c != EOF) {
    18811919      /*
  • cpukit/libcsupport/src/termios_setbestbaud.c

    ra830cb8 r7fd5e89  
    2020
    2121void rtems_termios_set_best_baud(
    22   rtems_termios_tty *tty,
    23   uint32_t           baud
     22  struct termios *term,
     23  uint32_t        baud
    2424)
    2525{
     
    4242  }
    4343
    44   tty->termios.c_cflag = (tty->termios.c_cflag & ~cbaud_mask) | cbaud;
     44  term->c_cflag = (term->c_cflag & ~cbaud_mask) | cbaud;
    4545}
  • cpukit/libnetworking/net/if_ppp.c

    ra830cb8 r7fd5e89  
    388388        /* write out frame byte to start the transmission */
    389389                sc->sc_outchar = (u_char)PPP_FLAG;
    390         (*tp->handler.write)(tp, (char *)&sc->sc_outchar, 1);
     390        (*tp->handler.write)(tp->device_context, (char *)&sc->sc_outchar, 1);
    391391      }
    392392
  • cpukit/libnetworking/net/ppp_tty.c

    ra830cb8 r7fd5e89  
    569569  struct mbuf        *m       = (struct mbuf *)0;
    570570  struct ppp_softc   *sc      = tp->t_sc;
     571  rtems_termios_device_context *ctx = rtems_termios_get_device_context(tp);
    571572
    572573  /* ensure input is valid and we are busy */
     
    607608        sc->sc_outflag &=~(SC_TX_FCS);
    608609                sc->sc_outchar = (u_char)PPP_FLAG;
    609         (*tp->handler.write)(tp, (char *)&sc->sc_outchar, 1);
     610        (*tp->handler.write)(ctx, (char *)&sc->sc_outchar, 1);
    610611        return(0);
    611612      }
     
    644645
    645646      /* write out the character(s) and update the stats */
    646       (*tp->handler.write)(tp, (char *)sendBegin, (ioffset > 0) ? ioffset : 1);
     647      (*tp->handler.write)(ctx, (char *)sendBegin, (ioffset > 0) ? ioffset : 1);
    647648      sc->sc_stats.ppp_obytes += (ioffset > 0) ? ioffset : 1;
    648649      sc->sc_outoff += ioffset;
  • doc/bsp_howto/console.t

    ra830cb8 r7fd5e89  
    275275/* Low-level driver specific data structure */
    276276typedef struct @{
     277  rtems_termios_device_context base;
    277278  const char *device_name;
    278279  volatile module_register_block *regs;
     
    299300@group
    300301static void my_driver_poll_write(
    301   rtems_termios_tty *tty,
    302   const char        *buf,
    303   size_t             n
     302  rtems_termios_device_context *base,
     303  const char                   *buf,
     304  size_t                        n
    304305)
    305306@{
    306   my_driver_context *ctx = rtems_termios_get_device_context(tty);
     307  my_driver_context *ctx = (my_driver_context *) base;
    307308  size_t i;
    308309
     
    321322@example
    322323@group
    323 static int my_driver_poll_read(rtems_termios_tty *tty)
    324 @{
    325   my_driver_context *ctx = rtems_termios_get_device_context(tty);
     324static int my_driver_poll_read(rtems_termios_device_context *base)
     325@{
     326  my_driver_context *ctx = (my_driver_context *) base;
    326327
    327328  /* Check if a character is available */
     
    410411@group
    411412static void my_driver_interrupt_write(
    412   rtems_termios_tty *tty,
    413   const char        *buf,
    414   size_t             n
     413  rtems_termios_device_context  *base,
     414  const char                    *buf,
     415  size_t                         n
    415416)
    416417@{
    417   my_driver_context *ctx = rtems_termios_get_device_context(tty);
     418  my_driver_context *ctx = (my_driver_context *) base;
    418419
    419420  /*
     
    519520static bool my_driver_first_open(
    520521  rtems_termios_tty             *tty,
     522  rtems_termios_device_context  *base,
     523  struct termios                *term,
    521524  rtems_libio_open_close_args_t *args
    522525)
    523526@{
    524   my_driver_context *ctx = rtems_termios_get_device_context(tty);
     527  my_driver_context *ctx = (my_driver_context *) base;
    525528  rtems_status_code sc;
    526529  bool ok;
     
    543546   * Alternatively you can set the best baud.
    544547   */
    545   rtems_termios_set_best_baud(tty, MY_DRIVER_BAUD_RATE);
     548  rtems_termios_set_best_baud(term, MY_DRIVER_BAUD_RATE);
    546549
    547550  /*
     
    549552   * this.
    550553   */
    551   ok = my_driver_set_attributes(tty, rtems_termios_get_termios(tty));
     554  ok = my_driver_set_attributes(base, term);
    552555  if (!ok) @{
    553556    /* This is bad */
     
    575578static void my_driver_last_close(
    576579  rtems_termios_tty             *tty,
     580  rtems_termios_device_context  *base,
    577581  rtems_libio_open_close_args_t *args
    578582)
    579583@{
    580   my_driver_context *ctx = rtems_termios_get_device_context(tty);
     584  my_driver_context *ctx = (my_driver_context *) base;
    581585
    582586  /*
     
    619623@group
    620624static bool my_driver_set_attributes(
    621   rtems_termios_tty    *tty,
    622   const struct termios *term
     625  rtems_termios_device_context *base,
     626  const struct termios         *term
    623627)
    624628@{
    625   my_driver_context *ctx = rtems_termios_get_device_context(tty);
     629  my_driver_context *ctx = (my_driver_context *) base;
    626630
    627631  /*
  • testsuites/libtests/termios01/init.c

    ra830cb8 r7fd5e89  
    518518}
    519519
     520typedef struct {
     521  rtems_termios_device_context base;
     522  bool done;
     523} device_context;
     524
    520525static rtems_status_code test_early_device_install_remove(
    521526  rtems_device_major_number major,
     
    529534  rtems_resource_snapshot_take( &snapshot );
    530535
    531   sc = rtems_termios_device_install( "/", 0, 0, NULL, NULL );
     536  sc = rtems_termios_device_install( "/", 0, 0, NULL, NULL, NULL );
    532537  rtems_test_assert( sc == RTEMS_INCORRECT_STATE );
    533538
     
    631636static bool first_open_error(
    632637  rtems_termios_tty *tty,
     638  rtems_termios_device_context *base,
     639  struct termios *term,
    633640  rtems_libio_open_close_args_t *args
    634641)
    635642{
    636   bool *done = rtems_termios_get_device_context( tty );
    637 
     643  device_context *ctx = (device_context *) base;
     644
     645  (void) tty;
     646  (void) term;
    638647  (void) args;
    639648
    640   *done = true;
     649  ctx->done = true;
    641650
    642651  return false;
     
    656665  rtems_libio_t iop;
    657666  rtems_libio_open_close_args_t args;
    658   bool done = false;
     667  device_context ctx = {
     668    .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "abc" ),
     669    .done = false
     670  };
    659671
    660672  rtems_resource_snapshot_take( &snapshot );
     
    666678    &handler,
    667679    NULL,
    668     &done
     680    &ctx.base
    669681  );
    670682  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     
    674686  args.iop = &iop;
    675687
    676   rtems_test_assert( !done );
     688  rtems_test_assert( !ctx.done );
    677689  sc = rtems_termios_device_open( major, minor, &args );
    678690  rtems_test_assert( sc == RTEMS_NO_MEMORY );
    679   rtems_test_assert( done );
     691  rtems_test_assert( ctx.done );
    680692
    681693  sc = rtems_termios_device_remove( &dev[0], major, minor );
     
    686698
    687699static bool set_attributes_error(
    688   rtems_termios_tty *tty,
     700  rtems_termios_device_context *base,
    689701  const struct termios *term
    690702)
    691703{
    692   bool *done = rtems_termios_get_device_context( tty );
     704  device_context *ctx = (device_context *) base;
    693705
    694706  (void) term;
    695707
    696   *done = true;
     708  ctx->done = true;
    697709
    698710  return false;
     
    714726  rtems_libio_ioctl_args_t io_args;
    715727  struct termios term;
    716   bool done = false;
     728  device_context ctx = {
     729    .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "abc" ),
     730    .done = false
     731  };
    717732
    718733  rtems_resource_snapshot_take( &snapshot );
     
    724739    &handler,
    725740    NULL,
    726     &done
     741    &ctx.base
    727742  );
    728743  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     
    740755  io_args.buffer = &term;
    741756
    742   rtems_test_assert( !done );
     757  rtems_test_assert( !ctx.done );
    743758  sc = rtems_termios_ioctl( &io_args );
    744759  rtems_test_assert( sc == RTEMS_IO_ERROR );
    745   rtems_test_assert( done );
     760  rtems_test_assert( ctx.done );
    746761
    747762  sc = rtems_termios_device_close( &oc_args );
     
    791806
    792807  for ( i = 0; i < n; ++i ) {
    793     rtems_termios_tty tty;
    794     struct termios *term = rtems_termios_get_termios( &tty );
     808    struct termios term;
    795809    tcflag_t cbaud_mask = CBAUD;
    796810
    797     memset( &tty, 0xff, sizeof( tty ) );
    798     rtems_termios_set_best_baud( &tty, baud_to_cflag_table[ i ].baud );
     811    memset( &term, 0xff, sizeof( term ) );
     812    rtems_termios_set_best_baud( &term, baud_to_cflag_table[ i ].baud );
    799813
    800814    rtems_test_assert(
    801       (term->c_cflag & cbaud_mask) == baud_to_cflag_table[ i ].cflag
     815      (term.c_cflag & cbaud_mask) == baud_to_cflag_table[ i ].cflag
    802816    );
    803817  }
Note: See TracChangeset for help on using the changeset viewer.