Skip to content

Commit 471c15b

Browse files
kraxelmergify[bot]
authored andcommitted
OvmfPkg/VirtioSerialDxe: set EFI_SERIAL_INPUT_BUFFER_EMPTY
Check if there is data available for read, set the EFI_SERIAL_INPUT_BUFFER_EMPTY flag accordingly. With proper status returned VirtioSerialIoRead() will only be called if there is actual data to read, so we must call VirtioSerialIoWriteFlush() to make sure pending writes get flushed to the host properly. Signed-off-by: Gerd Hoffmann <[email protected]>
1 parent 8b11d8b commit 471c15b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

OvmfPkg/VirtioSerialDxe/VirtioSerialPort.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,29 @@ VirtioSerialIoGetControl (
157157
OUT UINT32 *Control
158158
)
159159
{
160+
VIRTIO_SERIAL_IO_PROTOCOL *SerialIo = (VIRTIO_SERIAL_IO_PROTOCOL *)This;
161+
BOOLEAN HaveData = FALSE;
162+
163+
VirtioSerialIoWriteFlush (This);
164+
160165
*Control = 0;
166+
167+
if (SerialIo->ReadOffset < SerialIo->ReadSize) {
168+
// have unread data in current buffer
169+
HaveData = TRUE;
170+
} else if (VirtioSerialRingHasBuffer (
171+
SerialIo->Dev,
172+
PortRx (SerialIo->PortId)
173+
))
174+
{
175+
// have unread buffers in rx ring
176+
HaveData = TRUE;
177+
}
178+
179+
if (!HaveData) {
180+
*Control |= EFI_SERIAL_INPUT_BUFFER_EMPTY;
181+
}
182+
161183
return EFI_SUCCESS;
162184
}
163185

0 commit comments

Comments
 (0)