mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-22 13:14:26 +02:00
MdeModulePkg: Refactored out CoreAcquireLockOrFail(), CoreAcquireLock()
and CoreReleaseLock().
This commit is contained in:
parent
07188c19a8
commit
173d9edad4
@ -204,7 +204,7 @@ CoreAcquireDispatcherLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreAcquireLock (&mDispatcherLock);
|
EfiAcquireLock (&mDispatcherLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -216,7 +216,7 @@ CoreReleaseDispatcherLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreReleaseLock (&mDispatcherLock);
|
EfiReleaseLock (&mDispatcherLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,7 +95,7 @@ CoreAcquireEventLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreAcquireLock (&gEventQueueLock);
|
EfiAcquireLock (&gEventQueueLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,7 +107,7 @@ CoreReleaseEventLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreReleaseLock (&gEventQueueLock);
|
EfiReleaseLock (&gEventQueueLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,9 +74,9 @@ CoreCurrentSystemTime (
|
|||||||
{
|
{
|
||||||
UINT64 SystemTime;
|
UINT64 SystemTime;
|
||||||
|
|
||||||
CoreAcquireLock (&mEfiSystemTimeLock);
|
EfiAcquireLock (&mEfiSystemTimeLock);
|
||||||
SystemTime = mEfiSystemTime;
|
SystemTime = mEfiSystemTime;
|
||||||
CoreReleaseLock (&mEfiSystemTimeLock);
|
EfiReleaseLock (&mEfiSystemTimeLock);
|
||||||
|
|
||||||
return SystemTime;
|
return SystemTime;
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ CoreCheckTimers (
|
|||||||
//
|
//
|
||||||
// Check the timer database for expired timers
|
// Check the timer database for expired timers
|
||||||
//
|
//
|
||||||
CoreAcquireLock (&mEfiTimerLock);
|
EfiAcquireLock (&mEfiTimerLock);
|
||||||
SystemTime = CoreCurrentSystemTime ();
|
SystemTime = CoreCurrentSystemTime ();
|
||||||
|
|
||||||
while (!IsListEmpty (&mEfiTimerList)) {
|
while (!IsListEmpty (&mEfiTimerList)) {
|
||||||
@ -151,7 +151,7 @@ CoreCheckTimers (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreReleaseLock (&mEfiTimerLock);
|
EfiReleaseLock (&mEfiTimerLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -194,7 +194,7 @@ CoreTimerTick (
|
|||||||
//
|
//
|
||||||
// Check runtiem flag in case there are ticks while exiting boot services
|
// Check runtiem flag in case there are ticks while exiting boot services
|
||||||
//
|
//
|
||||||
CoreAcquireLock (&mEfiSystemTimeLock);
|
EfiAcquireLock (&mEfiSystemTimeLock);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Update the system time
|
// Update the system time
|
||||||
@ -213,7 +213,7 @@ CoreTimerTick (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreReleaseLock (&mEfiSystemTimeLock);
|
EfiReleaseLock (&mEfiSystemTimeLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -255,7 +255,7 @@ CoreSetTimer (
|
|||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreAcquireLock (&mEfiTimerLock);
|
EfiAcquireLock (&mEfiTimerLock);
|
||||||
|
|
||||||
//
|
//
|
||||||
// If the timer is queued to the timer database, remove it
|
// If the timer is queued to the timer database, remove it
|
||||||
@ -285,7 +285,7 @@ CoreSetTimer (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreReleaseLock (&mEfiTimerLock);
|
EfiReleaseLock (&mEfiTimerLock);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ CoreAcquireGcdMemoryLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreAcquireLock (&mGcdMemorySpaceLock);
|
EfiAcquireLock (&mGcdMemorySpaceLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -278,7 +278,7 @@ CoreReleaseGcdMemoryLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreReleaseLock (&mGcdMemorySpaceLock);
|
EfiReleaseLock (&mGcdMemorySpaceLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -290,7 +290,7 @@ CoreAcquireGcdIoLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreAcquireLock (&mGcdIoSpaceLock);
|
EfiAcquireLock (&mGcdIoSpaceLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -302,7 +302,7 @@ CoreReleaseGcdIoLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreReleaseLock (&mGcdIoSpaceLock);
|
EfiReleaseLock (&mGcdIoSpaceLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -29,7 +29,7 @@ CoreAcquireProtocolLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreAcquireLock (&gProtocolDatabaseLock);
|
EfiAcquireLock (&gProtocolDatabaseLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +41,7 @@ CoreReleaseProtocolLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreReleaseLock (&gProtocolDatabaseLock);
|
EfiReleaseLock (&gProtocolDatabaseLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -600,7 +600,7 @@ CoreLocateProtocol (
|
|||||||
//
|
//
|
||||||
// Lock the protocol database
|
// Lock the protocol database
|
||||||
//
|
//
|
||||||
Status = CoreAcquireLockOrFail (&gProtocolDatabaseLock);
|
Status = EfiAcquireLockOrFail (&gProtocolDatabaseLock);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ CoreAcquireMemoryProfileLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreAcquireLock (&mMemoryProfileLock);
|
EfiAcquireLock (&mMemoryProfileLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -233,7 +233,7 @@ CoreReleaseMemoryProfileLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreReleaseLock (&mMemoryProfileLock);
|
EfiReleaseLock (&mMemoryProfileLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +104,7 @@ CoreAcquireMemoryLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreAcquireLock (&gMemoryLock);
|
EfiAcquireLock (&gMemoryLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,7 +116,7 @@ CoreReleaseMemoryLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreReleaseLock (&gMemoryLock);
|
EfiReleaseLock (&gMemoryLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2197,7 +2197,7 @@ CoreAllocatePoolPagesI (
|
|||||||
VOID *Buffer;
|
VOID *Buffer;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
Status = CoreAcquireLockOrFail (&gMemoryLock);
|
Status = EfiAcquireLockOrFail (&gMemoryLock);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ CoreAcquiremMemoryAttributesTableLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreAcquireLock (&mMemoryAttributesTableLock);
|
EfiAcquireLock (&mMemoryAttributesTableLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -351,7 +351,7 @@ CoreReleasemMemoryAttributesTableLock (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CoreReleaseLock (&mMemoryAttributesTableLock);
|
EfiReleaseLock (&mMemoryAttributesTableLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -198,50 +198,4 @@ IsMemoryTypeToGuard (
|
|||||||
IN UINT8 PageOrPool
|
IN UINT8 PageOrPool
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
Raising to the task priority level of the mutual exclusion
|
|
||||||
lock, and then acquires ownership of the lock.
|
|
||||||
|
|
||||||
@param Lock The lock to acquire
|
|
||||||
|
|
||||||
@return Lock owned
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
CoreAcquireLock (
|
|
||||||
IN EFI_LOCK *Lock
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize a basic mutual exclusion lock. Each lock
|
|
||||||
provides mutual exclusion access at it's task priority
|
|
||||||
level. Since there is no-premption (at any TPL) or
|
|
||||||
multiprocessor support, acquiring the lock only consists
|
|
||||||
of raising to the locks TPL.
|
|
||||||
|
|
||||||
@param Lock The EFI_LOCK structure to initialize
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Lock Owned.
|
|
||||||
@retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
CoreAcquireLockOrFail (
|
|
||||||
IN EFI_LOCK *Lock
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Releases ownership of the mutual exclusion lock, and
|
|
||||||
restores the previous task priority level.
|
|
||||||
|
|
||||||
@param Lock The lock to release
|
|
||||||
|
|
||||||
@return Lock unowned
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
CoreReleaseLock (
|
|
||||||
IN EFI_LOCK *Lock
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
/** @file
|
|
||||||
DXE Core functions necessary for pool management functions.
|
|
||||||
|
|
||||||
Copyright (c) 2024, Mikhail Krichanov. All rights reserved.
|
|
||||||
SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
|
||||||
#include <Library/UefiLib.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize a basic mutual exclusion lock. Each lock
|
|
||||||
provides mutual exclusion access at it's task priority
|
|
||||||
level. Since there is no-premption (at any TPL) or
|
|
||||||
multiprocessor support, acquiring the lock only consists
|
|
||||||
of raising to the locks TPL.
|
|
||||||
|
|
||||||
@param Lock The EFI_LOCK structure to initialize
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Lock Owned.
|
|
||||||
@retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
CoreAcquireLockOrFail (
|
|
||||||
IN EFI_LOCK *Lock
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return EfiAcquireLockOrFail (Lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Raising to the task priority level of the mutual exclusion
|
|
||||||
lock, and then acquires ownership of the lock.
|
|
||||||
|
|
||||||
@param Lock The lock to acquire
|
|
||||||
|
|
||||||
@return Lock owned
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
CoreAcquireLock (
|
|
||||||
IN EFI_LOCK *Lock
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EfiAcquireLock (Lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Releases ownership of the mutual exclusion lock, and
|
|
||||||
restores the previous task priority level.
|
|
||||||
|
|
||||||
@param Lock The lock to release
|
|
||||||
|
|
||||||
@return Lock unowned
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
CoreReleaseLock (
|
|
||||||
IN EFI_LOCK *Lock
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EfiReleaseLock (Lock);
|
|
||||||
}
|
|
@ -4,6 +4,9 @@
|
|||||||
Copyright (c) 2024, Mikhail Krichanov. All rights reserved.
|
Copyright (c) 2024, Mikhail Krichanov. All rights reserved.
|
||||||
SPDX-License-Identifier: BSD-3-Clause
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef _INTERNAL_POOL_H_
|
#ifndef _INTERNAL_POOL_H_
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
[Sources]
|
[Sources]
|
||||||
InternalPool.c
|
|
||||||
InternalPool.h
|
InternalPool.h
|
||||||
Pool.c
|
Pool.c
|
||||||
|
|
||||||
|
@ -310,13 +310,13 @@ CoreInternalAllocatePool (
|
|||||||
//
|
//
|
||||||
// Acquire the memory lock and make the allocation
|
// Acquire the memory lock and make the allocation
|
||||||
//
|
//
|
||||||
Status = CoreAcquireLockOrFail (&mPoolMemoryLock);
|
Status = EfiAcquireLockOrFail (&mPoolMemoryLock);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
*Buffer = CoreAllocatePoolI (PoolType, Size, NeedGuard);
|
*Buffer = CoreAllocatePoolI (PoolType, Size, NeedGuard);
|
||||||
CoreReleaseLock (&mPoolMemoryLock);
|
EfiReleaseLock (&mPoolMemoryLock);
|
||||||
return (*Buffer != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
|
return (*Buffer != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,9 +596,9 @@ CoreInternalFreePool (
|
|||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreAcquireLock (&mPoolMemoryLock);
|
EfiAcquireLock (&mPoolMemoryLock);
|
||||||
Status = CoreFreePoolI (Buffer, PoolType);
|
Status = CoreFreePoolI (Buffer, PoolType);
|
||||||
CoreReleaseLock (&mPoolMemoryLock);
|
EfiReleaseLock (&mPoolMemoryLock);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user