summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot
diff options
context:
space:
mode:
Diffstat (limited to 'Private/NewBoot')
-rw-r--r--Private/NewBoot/BootKit/BootKit.hxx4
-rw-r--r--Private/NewBoot/Source/RuntimeMain.cxx42
-rw-r--r--Private/NewBoot/Source/bundle.mk35
-rw-r--r--Private/NewBoot/Source/standard.mk (renamed from Private/NewBoot/Source/makefile)0
4 files changed, 76 insertions, 5 deletions
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx
index dcb8daf4..093b20dc 100644
--- a/Private/NewBoot/BootKit/BootKit.hxx
+++ b/Private/NewBoot/BootKit/BootKit.hxx
@@ -14,6 +14,10 @@
#pragma once
+class BTextWriter;
+class BFileReader;
+class BFileRunner;
+
#include <BootKit/Arch/ATA.hxx>
#include <EFIKit/EFI.hxx>
#include <NewKit/Defines.hpp>
diff --git a/Private/NewBoot/Source/RuntimeMain.cxx b/Private/NewBoot/Source/RuntimeMain.cxx
index 65cd1e44..0db90e6f 100644
--- a/Private/NewBoot/Source/RuntimeMain.cxx
+++ b/Private/NewBoot/Source/RuntimeMain.cxx
@@ -24,6 +24,10 @@
#define kHeadersSz \
(sizeof(DosHeader) + sizeof(ExecHeader) + sizeof(ExecOptionalHeader))
+#ifdef __BUNDLE_KERNEL__
+EXTERN_C EFI_API void RuntimeMain(HEL::HandoverInformationHeader* HIH);
+#endif
+
EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
EfiSystemTable* SystemTable) {
InitEFI(SystemTable);
@@ -31,25 +35,41 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
BTextWriter writer;
+#ifdef __BUNDLE_KERNEL__
+ writer.WriteString(L"HCoreLite: ");
+#else
+ writer.WriteString(L"HCoreLdr:");
+#endif
+
#ifndef __DEBUG__
- writer.WriteString(L"HCoreLdr: Version 1.00 (Release Channel)\r\n");
+ writer.WriteString(L"Version 1.00 (Release Channel)\r\n");
#else
- writer.WriteString(L"HCoreLdr: Version 1.00 (Insiders Channel)\r\n");
+ writer.WriteString(L"Version 1.00 (Insiders Channel)\r\n");
#endif
const char strDate[] = __DATE__;
+#ifdef __BUNDLE_KERNEL__
+ writer.WriteString(L"HCoreLite: Build: ");
+#else
writer.WriteString(L"HCoreLdr: Build: ");
+#endif
for (auto& ch : strDate) writer.WriteCharacter(ch);
+#ifdef __BUNDLE_KERNEL__
+ writer.WriteString(L"\r\nHCoreLite: Firmware Vendor: ")
+ .WriteString(SystemTable->FirmwareVendor)
+ .WriteString(L"\r\n");
+#else
writer.WriteString(L"\r\nHCoreLdr: Firmware Vendor: ")
.WriteString(SystemTable->FirmwareVendor)
.WriteString(L"\r\n");
+#endif
BFileReader img(L"HCOREKRNL.EXE", ImageHandle);
@@ -75,7 +95,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
UInt32 SzDesc = 0;
UInt32 RevDesc = 0;
- if (BS->AllocatePool(EfiLoaderData, sizeof(UInt64), (VoidPtr*)&Size) !=
+ if (BS->AllocatePool(EfiLoaderData, sizeof(UInt32), (VoidPtr*)&Size) !=
kEfiOk) {
EFI::RaiseHardError(
L"HCoreLdr-BadAlloc",
@@ -108,7 +128,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
handoverHdrPtr->f_PhysicalStart =
reinterpret_cast<voidPtr>(Descriptor->PhysicalStart);
- handoverHdrPtr->f_PhysicalSize = Descriptor->NumberOfPages * kPTESize;
+ handoverHdrPtr->f_PhysicalSize = Descriptor->NumberOfPages;
handoverHdrPtr->f_VirtualStart =
reinterpret_cast<voidPtr>(Descriptor->VirtualStart);
@@ -123,10 +143,22 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
SystemTable->FirmwareVendor,
handoverHdrPtr->f_FirmwareVendorLen);
- writer.WriteString(L"HCoreLdr: Booting HCore...\r\n");
+#ifdef __BUNDLE_KERNEL__
+ writer.WriteString(L"HCoreLite: Exit Boot...").WriteString(L"\r\n");
+#else
+ writer.WriteString(L"HCoreLdr: Load File succeeded, running it...")
+ .WriteString(L"\r\n");
+#endif
EFI::ExitBootServices(MapKey, ImageHandle);
+#ifdef __BUNDLE_KERNEL__
+ RuntimeMain(handoverHdrPtr);
+#else
+ // Load HCoreKrnl.exe (TODO)
+
+#endif // ifdef __BUNDLE_KERNEL__
+
EFI::Stop();
return kEfiOk;
diff --git a/Private/NewBoot/Source/bundle.mk b/Private/NewBoot/Source/bundle.mk
new file mode 100644
index 00000000..c5a83ffb
--- /dev/null
+++ b/Private/NewBoot/Source/bundle.mk
@@ -0,0 +1,35 @@
+##################################################
+# ; (C) Mahrouss Logic, 2024, all rights reserved.
+# This is the bootloader makefile.
+##################################################
+
+CC_GNU=x86_64-w64-mingw32-g++
+LD_GNU=x86_64-w64-mingw32-ld
+LD_FLAGS=-e efi_main -shared --subsystem=10 -ffreestanding
+ASM=nasm
+OBJ=$(wildcard *.obj) $(wildcard *.o) $(wildcard ../../Obj/*.obj) $(wildcard HEL/AMD64/*.obj) $(wildcard HEL/AMD64/*.o)
+
+FLAG_ASM=-f win64
+FLAG_GNU=-fshort-wchar -O0 -D__BUNDLE_KERNEL__ -D__DEBUG__ -fPIC -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_HCORE_APIS__ -D__HCORE__ -I./ -I$(HOME)/
+
+.PHONY: invalid-recipe
+invalid-recipe:
+ @echo "invalid-recipe: Use make bootloader-<arch> all instead."
+
+.PHONY: bootloader-amd64
+bootloader-amd64:
+ $(CC_GNU) $(FLAG_GNU) HEL/AMD64/*.cxx *.cxx
+ $(ASM) $(FLAG_ASM) HEl/AMD64/AMD64-VirtualMemory.asm
+ $(LD_GNU) $(OBJ) $(LD_FLAGS) -o HCoreKrnl.exe
+ cp HCoreKrnl.exe CDROM/EFI/BOOT/BOOTX64.EFI
+ cp HCoreKrnl.exe CDROM/HCOREKRNL.EXE
+ cp ../../Root/System/LookAndFeel.css CDROM/LOOK.CSS
+
+.PHONY: run-efi-amd64
+run-efi-amd64:
+ wget https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd
+ qemu-system-x86_64 -net none -smp 2 -m 8G -M q35 -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -serial stdio
+
+.PHONY: clean
+clean:
+ rm -f $(OBJ) HCoreLdr.exe OVMF.fd
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/standard.mk
index fab7453d..fab7453d 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/standard.mk