From 5b64cf21a0a98e0c73b93fdfb8cc75f0107b21bf Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Sat, 30 Dec 2023 16:34:27 +0100 Subject: [PATCH] Add boot protocol parameters --- sdk/xtdk/bltypes.h | 13 +++++++++++++ xtldr2/xtldr.c | 48 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/sdk/xtdk/bltypes.h b/sdk/xtdk/bltypes.h index ce550d8..687684e 100644 --- a/sdk/xtdk/bltypes.h +++ b/sdk/xtdk/bltypes.h @@ -79,6 +79,19 @@ typedef VOID (*PBL_TUI_UPDATE_PROGRESS_BAR)(IN PXTBL_DIALOG_HANDLE Handle, IN PW typedef EFI_STATUS (*PBL_WAIT_FOR_EFI_EVENT)(IN UINT_PTR NumberOfEvents, IN PEFI_EVENT Event, OUT PUINT_PTR Index); typedef VOID (*PBL_XT_BOOT_MENU)(); +/* Boot parameters structure */ +typedef struct _XTBL_BOOT_PARAMETERS +{ + PEFI_DEVICE_PATH_PROTOCOL DevicePath; + PWCHAR ArcName; + PWCHAR SystemPath; + PWCHAR SystemType; + PWCHAR KernelFile; + PWCHAR InitrdFile; + PWCHAR HalFile; + PWCHAR Parameters; +} XTBL_BOOT_PARAMETERS, *PXTBL_BOOT_PARAMETERS; + /* Boot menu list structure */ typedef struct _XTBL_BOOTMENU_ITEM { diff --git a/xtldr2/xtldr.c b/xtldr2/xtldr.c index be50e7d..8a4e324 100644 --- a/xtldr2/xtldr.c +++ b/xtldr2/xtldr.c @@ -110,16 +110,17 @@ XTCDECL EFI_STATUS BlInvokeBootProtocol(IN PLIST_ENTRY OptionsList) { - PWCHAR ModulesList, ProtocolName; + XTBL_BOOT_PARAMETERS BootParameters; + PWCHAR ModulesList; PLIST_ENTRY OptionsListEntry; PXTBL_CONFIG_ENTRY Option; SIZE_T ModuleListLength; EFI_STATUS Status; - /* Set default values */ - ProtocolName = NULL; + /* Initialize boot parameters */ + RtlZeroMemory(&BootParameters, sizeof(XTBL_BOOT_PARAMETERS)); - /* Iterate through all options provided by boot menu entry */ + /* Iterate through all options provided by boot menu entry and propagate boot parameters */ OptionsListEntry = OptionsList->Flink; while(OptionsListEntry != OptionsList) { @@ -127,12 +128,7 @@ BlInvokeBootProtocol(IN PLIST_ENTRY OptionsList) Option = CONTAIN_RECORD(OptionsListEntry, XTBL_CONFIG_ENTRY, Flink); /* Look for boot protocol and modules list */ - if(RtlCompareWideStringInsensitive(Option->Name, L"SYSTEMTYPE", 0) == 0) - { - /* Boot protocol found */ - ProtocolName = Option->Value; - } - else if(RtlCompareWideStringInsensitive(Option->Name, L"BOOTMODULES", 0) == 0) + if(RtlCompareWideStringInsensitive(Option->Name, L"BOOTMODULES", 0) == 0) { /* Check a length of modules list */ ModuleListLength = RtlWideStringLength(Option->Value, 0); @@ -148,6 +144,36 @@ BlInvokeBootProtocol(IN PLIST_ENTRY OptionsList) /* Make a copy of modules list */ RtlCopyMemory(ModulesList, Option->Value, sizeof(PWCHAR) * ModuleListLength); } + else if(RtlCompareWideStringInsensitive(Option->Name, L"SYSTEMTYPE", 0) == 0) + { + /* Boot protocol found */ + BootParameters.SystemType = Option->Value; + } + else if(RtlCompareWideStringInsensitive(Option->Name, L"SYSTEMPATH", 0) == 0) + { + /* System path found, get boot volume */ + + } + else if(RtlCompareWideStringInsensitive(Option->Name, L"KERNELFILE", 0) == 0) + { + /* Kernel file name found */ + BootParameters.KernelFile = Option->Value; + } + else if(RtlCompareWideStringInsensitive(Option->Name, L"INITRDFILE", 0) == 0) + { + /* Initrd file name found */ + BootParameters.InitrdFile = Option->Value; + } + else if(RtlCompareWideStringInsensitive(Option->Name, L"HALFILE", 0) == 0) + { + /* Hal file name found */ + BootParameters.HalFile = Option->Value; + } + else if(RtlCompareWideStringInsensitive(Option->Name, L"PARAMETERS", 0) == 0) + { + /* Kernel parameters found */ + BootParameters.Parameters = Option->Value; + } /* Move to the next option entry */ OptionsListEntry = OptionsListEntry->Flink; @@ -163,7 +189,7 @@ BlInvokeBootProtocol(IN PLIST_ENTRY OptionsList) } // TODO: Add support for boot protocol and invoke it - for(;;); + return STATUS_EFI_UNSUPPORTED; /* This point should never be reached */ return STATUS_EFI_SUCCESS;