summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Cook (WINDOWS) <dcook@microsoft.com>2024-11-30 17:47:38 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-12-02 02:23:31 +0000
commit9098efdf0dd82dea36b517e92ce7c5740e00b1eb (patch)
treeabcda68b80e17335d3fe4b2dbfbafcd4ee25d47a
parent5158b598f7a64459ffdc7bcd688d9e573008b8f6 (diff)
downloadedk2-9098efdf0dd82dea36b517e92ce7c5740e00b1eb.tar.gz
EmulatorPkg: BlockIo2 APIs do not signal event
BlockIo2 Read/Write/Flush APIs should signal the token's event when the I/O operation completes, but the Emulator APIs do not. As a result, any code that tries to implement async I/O will hang on emulator. Both Windows and Unix emulator hosts work the same way: - All I/O is completed synchronously. - All I/O implementations contain the comment: `// Caller is responsible for signaling EFI Event` However, the protocol implementations do not signal the event, so the event is never signalled. Fix is to signal the event in the appropriate protocol implementations. - If the host API returns success then the I/O is complete since it's always synchronous. - If there is a Token and Token->Event is not null and the I/O is successful then the event should be signalled. Signed-off-by: Doug Cook <idigdoug@gmail.com>
-rw-r--r--EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c b/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c
index 4e8caf2514..685824b79b 100644
--- a/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c
+++ b/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c
@@ -96,6 +96,11 @@ EmuBlockIo2ReadBlocksEx (
Status = Private->Io->ReadBlocks (Private->Io, MediaId, LBA, Token, BufferSize, Buffer);
gBS->RestoreTPL (OldTpl);
+
+ if (Token && Token->Event && !EFI_ERROR (Status)) {
+ gBS->SignalEvent (Token->Event);
+ }
+
return Status;
}
@@ -152,6 +157,11 @@ EmuBlockIo2WriteBlocksEx (
Status = Private->Io->WriteBlocks (Private->Io, MediaId, LBA, Token, BufferSize, Buffer);
gBS->RestoreTPL (OldTpl);
+
+ if (Token && Token->Event && !EFI_ERROR (Status)) {
+ gBS->SignalEvent (Token->Event);
+ }
+
return Status;
}
@@ -195,6 +205,11 @@ EmuBlockIo2Flush (
Status = Private->Io->FlushBlocks (Private->Io, Token);
gBS->RestoreTPL (OldTpl);
+
+ if (Token && Token->Event && !EFI_ERROR (Status)) {
+ gBS->SignalEvent (Token->Event);
+ }
+
return Status;
}