mirror of https://github.com/acidanthera/audk.git
Ring3: Added MakeUserPageTableTemplate() for ARM.
This commit is contained in:
parent
ebe2f8089c
commit
2f3c4c9dc6
|
@ -162,8 +162,7 @@
|
|||
TT_DESCRIPTOR_SECTION_NG_GLOBAL | \
|
||||
TT_DESCRIPTOR_SECTION_S_SHARED | \
|
||||
TT_DESCRIPTOR_SECTION_DOMAIN(0) | \
|
||||
TT_DESCRIPTOR_SECTION_AP_NO_RW | \
|
||||
TT_DESCRIPTOR_SECTION_AF)
|
||||
TT_DESCRIPTOR_SECTION_AP_NO_RW)
|
||||
|
||||
#define TT_DESCRIPTOR_SECTION_WRITE_BACK (TT_DESCRIPTOR_SECTION_DEFAULT | \
|
||||
TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_BACK_ALLOC)
|
||||
|
@ -179,8 +178,7 @@
|
|||
|
||||
#define TT_DESCRIPTOR_PAGE_DEFAULT (TT_DESCRIPTOR_PAGE_TYPE_PAGE | \
|
||||
TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
|
||||
TT_DESCRIPTOR_PAGE_AP_NO_RW | \
|
||||
TT_DESCRIPTOR_PAGE_AF)
|
||||
TT_DESCRIPTOR_PAGE_AP_NO_RW)
|
||||
|
||||
#define TT_DESCRIPTOR_PAGE_WRITE_BACK (TT_DESCRIPTOR_PAGE_DEFAULT | \
|
||||
TT_DESCRIPTOR_PAGE_S_SHARED | \
|
||||
|
|
|
@ -86,7 +86,8 @@ PopulateLevel2PageTable (
|
|||
IN UINT32 *SectionEntry,
|
||||
IN UINT32 PhysicalBase,
|
||||
IN UINT32 RemainLength,
|
||||
IN ARM_MEMORY_REGION_ATTRIBUTES Attributes
|
||||
IN ARM_MEMORY_REGION_ATTRIBUTES Attributes,
|
||||
IN BOOLEAN UserTable
|
||||
)
|
||||
{
|
||||
UINT32 *PageEntry;
|
||||
|
@ -132,6 +133,10 @@ PopulateLevel2PageTable (
|
|||
PageAttributes &= ~TT_DESCRIPTOR_PAGE_S_SHARED;
|
||||
}
|
||||
|
||||
if (!UserTable) {
|
||||
PageAttributes |= TT_DESCRIPTOR_PAGE_AF;
|
||||
}
|
||||
|
||||
// Check if the Section Entry has already been populated. Otherwise attach a
|
||||
// Level 2 Translation Table to it
|
||||
if (*SectionEntry != 0) {
|
||||
|
@ -220,7 +225,8 @@ STATIC
|
|||
VOID
|
||||
FillTranslationTable (
|
||||
IN UINT32 *TranslationTable,
|
||||
IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryRegion
|
||||
IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryRegion,
|
||||
IN BOOLEAN UserTable
|
||||
)
|
||||
{
|
||||
UINT32 *SectionEntry;
|
||||
|
@ -272,6 +278,10 @@ FillTranslationTable (
|
|||
Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;
|
||||
}
|
||||
|
||||
if (!UserTable) {
|
||||
Attributes |= TT_DESCRIPTOR_SECTION_AF;
|
||||
}
|
||||
|
||||
// Get the first section entry for this mapping
|
||||
SectionEntry = TRANSLATION_TABLE_ENTRY_FOR_VIRTUAL_ADDRESS (TranslationTable, MemoryRegion->VirtualBase);
|
||||
|
||||
|
@ -307,7 +317,8 @@ FillTranslationTable (
|
|||
SectionEntry,
|
||||
PhysicalBase,
|
||||
PageMapLength,
|
||||
MemoryRegion->Attributes
|
||||
MemoryRegion->Attributes,
|
||||
UserTable
|
||||
);
|
||||
|
||||
//
|
||||
|
@ -364,7 +375,7 @@ ArmConfigureMmu (
|
|||
ZeroMem (TranslationTable, TRANSLATION_TABLE_SECTION_SIZE);
|
||||
|
||||
while (MemoryTable->Length != 0) {
|
||||
FillTranslationTable (TranslationTable, MemoryTable);
|
||||
FillTranslationTable (TranslationTable, MemoryTable, FALSE);
|
||||
MemoryTable++;
|
||||
}
|
||||
|
||||
|
@ -424,3 +435,32 @@ ArmConfigureMmu (
|
|||
ArmEnableMmu ();
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ArmMakeUserPageTableTemplate (
|
||||
IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable,
|
||||
OUT UINTN *TranslationTableBase,
|
||||
OUT UINTN *TranslationTableSize
|
||||
)
|
||||
{
|
||||
VOID *TranslationTable;
|
||||
|
||||
TranslationTable = AllocateAlignedPages (
|
||||
EFI_SIZE_TO_PAGES (TRANSLATION_TABLE_SECTION_SIZE),
|
||||
TRANSLATION_TABLE_SECTION_ALIGNMENT
|
||||
);
|
||||
if (TranslationTable == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
ZeroMem (TranslationTable, TRANSLATION_TABLE_SECTION_SIZE);
|
||||
|
||||
FillTranslationTable (TranslationTable, MemoryTable, TRUE);
|
||||
|
||||
*TranslationTableBase = (UINTN)TranslationTable;
|
||||
*TranslationTableSize = TRANSLATION_TABLE_SECTION_SIZE;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
**/
|
||||
|
||||
#include <Library/ArmLib.h>
|
||||
#include <Library/ArmMmuLib.h>
|
||||
#include <Library/DefaultExceptionHandlerLib.h>
|
||||
|
||||
#include "DxeMain.h"
|
||||
|
@ -97,6 +98,34 @@ SysCallBootService (
|
|||
return Status;
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
MakeUserPageTableTemplate (
|
||||
OUT UINTN *UserPageTableTemplate,
|
||||
OUT UINTN *UserPageTableTemplateSize
|
||||
)
|
||||
{
|
||||
ARM_MEMORY_REGION_DESCRIPTOR Descriptor;
|
||||
VOID *MemorySizeHob;
|
||||
|
||||
MemorySizeHob = GetFirstGuidHob (&gArmVirtSystemMemorySizeGuid);
|
||||
ASSERT (MemorySizeHob != NULL);
|
||||
if (MemorySizeHob == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Descriptor.PhysicalBase = PcdGet64 (PcdSystemMemoryBase);
|
||||
Descriptor.VirtualBase = Descriptor.PhysicalBase;
|
||||
Descriptor.Length = *(UINT64 *)GET_GUID_HOB_DATA (MemorySizeHob);
|
||||
Descriptor.Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
|
||||
|
||||
ArmMakeUserPageTableTemplate (
|
||||
&Descriptor,
|
||||
UserPageTableTemplate,
|
||||
UserPageTableTemplateSize
|
||||
);
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
InitializeMsr (
|
||||
|
|
Loading…
Reference in New Issue