diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-03-12 09:48:53 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-03-12 09:48:53 +0000 |
commit | ac10bddd8ecdb4a4505271aca05c8b991f99282f (patch) | |
tree | 29c5a153a85fee14e1ac79d77192751d700a07e8 /EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c | |
parent | ddcbfc1674ffc46282d66bfd6d5dd66febdb56cb (diff) | |
download | edk2-platforms-ac10bddd8ecdb4a4505271aca05c8b991f99282f.tar.xz |
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@2449 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c')
-rw-r--r-- | EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c index 1425531cf8..ffdf6cf89b 100644 --- a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c +++ b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c @@ -1,6 +1,6 @@ /*++
-Copyright (c) 2004 - 2005, Intel Corporation
+Copyright (c) 2004 - 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
@@ -1064,25 +1064,32 @@ UnixBlockIoReadBlocks ( UNIX_BLOCK_IO_PRIVATE *Private;
ssize_t len;
EFI_STATUS Status;
+ EFI_TPL OldTpl;
+
+ OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
Status = UnixBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "UnixReadBlocks");
if (EFI_ERROR (Status)) {
- return Status;
+ goto Done;
}
len = Private->UnixThunk->Read (Private->fd, Buffer, BufferSize);
if (len != BufferSize) {
DEBUG ((EFI_D_INIT, "ReadBlocks: ReadFile failed.\n"));
- return UnixBlockIoError (Private);
+ Status = UnixBlockIoError (Private);
+ goto Done;
}
//
// If we wrote then media is present.
//
This->Media->MediaPresent = TRUE;
- return EFI_SUCCESS;
+ Status = EFI_SUCCESS;
+
+ gBS->RestoreTPL (OldTpl);
+ return Status;
}
STATIC
@@ -1123,18 +1130,22 @@ UnixBlockIoWriteBlocks ( UNIX_BLOCK_IO_PRIVATE *Private;
ssize_t len;
EFI_STATUS Status;
+ EFI_TPL OldTpl;
+
+ OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
Status = UnixBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "UnixWriteBlocks");
if (EFI_ERROR (Status)) {
- return Status;
+ goto Done;
}
len = Private->UnixThunk->Write (Private->fd, Buffer, BufferSize);
if (len != BufferSize) {
DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed.\n"));
- return UnixBlockIoError (Private);
+ Status = UnixBlockIoError (Private);
+ goto Done;
}
//
@@ -1142,7 +1153,11 @@ UnixBlockIoWriteBlocks ( //
This->Media->MediaPresent = TRUE;
This->Media->ReadOnly = FALSE;
- return EFI_SUCCESS;
+ Status = EFI_SUCCESS;
+
+Done:
+ gBS->RestoreTPL (OldTpl);
+ return Status;
}
STATIC
@@ -1193,7 +1208,10 @@ UnixBlockIoResetBlock ( --*/
{
UNIX_BLOCK_IO_PRIVATE *Private;
+ EFI_TPL OldTpl;
+ OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
+
Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
if (Private->fd >= 0) {
@@ -1201,6 +1219,8 @@ UnixBlockIoResetBlock ( Private->fd = -1;
}
+ gBS->RestoreTPL (OldTpl);
+
return EFI_SUCCESS;
}
|