Changeset e0cd9042 in mainline


Ignore:
Timestamp:
2012-08-13T22:55:25Z (12 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
188c76c
Parents:
58a369e
Message:

ns8250: Report buffer overrun errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/char/ns8250/ns8250.c

    r58a369e re0cd9042  
    8282/** Interrupt ID Register definition. */
    8383#define NS8250_IID_ACTIVE       (1 << 0)
     84#define NS8250_IID_CAUSE_MASK 0x0e
     85#define NS8250_IID_CAUSE_RXSTATUS 0x06
    8486
    8587/** FIFO Control Register definition. */
     
    466468{
    467469        /* Interrupt when data received. */
    468         pio_write_8(&regs->ier, NS8250_IER_RXREADY);
     470        pio_write_8(&regs->ier, NS8250_IER_RXREADY | NS8250_IER_RXSTATUS);
    469471        pio_write_8(&regs->mcr, NS8250_MCR_DTR | NS8250_MCR_RTS
    470472            | NS8250_MCR_OUT2);
     
    504506        async_msg_1(exch, IRC_ENABLE_INTERRUPT, ns->irq);
    505507        async_exchange_end(exch);
     508
     509        /* Read LSR to clear possible previous LSR interrupt */
     510        pio_read_8(&ns->regs->lsr);
    506511
    507512        /* Enable interrupt on the serial port. */
     
    766771/** The interrupt handler.
    767772 *
    768  * The serial port is initialized to interrupt when some data come, so the
    769  * interrupt is handled by reading the incomming data.
     773 * The serial port is initialized to interrupt when some data come or line
     774 * status register changes, so the interrupt is handled by reading the incoming
     775 * data and reading the line status register.
    770776 *
    771777 * @param dev           The serial port device.
     
    774780    ipc_call_t *icall)
    775781{
    776         ns8250_read_from_device(NS8250_FROM_DEV(dev));
     782        ns8250_t *ns = NS8250_FROM_DEV(dev);
     783
     784        uint8_t iir = pio_read_8(&ns->regs->iid);
     785        if ((iir & NS8250_IID_CAUSE_MASK) == NS8250_IID_CAUSE_RXSTATUS) {
     786                uint8_t lsr = pio_read_8(&ns->regs->lsr);
     787                if (lsr & NS8250_LSR_OE) {
     788                        ddf_msg(LVL_WARN, "Overrun error on %s", ns->dev->name);
     789                }
     790        }
     791       
     792        ns8250_read_from_device(ns);
    777793}
    778794
Note: See TracChangeset for help on using the changeset viewer.