VirtualBox

Ticket #1548: serial.patch

File serial.patch, 3.9 KB (added by Timo Kreuzer, 14 years ago)
  • include/VBox/pdmifs.h

     
    14951495    DECLR3CALLBACKMEMBER(int, pfnNotifyStatusLinesChanged,(PPDMICHARPORT pInterface, uint32_t fNewStatusLines));
    14961496
    14971497    /**
     1498     * Notify the device/driver when the lsr changed.
     1499     *
     1500     * @returns VBox status code.
     1501     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     1502     * @param   fNewStatusLine  New state of the status line pins.
     1503     * @thread  Any thread.
     1504     */
     1505    DECLR3CALLBACKMEMBER(int, pfnNotifyLsrChanged,(PPDMICHARPORT pInterface, uint32_t fNewLsr));
     1506
     1507    /**
    14981508     * Notify the device/driver that a break occurred.
    14991509     *
    15001510     * @returns VBox statsus code.
     
    15141524#define PDMICHARPORT_STATUS_LINES_CTS   RT_BIT(3)
    15151525/** @} */
    15161526
     1527/** @name Bit mask definitions for lsr type.
     1528 * @{ */
     1529#define PDMICHARPORT_LSR_THRE   RT_BIT(0)
     1530/** @} */
    15171531
    15181532/** Pointer to a char interface. */
    15191533typedef struct PDMICHARCONNECTOR *PPDMICHARCONNECTOR;
  • src/VBox/Devices/Serial/DevSerial.cpp

     
    273273        if (s->lcr & UART_LCR_DLAB) {
    274274            s->divider = (s->divider & 0xff00) | val;
    275275            serial_update_parameters(s);
    276         } else {
     276        } else if (s->lsr & UART_LSR_THRE) {
    277277            s->thr_ipending = 0;
    278278            s->lsr &= ~UART_LSR_THRE;
    279279            serial_update_irq(s);
     
    285285                AssertRC(rc);
    286286            }
    287287            s->thr_ipending = 1;
    288             s->lsr |= UART_LSR_THRE;
    289288            s->lsr |= UART_LSR_TEMT;
    290289            serial_update_irq(s);
     290        } else {
     291            /* Transmitter Holding Register is not empty! */
     292            Log(("serial_ioport_write: THR not empty\n", ch));
    291293        }
    292294        break;
    293295    case 1:
     
    507509    return VINF_SUCCESS;
    508510}
    509511
     512static DECLCALLBACK(int) serialNotifyLsrChanged(PPDMICHARPORT pInterface, uint32_t newStatusLines)
     513{
     514    SerialState *pThis = PDMICHARPORT_2_SERIALSTATE(pInterface);
     515    uint8_t newLsr = s->lsr;
     516
     517    PDMCritSectEnter(&pThis->CritSect, VERR_PERMISSION_DENIED);
     518
     519    /* Set new states. */
     520    if (newStatusLines & PDMICHARPORT_LSR_THRE)
     521        newLsr |= UART_LSR_THRE;
     522    else
     523        newLsr &= ~UART_LSR_THRE;
     524
     525    s->lsr = newLsr;
     526
     527    PDMCritSectLeave(&pThis->CritSect);
     528
     529    return VINF_SUCCESS;
     530}
     531
    510532static DECLCALLBACK(int) serialNotifyBreak(PPDMICHARPORT pInterface)
    511533{
    512534    SerialState *pThis = PDMICHARPORT_2_SERIALSTATE(pInterface);
     
    797819    /* ICharPort */
    798820    pThis->ICharPort.pfnNotifyRead               = serialNotifyRead;
    799821    pThis->ICharPort.pfnNotifyStatusLinesChanged = serialNotifyStatusLinesChanged;
     822    pThis->ICharPort.pfnNotifyLsrChanged         = serialNotifyLsrChanged;
    800823    pThis->ICharPort.pfnNotifyBreak              = serialNotifyBreak;
    801824
    802825#ifdef VBOX_SERIAL_PCI
  • src/VBox/Devices/Serial/DrvChar.cpp

     
    178178                Assert(cbProcessed);
    179179                pThis->iSendQueueTail++;
    180180                pThis->iSendQueueTail &= CHAR_MAX_SEND_QUEUE_MASK;
     181
     182                rc = pThis->pDrvCharPort->pfnNotifyLsrChanged(pThis->pDrvCharPort, PDMICHARPORT_LSR_THRE);
     183                if (RT_FAILURE(rc))
     184                {
     185                    /* Notifying device failed, continue but log it */
     186                    LogRel(("HostSerial#%d: Notifying device failed with error %Rrc; continuing.\n", pDrvIns->iInstance, rc));
     187                }
    181188            }
    182189            else if (rc == VERR_TIMEOUT)
    183190            {

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy