Changeset 688e101a in rtems


Ignore:
Timestamp:
Sep 14, 2018, 5:30:46 AM (15 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
62cb39d7
Parents:
d22147e
git-author:
Sebastian Huber <sebastian.huber@…> (09/14/18 05:30:46)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/17/18 06:56:32)
Message:

bsp/tqm8xx: Fix polled vs. interrupt output

Update #3513.

Location:
bsps/powerpc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • bsps/powerpc/include/mpc8xx.h

    rd22147e r688e101a  
    684684  volatile uint16_t          status;
    685685  uint16_t                 length;
    686   volatile void                    *buffer;
     686  void                     *buffer;
    687687} m8xxBufferDescriptor_t;
    688688
  • bsps/powerpc/tqm8xx/console/console.c

    rd22147e r688e101a  
    106106#define SCC_RXBD_CNT 4
    107107#define SCC_TXBD_CNT 4
    108 typedef volatile char sccRxBuf_t[SCC_RXBD_CNT][RXBUFSIZE];
     108typedef char sccRxBuf_t[SCC_RXBD_CNT][RXBUFSIZE];
    109109
    110110/*
     
    418418  rtems_termios_tty *tty = arg;
    419419  m8xx_console_chan_desc_t *cd = rtems_termios_get_device_context(tty);
     420  uint16_t status;
     421  uint16_t length;
     422  void *buffer;
    420423
    421424  /*
     
    430433     * process event
    431434     */
    432     while ((cd->sccCurrRxBd->status & M8xx_BD_EMPTY) == 0) {
    433       rtems_cache_invalidate_multiple_data_lines((void *)cd->sccCurrRxBd->buffer,
    434                                                   cd->sccCurrRxBd->length);
    435       rtems_termios_enqueue_raw_characters (tty,
    436                                             (char *)cd->sccCurrRxBd->buffer,
    437                                             cd->sccCurrRxBd->length);
     435    while (true) {
     436      status = cd->sccCurrRxBd->status;
     437
     438      if ((cd->sccCurrRxBd->status & M8xx_BD_EMPTY) != 0) {
     439        break;
     440      }
     441
     442      buffer = cd->sccCurrRxBd->buffer;
     443      length = cd->sccCurrRxBd->length;
     444      rtems_cache_invalidate_multiple_data_lines(buffer, length);
     445      rtems_termios_enqueue_raw_characters (tty, buffer, length);
     446
    438447      /*
    439448       * clear status
    440449       */
    441       cd->sccCurrRxBd->status =
    442         (cd->sccCurrRxBd->status
    443          & (M8xx_BD_WRAP | M8xx_BD_INTERRUPT))
    444         | M8xx_BD_EMPTY;
     450      cd->sccCurrRxBd->status = (status & (M8xx_BD_WRAP | M8xx_BD_INTERRUPT))
     451        | M8xx_BD_EMPTY;
    445452      /*
    446453       * advance to next BD
    447454       */
    448       if ((cd->sccCurrRxBd->status & M8xx_BD_WRAP) != 0) {
    449         cd->sccCurrRxBd = cd->sccFrstRxBd;
    450       }
    451       else {
    452         cd->sccCurrRxBd++;
     455      if ((status & M8xx_BD_WRAP) != 0) {
     456        cd->sccCurrRxBd = cd->sccFrstRxBd;
     457      } else {
     458        cd->sccCurrRxBd++;
    453459      }
    454460    }
     
    468474     * FIXME: multiple dequeue calls for multiple buffers
    469475     */
    470     while((cd->sccDequTxBd != cd->sccPrepTxBd) &&
    471           ((cd->sccDequTxBd->status & M8xx_BD_READY) == 0)) {
    472       rtems_termios_dequeue_characters (tty, cd->sccDequTxBd->length);
     476    while (cd->sccDequTxBd != cd->sccPrepTxBd) {
     477      status = cd->sccDequTxBd->status;
     478
     479      if ((status & M8xx_BD_READY) != 0) {
     480        break;
     481      }
     482
     483      if ((status & M8xx_BD_INTERRUPT) != 0) {
     484        rtems_termios_dequeue_characters (tty, cd->sccDequTxBd->length);
     485      }
     486
    473487      /*
    474488       * advance to next BD
    475489       */
    476       if ((cd->sccDequTxBd->status & M8xx_BD_WRAP) != 0) {
    477         cd->sccDequTxBd = cd->sccFrstTxBd;
    478       }
    479       else {
    480         cd->sccDequTxBd++;
     490      if ((status & M8xx_BD_WRAP) != 0) {
     491        cd->sccDequTxBd = cd->sccFrstTxBd;
     492      } else {
     493        cd->sccDequTxBd++;
    481494      }
    482495    }
     
    731744sccInterruptWrite (rtems_termios_device_context *base, const char *buf, size_t len)
    732745{
     746  m8xx_console_chan_desc_t *cd = (m8xx_console_chan_desc_t *)base;
     747
    733748  if (len > 0) {
    734     m8xx_console_chan_desc_t *cd = (m8xx_console_chan_desc_t *)base;
    735     if ((cd->sccPrepTxBd->status & M8xx_BD_READY) == 0) {
    736       cd->sccPrepTxBd->buffer = (char *)buf;
     749    uint16_t status = cd->sccPrepTxBd->status;
     750
     751    if ((status & M8xx_BD_READY) == 0) {
     752      cd->sccPrepTxBd->buffer = RTEMS_DECONST(char*, buf);
    737753      cd->sccPrepTxBd->length = len;
    738       rtems_cache_flush_multiple_data_lines((const void *)buf,len);
     754      rtems_cache_flush_multiple_data_lines(buf, len);
     755
    739756      /*
    740757       * clear status, set ready bit
    741758       */
    742       cd->sccPrepTxBd->status =
    743         (cd->sccPrepTxBd->status
    744          & M8xx_BD_WRAP)
     759      cd->sccPrepTxBd->status = (status & M8xx_BD_WRAP)
    745760        | M8xx_BD_READY | M8xx_BD_INTERRUPT;
    746       if ((cd->sccPrepTxBd->status & M8xx_BD_WRAP) != 0) {
     761
     762      if ((status & M8xx_BD_WRAP) != 0) {
    747763        cd->sccPrepTxBd = cd->sccFrstTxBd;
    748       }
    749       else {
     764      } else {
    750765        cd->sccPrepTxBd++;
    751766      }
     
    758773{
    759774  m8xx_console_chan_desc_t *cd = (m8xx_console_chan_desc_t *)base;
    760   static char txBuf[CONS_CHN_CNT][SCC_TXBD_CNT];
    761   int chan = cd->chan;
    762   int bd_used;
    763 
    764   while (len--) {
    765     while (cd->sccPrepTxBd->status & M8xx_BD_READY)
    766       continue;
    767     bd_used = cd->sccPrepTxBd - cd->sccFrstTxBd;
    768     txBuf[chan][bd_used] = *buf++;
    769       rtems_cache_flush_multiple_data_lines((const void *)&txBuf[chan][bd_used],
    770                                             sizeof(txBuf[chan][bd_used]));
    771     cd->sccPrepTxBd->buffer = &(txBuf[chan][bd_used]);
    772     cd->sccPrepTxBd->length = 1;
    773     cd->sccPrepTxBd->status =
    774       (cd->sccPrepTxBd->status
    775        & M8xx_BD_WRAP)
    776       | M8xx_BD_READY;
    777     if ((cd->sccPrepTxBd->status & M8xx_BD_WRAP) != 0) {
    778       cd->sccPrepTxBd = cd->sccFrstTxBd;
    779     }
    780     else {
    781       cd->sccPrepTxBd++;
    782     }
     775  volatile m8xxBufferDescriptor_t *bd = NULL;
     776
     777  rtems_cache_flush_multiple_data_lines (buf, len);
     778
     779  while (bd == NULL) {
     780    rtems_interrupt_level level;
     781    uint16_t status;
     782
     783    rtems_interrupt_disable(level);
     784
     785    bd = cd->sccPrepTxBd;
     786    status = bd->status;
     787
     788    if ((status & M8xx_BD_READY) == 0) {
     789      bd->buffer = RTEMS_DECONST (char *, buf);
     790      bd->length = len;
     791      bd->status = (status & M8xx_BD_WRAP) | M8xx_BD_READY;
     792
     793      if ((status & M8xx_BD_WRAP) != 0) {
     794        cd->sccPrepTxBd = cd->sccFrstTxBd;
     795      } else {
     796        cd->sccPrepTxBd++;
     797      }
     798    } else {
     799      bd = NULL;
     800    }
     801
     802    rtems_interrupt_enable(level);
     803  }
     804
     805  while ((bd->status & M8xx_BD_READY) != 0) {
     806    /* Wait */
    783807  }
    784808}
Note: See TracChangeset for help on using the changeset viewer.