forked from xt-sys/exectos
Fill in kernel initialization block
This commit is contained in:
@@ -156,27 +156,58 @@ 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));
|
||||
|
||||
LoaderBlock->LoaderInformation.DbgPrint = XtLdrProtocol->DbgPrint;
|
||||
/* Set basic loader block properties */
|
||||
LoaderBlock->Size = sizeof(KERNEL_INITIALIZATION_BLOCK);
|
||||
LoaderBlock->Version = INITIALIZATION_BLOCK_VERSION;
|
||||
|
||||
XtLdrProtocol->AddVirtualMemoryMapping(MemoryMappings, *VirtualAddress, (PVOID)LoaderBlock, BlockPages, LoaderSystemBlock);
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user