Move lock to FAT driver binding start to prevent interrupt during hot plug event.
(based on FatPkg commit b449ca31443f754ed2e6998ca32f49547dabd615) [jordan.l.justen@intel.com: Use script to relicense to 2-clause BSD] Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Acked-by: Mark Doran <mark.doran@intel.com> Acked-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
parent
6163cc98b6
commit
5251cb9d68
@ -1,6 +1,6 @@
|
|||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials are licensed and made available
|
This program and the accompanying materials are licensed and made available
|
||||||
under the terms and conditions of the BSD License which accompanies this
|
under the terms and conditions of the BSD License which accompanies this
|
||||||
distribution. The full text of the license may be found at
|
distribution. The full text of the license may be found at
|
||||||
@ -269,10 +269,21 @@ Returns:
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_BLOCK_IO_PROTOCOL *BlockIo;
|
EFI_BLOCK_IO_PROTOCOL *BlockIo;
|
||||||
EFI_DISK_IO_PROTOCOL *DiskIo;
|
EFI_DISK_IO_PROTOCOL *DiskIo;
|
||||||
|
BOOLEAN LockedByMe;
|
||||||
|
|
||||||
|
LockedByMe = FALSE;
|
||||||
|
//
|
||||||
|
// Acquire the lock.
|
||||||
|
// If caller has already acquired the lock, cannot lock it again.
|
||||||
|
//
|
||||||
|
Status = FatAcquireLockOrFail ();
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
LockedByMe = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
Status = InitializeUnicodeCollationSupport (This->DriverBindingHandle);
|
Status = InitializeUnicodeCollationSupport (This->DriverBindingHandle);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
goto Exit;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Open our required BlockIo and DiskIo
|
// Open our required BlockIo and DiskIo
|
||||||
@ -286,7 +297,7 @@ Returns:
|
|||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = gBS->OpenProtocol (
|
Status = gBS->OpenProtocol (
|
||||||
@ -298,7 +309,7 @@ Returns:
|
|||||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
goto Exit;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Allocate Volume structure. In FatAllocateVolume(), Resources
|
// Allocate Volume structure. In FatAllocateVolume(), Resources
|
||||||
@ -330,6 +341,13 @@ Returns:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Exit:
|
||||||
|
//
|
||||||
|
// Unlock if locked by myself.
|
||||||
|
//
|
||||||
|
if (LockedByMe) {
|
||||||
|
FatReleaseLock ();
|
||||||
|
}
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,7 @@ Returns:
|
|||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
FAT_VOLUME *Volume;
|
FAT_VOLUME *Volume;
|
||||||
BOOLEAN LockedByMe;
|
|
||||||
LockedByMe = FALSE;
|
|
||||||
//
|
//
|
||||||
// Allocate a volume structure
|
// Allocate a volume structure
|
||||||
//
|
//
|
||||||
@ -60,14 +59,7 @@ Returns:
|
|||||||
if (Volume == NULL) {
|
if (Volume == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// Acquire the lock.
|
|
||||||
// If caller has already acquired the lock, cannot lock it again.
|
|
||||||
//
|
|
||||||
Status = FatAcquireLockOrFail ();
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
LockedByMe = TRUE;
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
// Initialize the structure
|
// Initialize the structure
|
||||||
//
|
//
|
||||||
@ -119,13 +111,6 @@ Returns:
|
|||||||
Volume->Valid = TRUE;
|
Volume->Valid = TRUE;
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
//
|
|
||||||
// Unlock if locked by myself.
|
|
||||||
//
|
|
||||||
if (LockedByMe) {
|
|
||||||
FatReleaseLock ();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
FatFreeVolume (Volume);
|
FatFreeVolume (Volume);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user