From a4b9f495e5e3b55a4356c0c8bb95d661fb94266c Mon Sep 17 00:00:00 2001 From: Aiken Harris Date: Tue, 27 Jan 2026 16:50:11 +0100 Subject: [PATCH] Calculate total boot image size and pass it to kernel --- boot/xtldr/modules/xtos_o/xtos.cc | 6 ++++++ sdk/xtdk/xtfw.h | 1 + 2 files changed, 7 insertions(+) diff --git a/boot/xtldr/modules/xtos_o/xtos.cc b/boot/xtldr/modules/xtos_o/xtos.cc index 7334693..aabecb9 100644 --- a/boot/xtldr/modules/xtos_o/xtos.cc +++ b/boot/xtldr/modules/xtos_o/xtos.cc @@ -234,6 +234,9 @@ Xtos::GetMemoryDescriptorList(IN PXTBL_PAGE_MAPPING PageMap, XtLdrProtocol->Memory.PhysicalListToVirtual(PageMap, MemoryDescriptorList, PhysicalBase, *VirtualAddress); + /* Calculate next valid virtual address */ + *VirtualAddress = (PUINT8)*VirtualAddress + (Pages * EFI_PAGE_SIZE); + return STATUS_EFI_SUCCESS; } @@ -469,6 +472,9 @@ Xtos::InitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap, XtLdrProtocol->LinkedList.InitializeHead(&LoaderBlock->MemoryDescriptorListHead); GetMemoryDescriptorList(PageMap, VirtualAddress, &LoaderBlock->MemoryDescriptorListHead); + /* Set boot image size */ + LoaderBlock->BootImageSize = (PFN_NUMBER)(((ULONGLONG)*VirtualAddress - KSEG0_BASE) / EFI_PAGE_SIZE); + /* Return success */ return STATUS_EFI_SUCCESS; } diff --git a/sdk/xtdk/xtfw.h b/sdk/xtdk/xtfw.h index 1a4642a..fbe3965 100644 --- a/sdk/xtdk/xtfw.h +++ b/sdk/xtdk/xtfw.h @@ -107,6 +107,7 @@ typedef struct _KERNEL_INITIALIZATION_BLOCK ULONG BlockVersion; ULONG ProtocolVersion; PWCHAR KernelParameters; + PFN_NUMBER BootImageSize; LIST_ENTRY LoadOrderListHead; LIST_ENTRY MemoryDescriptorListHead; LIST_ENTRY BootDriverListHead;