Skip to content

Commit 70dac0f

Browse files
committed
OvmfPkg/VirtioSerialDxe: factor out VirtioSerialIoWriteFlush
Next patch needs this function. No functional change. Signed-off-by: Gerd Hoffmann <[email protected]>
1 parent b753157 commit 70dac0f

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

OvmfPkg/VirtioSerialDxe/VirtioSerialPort.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,31 @@ VirtioSerialIoReset (
8888
return EFI_SUCCESS;
8989
}
9090

91+
STATIC
92+
VOID
93+
VirtioSerialIoWriteFlush (
94+
IN EFI_SERIAL_IO_PROTOCOL *This
95+
)
96+
{
97+
VIRTIO_SERIAL_IO_PROTOCOL *SerialIo = (VIRTIO_SERIAL_IO_PROTOCOL *)This;
98+
EFI_TPL OldTpl;
99+
100+
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
101+
if (SerialIo->WriteOffset) {
102+
DEBUG ((DEBUG_VERBOSE, "%a:%d: WriteFlush %d\n", __func__, __LINE__, SerialIo->WriteOffset));
103+
VirtioSerialRingSendBuffer (
104+
SerialIo->Dev,
105+
PortTx (SerialIo->PortId),
106+
SerialIo->WriteBuffer,
107+
SerialIo->WriteOffset,
108+
TRUE
109+
);
110+
SerialIo->WriteOffset = 0;
111+
}
112+
113+
gBS->RestoreTPL (OldTpl);
114+
}
115+
91116
STATIC
92117
EFI_STATUS
93118
EFIAPI
@@ -194,26 +219,12 @@ VirtioSerialIoRead (
194219
VIRTIO_SERIAL_PORT *Port = SerialIo->Dev->Ports + SerialIo->PortId;
195220
BOOLEAN HasData;
196221
UINT32 Length;
197-
EFI_TPL OldTpl;
198222

199223
if (!Port->DeviceOpen) {
200224
goto NoData;
201225
}
202226

203-
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
204-
if (SerialIo->WriteOffset) {
205-
DEBUG ((DEBUG_VERBOSE, "%a:%d: WriteFlush %d\n", __func__, __LINE__, SerialIo->WriteOffset));
206-
VirtioSerialRingSendBuffer (
207-
SerialIo->Dev,
208-
PortTx (SerialIo->PortId),
209-
SerialIo->WriteBuffer,
210-
SerialIo->WriteOffset,
211-
TRUE
212-
);
213-
SerialIo->WriteOffset = 0;
214-
}
215-
216-
gBS->RestoreTPL (OldTpl);
227+
VirtioSerialIoWriteFlush (This);
217228

218229
if (SerialIo->ReadOffset == SerialIo->ReadSize) {
219230
HasData = VirtioSerialRingGetBuffer (

0 commit comments

Comments
 (0)