X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkNt32Pkg%2FDxe%2FWinNtThunk%2FBus%2FBlockIo%2FWinNtBlockIo.c;h=143d6b5a1eeca5a869782b7753222376df293d57;hp=c160aaf8361df799e33cf4387ed893385dc5d223;hb=1a682c8c376a087d3c2aeafd466b9aee301caeaa;hpb=8b018de64f54b67f437c95bf0ed591b03a6cc63b diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo/WinNtBlockIo.c b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo/WinNtBlockIo.c index c160aaf836..143d6b5a1e 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; }