diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-03-12 07:47:33 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-03-12 07:47:33 +0000 |
commit | c094abe5852057ef47941d8de3af20b2286cd822 (patch) | |
tree | 523f3c7a15cf60c0d02734861ae3447b2b2b854c /EdkModulePkg/Bus/Usb | |
parent | 90a98f29c5db0a9e008c6779866ba6f1ada45cae (diff) | |
download | edk2-platforms-c094abe5852057ef47941d8de3af20b2286cd822.tar.xz |
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
Diffstat (limited to 'EdkModulePkg/Bus/Usb')
-rw-r--r-- | EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.c b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.c index 951ab0a186..9caa006715 100644 --- a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.c +++ b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.c @@ -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;
}
|