From 5c0193ded6fee59fc37987515d58c8111c5af4f5 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 11 Jun 2025 09:56:32 +0200 Subject: refactor!: Refactor the `ONet` protocol to include a version field. and a updated magic string. feat: Add validation for `Version` field inside `net.efi`. Signed-off-by: Amlal El Mahrouss --- dev/boot/modules/BootNet/BootNet.cc | 5 +++++ dev/kernel/FirmwareKit/CoreBoot/BootNet.h | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'dev') diff --git a/dev/boot/modules/BootNet/BootNet.cc b/dev/boot/modules/BootNet/BootNet.cc index c91460cb..d4f8c1fc 100644 --- a/dev/boot/modules/BootNet/BootNet.cc +++ b/dev/boot/modules/BootNet/BootNet.cc @@ -44,6 +44,11 @@ EXTERN_C Int32 BootNetModuleMain(Kernel::HEL::BootInfoHeader* handover) { return kEfiFail; } + if (inet_out->Version != kBootNetVersion) { + writer.Write("BootNet: The version clashes, not good.\r"); + return kEfiFail; + } + if (!inet_out->ImpliesProgram) { Boot::BootThread thread(inet_out->Data); diff --git a/dev/kernel/FirmwareKit/CoreBoot/BootNet.h b/dev/kernel/FirmwareKit/CoreBoot/BootNet.h index b05f382e..c42c98db 100644 --- a/dev/kernel/FirmwareKit/CoreBoot/BootNet.h +++ b/dev/kernel/FirmwareKit/CoreBoot/BootNet.h @@ -8,9 +8,9 @@ #include -#define kBootNetINetMagic "NETB" +#define kBootNetINetMagic "ONET" #define kBootNetINetMagicLength (4) - +#define kBootNetVersion (0x001) #define kBootNetNameLen (256U) /// @brief Netboot Internet Header @@ -18,11 +18,11 @@ /// sent (if m_preflight = 0) /// @note Can be used to patch ROMs too (if ImpliesProgram = 1) typedef struct BOOTNET_INTERNET_HEADER { - Kernel::Char NB1; /// magic char 1 'N' - Kernel::Char NB2; /// magic char 2 'E' - Kernel::Char NB3; /// magic char 3 'T' - Kernel::Char NB4; /// magic char 4 'B' - + Kernel::Char NB1; /// magic char 1 'O' + Kernel::Char NB2; /// magic char 2 'N' + Kernel::Char NB3; /// magic char 3 'E' + Kernel::Char NB4; /// magic char 4 'T' + Kernel::UInt16 Version; Kernel::Char Name[kBootNetNameLen]; /// example: Modjo Kernel::Int32 Length; /// the patch length. Kernel::Char Target[kBootNetNameLen]; /// the target file. -- cgit v1.2.3