summaryrefslogtreecommitdiffstats
path: root/IntelFrameworkModulePkg/Library/GenericBdsLib
diff options
context:
space:
mode:
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-25 03:55:39 +0000
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-25 03:55:39 +0000
commitef949581ea3c622f42ad83337fd2625faa77c17f (patch)
tree620f69b67f4ff941871bd1abdb00edebe00ca7c0 /IntelFrameworkModulePkg/Library/GenericBdsLib
parent670a64e7b79568db83b4dfca06eda9ac52e15423 (diff)
downloadedk2-ef949581ea3c622f42ad83337fd2625faa77c17f.tar.gz
edk2-ef949581ea3c622f42ad83337fd2625faa77c17f.tar.bz2
edk2-ef949581ea3c622f42ad83337fd2625faa77c17f.zip
Raise TPL to prevent the BlockIo instance for USB device is removed during the locating the instance and using it.
Signed-off-by: niruiyu Reviewed-by: erictian git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12203 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFrameworkModulePkg/Library/GenericBdsLib')
-rw-r--r--IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
index 1ac2946360..a697fcfda3 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
@@ -1904,6 +1904,7 @@ BdsLibGetBootableHandle (
)
{
EFI_STATUS Status;
+ EFI_TPL OldTpl;
EFI_DEVICE_PATH_PROTOCOL *UpdatedDevicePath;
EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;
EFI_HANDLE Handle;
@@ -1924,6 +1925,12 @@ BdsLibGetBootableHandle (
UpdatedDevicePath = DevicePath;
//
+ // Enter to critical section to protect the acquired BlockIo instance
+ // from getting released due to the USB mass storage hotplug event
+ //
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+
+ //
// Check whether the device is connected
//
Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &UpdatedDevicePath, &Handle);
@@ -1950,6 +1957,8 @@ BdsLibGetBootableHandle (
// Get BlockIo protocol and check removable attribute
//
Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);
+ ASSERT_EFI_ERROR (Status);
+
//
// Issue a dummy read to the device to check for media change.
// When the removable media is changed, any Block IO read/write will
@@ -2046,6 +2055,8 @@ BdsLibGetBootableHandle (
FreePool(SimpleFileSystemHandles);
}
+ gBS->RestoreTPL (OldTpl);
+
return ReturnHandle;
}