-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create the MMU access lib to abstract memory protection settings
There are a number of Arm-specific accesses that are abstracted behind this. It may need to be refactored to work better across architectures.
- Loading branch information
1 parent
dac80fe
commit ec4bdf7
Showing
5 changed files
with
194 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** @file | ||
This lib abstracts some of the MMU accesses currently hardcoded against | ||
an Arm lib. It's likely that this will need to be refactored at some point. | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef _MMU_LIB_H_ | ||
#define _MMU_LIB_H_ | ||
|
||
#include <Uefi.h> | ||
|
||
/** | ||
Bitwise sets the memory attributes on a range of memory based on an attributes mask. | ||
@param BaseAddress The start of the range for which to set attributes. | ||
@param Length The length of the range. | ||
@param Attributes A bitmask of the attributes to set. See "Physical memory | ||
protection attributes" in UefiSpec.h | ||
@return EFI_SUCCESS | ||
@return Others | ||
**/ | ||
EFI_STATUS | ||
EFIAPI | ||
MmuSetAttributes ( | ||
IN EFI_PHYSICAL_ADDRESS BaseAddress, | ||
IN UINT64 Length, | ||
IN UINT64 Attributes | ||
); | ||
|
||
/** | ||
Bitwise clears the memory attributes on a range of memory based on an attributes mask. | ||
@param BaseAddress The start of the range for which to clear attributes. | ||
@param Length The length of the range. | ||
@param Attributes A bitmask of the attributes to clear. See "Physical memory | ||
protection attributes" in UefiSpec.h | ||
@return EFI_SUCCESS | ||
@return Others | ||
**/ | ||
EFI_STATUS | ||
EFIAPI | ||
MmuClearAttributes ( | ||
IN EFI_PHYSICAL_ADDRESS BaseAddress, | ||
IN UINT64 Length, | ||
IN UINT64 Attributes | ||
); | ||
|
||
/** | ||
Returns the memory attributes on a range of memory. | ||
@param BaseAddress The start of the range for which to set attributes. | ||
@param Attributes A return pointer for the attributes. | ||
@return EFI_SUCCESS | ||
@return EFI_INVALID_PARAMETER A return pointer is NULL. | ||
@return Others | ||
**/ | ||
EFI_STATUS | ||
EFIAPI | ||
MmuGetAttributes ( | ||
IN EFI_PHYSICAL_ADDRESS BaseAddress, | ||
OUT UINT64 *Attributes | ||
); | ||
|
||
#endif // _MMU_LIB_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** @file | ||
This lib abstracts some of the MMU accesses currently hardcoded against | ||
an Arm lib. It's likely that this will need to be refactored at some point. | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <Uefi.h> | ||
#include <Library/DebugLib.h> | ||
|
||
/** | ||
Bitwise sets the memory attributes on a range of memory based on an attributes mask. | ||
@param BaseAddress The start of the range for which to set attributes. | ||
@param Length The length of the range. | ||
@param Attributes A bitmask of the attributes to set. See "Physical memory | ||
protection attributes" in UefiSpec.h | ||
@return EFI_SUCCESS | ||
@return Others | ||
**/ | ||
EFI_STATUS | ||
EFIAPI | ||
MmuSetAttributes ( | ||
IN EFI_PHYSICAL_ADDRESS BaseAddress, | ||
IN UINT64 Length, | ||
IN UINT64 Attributes | ||
) | ||
{ | ||
DEBUG ((DEBUG_ERROR, "%a() NULL implementation used!\n", __FUNCTION__)); | ||
ASSERT (FALSE); | ||
return EFI_UNSUPPORTED; | ||
} | ||
|
||
/** | ||
Bitwise clears the memory attributes on a range of memory based on an attributes mask. | ||
@param BaseAddress The start of the range for which to clear attributes. | ||
@param Length The length of the range. | ||
@param Attributes A bitmask of the attributes to clear. See "Physical memory | ||
protection attributes" in UefiSpec.h | ||
@return EFI_SUCCESS | ||
@return Others | ||
**/ | ||
EFI_STATUS | ||
EFIAPI | ||
MmuClearAttributes ( | ||
IN EFI_PHYSICAL_ADDRESS BaseAddress, | ||
IN UINT64 Length, | ||
IN UINT64 Attributes | ||
) | ||
{ | ||
DEBUG ((DEBUG_ERROR, "%a() NULL implementation used!\n", __FUNCTION__)); | ||
ASSERT (FALSE); | ||
return EFI_UNSUPPORTED; | ||
} | ||
|
||
/** | ||
Returns the memory attributes on a range of memory. | ||
@param BaseAddress The start of the range for which to set attributes. | ||
@param Attributes A return pointer for the attributes. | ||
@return EFI_SUCCESS | ||
@return EFI_INVALID_PARAMETER A return pointer is NULL. | ||
@return Others | ||
**/ | ||
EFI_STATUS | ||
EFIAPI | ||
MmuGetAttributes ( | ||
IN EFI_PHYSICAL_ADDRESS BaseAddress, | ||
OUT UINT64 *Attributes | ||
) | ||
{ | ||
DEBUG ((DEBUG_ERROR, "%a() NULL implementation used!\n", __FUNCTION__)); | ||
ASSERT (FALSE); | ||
return EFI_UNSUPPORTED; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## @file | ||
# This lib abstracts some of the MMU accesses currently hardcoded against | ||
# an Arm lib. It's likely that this will need to be refactored at some point. | ||
# | ||
## | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
## | ||
|
||
|
||
[Defines] | ||
INF_VERSION = 0x00010017 | ||
BASE_NAME = BaseMmuLibNull | ||
FILE_GUID = 97196A48-00C0-4487-802A-CC5540583EEB | ||
VERSION_STRING = 1.0 | ||
MODULE_TYPE = BASE | ||
LIBRARY_CLASS = MmuLib | ||
|
||
|
||
[Sources] | ||
BaseMmuLibNull.c | ||
|
||
|
||
[LibraryClasses] | ||
DebugLib | ||
|
||
|
||
[Packages] | ||
MdePkg/MdePkg.dec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters