summaryrefslogtreecommitdiffhomepage
path: root/dev/boot/modules
diff options
context:
space:
mode:
Diffstat (limited to 'dev/boot/modules')
-rw-r--r--dev/boot/modules/BootNet/BootNet.cc53
-rw-r--r--dev/boot/modules/BootNet/BootNet.h2
-rw-r--r--dev/boot/modules/SysChk/arm64.json2
3 files changed, 42 insertions, 15 deletions
diff --git a/dev/boot/modules/BootNet/BootNet.cc b/dev/boot/modules/BootNet/BootNet.cc
index 8ee08929..28d96cb2 100644
--- a/dev/boot/modules/BootNet/BootNet.cc
+++ b/dev/boot/modules/BootNet/BootNet.cc
@@ -7,29 +7,40 @@
* ========================================================
*/
+#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)
{
+ fw_init_efi((EfiSystemTable*)handover->f_FirmwareCustomTables[0]);
+
+
+ Boot::BootTextWriter writer;
+
+ if (BS->LocateProtocol(&kEfiSimpleProtoGUID, nullptr, (VoidPtr*)&kEfiProtocol) != kEfiOk)
+ {
+ writer.Write("[BOOT] 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));
- /// TODO: Read address from JSON file 'bootnet.json'
+ writer.Write("[BOOT] BootNet: Downloading kernel...\r");
+
+ bootnet_read_ip_packet(inet);
if (inet.Length < 1)
{
- Boot::BootTextWriter writer;
- writer.Write("BootNet: No executable attached to the packet, aborting.\r");
-
+ writer.Write("[BOOT] BootNet: No executable attached to the packet, aborting.\r");
return kEfiFail;
}
@@ -38,23 +49,39 @@ EXTERN_C Int32 BootNetModuleMain(Kernel::HEL::BootInfoHeader* handover)
Boot::BootThread thread(inet.Data);
if (thread.IsValid())
+ {
+ writer.Write("[BOOT] 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("[BOOT] BootNet: Not within 512K.\r");
+ return kEfiFail;
+ }
+
+ writer.Write("[BOOT] 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)
{
+ kEfiProtocol->Start(kEfiProtocol);
+
+ NE_UNUSED(inet);
+
+ kEfiProtocol->Stop(kEfiProtocol);
} \ No newline at end of file
diff --git a/dev/boot/modules/BootNet/BootNet.h b/dev/boot/modules/BootNet/BootNet.h
index aba7924f..b38ed0e9 100644
--- a/dev/boot/modules/BootNet/BootNet.h
+++ b/dev/boot/modules/BootNet/BootNet.h
@@ -29,5 +29,5 @@ typedef struct BOOTNET_INTERNET_HEADER
Kernel::Char Target[kBootNetNameLen]; /// the target file.
Kernel::Boolean ImpliesProgram : 1; /// does it imply an EEPROM reprogram?
Kernel::Boolean Preflight : 1; /// is it a preflight packet.
- Kernel::Char Data[]; /// non preflight packet has a patch blob for a **PatchTarget**
+ Kernel::Char Data[1]; /// non preflight packet has a patch blob for a **PatchTarget**
} ATTRIBUTE(packed) BOOTNET_INTERNET_HEADER;
diff --git a/dev/boot/modules/SysChk/arm64.json b/dev/boot/modules/SysChk/arm64.json
index 1f91326e..ad5fde6e 100644
--- a/dev/boot/modules/SysChk/arm64.json
+++ b/dev/boot/modules/SysChk/arm64.json
@@ -11,7 +11,7 @@
"-fno-rtti",
"-fno-exceptions",
"-fuse-ld=lld",
- "-Wl,-subsystem:efi_application,-entry:ModuleMain",
+ "-Wl,-subsystem:efi_application,-entry:BootloaderMain",
"-target aarch64-unknown-windows"
],
"cpp_macros": [