mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-23 13:44:33 +02:00
MdeModulePkg: Moved IsPoolTypeToGuard(), CoreAcquireLockOrFail(),
CoreReleaseLock() and CoreAcquireLock() to MemoryPoolLib.
This commit is contained in:
parent
8a7bd316ef
commit
698b7e3ada
@ -2388,52 +2388,6 @@ ProduceFVBProtocolOnBuffer (
|
|||||||
OUT EFI_HANDLE *FvProtocol OPTIONAL
|
OUT EFI_HANDLE *FvProtocol OPTIONAL
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Read data from Firmware Block by FVB protocol Read.
|
Read data from Firmware Block by FVB protocol Read.
|
||||||
The data may cross the multi block ranges.
|
The data may cross the multi block ranges.
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
Misc/InstallConfigurationTable.c
|
Misc/InstallConfigurationTable.c
|
||||||
Misc/MemoryAttributesTable.c
|
Misc/MemoryAttributesTable.c
|
||||||
Misc/MemoryProtection.c
|
Misc/MemoryProtection.c
|
||||||
Library/Library.c
|
|
||||||
Hand/DriverSupport.c
|
Hand/DriverSupport.c
|
||||||
Hand/Notify.c
|
Hand/Notify.c
|
||||||
Hand/Locate.c
|
Hand/Locate.c
|
||||||
|
@ -1,94 +0,0 @@
|
|||||||
/** @file
|
|
||||||
DXE Core library services.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "DxeMain.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// Lock Stuff
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
)
|
|
||||||
{
|
|
||||||
ASSERT (Lock != NULL);
|
|
||||||
ASSERT (Lock->Lock != EfiLockUninitialized);
|
|
||||||
|
|
||||||
if (Lock->Lock == EfiLockAcquired) {
|
|
||||||
//
|
|
||||||
// Lock is already owned, so bail out
|
|
||||||
//
|
|
||||||
return EFI_ACCESS_DENIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
Lock->OwnerTpl = CoreRaiseTpl (Lock->Tpl);
|
|
||||||
|
|
||||||
Lock->Lock = EfiLockAcquired;
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
)
|
|
||||||
{
|
|
||||||
ASSERT (Lock != NULL);
|
|
||||||
ASSERT (Lock->Lock == EfiLockReleased);
|
|
||||||
|
|
||||||
Lock->OwnerTpl = CoreRaiseTpl (Lock->Tpl);
|
|
||||||
Lock->Lock = EfiLockAcquired;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_TPL Tpl;
|
|
||||||
|
|
||||||
ASSERT (Lock != NULL);
|
|
||||||
ASSERT (Lock->Lock == EfiLockAcquired);
|
|
||||||
|
|
||||||
Tpl = Lock->OwnerTpl;
|
|
||||||
|
|
||||||
Lock->Lock = EfiLockReleased;
|
|
||||||
|
|
||||||
CoreRestoreTpl (Tpl);
|
|
||||||
}
|
|
@ -572,27 +572,6 @@ UnsetGuardPage (
|
|||||||
mOnGuarding = FALSE;
|
mOnGuarding = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Check to see if the pool at the given address should be guarded or not.
|
|
||||||
|
|
||||||
@param[in] MemoryType Pool type to check.
|
|
||||||
|
|
||||||
|
|
||||||
@return TRUE The given type of pool should be guarded.
|
|
||||||
@return FALSE The given type of pool should not be guarded.
|
|
||||||
**/
|
|
||||||
BOOLEAN
|
|
||||||
IsPoolTypeToGuard (
|
|
||||||
IN EFI_MEMORY_TYPE MemoryType
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return IsMemoryTypeToGuard (
|
|
||||||
MemoryType,
|
|
||||||
AllocateAnyPages,
|
|
||||||
GUARD_HEAP_TYPE_POOL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if the page at the given address should be guarded or not.
|
Check to see if the page at the given address should be guarded or not.
|
||||||
|
|
||||||
|
@ -281,20 +281,6 @@ AdjustMemoryS (
|
|||||||
IN UINT64 SizeRequested
|
IN UINT64 SizeRequested
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
Check to see if the pool at the given address should be guarded or not.
|
|
||||||
|
|
||||||
@param[in] MemoryType Pool type to check.
|
|
||||||
|
|
||||||
|
|
||||||
@return TRUE The given type of pool should be guarded.
|
|
||||||
@return FALSE The given type of pool should not be guarded.
|
|
||||||
**/
|
|
||||||
BOOLEAN
|
|
||||||
IsPoolTypeToGuard (
|
|
||||||
IN EFI_MEMORY_TYPE MemoryType
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if the page at the given address should be guarded or not.
|
Check to see if the page at the given address should be guarded or not.
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
#ifndef _MEMORY_POOL_LIB_H_
|
#ifndef _MEMORY_POOL_LIB_H_
|
||||||
#define _MEMORY_POOL_LIB_H_
|
#define _MEMORY_POOL_LIB_H_
|
||||||
|
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// +---------------------------------------------------+
|
// +---------------------------------------------------+
|
||||||
// | 0..(EfiMaxMemoryType - 1) - Normal memory type |
|
// | 0..(EfiMaxMemoryType - 1) - Normal memory type |
|
||||||
@ -164,6 +166,20 @@ IsHeapGuardEnabled (
|
|||||||
UINT8 GuardType
|
UINT8 GuardType
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check to see if the pool at the given address should be guarded or not.
|
||||||
|
|
||||||
|
@param[in] MemoryType Pool type to check.
|
||||||
|
|
||||||
|
|
||||||
|
@return TRUE The given type of pool should be guarded.
|
||||||
|
@return FALSE The given type of pool should not be guarded.
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
IsPoolTypeToGuard (
|
||||||
|
IN EFI_MEMORY_TYPE MemoryType
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if the memory at the given address should be guarded or not.
|
Check to see if the memory at the given address should be guarded or not.
|
||||||
|
|
||||||
@ -182,4 +198,50 @@ 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
|
||||||
|
@ -7,3 +7,59 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#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);
|
||||||
|
}
|
||||||
|
@ -11,52 +11,6 @@
|
|||||||
|
|
||||||
extern BOOLEAN mOnGuarding;
|
extern BOOLEAN mOnGuarding;
|
||||||
|
|
||||||
/**
|
|
||||||
Check to see if the pool at the given address should be guarded or not.
|
|
||||||
|
|
||||||
@param[in] MemoryType Pool type to check.
|
|
||||||
|
|
||||||
|
|
||||||
@return TRUE The given type of pool should be guarded.
|
|
||||||
@return FALSE The given type of pool should not be guarded.
|
|
||||||
**/
|
|
||||||
BOOLEAN
|
|
||||||
IsPoolTypeToGuard (
|
|
||||||
IN EFI_MEMORY_TYPE MemoryType
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Update memory profile information.
|
Update memory profile information.
|
||||||
|
|
||||||
@ -118,20 +72,6 @@ AdjustPoolHeadA (
|
|||||||
IN UINTN Size
|
IN UINTN Size
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adjust the start address and number of pages to free according to Guard.
|
Adjust the start address and number of pages to free according to Guard.
|
||||||
|
|
||||||
|
@ -825,6 +825,27 @@ IsHeapGuardEnabled (
|
|||||||
return IsMemoryTypeToGuard (EfiMaxMemoryType, AllocateAnyPages, GuardType);
|
return IsMemoryTypeToGuard (EfiMaxMemoryType, AllocateAnyPages, GuardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check to see if the pool at the given address should be guarded or not.
|
||||||
|
|
||||||
|
@param[in] MemoryType Pool type to check.
|
||||||
|
|
||||||
|
|
||||||
|
@return TRUE The given type of pool should be guarded.
|
||||||
|
@return FALSE The given type of pool should not be guarded.
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
IsPoolTypeToGuard (
|
||||||
|
IN EFI_MEMORY_TYPE MemoryType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return IsMemoryTypeToGuard (
|
||||||
|
MemoryType,
|
||||||
|
AllocateAnyPages,
|
||||||
|
GUARD_HEAP_TYPE_POOL
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if the memory at the given address should be guarded or not.
|
Check to see if the memory at the given address should be guarded or not.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user