audk/EmulatorPkg
Ruiyu Ni 1e57188216 EmulatorPkg: IoThunk->Close() is called too early, may causing hang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1121

To produce a EFI_BLOCK_IO_PROTOCOL instance in Emulator platform,
EmulatorPkg defines the EMU_IO_THUNK_PROTOCOL. OS dependent layer
needs to produce this protocol implementation and a generic OS
independent layer consumes this protocol to produce
EFI_BLOCK_IO_PROTOCOL.

EMU_IO_THUNK_PROTOCOL can also be used to abstract the OS dependent
IO operation for other UEFI protocols, e.g.: GOP, SimpleFileSystem
and etc.

It contains two interfaces Open() and Close(). Open() creates the
specific IO instances, e.g. for Block IO access, File System access,
Screen access, etc. Close() destroys the specific IO instances.

Later on the Emulator generic module (e.g.: EmuBlockIoDxe) calls
Open() to create the IO instance in DriverBindingStart() and calls
Close() in DriverBindingStop().
But today's implementation of DriverBindingStop() contains a bug
that it calls Close() before uninstalling the EFI_BLOCK_IO_PROTOCOL.

It's a mistake in code. Take EFI_BLOCK_IO for example,
the uninstallation may cause the upper layer driver that consumes
EFI_BLOCK_IO call BlockIo.Reset(), which consequently calls
EmuBlockIo.Reset(). But the EmuBlockIo instance is already destroyed
by Close() that happens before uninstallation.

So a proper implementation is to call Close() after uninstallation
succeeds.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1121

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
2018-08-31 10:40:20 +08:00
..
AutoScanPei EmulatorPkg/AutoScanPei: Report the correct CPU address size 2018-08-31 10:40:15 +08:00
BootModePei
CpuRuntimeDxe EmulatorPkg: formalize line endings 2018-08-30 09:26:54 +08:00
EmuBlockIoDxe EmulatorPkg: IoThunk->Close() is called too early, may causing hang 2018-08-31 10:40:20 +08:00
EmuBusDriverDxe EmulatorPkg: Fix bug with missing &. Causes a link failure on TOT clang. 2011-07-15 19:01:16 +00:00
EmuGopDxe EmulatorPkg/EmuGopDxe: Clear screen to black in GOP.SetMode 2018-08-31 10:40:08 +08:00
EmuSimpleFileSystemDxe EmulatorPkg: IoThunk->Close() is called too early, may causing hang 2018-08-31 10:40:20 +08:00
EmuSnpDxe EmulatorPkg: IoThunk->Close() is called too early, may causing hang 2018-08-31 10:40:20 +08:00
EmuThunkDxe
FirmwareVolumePei EmulatorPkg: Fix typos in comments and variables 2016-10-19 13:32:20 -07:00
FlashMapPei
FvbServicesRuntimeDxe EmulatorPkg/FvbServicesRuntimeDxe: correct NumOfLba vararg type in EraseBlocks() 2017-05-18 23:38:45 +02:00
Include EmulatorPkg: formalize line endings 2018-08-30 09:26:54 +08:00
Library EmulatorPkg: Use MdeModulePkg/Bds module 2018-08-31 10:40:18 +08:00
MiscSubClassPlatformDxe EmulatorPkg: formalize line endings 2018-08-30 09:26:54 +08:00
PlatformSmbiosDxe EmulatorPkg: formalize line endings 2018-08-30 09:26:54 +08:00
RealTimeClockRuntimeDxe
ResetRuntimeDxe
Sec EmulatorPkg: formalize line endings 2018-08-30 09:26:54 +08:00
ThunkPpiToProtocolPei
TimerDxe EmulatorPkg: Fix typos in comments 2016-07-25 16:56:57 -07:00
Unix EmulatorPkg: formalize line endings 2018-08-30 09:26:54 +08:00
Win EmulatorPkg/Win: Add VS2017 project file 2018-08-31 10:40:16 +08:00
EmulatorPkg.dec Add a new SMBIOS Library, and platform SMBIOS driver that does not use Framework or Hii. 2012-01-30 18:57:30 +00:00
EmulatorPkg.dsc EmulatorPkg: Use MdeModulePkg/Bds module 2018-08-31 10:40:18 +08:00
EmulatorPkg.fdf EmulatorPkg: Use MdeModulePkg/Bds module 2018-08-31 10:40:18 +08:00
README EmulatorPkg: Update web page and wiki urls 2015-02-05 18:25:01 +00:00
build.sh EmulatorPkg/build.sh: Merge GCC toolchain detection from OVMF 2017-06-02 17:44:00 -07:00

README

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.


=== EmulatorPkg Overview ===

EmulatorPkg provides an environment where a UEFI environment can be
emulated under an environment where a full UEFI compatible
environment is not possible.  (For example, running under an OS
where an OS process hosts the UEFI emulation environment.)

https://github.com/tianocore/tianocore.github.io/wiki/EmulatorPkg

=== Status ===

* Builds and runs under a posix-like environment with X windows
  - Linux
  - OS X

=== Future Plans ===

* Win32 and Win64 support

=== Build Scripts ===

On systems with the bash shell you can use EmulatorPkg/build.sh to simplify
building and running EmulatorPkg.

For example, to build + run:
$ EmulatorPkg/build.sh
$ EmulatorPkg/build.sh run

The build architecture will match your host machine's architecture.

On X64 host machines, you can build + run IA32 mode as well:
$ EmulatorPkg/build.sh -a IA32
$ EmulatorPkg/build.sh -a IA32 run