Changeset 73331 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jul 23, 2018 3:23:48 PM (6 years ago)
- Location:
- trunk/src/VBox/Devices/Serial
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Serial/DrvCharNew.cpp
r73299 r73331 114 114 static DECLCALLBACK(int) drvCharDataAvailWrNotify(PPDMISERIALCONNECTOR pInterface, size_t cbAvail) 115 115 { 116 LogFlowFunc(("pInterface=%#p cbAvail=%zu\n", pInterface, cbAvail)); 116 117 PDRVCHAR pThis = RT_FROM_MEMBER(pInterface, DRVCHAR, ISerialConnector); 117 118 … … 130 131 static DECLCALLBACK(int) drvCharReadRdr(PPDMISERIALCONNECTOR pInterface, void *pvBuf, size_t cbRead, size_t *pcbRead) 131 132 { 133 LogFlowFunc(("pInterface=%#p pvBuf=%#p cbRead=%zu pcbRead=%#p\n", pInterface, pvBuf, cbRead, pcbRead)); 132 134 PDRVCHAR pThis = RT_FROM_MEMBER(pInterface, DRVCHAR, ISerialConnector); 133 135 int rc = VINF_SUCCESS; … … 136 138 size_t cbToRead = RT_MIN(cbRead, pThis->cbRemaining); 137 139 memcpy(pvBuf, pThis->pbBuf, cbToRead); 140 141 pThis->pbBuf += cbToRead; 138 142 *pcbRead = cbToRead; 139 143 size_t cbOld = ASMAtomicSubZ(&pThis->cbRemaining, cbToRead); … … 142 146 STAM_COUNTER_ADD(&pThis->StatBytesRead, cbToRead); 143 147 148 LogFlowFunc(("-> %Rrc\n", rc)); 144 149 return rc; 145 150 } … … 230 235 { 231 236 /* Stuff as much data into the TX buffer as we can. */ 232 size_t cbToFetch = RT_ ELEMENTS(pThis->abTxBuf) - pThis->cbTxUsed;237 size_t cbToFetch = RT_MIN(RT_ELEMENTS(pThis->abTxBuf) - pThis->cbTxUsed, pThis->cbAvailWr); 233 238 size_t cbFetched = 0; 234 239 rc = pThis->pDrvSerialPort->pfnReadWr(pThis->pDrvSerialPort, &pThis->abTxBuf[pThis->cbTxUsed], cbToFetch, … … 239 244 { 240 245 ASMAtomicSubZ(&pThis->cbAvailWr, cbFetched); 241 pThis->cbTxUsed += cbFetched;246 pThis->cbTxUsed += cbFetched; 242 247 } 243 248 else … … 281 286 break; 282 287 } 283 pThis->pbBuf = &pThis->abBuffer[0]; 284 ASMAtomicWriteZ(&pThis->cbRemaining, cbRead); 285 /* Notify the upper device/driver. */ 286 rc = pThis->pDrvSerialPort->pfnDataAvailRdrNotify(pThis->pDrvSerialPort, cbRead); 288 289 if (cbRead) 290 { 291 pThis->pbBuf = &pThis->abBuffer[0]; 292 ASMAtomicWriteZ(&pThis->cbRemaining, cbRead); 293 /* Notify the upper device/driver. */ 294 rc = pThis->pDrvSerialPort->pfnDataAvailRdrNotify(pThis->pDrvSerialPort, cbRead); 295 } 287 296 } 288 297 } -
trunk/src/VBox/Devices/Serial/DrvHostSerialNew.cpp
r73243 r73331 394 394 { 395 395 /* Stuff as much data into the TX buffer as we can. */ 396 size_t cbToFetch = RT_ ELEMENTS(pThis->abTxBuf) - pThis->cbTxUsed;396 size_t cbToFetch = RT_MIN(RT_ELEMENTS(pThis->abTxBuf) - pThis->cbTxUsed, pThis->cbAvailWr); 397 397 size_t cbFetched = 0; 398 398 rc = pThis->pDrvSerialPort->pfnReadWr(pThis->pDrvSerialPort, &pThis->abTxBuf[pThis->cbTxUsed], cbToFetch, … … 403 403 { 404 404 ASMAtomicSubZ(&pThis->cbAvailWr, cbFetched); 405 pThis->cbTxUsed += cbFetched;405 pThis->cbTxUsed += cbFetched; 406 406 } 407 407 else -
trunk/src/VBox/Devices/Serial/UartCore.cpp
r73306 r73331 614 614 while (cbFilled < cbFill) 615 615 { 616 size_t cbThisRead = RT_MIN(cbFill - cbFilled, (uint8_t)(pFifo->cbMax - pFifo->offWrite)); 616 size_t cbThisRead = cbFill - cbFilled; 617 618 if (pFifo->offRead <= pFifo->offWrite) 619 cbThisRead = RT_MIN(cbThisRead, (uint8_t)(pFifo->cbMax - pFifo->offWrite)); 620 else 621 cbThisRead = RT_MIN(cbThisRead, (uint8_t)(pFifo->offRead - pFifo->offWrite)); 622 617 623 size_t cbRead = 0; 618 624 int rc = pThis->pDrvSerial->pfnReadRdr(pThis->pDrvSerial, &pFifo->abBuf[pFifo->offWrite], cbThisRead, &cbRead); … … 670 676 else 671 677 uartR3ByteFetch(pThis); 678 } 679 680 681 /** 682 * Reset the transmit/receive related bits to the standard values 683 * (after a detach/attach/reset event). 684 * 685 * @returns nothing. 686 * @param pThis The serial port instance. 687 */ 688 static void uartR3XferReset(PUARTCORE pThis) 689 { 690 pThis->uRegLsr = UART_REG_LSR_THRE | UART_REG_LSR_TEMT; 691 692 uartFifoClear(&pThis->FifoXmit); 693 uartFifoClear(&pThis->FifoRecv); 694 uartR3ParamsUpdate(pThis); 695 uartIrqUpdate(pThis); 696 697 if (pThis->pDrvSerial) 698 { 699 /* Set the modem lines to reflect the current state. */ 700 int rc = pThis->pDrvSerial->pfnChgModemLines(pThis->pDrvSerial, false /*fRts*/, false /*fDtr*/); 701 if (RT_FAILURE(rc)) 702 LogRel(("Serial#%d: Failed to set modem lines with %Rrc during reset\n", 703 pThis->pDevInsR3->iInstance, rc)); 704 705 uint32_t fStsLines = 0; 706 rc = pThis->pDrvSerial->pfnQueryStsLines(pThis->pDrvSerial, &fStsLines); 707 if (RT_SUCCESS(rc)) 708 uartR3StsLinesUpdate(pThis, fStsLines); 709 else 710 LogRel(("Serial#%d: Failed to query status line status with %Rrc during reset\n", 711 pThis->pDevInsR3->iInstance, rc)); 712 } 713 672 714 } 673 715 #endif … … 1600 1642 pThis->FifoXmit.cbMax = 16; 1601 1643 pThis->FifoRecv.cbMax = 16; 1602 uartFifoClear(&pThis->FifoXmit);1603 uartFifoClear(&pThis->FifoRecv);1604 1644 pThis->FifoRecv.cbItl = 1; 1605 1645 1606 uartR3ParamsUpdate(pThis); 1607 uartIrqUpdate(pThis); 1608 1609 if (pThis->pDrvSerial) 1610 { 1611 /* Set the modem lines to reflect the current state. */ 1612 int rc = pThis->pDrvSerial->pfnChgModemLines(pThis->pDrvSerial, false /*fRts*/, false /*fDtr*/); 1613 if (RT_FAILURE(rc)) 1614 LogRel(("Serial#%d: Failed to set modem lines with %Rrc during reset\n", 1615 pThis->pDevInsR3->iInstance, rc)); 1616 1617 uint32_t fStsLines = 0; 1618 rc = pThis->pDrvSerial->pfnQueryStsLines(pThis->pDrvSerial, &fStsLines); 1619 if (RT_SUCCESS(rc)) 1620 uartR3StsLinesUpdate(pThis, fStsLines); 1621 else 1622 LogRel(("Serial#%d: Failed to query status line status with %Rrc during reset\n", 1623 pThis->pDevInsR3->iInstance, rc)); 1624 } 1646 uartR3XferReset(pThis); 1625 1647 } 1626 1648 … … 1637 1659 return VERR_PDM_MISSING_INTERFACE; 1638 1660 } 1661 uartR3XferReset(pThis); 1639 1662 } 1640 1663 else if (rc == VERR_PDM_NO_ATTACHED_DRIVER) … … 1643 1666 pThis->pDrvSerial = NULL; 1644 1667 rc = VINF_SUCCESS; 1668 uartR3XferReset(pThis); 1645 1669 LogRel(("Serial#%d: no unit\n", pThis->pDevInsR3->iInstance)); 1646 1670 } … … 1657 1681 pThis->pDrvBase = NULL; 1658 1682 pThis->pDrvSerial = NULL; 1683 uartR3XferReset(pThis); 1659 1684 } 1660 1685
Note:
See TracChangeset
for help on using the changeset viewer.