summaryrefslogtreecommitdiff
path: root/EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2007-03-12 09:58:28 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2007-03-12 09:58:28 +0000
commit1a682c8c376a087d3c2aeafd466b9aee301caeaa (patch)
tree3d515e83ba41a2d19c0cd49bac61b54153d6e2dd /EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo
parentac10bddd8ecdb4a4505271aca05c8b991f99282f (diff)
downloadedk2-1a682c8c376a087d3c2aeafd466b9aee301caeaa.zip
edk2-1a682c8c376a087d3c2aeafd466b9aee301caeaa.tar.gz
edk2-1a682c8c376a087d3c2aeafd466b9aee301caeaa.tar.bz2
Add a lock to protect the critical region in Service APIs for gEfiBlockIoProtocolGuid and gEfiSimpleFileSystemProtocolGuid Protocol to prevent re-entrance of the same API from from different TPL level. In UEFI 2.1 spec, it is state that the service API for this Protocol is callable at EFI_TPL_CALLBACK level.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2450 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo')
-rw-r--r--EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo/WinNtBlockIo.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo/WinNtBlockIo.c b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo/WinNtBlockIo.c
index c160aaf..143d6b5 100644
--- a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo/WinNtBlockIo.c
+++ b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo/WinNtBlockIo.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
@@ -851,25 +851,33 @@ WinNtBlockIoReadBlocks (
BOOL Flag;
EFI_STATUS Status;
DWORD BytesRead;
+ EFI_TPL OldTpl;
+
+ OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
Status = WinNtBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "WinNtReadBlocks");
if (EFI_ERROR (Status)) {
- return Status;
+ goto Done;
}
Flag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);
if (!Flag || (BytesRead != BufferSize)) {
DEBUG ((EFI_D_INIT, "ReadBlocks: ReadFile failed. (%d)\n", Private->WinNtThunk->GetLastError ()));
- return WinNtBlockIoError (Private);
+ Status = WinNtBlockIoError (Private);
+ goto Done;
}
//
// If we wrote then media is present.
//
This->Media->MediaPresent = TRUE;
- return EFI_SUCCESS;
+ Status = EFI_SUCCESS;
+
+Done:
+ gBS->RestoreTPL (OldTpl);
+ return Status;
}
STATIC
@@ -911,18 +919,22 @@ WinNtBlockIoWriteBlocks (
UINTN BytesWritten;
BOOL Flag;
EFI_STATUS Status;
+ EFI_TPL OldTpl;
+
+ OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
Status = WinNtBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "WinNtWriteBlocks");
if (EFI_ERROR (Status)) {
- return Status;
+ goto Done;
}
Flag = Private->WinNtThunk->WriteFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesWritten, NULL);
if (!Flag || (BytesWritten != BufferSize)) {
DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed. (%d)\n", Private->WinNtThunk->GetLastError ()));
- return WinNtBlockIoError (Private);
+ Status = WinNtBlockIoError (Private);
+ goto Done;
}
//
@@ -930,7 +942,12 @@ WinNtBlockIoWriteBlocks (
//
This->Media->MediaPresent = TRUE;
This->Media->ReadOnly = FALSE;
- return EFI_SUCCESS;
+ Status = EFI_SUCCESS;
+
+Done:
+ OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
+ return Status;
+
}
STATIC
@@ -981,6 +998,9 @@ WinNtBlockIoResetBlock (
--*/
{
WIN_NT_BLOCK_IO_PRIVATE *Private;
+ EFI_TPL OldTpl;
+
+ OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
@@ -989,6 +1009,8 @@ WinNtBlockIoResetBlock (
Private->NtHandle = INVALID_HANDLE_VALUE;
}
+ gBS->RestoreTPL (OldTpl);
+
return EFI_SUCCESS;
}