mirror of https://github.com/acidanthera/audk.git
Ring3: Added GetMemoryAttributes() into EFI_CPU_ARCH_PROTOCOL.
This commit is contained in:
parent
f2a28c5a55
commit
db50e4edf1
|
@ -1595,6 +1595,7 @@ CoreStartImage (
|
|||
UINT64 HandleDatabaseKey;
|
||||
UINTN SetJumpFlag;
|
||||
EFI_HANDLE Handle;
|
||||
UINT64 Attributes;
|
||||
|
||||
Handle = ImageHandle;
|
||||
|
||||
|
@ -1686,7 +1687,15 @@ CoreStartImage (
|
|||
// Call the image's entry point
|
||||
//
|
||||
Image->Started = TRUE;
|
||||
Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
|
||||
|
||||
if (!Image->IsUserImage) {
|
||||
Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
|
||||
} else {
|
||||
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)Image->EntryPoint, &Attributes);
|
||||
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
|
||||
|
||||
Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
|
||||
}
|
||||
|
||||
//
|
||||
// Add some debug information if the image returned with error.
|
||||
|
|
|
@ -244,12 +244,20 @@ EFI_STATUS
|
|||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_CPU_SET_MEMORY_ATTRIBUTES)(
|
||||
IN EFI_CPU_ARCH_PROTOCOL *This,
|
||||
IN EFI_CPU_ARCH_PROTOCOL *This,
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_CPU_GET_MEMORY_ATTRIBUTES)(
|
||||
IN EFI_CPU_ARCH_PROTOCOL *This,
|
||||
IN EFI_PHYSICAL_ADDRESS Address,
|
||||
OUT UINT64 *Attributes
|
||||
);
|
||||
|
||||
///
|
||||
/// The EFI_CPU_ARCH_PROTOCOL is used to abstract processor-specific functions from the DXE
|
||||
/// Foundation. This includes flushing caches, enabling and disabling interrupts, hooking interrupt
|
||||
|
@ -279,6 +287,7 @@ struct _EFI_CPU_ARCH_PROTOCOL {
|
|||
/// a read-only field.
|
||||
///
|
||||
UINT32 DmaBufferAlignment;
|
||||
EFI_CPU_GET_MEMORY_ATTRIBUTES GetMemoryAttributes;
|
||||
};
|
||||
|
||||
extern EFI_GUID gEfiCpuArchProtocolGuid;
|
||||
|
|
|
@ -31,7 +31,8 @@ EFI_CPU_ARCH_PROTOCOL gCpuImpl = {
|
|||
CpuGetTimerValue,
|
||||
CpuSetMemoryAttributes,
|
||||
1, // NumberOfTimers
|
||||
4 // DmaBufferAlignment
|
||||
4, // DmaBufferAlignment
|
||||
CpuGetMemoryAttributes
|
||||
};
|
||||
|
||||
EFI_HOB_PLATFORM_INFO *mPlatformInfoHob2 = NULL;
|
||||
|
|
|
@ -221,6 +221,14 @@ CpuSetMemoryAttributes (
|
|||
IN UINT64 Attributes
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CpuGetMemoryAttributes (
|
||||
IN EFI_CPU_ARCH_PROTOCOL *This,
|
||||
IN EFI_PHYSICAL_ADDRESS Address,
|
||||
OUT UINT64 *Attributes
|
||||
);
|
||||
|
||||
/**
|
||||
Initialize Global Descriptor Table.
|
||||
|
||||
|
|
|
@ -405,6 +405,30 @@ GetAttributesFromPageEntry (
|
|||
return Attributes;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CpuGetMemoryAttributes (
|
||||
IN EFI_CPU_ARCH_PROTOCOL *This,
|
||||
IN EFI_PHYSICAL_ADDRESS Address,
|
||||
OUT UINT64 *Attributes
|
||||
)
|
||||
{
|
||||
PAGE_TABLE_LIB_PAGING_CONTEXT PagingContext;
|
||||
PAGE_ATTRIBUTE PageAttribute;
|
||||
UINT64 *PageEntry;
|
||||
|
||||
GetCurrentPagingContext (&PagingContext);
|
||||
|
||||
PageEntry = GetPageTableEntry (&PagingContext, Address, &PageAttribute);
|
||||
if (PageEntry == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
*Attributes = GetAttributesFromPageEntry (PageEntry);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Modify memory attributes of page entry.
|
||||
|
||||
|
|
Loading…
Reference in New Issue