mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-23 21:54:27 +02:00
Ring3: Added MakeUserPageTableTemplate() for ARM.
This commit is contained in:
parent
f438a38561
commit
b739cbd2b5
@ -86,7 +86,8 @@ PopulateLevel2PageTable (
|
|||||||
IN UINT32 *SectionEntry,
|
IN UINT32 *SectionEntry,
|
||||||
IN UINT32 PhysicalBase,
|
IN UINT32 PhysicalBase,
|
||||||
IN UINT32 RemainLength,
|
IN UINT32 RemainLength,
|
||||||
IN ARM_MEMORY_REGION_ATTRIBUTES Attributes
|
IN ARM_MEMORY_REGION_ATTRIBUTES Attributes,
|
||||||
|
IN BOOLEAN UserTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 *PageEntry;
|
UINT32 *PageEntry;
|
||||||
@ -132,6 +133,10 @@ PopulateLevel2PageTable (
|
|||||||
PageAttributes &= ~TT_DESCRIPTOR_PAGE_S_SHARED;
|
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
|
// Check if the Section Entry has already been populated. Otherwise attach a
|
||||||
// Level 2 Translation Table to it
|
// Level 2 Translation Table to it
|
||||||
if (*SectionEntry != 0) {
|
if (*SectionEntry != 0) {
|
||||||
@ -220,7 +225,8 @@ STATIC
|
|||||||
VOID
|
VOID
|
||||||
FillTranslationTable (
|
FillTranslationTable (
|
||||||
IN UINT32 *TranslationTable,
|
IN UINT32 *TranslationTable,
|
||||||
IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryRegion
|
IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryRegion,
|
||||||
|
IN BOOLEAN UserTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 *SectionEntry;
|
UINT32 *SectionEntry;
|
||||||
@ -272,6 +278,10 @@ FillTranslationTable (
|
|||||||
Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;
|
Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!UserTable) {
|
||||||
|
Attributes |= TT_DESCRIPTOR_SECTION_AF;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the first section entry for this mapping
|
// Get the first section entry for this mapping
|
||||||
SectionEntry = TRANSLATION_TABLE_ENTRY_FOR_VIRTUAL_ADDRESS (TranslationTable, MemoryRegion->VirtualBase);
|
SectionEntry = TRANSLATION_TABLE_ENTRY_FOR_VIRTUAL_ADDRESS (TranslationTable, MemoryRegion->VirtualBase);
|
||||||
|
|
||||||
@ -307,7 +317,8 @@ FillTranslationTable (
|
|||||||
SectionEntry,
|
SectionEntry,
|
||||||
PhysicalBase,
|
PhysicalBase,
|
||||||
PageMapLength,
|
PageMapLength,
|
||||||
MemoryRegion->Attributes
|
MemoryRegion->Attributes,
|
||||||
|
UserTable
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -364,7 +375,7 @@ ArmConfigureMmu (
|
|||||||
ZeroMem (TranslationTable, TRANSLATION_TABLE_SECTION_SIZE);
|
ZeroMem (TranslationTable, TRANSLATION_TABLE_SECTION_SIZE);
|
||||||
|
|
||||||
while (MemoryTable->Length != 0) {
|
while (MemoryTable->Length != 0) {
|
||||||
FillTranslationTable (TranslationTable, MemoryTable);
|
FillTranslationTable (TranslationTable, MemoryTable, FALSE);
|
||||||
MemoryTable++;
|
MemoryTable++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,3 +435,32 @@ ArmConfigureMmu (
|
|||||||
ArmEnableMmu ();
|
ArmEnableMmu ();
|
||||||
return RETURN_SUCCESS;
|
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/ArmLib.h>
|
||||||
|
#include <Library/ArmMmuLib.h>
|
||||||
#include <Library/DefaultExceptionHandlerLib.h>
|
#include <Library/DefaultExceptionHandlerLib.h>
|
||||||
|
|
||||||
#include "DxeMain.h"
|
#include "DxeMain.h"
|
||||||
@ -97,6 +98,34 @@ SysCallBootService (
|
|||||||
return Status;
|
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
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
InitializeMsr (
|
InitializeMsr (
|
||||||
|
@ -162,8 +162,7 @@
|
|||||||
TT_DESCRIPTOR_SECTION_NG_GLOBAL | \
|
TT_DESCRIPTOR_SECTION_NG_GLOBAL | \
|
||||||
TT_DESCRIPTOR_SECTION_S_SHARED | \
|
TT_DESCRIPTOR_SECTION_S_SHARED | \
|
||||||
TT_DESCRIPTOR_SECTION_DOMAIN(0) | \
|
TT_DESCRIPTOR_SECTION_DOMAIN(0) | \
|
||||||
TT_DESCRIPTOR_SECTION_AP_NO_RW | \
|
TT_DESCRIPTOR_SECTION_AP_NO_RW)
|
||||||
TT_DESCRIPTOR_SECTION_AF)
|
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_SECTION_WRITE_BACK (TT_DESCRIPTOR_SECTION_DEFAULT | \
|
#define TT_DESCRIPTOR_SECTION_WRITE_BACK (TT_DESCRIPTOR_SECTION_DEFAULT | \
|
||||||
TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_BACK_ALLOC)
|
TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_BACK_ALLOC)
|
||||||
@ -179,8 +178,7 @@
|
|||||||
|
|
||||||
#define TT_DESCRIPTOR_PAGE_DEFAULT (TT_DESCRIPTOR_PAGE_TYPE_PAGE | \
|
#define TT_DESCRIPTOR_PAGE_DEFAULT (TT_DESCRIPTOR_PAGE_TYPE_PAGE | \
|
||||||
TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
|
TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
|
||||||
TT_DESCRIPTOR_PAGE_AP_NO_RW | \
|
TT_DESCRIPTOR_PAGE_AP_NO_RW)
|
||||||
TT_DESCRIPTOR_PAGE_AF)
|
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_PAGE_WRITE_BACK (TT_DESCRIPTOR_PAGE_DEFAULT | \
|
#define TT_DESCRIPTOR_PAGE_WRITE_BACK (TT_DESCRIPTOR_PAGE_DEFAULT | \
|
||||||
TT_DESCRIPTOR_PAGE_S_SHARED | \
|
TT_DESCRIPTOR_PAGE_S_SHARED | \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user