Changeset 0a697dd9 in rtems


Ignore:
Timestamp:
Jul 9, 2013, 9:24:27 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
155ea78
Parents:
d168079
git-author:
Sebastian Huber <sebastian.huber@…> (07/09/13 09:24:27)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/09/13 14:42:01)
Message:

bsp/virtex: Add VIRTEX_CONSOLE_USE_INTERRUPTS

Add interrupt support for console driver.

Location:
c/src/lib/libbsp/powerpc/virtex
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/virtex/configure.ac

    rd168079 r0a697dd9  
    2626 in the file system. Specify an absolute path. Do not forget the double quotes])
    2727
     28RTEMS_BSPOPTS_SET([VIRTEX_CONSOLE_USE_INTERRUPTS],[*],[1])
     29RTEMS_BSPOPTS_HELP([VIRTEX_CONSOLE_USE_INTERRUPTS],[if defined use interrupt driven Termios mode])
     30
    2831AC_DEFUN([VIRTEX_REGION],[
    2932AC_ARG_VAR([$1],[$2; default $3])dnl
  • c/src/lib/libbsp/powerpc/virtex/console/consolelite.c

    rd168079 r0a697dd9  
    1616 */
    1717
     18#include <assert.h>
     19
    1820#include <rtems.h>
    1921#include <rtems/libio.h>
     
    110112}
    111113
    112 
    113 
    114 
    115 
    116 
    117 
    118 
    119 
    120 
    121 
    122 static void xlite_init (int minor )
    123 {
    124    uint32_t base = Console_Port_Tbl[minor]->ulCtrlPort1;
    125 
    126    /* clear status register */
    127    *((volatile uint32_t*)(base+STAT_REG)) = 0;
    128 
    129    /* clear control register; reset fifos & interrupt enable */
    130    *((volatile uint32_t*)(base+CTRL_REG)) = RST_RX_FIFO | RST_TX_FIFO;
    131 }
    132 
     114static void xlite_init(int minor )
     115{
     116   /* Nothing to do */
     117}
     118
     119#ifdef VIRTEX_CONSOLE_USE_INTERRUPTS
     120static void xlite_interrupt_handler(void *arg)
     121{
     122   int minor = (int) arg;
     123   const console_tbl *ct = Console_Port_Tbl[minor];
     124   console_data *cd = &Console_Port_Data[minor];
     125   uint32_t base = ct->ulCtrlPort1;
     126   uint32_t status = xlite_uart_status(base);
     127
     128   while ((status & RX_FIFO_VALID_DATA) != 0) {
     129      char c = (char) xlite_uart_read(base);
     130
     131      rtems_termios_enqueue_raw_characters(cd->termios_data, &c, 1);
     132
     133      status = xlite_uart_status(base);
     134   }
     135
     136   if (cd->bActive) {
     137      rtems_termios_dequeue_characters(cd->termios_data, 1);
     138   }
     139}
     140#endif /* VIRTEX_CONSOLE_USE_INTERRUPTS */
    133141
    134142static int xlite_open(
     
    138146)
    139147{
    140    uint32_t base = Console_Port_Tbl[minor]->ulCtrlPort1;
    141 
    142    /* the lite uarts have hardcoded baud & serial parms so no port
    143     * conditioning is needed.  We're running polled so no interrupt
    144     * enables either */
     148   const console_tbl *ct = Console_Port_Tbl[minor];
     149   uint32_t base = ct->ulCtrlPort1;
     150#ifdef VIRTEX_CONSOLE_USE_INTERRUPTS
     151   rtems_status_code sc;
     152#endif /* VIRTEX_CONSOLE_USE_INTERRUPTS */
    145153
    146154   /* clear status register */
    147155   *((volatile uint32_t*)(base+STAT_REG)) = 0;
    148156
    149    /* clear control register; reset fifos & disable interrupts */
     157   /* clear control register; reset fifos */
    150158   *((volatile uint32_t*)(base+CTRL_REG)) = RST_RX_FIFO | RST_TX_FIFO;
    151159
    152    return RTEMS_SUCCESSFUL;
    153 }
    154 
     160#ifdef VIRTEX_CONSOLE_USE_INTERRUPTS
     161   *((volatile uint32_t*)(base+CTRL_REG)) = ENABLE_INTR;
     162
     163   sc = rtems_interrupt_handler_install(
     164      ct->ulIntVector,
     165      "xlite",
     166      RTEMS_INTERRUPT_UNIQUE,
     167      xlite_interrupt_handler,
     168      (void *) minor
     169   );
     170   assert(sc == RTEMS_SUCCESSFUL);
     171#endif /* VIRTEX_CONSOLE_USE_INTERRUPTS */
     172
     173   return 0;
     174}
    155175
    156176static int xlite_close(
     
    160180)
    161181{
    162    /* no shutdown protocol necessary */
    163    return RTEMS_SUCCESSFUL;
     182   const console_tbl *ct = Console_Port_Tbl[minor];
     183   uint32_t base = ct->ulCtrlPort1;
     184#ifdef VIRTEX_CONSOLE_USE_INTERRUPTS
     185   rtems_status_code sc;
     186#endif /* VIRTEX_CONSOLE_USE_INTERRUPTS */
     187
     188   *((volatile uint32_t*)(base+CTRL_REG)) = 0;
     189
     190#ifdef VIRTEX_CONSOLE_USE_INTERRUPTS
     191   sc = rtems_interrupt_handler_remove(
     192      ct->ulIntVector,
     193      xlite_interrupt_handler,
     194      (void *) minor
     195   );
     196   assert(sc == RTEMS_SUCCESSFUL);
     197#endif /* VIRTEX_CONSOLE_USE_INTERRUPTS */
     198
     199   return 0;
    164200}
    165201
     
    178214}
    179215
    180 
    181 
     216#ifdef VIRTEX_CONSOLE_USE_INTERRUPTS
     217
     218static ssize_t xlite_write_interrupt_driven(
     219  int minor,
     220  const char *buf,
     221  size_t len
     222)
     223{
     224  console_data *cd = &Console_Port_Data[minor];
     225
     226  if (len > 0) {
     227    const console_tbl *ct = Console_Port_Tbl[minor];
     228    uint32_t base = ct->ulCtrlPort1;
     229
     230    xlite_uart_write(base, buf[0]);
     231
     232    cd->bActive = true;
     233  } else {
     234    cd->bActive = false;
     235  }
     236
     237  return 0;
     238}
     239
     240#else /* VIRTEX_CONSOLE_USE_INTERRUPTS */
    182241
    183242static ssize_t xlite_write_buffer_polled(
     
    205264}
    206265
     266#endif /* VIRTEX_CONSOLE_USE_INTERRUPTS */
    207267
    208268static void xlite_write_char_polled(
     
    216276}
    217277
    218 
    219 
    220278static int xlite_set_attributes(int minor, const struct termios *t)
    221279{
     
    231289static const console_fns xlite_fns_polled =
    232290{
    233   libchip_serial_default_probe,        /* deviceProbe */
    234   xlite_open,                          /* deviceFirstOpen */
    235   xlite_close,                         /* deviceLastClose */
    236   xlite_read_polled,                   /* deviceRead */
    237   xlite_write_buffer_polled,           /* deviceWrite */
    238   xlite_init,                          /* deviceInitialize */
    239   xlite_write_char_polled,             /* deviceWritePolled */
    240   xlite_set_attributes,                /* deviceSetAttributes */
    241   FALSE,                               /* deviceOutputUsesInterrupts */
     291  .deviceProbe = libchip_serial_default_probe,
     292  .deviceFirstOpen = xlite_open,
     293  .deviceLastClose = xlite_close,
     294  .deviceRead = xlite_read_polled,
     295  .deviceInitialize = xlite_init,
     296  .deviceWritePolled = xlite_write_char_polled,
     297  .deviceSetAttributes = xlite_set_attributes,
     298#ifdef VIRTEX_CONSOLE_USE_INTERRUPTS
     299  .deviceWrite = xlite_write_interrupt_driven,
     300  .deviceOutputUsesInterrupts = true
     301#else
     302  .deviceWrite = xlite_write_buffer_polled,
     303  .deviceOutputUsesInterrupts = false
     304#endif
    242305};
    243306
     
    270333   NULL, /* unused */                      /* setData */
    271334   0,                                      /* ulClock */
    272    0                                       /* ulIntVector -- base for port */
     335   #ifdef XPAR_XPS_INTC_0_RS232_UART_INTERRUPT_INTR
     336     .ulIntVector = XPAR_XPS_INTC_0_RS232_UART_INTERRUPT_INTR
     337   #else
     338     .ulIntVector = 0
     339   #endif
    273340},
    274341#ifdef XPAR_UARTLITE_1_BASEADDR
Note: See TracChangeset for help on using the changeset viewer.