Changeset 96c73ab in rtems


Ignore:
Timestamp:
Feb 19, 1998, 11:02:16 PM (22 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
88a877b3
Parents:
fde74a3
Message:

Patch from Eric Norum:

While trying to work through this problem I decided that the
build-time selection of the console I/O operation (polling or
interrupt) was too clumsy. Here's a patch that allows run-time
(actually init-time) selection of the console I/O mode.

It also shows the need for another flags' or options' field in
the rtems_driver_address_table structure...

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/m68k/gen68360/console/console.c

    rfde74a3 r96c73ab  
    22 *  SMC1 raw console serial I/O.
    33 *
    4  *  This driver is an example of `POLLING' or `INTERRUPT' input.
    5  *
    6  *  To compile with interrupt-driven input, define M360_SMC1_INTERRUPT
    7  *  in the make customization file for this bsp (gen68360.cfg).
     4 *  This driver is an example of `POLLING' or `INTERRUPT' I/O.
     5 *
     6 *  To run with interrupt-driven I/O, ensure m360_smc1_interrupt
     7 *  is set before calling the initialization routine.
    88 *
    99 *  Author:
     
    3131#include "m68360.h"
    3232
    33 #if (defined (M360_SMC1_INTERRUPT))
    34 # define RXBUFSIZE      16
     33/*
     34 * Interrupt-driven input buffer
     35 */
     36#define RXBUFSIZE       16
     37
     38/*
     39 * Interrupt-driven callback
     40 */
     41static int m360_smc1_interrupt = 1;
    3542static void *smc1ttyp;
    36 #else
    37 # define RXBUFSIZE      1
    38 #endif
    3943
    4044/*
     
    4751 * Device-specific routines
    4852 */
    49 #if (defined (M360_SMC1_INTERRUPT))
    5053static rtems_isr
    5154smc1InterruptHandler (rtems_vector_number v)
     
    7578}
    7679
    77 #endif
    78 
    7980static void
    8081smc1Initialize (void)
     
    111112        m360.smc1p.rfcr = M360_RFCR_MOT | M360_RFCR_DMA_SPACE;
    112113        m360.smc1p.tfcr = M360_TFCR_MOT | M360_TFCR_DMA_SPACE;
    113         m360.smc1p.mrblr = RXBUFSIZE;
     114        if (m360_smc1_interrupt)
     115                m360.smc1p.mrblr = RXBUFSIZE;
     116        else
     117                m360.smc1p.mrblr = 1;
    114118         
    115119        /*
     
    150154        m360.smc1.smcmr |= M360_SMCMR_TEN | M360_SMCMR_REN;
    151155
    152 #if (defined (M360_SMC1_INTERRUPT))
    153         {
     156        if (m360_smc1_interrupt) {
    154157        rtems_isr_entry old_handler;
    155158        rtems_status_code sc;
     
    161164        m360.cimr |= 1UL << 4;  /* Enable SMC1 interrupts */
    162165        }
    163 #endif
    164166}
    165167
     
    184186 */
    185187static int
    186 smc1Write (int minor, const char *buf, int len)
    187 {
    188 #if (defined (M360_SMC1_INTERRUPT))
     188smc1InterruptWrite (int minor, const char *buf, int len)
     189{
    189190        smcTxBd->buffer = (char *)buf;
    190191        smcTxBd->length = len;
    191192        smcTxBd->status = M360_BD_READY | M360_BD_WRAP | M360_BD_INTERRUPT;
    192 #else
     193        return 0;
     194}
     195
     196static int
     197smc1PollWrite (int minor, const char *buf, int len)
     198{
    193199        while (len--) {
    194200                static char txBuf;
     
    200206                smcTxBd->status = M360_BD_READY | M360_BD_WRAP;
    201207        }
    202 #endif
    203208        return 0;
    204209}
     
    261266        rtems_status_code sc;
    262267
    263 #if (defined (M360_SMC1_INTERRUPT))
    264         rtems_libio_open_close_args_t *args = arg;
    265 
    266         sc = rtems_termios_open (major, minor, arg,
    267                         NULL,
    268                         NULL,
    269                         NULL,
    270                         smc1Write,
    271                         1);
    272         smc1ttyp = args->iop->data1;
    273 #else
    274         sc = rtems_termios_open (major, minor, arg,
    275                         NULL,
    276                         NULL,
    277                         smc1Read,
    278                         smc1Write,
    279                         0);
    280 #endif
     268        if (m360_smc1_interrupt) {
     269                rtems_libio_open_close_args_t *args = arg;
     270
     271                sc = rtems_termios_open (major, minor, arg,
     272                                        NULL,
     273                                        NULL,
     274                                        NULL,
     275                                        smc1InterruptWrite,
     276                                        1);
     277                smc1ttyp = args->iop->data1;
     278        }
     279        else {
     280                sc = rtems_termios_open (major, minor, arg,
     281                                        NULL,
     282                                        NULL,
     283                                        smc1Read,
     284                                        smc1PollWrite,
     285                                        0);
     286        }
    281287        return sc;
    282288}
  • make/custom/gen68360.cfg

    rfde74a3 r96c73ab  
    7070#     If defined, debug checks in RTEMS and support library code are enabled.
    7171#
    72 #  M360_SMC1_INTERRUPT (gen68360 BSP)
    73 #     If defined, then the console driver operates in interrupt mode.
    74 #     Otherwise it operates in polled mode.
    75 #
    7672
    7773define make-target-options
     
    8177        @echo "/* #define STACK_CHECKER_REPORT_USAGE  1 */" >>$@
    8278        @echo "/* #define RTEMS_DEBUG  1 */"                >>$@
    83         @echo "#define M360_SMC1_INTERRUPT 1"               >>$@
    8479endef
    8580
Note: See TracChangeset for help on using the changeset viewer.