diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Private/NewBoot/Source/CDROM/SplashScreen.fmt | 2 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootMain.cxx | 72 | ||||
| -rw-r--r-- | Private/NewBoot/Source/makefile | 1 | ||||
| -rw-r--r-- | Private/NewLoader/ReadMe.md | 7 | ||||
| -rw-r--r-- | Private/makefile | 2 |
6 files changed, 53 insertions, 33 deletions
@@ -11,6 +11,8 @@ build.ninja cmake_install.cmake qtcsettings.cmake +*.exec + LOOK.CSS x86_64/ diff --git a/Private/NewBoot/Source/CDROM/SplashScreen.fmt b/Private/NewBoot/Source/CDROM/SplashScreen.fmt index e47a66a6..a3dba676 100644 --- a/Private/NewBoot/Source/CDROM/SplashScreen.fmt +++ b/Private/NewBoot/Source/CDROM/SplashScreen.fmt @@ -1,4 +1,4 @@ -Welcome to NeWS +Welcome to the NeWS. Brought to you by: * MicroKernel, Bootloader: Amlal EL Mahrouss. diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx index c4e741a4..1f140f7e 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx @@ -9,7 +9,7 @@ #include <Builtins/Toolbox/Lerp.hxx> #include <Builtins/Toolbox/Toolbox.hxx> #include <KernelKit/MSDOS.hpp> -#include <KernelKit/PE.hxx> +#include <KernelKit/PEF.hpp> #include <NewKit/Ref.hpp> /** Graphics related. */ @@ -154,42 +154,54 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, BFileReader reader(L"SplashScreen.fmt", ImageHandle); reader.ReadAll(512, 16); - Char* buf = (Char*)reader.Blob(); - - for (SizeT i = 0; i < reader.Size(); ++i) { - if (buf[i] != '\n' && buf[i] != '\r') { - if (buf[i] == '*') { - writer.WriteCharacter('\t'); - } else { - writer.WriteCharacter(buf[i]); - } - } else - writer.Write(L"\r\n"); + if (reader.Blob()) { + Char* buf = (Char*)reader.Blob(); + + for (SizeT i = 0; i < reader.Size(); ++i) { + if (buf[i] != '\n' && buf[i] != '\r') { + if (buf[i] == '*') { + writer.WriteCharacter('\t'); + } else { + writer.WriteCharacter(buf[i]); + } + } else + writer.Write(L"\r\n"); + } } - BFileReader kernelFile(L"NewKernel.exe", ImageHandle); - kernelFile.ReadAll(KIB(512), 4096); - - ExecOptionalHeaderPtr headerKind = (ExecOptionalHeaderPtr)rt_find_exec_header( - (DosHeaderPtr)kernelFile.Blob()); + BFileReader kernelFile(L"NewLoader.exe", ImageHandle); + kernelFile.ReadAll(MIB(1), 4096); + + if (kernelFile.Blob()) { + PEFContainer* headerKind = + reinterpret_cast<PEFContainer*>(kernelFile.Blob()); + + if (headerKind->Magic[0] == kPefMagic[0] && + headerKind->Magic[1] == kPefMagic[1] && + headerKind->Magic[2] == kPefMagic[2] && + headerKind->Magic[3] == kPefMagic[3] && + headerKind->Magic[4] == kPefMagic[4]) { + if (headerKind->Abi != kPefAbi || headerKind->Cpu != kPefArchAMD64) { + EFI::RaiseHardError(L"Bad-Architecture", + L"New Boot can't run this architecture."); + } - if (!headerKind) { - EFI::RaiseHardError(L"Bad-Exec", - L"New Boot can't recognize this executable."); - } + BootMainKind main = (BootMainKind) nullptr; - BootMainKind main = (BootMainKind) nullptr; + if (!main) { + EFI::RaiseHardError(L"Bad-Exec", + L"New Boot can't recognize this executable."); + } - if (!main) { - EFI::RaiseHardError(L"Bad-Exec", - L"New Boot can't recognize this executable."); - } + EFI::ExitBootServices(MapKey, ImageHandle); - EFI::ExitBootServices(MapKey, ImageHandle); + main(handoverHdrPtr); - main(handoverHdrPtr); + EFI::Stop(); - EFI::Stop(); + CANT_REACH(); + } + } - CANT_REACH(); + return kEfiFail; } diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile index 6fb945ff..224c352e 100644 --- a/Private/NewBoot/Source/makefile +++ b/Private/NewBoot/Source/makefile @@ -52,7 +52,6 @@ all: compile-amd64 $(COPY) $(BOOT_LOADER) CDROM/EFI/BOOT/BOOTX64.EFI $(COPY) $(BOOT_LOADER) CDROM/EFI/BOOT/NEWBOOT.EFI $(COPY) $(BOOT_LOADER) ../../Root/Boot/$(BOOT_LOADER) - $(COPY) ../../$(KERNEL) CDROM/$(KERNEL) ifneq ($(DEBUG_SUPPORT), ) DEBUG = -D__DEBUG__ diff --git a/Private/NewLoader/ReadMe.md b/Private/NewLoader/ReadMe.md new file mode 100644 index 00000000..28e07c54 --- /dev/null +++ b/Private/NewLoader/ReadMe.md @@ -0,0 +1,7 @@ +# NewOS Loader + +Loads and runs the NewKernel and it's components. + +- Loads: NewKernel.exe (PE) +- Loads: Bonjour.exec (PEF) +- Loads: MahroussUpdate.exec (PEF) diff --git a/Private/makefile b/Private/makefile index 37960c43..41f70c81 100644 --- a/Private/makefile +++ b/Private/makefile @@ -5,7 +5,7 @@ CC = x86_64-w64-mingw32-gcc LD = x86_64-w64-mingw32-ld -CCFLAGS = -c -ffreestanding -D__NEWOS_AMD64__ -mno-red-zone -fno-rtti -fno-exceptions -std=c++20 -D__FSKIT_NEWFS__ -D__KERNEL__ -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -I../ -I./ +CCFLAGS = -c -ffreestanding -fPIE -fPIC -D__NEWOS_AMD64__ -mno-red-zone -fno-rtti -fno-exceptions -std=c++20 -D__FSKIT_NEWFS__ -D__KERNEL__ -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -I../ -I./ ASM = nasm ifneq ($(ATA_PIO_SUPPORT), ) |
