Add a lock to protect the critical region in Service APIs for gEfiBlockIoProtocolGuid Protocol to prevent re-entrance of the same API from from different TPL level.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2443 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
Copyright (c) 2006 - 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -350,6 +350,9 @@ USBFloppyReset (
|
||||
USB_FLOPPY_DEV *UsbFloppyDevice;
|
||||
EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;
|
||||
EFI_STATUS Status;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||
|
||||
UsbFloppyDevice = USB_FLOPPY_DEV_FROM_THIS (This);
|
||||
|
||||
@@ -360,6 +363,8 @@ USBFloppyReset (
|
||||
//
|
||||
Status = UsbAtapiInterface->UsbAtapiReset (UsbAtapiInterface, ExtendedVerification);
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -404,6 +409,7 @@ USBFloppyReadBlocks (
|
||||
UINTN BlockSize;
|
||||
UINTN NumberOfBlocks;
|
||||
BOOLEAN MediaChange;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
MediaChange = FALSE;
|
||||
@@ -412,16 +418,16 @@ USBFloppyReadBlocks (
|
||||
//
|
||||
// Check parameters
|
||||
//
|
||||
if (!Buffer) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
if (Buffer == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (BufferSize == 0) {
|
||||
Status = EFI_SUCCESS;
|
||||
goto Done;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||
|
||||
UsbFloppyTestUnitReady (UsbFloppyDevice);
|
||||
|
||||
Status = UsbFloppyDetectMedia (UsbFloppyDevice, &MediaChange);
|
||||
@@ -485,6 +491,7 @@ USBFloppyReadBlocks (
|
||||
if (EFI_ERROR (Status)) {
|
||||
This->Reset (This, TRUE);
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (NumberOfBlocks > BLOCK_UNIT) {
|
||||
@@ -499,6 +506,7 @@ USBFloppyReadBlocks (
|
||||
}
|
||||
|
||||
Done:
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -546,6 +554,7 @@ USBFloppyWriteBlocks (
|
||||
UINTN BlockSize;
|
||||
UINTN NumberOfBlocks;
|
||||
BOOLEAN MediaChange;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
MediaChange = FALSE;
|
||||
@@ -555,16 +564,16 @@ USBFloppyWriteBlocks (
|
||||
//
|
||||
// Check parameters
|
||||
//
|
||||
if (!Buffer) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
if (Buffer == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (BufferSize == 0) {
|
||||
Status = EFI_SUCCESS;
|
||||
goto Done;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||
|
||||
UsbFloppyTestUnitReady (UsbFloppyDevice);
|
||||
|
||||
Status = UsbFloppyDetectMedia (UsbFloppyDevice, &MediaChange);
|
||||
@@ -633,6 +642,7 @@ USBFloppyWriteBlocks (
|
||||
if (EFI_ERROR (Status)) {
|
||||
This->Reset (This, TRUE);
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (NumberOfBlocks > BLOCK_UNIT) {
|
||||
@@ -647,7 +657,7 @@ USBFloppyWriteBlocks (
|
||||
}
|
||||
|
||||
Done:
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user