diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-16 18:15:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-16 18:15:13 +0200 |
| commit | 0033ef41f33ce3d39b4e7ed7e1353cec916bdd5d (patch) | |
| tree | cf298a3b522fed5b829c4b250932ab13ef407838 /dev/boot/modules/BootNet/BootNet.cc | |
| parent | d3cf45311cf3f6de0bc25bb0ddb5c14a29a72cd6 (diff) | |
| parent | 58b3d776ab5435de352217b2a3a525aeb9316e99 (diff) | |
Merge pull request #19 from amlel-el-mahrouss/dev
urgent patches.
Diffstat (limited to 'dev/boot/modules/BootNet/BootNet.cc')
| -rw-r--r-- | dev/boot/modules/BootNet/BootNet.cc | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/dev/boot/modules/BootNet/BootNet.cc b/dev/boot/modules/BootNet/BootNet.cc index 8ee08929..050148c4 100644 --- a/dev/boot/modules/BootNet/BootNet.cc +++ b/dev/boot/modules/BootNet/BootNet.cc @@ -7,29 +7,41 @@ * ======================================================== */ +#include <FirmwareKit/EFI/API.h> #include <modules/BootNet/BootNet.h> #include <BootKit/BootKit.h> #include <BootKit/BootThread.h> -STATIC EfiGUID kEfiIP4ProtoGUID = {}; +STATIC EfiGUID kEfiSimpleProtoGUID = EFI_SIMPLE_NETWORK_PROTOCOL_GUID; +STATIC EFI_SIMPLE_NETWORK_PROTOCOL* kEfiProtocol = nullptr; -STATIC Void bootnet_read_udp_packet(BOOTNET_INTERNET_HEADER&); +STATIC Void bootnet_read_ip_packet(BOOTNET_INTERNET_HEADER); EXTERN_C Int32 BootNetModuleMain(Kernel::HEL::BootInfoHeader* handover) { + Boot::BootTextWriter writer; + + writer.Write("BootNet: Init EFI...\r"); + + fw_init_efi((EfiSystemTable*)handover->f_FirmwareCustomTables[1]); + + if (BS->LocateProtocol(&kEfiSimpleProtoGUID, nullptr, (VoidPtr*)&kEfiProtocol) != kEfiOk) + { + writer.Write("BootNet: Not supported by firmware.\r"); + return kEfiFail; + } + BOOTNET_INTERNET_HEADER inet{}; - memset(&inet, 0, sizeof(BOOTNET_INTERNET_HEADER)); - - bootnet_read_udp_packet(inet); + SetMem(&inet, 0, sizeof(BOOTNET_INTERNET_HEADER)); + + writer.Write("BootNet: Downloading kernel...\r"); - /// TODO: Read address from JSON file 'bootnet.json' + bootnet_read_ip_packet(inet); if (inet.Length < 1) { - Boot::BootTextWriter writer; writer.Write("BootNet: No executable attached to the packet, aborting.\r"); - return kEfiFail; } @@ -38,23 +50,35 @@ EXTERN_C Int32 BootNetModuleMain(Kernel::HEL::BootInfoHeader* handover) Boot::BootThread thread(inet.Data); if (thread.IsValid()) + { + writer.Write("BootNet: Running kernel...\r"); return thread.Start(handover, YES); + } return kEfiFail; } else { - Boot::BootTextWriter writer; - writer.Write("BootNetLauncher: EEPROM flash is not available as of right now.\r"); + constexpr auto kROMSize = 0x200; + + if (inet.Length != kROMSize) + { + writer.Write("BootNet: Not within 512K.\r"); + return kEfiFail; + } + + writer.Write("BootNet: Programming the flash is not available as of right now.\r"); /// TODO: Program new firmware to EEPROM (if crc and size matches) - return kEfiFail; // TODO: Add support for EEPROM firmware update. + const UIntPtr kEEPROMAddress = 0; + const UInt16 kEEPROMSize = inet.Length; } return kEfiFail; } -STATIC Void bootnet_read_udp_packet(BOOTNET_INTERNET_HEADER&) +STATIC Void bootnet_read_ip_packet(BOOTNET_INTERNET_HEADER inet) { + NE_UNUSED(inet); }
\ No newline at end of file |
