VirtualBox

Changeset 23160 in vbox


Ignore:
Timestamp:
Sep 19, 2009 8:15:38 PM (15 years ago)
Author:
vboxsync
Message:

Serial: Add support for break conditions. On Windows it also possible to detect break conditions on the serial device

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/pdmifs.h

    r22812 r23160  
    14461446     */
    14471447    DECLR3CALLBACKMEMBER(int, pfnNotifyStatusLinesChanged,(PPDMICHARPORT pInterface, uint32_t fNewStatusLines));
     1448
     1449    /**
     1450     * Notify the device/driver that a break occurred.
     1451     *
     1452     * @returns VBox statsus code.
     1453     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     1454     * @thread  Any thread.
     1455     */
     1456    DECLR3CALLBACKMEMBER(int, pfnNotifyBreak,(PPDMICHARPORT pInterface));
    14481457} PDMICHARPORT;
    14491458
     
    14921501    DECLR3CALLBACKMEMBER(int, pfnSetModemLines,(PPDMICHAR pInterface, bool fRequestToSend, bool fDataTerminalReady));
    14931502
     1503    /**
     1504     * Sets the TD line into break condition.
     1505     *
     1506     * @returns VBox status code.
     1507     * @param   pInterface  Pointer to the interface structure containing the called function pointer.
     1508     * @param   fBreak      Set to true to let the device send a break false to put into normal operation.
     1509     * @thread  Any thread.
     1510     */
     1511    DECLR3CALLBACKMEMBER(int, pfnSetBreak,(PPDMICHAR pInterface, bool fBreak));
    14941512} PDMICHAR;
    14951513
  • trunk/src/VBox/Devices/Serial/DevSerial.cpp

    r22793 r23160  
    200200    } else if (s->msr_changed && (s->ier & UART_IER_RLSI)) {
    201201        s->iir = UART_IIR_RLSI;
     202    } else if (s->lsr & UART_LSR_BI) {
     203        s->iir = 0; /* No special status bit */
    202204    } else {
    203205        s->iir = UART_IIR_NO_INT;
     
    308310            if (break_enable != s->last_break_enable) {
    309311                s->last_break_enable = break_enable;
     312                if (RT_LIKELY(s->pDrvChar))
     313                {
     314                    Log(("serial_io_port_write: Set break %d\n", break_enable));
     315                    int rc = s->pDrvChar->pfnSetBreak(s->pDrvChar, !!break_enable);
     316                    AssertRC(rc);
     317                }
    310318            }
    311319        }
     
    494502}
    495503
     504static DECLCALLBACK(int) serialNotifyBreak(PPDMICHARPORT pInterface)
     505{
     506    SerialState *pThis = PDMICHARPORT_2_SERIALSTATE(pInterface);
     507
     508    Log(("%s: pInterface=%p\n", __FUNCTION__, pInterface));
     509
     510    PDMCritSectEnter(&pThis->CritSect, VERR_PERMISSION_DENIED);
     511
     512    pThis->lsr |= UART_LSR_BI;
     513    serial_update_irq(pThis);
     514
     515    PDMCritSectLeave(&pThis->CritSect);
     516
     517    return VINF_SUCCESS;
     518}
     519
    496520#endif /* IN_RING3 */
    497521
     
    757781
    758782    /* ICharPort */
    759     pThis->ICharPort.pfnNotifyRead = serialNotifyRead;
     783    pThis->ICharPort.pfnNotifyRead               = serialNotifyRead;
    760784    pThis->ICharPort.pfnNotifyStatusLinesChanged = serialNotifyStatusLinesChanged;
     785    pThis->ICharPort.pfnNotifyBreak              = serialNotifyBreak;
    761786
    762787#ifdef VBOX_SERIAL_PCI
  • trunk/src/VBox/Devices/Serial/DrvChar.cpp

    r22277 r23160  
    284284}
    285285
     286/**
     287 * Sets the TD line into break condition.
     288 *
     289 * @returns VBox status code.
     290 * @param   pInterface  Pointer to the interface structure containing the called function pointer.
     291 * @param   fBreak      Set to true to let the device send a break false to put into normal operation.
     292 * @thread  Any thread.
     293 */
     294static DECLCALLBACK(int) drvCharSetBreak(PPDMICHAR pInterface, bool fBreak)
     295{
     296    /* Nothing to do here. */
     297    return VINF_SUCCESS;
     298}
     299
    286300/* -=-=-=-=- driver interface -=-=-=-=- */
    287301
     
    307321    pThis->IChar.pfnSetParameters           = drvCharSetParameters;
    308322    pThis->IChar.pfnSetModemLines           = drvCharSetModemLines;
     323    pThis->IChar.pfnSetBreak                = drvCharSetBreak;
    309324
    310325    /*
  • trunk/src/VBox/Devices/Serial/DrvHostSerial.cpp

    r22876 r23160  
    849849                cbRemaining = dwNumberOfBytesTransferred;
    850850            }
     851            else if (dwEventMask & EV_BREAK)
     852            {
     853                Log(("HostSerial#%d: Detected break\n"));
     854                rc = pThis->pDrvCharPort->pfnNotifyBreak(pThis->pDrvCharPort);
     855            }
    851856            else
    852857            {
     
    11741179}
    11751180
     1181/**
     1182 * Sets the TD line into break condition.
     1183 *
     1184 * @returns VBox status code.
     1185 * @param   pInterface  Pointer to the interface structure containing the called function pointer.
     1186 * @param   fBreak      Set to true to let the device send a break false to put into normal operation.
     1187 * @thread  Any thread.
     1188 */
     1189static DECLCALLBACK(int) drvHostSerialSetBreak(PPDMICHAR pInterface, bool fBreak)
     1190{
     1191    PDRVHOSTSERIAL pThis = PDMICHAR_2_DRVHOSTSERIAL(pInterface);
     1192
     1193#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
     1194    if (fBreak)
     1195        ioctl(pThis->DeviceFile, TIOCSBRK);
     1196    else
     1197        ioctl(pThis->DeviceFile, TIOCCBRK);
     1198
     1199#elif defined(RT_OS_WINDOWS)
     1200    if (fBreak)
     1201        SetCommBreak(pThis->hDeviceFile);
     1202    else
     1203        ClearCommBreak(pThis->hDeviceFile);
     1204#endif
     1205
     1206    return VINF_SUCCESS;
     1207}
     1208
    11761209/* -=-=-=-=- driver interface -=-=-=-=- */
    11771210
     
    11981231#endif
    11991232    /* IBase. */
    1200     pDrvIns->IBase.pfnQueryInterface        = drvHostSerialQueryInterface;
     1233    pDrvIns->IBase.pfnQueryInterface = drvHostSerialQueryInterface;
    12011234    /* IChar. */
    1202     pThis->IChar.pfnWrite                   = drvHostSerialWrite;
    1203     pThis->IChar.pfnSetParameters           = drvHostSerialSetParameters;
    1204     pThis->IChar.pfnSetModemLines           = drvHostSerialSetModemLines;
     1235    pThis->IChar.pfnWrite            = drvHostSerialWrite;
     1236    pThis->IChar.pfnSetParameters    = drvHostSerialSetParameters;
     1237    pThis->IChar.pfnSetModemLines    = drvHostSerialSetModemLines;
     1238    pThis->IChar.pfnSetBreak         = drvHostSerialSetBreak;
    12051239
    12061240/** @todo Initialize all members with NIL values!! The destructor is ALWAYS called. */
Note: See TracChangeset for help on using the changeset viewer.

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