Update ohci_core.cc (#232)

On a buffer underrun (Short Packet), we still need to update the CBP

---------

Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
This commit is contained in:
Benjamin David Lunt 2024-01-20 22:56:35 -07:00 committed by GitHub
parent 7851bf8ce1
commit 9820cf934e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1027,7 +1027,7 @@ bool bx_ohci_core_c::process_ed(struct OHCI_ED *ed, const Bit32u ed_address)
} else {
BX_DEBUG(("Found a valid ED that points to an control/bulk/int TD"));
ret = 1;
while (ED_GET_HEADP(ed) != ED_GET_TAILP(ed)) {
while (!ED_GET_H(ed) && (ED_GET_HEADP(ed) != ED_GET_TAILP(ed))) {
toggle = ED_GET_C(ed);
DEV_MEM_READ_PHYSICAL(ED_GET_HEADP(ed), 4, (Bit8u*) &cur_td.dword0);
DEV_MEM_READ_PHYSICAL(ED_GET_HEADP(ed) + 4, 4, (Bit8u*) &cur_td.dword1);
@ -1257,9 +1257,17 @@ int bx_ohci_core_c::process_td(struct OHCI_TD *td, struct OHCI_ED *ed, int toggl
TD_SET_EC(td, 0);
}
} else {
if (ret >= 0)
if (ret >= 0) {
TD_SET_CC(td, DataUnderrun);
else {
if (((TD_GET_CBP(td) & 0xfff) + ret) >= 0x1000) {
TD_SET_CBP(td, (TD_GET_CBP(td) + ret) & 0x0FFF);
TD_SET_CBP(td, TD_GET_CBP(td) | (TD_GET_BE(td) & ~0x0FFF));
} else {
TD_SET_CBP(td, TD_GET_CBP(td) + ret);
}
if (!TD_GET_R(td))
ED_SET_H(ed, 1);
} else {
switch (ret) {
case USB_RET_NODEV: // (-1)
TD_SET_CC(td, DeviceNotResponding);