Small code formatting and refactoring
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
e9d30a0fd9
commit
4d68b93ed3
@ -112,7 +112,8 @@ BlFindVolumeDevicePath(IN PEFI_DEVICE_PATH_PROTOCOL FsHandle,
|
||||
EFI_STATUS
|
||||
BlGetMemoryMap(OUT PEFI_MEMORY_MAP MemoryMap);
|
||||
|
||||
VOID BlGetStackPointer(OUT PVOID *Stack);
|
||||
VOID
|
||||
BlGetStackPointer(OUT PVOID *Stack);
|
||||
|
||||
EFI_STATUS
|
||||
BlGetVirtualAddress(IN PLIST_ENTRY MemoryMappings,
|
||||
@ -132,6 +133,9 @@ BlInitializeVirtualMemory(IN OUT PLIST_ENTRY MemoryMappings,
|
||||
EFI_STATUS
|
||||
BlLoadEfiModules();
|
||||
|
||||
EFI_STATUS
|
||||
BlLoadXtSystem();
|
||||
|
||||
EFI_STATUS
|
||||
BlMapVirtualMemory(IN PLIST_ENTRY MemoryMappings,
|
||||
IN UINT_PTR VirtualAddress,
|
||||
|
@ -4,7 +4,8 @@ PROJECT(XTLDR_DUMMY)
|
||||
# Specify include directories
|
||||
include_directories(
|
||||
${EXECTOS_SOURCE_DIR}/sdk/xtdk
|
||||
${XTLDR_SOURCE_DIR}/includes)
|
||||
${XTLDR_SOURCE_DIR}/includes
|
||||
${XTLDR_DUMMY_SOURCE_DIR}/includes)
|
||||
|
||||
# Specify list of source code files
|
||||
list(APPEND XTLDR_DUMMY_SOURCE
|
||||
|
@ -6,7 +6,7 @@
|
||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
*/
|
||||
|
||||
#include <blmod.h>
|
||||
#include <dummy.h>
|
||||
|
||||
|
||||
/* EFI Image Handle */
|
||||
|
20
xtldr/modules/dummy/includes/dummy.h
Normal file
20
xtldr/modules/dummy/includes/dummy.h
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* PROJECT: ExectOS
|
||||
* COPYRIGHT: See COPYING.md in the top level directory
|
||||
* FILE: xtldr/modules/dummy/includes/dummy.h
|
||||
* DESCRIPTION: Dummy module header file
|
||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
*/
|
||||
|
||||
#ifndef __XTLDR_MODULES_DUMMY_H
|
||||
#define __XTLDR_MODULES_DUMMY_H
|
||||
|
||||
#include <blmod.h>
|
||||
|
||||
|
||||
/* Dummy module related routines forward references */
|
||||
EFI_STATUS
|
||||
BlXtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
||||
IN PEFI_SYSTEM_TABLE SystemTable);
|
||||
|
||||
#endif /* __XTLDR_MODULES_DUMMY_H */
|
@ -23,6 +23,10 @@ EFI_STATUS
|
||||
XtpBootSequence(IN PEFI_FILE_HANDLE BootDir,
|
||||
IN PXT_BOOT_PROTOCOL_PARAMETERS Parameters);
|
||||
|
||||
EFI_STATUS
|
||||
XtpInitializeLoaderBlock(IN PLIST_ENTRY MemoryMappings,
|
||||
IN PVOID *VirtualAddress);
|
||||
|
||||
EFI_STATUS
|
||||
XtpLoadModule(IN PEFI_FILE_HANDLE BootDir,
|
||||
IN PWCHAR FileName,
|
||||
|
@ -151,66 +151,6 @@ XtBootSystem(IN PXT_BOOT_PROTOCOL_PARAMETERS Parameters)
|
||||
return XtpBootSequence(BootDir, Parameters);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
XtpInitializeLoaderBlock(IN PLIST_ENTRY MemoryMappings, IN PVOID *VirtualAddress)
|
||||
{
|
||||
PKERNEL_INITIALIZATION_BLOCK LoaderBlock;
|
||||
EFI_PHYSICAL_ADDRESS Address;
|
||||
PVOID RuntimeServices;
|
||||
EFI_STATUS Status;
|
||||
UINT BlockPages;
|
||||
|
||||
/* Calculate number of pages needed for initialization block */
|
||||
BlockPages = EFI_SIZE_TO_PAGES(sizeof(KERNEL_INITIALIZATION_BLOCK));
|
||||
|
||||
/* Allocate memory for kernel initialization block */
|
||||
Status = XtLdrProtocol->AllocatePages(BlockPages, &Address);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Memory allocation failure */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Initialize and zero-fill kernel initialization block */
|
||||
LoaderBlock = (PKERNEL_INITIALIZATION_BLOCK)(UINT_PTR)Address;
|
||||
RtlZeroMemory(LoaderBlock, sizeof(KERNEL_INITIALIZATION_BLOCK));
|
||||
|
||||
/* Set basic loader block properties */
|
||||
LoaderBlock->Size = sizeof(KERNEL_INITIALIZATION_BLOCK);
|
||||
LoaderBlock->Version = INITIALIZATION_BLOCK_VERSION;
|
||||
|
||||
/* No kernel stack available now */
|
||||
LoaderBlock->KernelStack = (ULONG_PTR)NULL;
|
||||
|
||||
/* Set LoaderInformation block properties */
|
||||
LoaderBlock->LoaderInformation.DbgPrint = XtLdrProtocol->DbgPrint;
|
||||
|
||||
/* Attempt to find virtual address of the EFI Runtime Services */
|
||||
Status = XtLdrProtocol->GetVirtualAddress(MemoryMappings, &EfiSystemTable->RuntimeServices->Hdr, &RuntimeServices);
|
||||
if(Status == STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Set FirmwareInformation block properties */
|
||||
LoaderBlock->FirmwareInformation.FirmwareType = SystemFirmwareEfi;
|
||||
LoaderBlock->FirmwareInformation.EfiFirmware.EfiVersion = EfiSystemTable->Hdr.Revision;
|
||||
LoaderBlock->FirmwareInformation.EfiFirmware.EfiRuntimeServices = RuntimeServices;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set invalid firmware type to indicate that kernel cannot rely on FirmwareInformation block */
|
||||
LoaderBlock->FirmwareInformation.FirmwareType = SystemFirmwareInvalid;
|
||||
}
|
||||
|
||||
/* Map kernel initialization block */
|
||||
XtLdrProtocol->AddVirtualMemoryMapping(MemoryMappings, *VirtualAddress, (PVOID)LoaderBlock,
|
||||
BlockPages, LoaderSystemBlock);
|
||||
|
||||
/* Calculate next valid virtual address */
|
||||
*VirtualAddress += (UINT_PTR)(BlockPages * EFI_PAGE_SIZE);
|
||||
|
||||
/* Return success */
|
||||
return STATUS_EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* This routine initiates an XTOS boot sequence.
|
||||
*
|
||||
@ -298,6 +238,67 @@ XtpBootSequence(IN PEFI_FILE_HANDLE BootDir,
|
||||
return STATUS_EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
XtpInitializeLoaderBlock(IN PLIST_ENTRY MemoryMappings,
|
||||
IN PVOID *VirtualAddress)
|
||||
{
|
||||
PKERNEL_INITIALIZATION_BLOCK LoaderBlock;
|
||||
EFI_PHYSICAL_ADDRESS Address;
|
||||
PVOID RuntimeServices;
|
||||
EFI_STATUS Status;
|
||||
UINT BlockPages;
|
||||
|
||||
/* Calculate number of pages needed for initialization block */
|
||||
BlockPages = EFI_SIZE_TO_PAGES(sizeof(KERNEL_INITIALIZATION_BLOCK));
|
||||
|
||||
/* Allocate memory for kernel initialization block */
|
||||
Status = XtLdrProtocol->AllocatePages(BlockPages, &Address);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Memory allocation failure */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Initialize and zero-fill kernel initialization block */
|
||||
LoaderBlock = (PKERNEL_INITIALIZATION_BLOCK)(UINT_PTR)Address;
|
||||
RtlZeroMemory(LoaderBlock, sizeof(KERNEL_INITIALIZATION_BLOCK));
|
||||
|
||||
/* Set basic loader block properties */
|
||||
LoaderBlock->Size = sizeof(KERNEL_INITIALIZATION_BLOCK);
|
||||
LoaderBlock->Version = INITIALIZATION_BLOCK_VERSION;
|
||||
|
||||
/* No kernel stack available now */
|
||||
LoaderBlock->KernelStack = (ULONG_PTR)NULL;
|
||||
|
||||
/* Set LoaderInformation block properties */
|
||||
LoaderBlock->LoaderInformation.DbgPrint = XtLdrProtocol->DbgPrint;
|
||||
|
||||
/* Attempt to find virtual address of the EFI Runtime Services */
|
||||
Status = XtLdrProtocol->GetVirtualAddress(MemoryMappings, &EfiSystemTable->RuntimeServices->Hdr, &RuntimeServices);
|
||||
if(Status == STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Set FirmwareInformation block properties */
|
||||
LoaderBlock->FirmwareInformation.FirmwareType = SystemFirmwareEfi;
|
||||
LoaderBlock->FirmwareInformation.EfiFirmware.EfiVersion = EfiSystemTable->Hdr.Revision;
|
||||
LoaderBlock->FirmwareInformation.EfiFirmware.EfiRuntimeServices = RuntimeServices;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set invalid firmware type to indicate that kernel cannot rely on FirmwareInformation block */
|
||||
LoaderBlock->FirmwareInformation.FirmwareType = SystemFirmwareInvalid;
|
||||
}
|
||||
|
||||
/* Map kernel initialization block */
|
||||
XtLdrProtocol->AddVirtualMemoryMapping(MemoryMappings, *VirtualAddress, (PVOID)LoaderBlock,
|
||||
BlockPages, LoaderSystemBlock);
|
||||
|
||||
/* Calculate next valid virtual address */
|
||||
*VirtualAddress += (UINT_PTR)(BlockPages * EFI_PAGE_SIZE);
|
||||
|
||||
/* Return success */
|
||||
return STATUS_EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads XTOS PE/COFF module.
|
||||
*
|
||||
|
@ -263,7 +263,8 @@ BlLoadEfiModules()
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
EFI_STATUS BlLoadXtSystem()
|
||||
EFI_STATUS
|
||||
BlLoadXtSystem()
|
||||
{
|
||||
EFI_GUID ProtocolGuid = XT_XTOS_BOOT_PROTOCOL_GUID;
|
||||
XT_BOOT_PROTOCOL_PARAMETERS BootParameters;
|
||||
|
Loading…
Reference in New Issue
Block a user