[BOOT] Execution contexts and more refactoring
This commit is contained in:
@@ -62,15 +62,32 @@ Return Value:
|
||||
--*/
|
||||
|
||||
{
|
||||
return EfiGetNtStatusCode(
|
||||
EfiBS->GetMemoryMap(
|
||||
MemoryMapSize,
|
||||
MemoryMap,
|
||||
MapKey,
|
||||
DescriptorSize,
|
||||
DescriptorVersion
|
||||
)
|
||||
EXECUTION_CONTEXT_TYPE ContextType;
|
||||
EFI_STATUS EfiStatus;
|
||||
|
||||
ContextType = CurrentExecutionContext->Type;
|
||||
if (ContextType != ExecutionContextFirmware) {
|
||||
//
|
||||
// TODO: Translate addresses here.
|
||||
// Need MmArchTranslateVirtualAddress().
|
||||
//
|
||||
|
||||
BlpArchSwitchContext(ExecutionContextFirmware);
|
||||
}
|
||||
|
||||
EfiStatus = EfiBS->GetMemoryMap(
|
||||
MemoryMapSize,
|
||||
MemoryMap,
|
||||
MapKey,
|
||||
DescriptorSize,
|
||||
DescriptorVersion
|
||||
);
|
||||
|
||||
if (ContextType != ExecutionContextFirmware) {
|
||||
BlpArchSwitchContext(ContextType);
|
||||
}
|
||||
|
||||
return EfiGetNtStatusCode(EfiStatus);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
@@ -106,14 +123,26 @@ Return Value:
|
||||
--*/
|
||||
|
||||
{
|
||||
return EfiGetNtStatusCode(
|
||||
EfiBS->AllocatePages(
|
||||
Type,
|
||||
MemoryType,
|
||||
Pages,
|
||||
Memory
|
||||
)
|
||||
EXECUTION_CONTEXT_TYPE ContextType;
|
||||
EFI_STATUS EfiStatus;
|
||||
|
||||
ContextType = CurrentExecutionContext->Type;
|
||||
if (ContextType != ExecutionContextFirmware) {
|
||||
BlpArchSwitchContext(ExecutionContextFirmware);
|
||||
}
|
||||
|
||||
EfiStatus = EfiBS->AllocatePages(
|
||||
Type,
|
||||
MemoryType,
|
||||
Pages,
|
||||
Memory
|
||||
);
|
||||
|
||||
if (ContextType != ExecutionContextFirmware) {
|
||||
BlpArchSwitchContext(ContextType);
|
||||
}
|
||||
|
||||
return EfiGetNtStatusCode(EfiStatus);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
@@ -143,12 +172,24 @@ Return Value:
|
||||
--*/
|
||||
|
||||
{
|
||||
return EfiGetNtStatusCode(
|
||||
EfiBS->FreePages(
|
||||
Memory,
|
||||
Pages
|
||||
)
|
||||
EXECUTION_CONTEXT_TYPE ContextType;
|
||||
EFI_STATUS EfiStatus;
|
||||
|
||||
ContextType = CurrentExecutionContext->Type;
|
||||
if (ContextType != ExecutionContextFirmware) {
|
||||
BlpArchSwitchContext(ExecutionContextFirmware);
|
||||
}
|
||||
|
||||
EfiStatus = EfiBS->FreePages(
|
||||
Memory,
|
||||
Pages
|
||||
);
|
||||
|
||||
if (ContextType != ExecutionContextFirmware) {
|
||||
BlpArchSwitchContext(ContextType);
|
||||
}
|
||||
|
||||
return EfiGetNtStatusCode(EfiStatus);
|
||||
}
|
||||
|
||||
MEMORY_TYPE
|
||||
@@ -616,7 +657,7 @@ Return Value:
|
||||
//
|
||||
// Remove the current descriptor.
|
||||
//
|
||||
Status = MmMdRemoveRegionFromMdlEx(Mdl, NtStartPage, NtPageCount, MDL_OPERATION_FLAGS_PHYSICAL, NULL);
|
||||
Status = MmMdRemoveRegionFromMdl(Mdl, NtStartPage, NtPageCount, MDL_OPERATION_FLAGS_PHYSICAL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
MmMdFreeDescriptor(NtDescriptor);
|
||||
goto exit;
|
||||
|
Reference in New Issue
Block a user