Skip to content

Commit

Permalink
MdeModulePkg: Refactored out CoreAcquireLockOrFail(), CoreAcquireLock()
Browse files Browse the repository at this point in the history
and CoreReleaseLock().
  • Loading branch information
Mikhail Krichanov committed Feb 29, 2024
1 parent 641d4f1 commit c350d80
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 142 deletions.
4 changes: 2 additions & 2 deletions MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ CoreAcquireDispatcherLock (
VOID
)
{
CoreAcquireLock (&mDispatcherLock);
EfiAcquireLock (&mDispatcherLock);
}

/**
Expand All @@ -216,7 +216,7 @@ CoreReleaseDispatcherLock (
VOID
)
{
CoreReleaseLock (&mDispatcherLock);
EfiReleaseLock (&mDispatcherLock);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Core/Dxe/Event/Event.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ CoreAcquireEventLock (
VOID
)
{
CoreAcquireLock (&gEventQueueLock);
EfiAcquireLock (&gEventQueueLock);
}

/**
Expand All @@ -107,7 +107,7 @@ CoreReleaseEventLock (
VOID
)
{
CoreReleaseLock (&gEventQueueLock);
EfiReleaseLock (&gEventQueueLock);
}

/**
Expand Down
16 changes: 8 additions & 8 deletions MdeModulePkg/Core/Dxe/Event/Timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ CoreCurrentSystemTime (
{
UINT64 SystemTime;

CoreAcquireLock (&mEfiSystemTimeLock);
EfiAcquireLock (&mEfiSystemTimeLock);
SystemTime = mEfiSystemTime;
CoreReleaseLock (&mEfiSystemTimeLock);
EfiReleaseLock (&mEfiSystemTimeLock);

return SystemTime;
}
Expand All @@ -102,7 +102,7 @@ CoreCheckTimers (
//
// Check the timer database for expired timers
//
CoreAcquireLock (&mEfiTimerLock);
EfiAcquireLock (&mEfiTimerLock);
SystemTime = CoreCurrentSystemTime ();

while (!IsListEmpty (&mEfiTimerList)) {
Expand Down Expand Up @@ -151,7 +151,7 @@ CoreCheckTimers (
}
}

CoreReleaseLock (&mEfiTimerLock);
EfiReleaseLock (&mEfiTimerLock);
}

/**
Expand Down Expand Up @@ -194,7 +194,7 @@ CoreTimerTick (
//
// Check runtiem flag in case there are ticks while exiting boot services
//
CoreAcquireLock (&mEfiSystemTimeLock);
EfiAcquireLock (&mEfiSystemTimeLock);

//
// Update the system time
Expand All @@ -213,7 +213,7 @@ CoreTimerTick (
}
}

CoreReleaseLock (&mEfiSystemTimeLock);
EfiReleaseLock (&mEfiSystemTimeLock);
}

/**
Expand Down Expand Up @@ -255,7 +255,7 @@ CoreSetTimer (
return EFI_INVALID_PARAMETER;
}

CoreAcquireLock (&mEfiTimerLock);
EfiAcquireLock (&mEfiTimerLock);

//
// If the timer is queued to the timer database, remove it
Expand Down Expand Up @@ -285,7 +285,7 @@ CoreSetTimer (
}
}

CoreReleaseLock (&mEfiTimerLock);
EfiReleaseLock (&mEfiTimerLock);

return EFI_SUCCESS;
}
8 changes: 4 additions & 4 deletions MdeModulePkg/Core/Dxe/Gcd/Gcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ CoreAcquireGcdMemoryLock (
VOID
)
{
CoreAcquireLock (&mGcdMemorySpaceLock);
EfiAcquireLock (&mGcdMemorySpaceLock);
}

/**
Expand All @@ -278,7 +278,7 @@ CoreReleaseGcdMemoryLock (
VOID
)
{
CoreReleaseLock (&mGcdMemorySpaceLock);
EfiReleaseLock (&mGcdMemorySpaceLock);
}

/**
Expand All @@ -290,7 +290,7 @@ CoreAcquireGcdIoLock (
VOID
)
{
CoreAcquireLock (&mGcdIoSpaceLock);
EfiAcquireLock (&mGcdIoSpaceLock);
}

/**
Expand All @@ -302,7 +302,7 @@ CoreReleaseGcdIoLock (
VOID
)
{
CoreReleaseLock (&mGcdIoSpaceLock);
EfiReleaseLock (&mGcdIoSpaceLock);
}

//
Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Core/Dxe/Hand/Handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CoreAcquireProtocolLock (
VOID
)
{
CoreAcquireLock (&gProtocolDatabaseLock);
EfiAcquireLock (&gProtocolDatabaseLock);
}

/**
Expand All @@ -41,7 +41,7 @@ CoreReleaseProtocolLock (
VOID
)
{
CoreReleaseLock (&gProtocolDatabaseLock);
EfiReleaseLock (&gProtocolDatabaseLock);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion MdeModulePkg/Core/Dxe/Hand/Locate.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ CoreLocateProtocol (
//
// Lock the protocol database
//
Status = CoreAcquireLockOrFail (&gProtocolDatabaseLock);
Status = EfiAcquireLockOrFail (&gProtocolDatabaseLock);
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ CoreAcquireMemoryProfileLock (
VOID
)
{
CoreAcquireLock (&mMemoryProfileLock);
EfiAcquireLock (&mMemoryProfileLock);
}

/**
Expand All @@ -233,7 +233,7 @@ CoreReleaseMemoryProfileLock (
VOID
)
{
CoreReleaseLock (&mMemoryProfileLock);
EfiReleaseLock (&mMemoryProfileLock);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions MdeModulePkg/Core/Dxe/Mem/Page.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ CoreAcquireMemoryLock (
VOID
)
{
CoreAcquireLock (&gMemoryLock);
EfiAcquireLock (&gMemoryLock);
}

/**
Expand All @@ -116,7 +116,7 @@ CoreReleaseMemoryLock (
VOID
)
{
CoreReleaseLock (&gMemoryLock);
EfiReleaseLock (&gMemoryLock);
}

/**
Expand Down Expand Up @@ -2079,7 +2079,7 @@ CoreAllocatePoolPagesI (
VOID *Buffer;
EFI_STATUS Status;

Status = CoreAcquireLockOrFail (&gMemoryLock);
Status = EfiAcquireLockOrFail (&gMemoryLock);
if (EFI_ERROR (Status)) {
return NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ CoreAcquiremMemoryAttributesTableLock (
VOID
)
{
CoreAcquireLock (&mMemoryAttributesTableLock);
EfiAcquireLock (&mMemoryAttributesTableLock);
}

/**
Expand All @@ -389,7 +389,7 @@ CoreReleasemMemoryAttributesTableLock (
VOID
)
{
CoreReleaseLock (&mMemoryAttributesTableLock);
EfiReleaseLock (&mMemoryAttributesTableLock);
}

/**
Expand Down
46 changes: 0 additions & 46 deletions MdeModulePkg/Include/Library/MemoryPoolLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,50 +198,4 @@ IsMemoryTypeToGuard (
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
65 changes: 0 additions & 65 deletions MdeModulePkg/Library/MemoryPoolLib/InternalPool.c

This file was deleted.

3 changes: 3 additions & 0 deletions MdeModulePkg/Library/MemoryPoolLib/InternalPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
Copyright (c) 2024, Mikhail Krichanov. All rights reserved.
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_
Expand Down
1 change: 0 additions & 1 deletion MdeModulePkg/Library/MemoryPoolLib/MemoryPoolLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#

[Sources]
InternalPool.c
InternalPool.h
Pool.c

Expand Down
8 changes: 4 additions & 4 deletions MdeModulePkg/Library/MemoryPoolLib/Pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,13 @@ CoreInternalAllocatePool (
//
// Acquire the memory lock and make the allocation
//
Status = CoreAcquireLockOrFail (&mPoolMemoryLock);
Status = EfiAcquireLockOrFail (&mPoolMemoryLock);
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}

*Buffer = CoreAllocatePoolI (PoolType, Size, NeedGuard);
CoreReleaseLock (&mPoolMemoryLock);
EfiReleaseLock (&mPoolMemoryLock);
return (*Buffer != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
}

Expand Down Expand Up @@ -585,9 +585,9 @@ CoreInternalFreePool (
return EFI_INVALID_PARAMETER;
}

CoreAcquireLock (&mPoolMemoryLock);
EfiAcquireLock (&mPoolMemoryLock);
Status = CoreFreePoolI (Buffer, PoolType);
CoreReleaseLock (&mPoolMemoryLock);
EfiReleaseLock (&mPoolMemoryLock);
return Status;
}

Expand Down

0 comments on commit c350d80

Please sign in to comment.