From b842e2d8e09189d527006ca5b3dec58128afe953 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 24 Feb 2024 10:37:20 +0100 Subject: Kernel: :boom: Fixing stuff due to misguided efforts. Signed-off-by: Amlal El Mahrouss --- Private/NewBoot/BootKit/BootKit.hxx | 1 + Private/NewBoot/Source/BootMain.cxx | 11 +++++++++-- Private/NewBoot/Source/TextWriter.cxx | 20 ++++++++++++++++++++ Private/NewBoot/Source/bundle.mk | 3 +-- Private/NewBoot/Source/standard.mk | 1 + Private/Source/KernelCheck.cxx | 2 +- Private/Source/KernelMain.cxx | 4 ++-- 7 files changed, 35 insertions(+), 7 deletions(-) (limited to 'Private') diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx index 093b20dc..5128d02f 100644 --- a/Private/NewBoot/BootKit/BootKit.hxx +++ b/Private/NewBoot/BootKit/BootKit.hxx @@ -41,6 +41,7 @@ typedef WideChar CharacterType; */ class BTextWriter final { public: + BTextWriter &WriteString(const Long &num); BTextWriter &WriteString(const CharacterType *str); BTextWriter &WriteCharacter(CharacterType c); diff --git a/Private/NewBoot/Source/BootMain.cxx b/Private/NewBoot/Source/BootMain.cxx index ea83e1f4..73ca1364 100644 --- a/Private/NewBoot/Source/BootMain.cxx +++ b/Private/NewBoot/Source/BootMain.cxx @@ -72,7 +72,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, .WriteString(L"\r\n"); #endif - BFileReader img(L"HCOREKRNL.EXE", ImageHandle); + BFileReader img(L"HCOREKRNL.DLL", ImageHandle); img.Size(kHeadersSz); img.ReadAll(); @@ -90,6 +90,13 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, ExecOptionalHeaderPtr optHdr = reinterpret_cast( ptrHdr + sizeof(ExecHeader)); + if (optHdr->mSubsystem != 0xAFAF) { + writer.WriteString(L"HCoreLdr: This is not an HCore app: Subsystem: ") + .WriteString(optHdr->mSubsystem) + .WriteString(L"\r\n"); + EFI::Stop(); + } + UInt32 MapKey = 0; UInt32* Size; EfiMemoryDescriptor* Descriptor; @@ -157,7 +164,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, #ifdef __BUNDLE_KERNEL__ RuntimeMain(handoverHdrPtr); #else - // Load HCoreKrnl.exe (TODO) + // Load HCoreKrnl.dll (TODO) #endif // ifdef __BUNDLE_KERNEL__ diff --git a/Private/NewBoot/Source/TextWriter.cxx b/Private/NewBoot/Source/TextWriter.cxx index 0ea3a972..fe058aa4 100644 --- a/Private/NewBoot/Source/TextWriter.cxx +++ b/Private/NewBoot/Source/TextWriter.cxx @@ -40,3 +40,23 @@ BTextWriter &BTextWriter::WriteCharacter(CharacterType c) { return *this; } + +BTextWriter &BTextWriter::WriteString(const Long &x) { + int y = x / 16; + int h = x % 16; + + if (y) this->WriteString(y); + + /* fail if the hex number is not base-16 */ + if (h > 15) { + this->WriteCharacter('?'); + return *this; + } + + if (y < 0) y = -y; + + const char g_numbers[17] = "0123456789ABCDEF"; + + this->WriteCharacter(g_numbers[h]); + return *this; +} diff --git a/Private/NewBoot/Source/bundle.mk b/Private/NewBoot/Source/bundle.mk index 3f1df9e0..e0894f94 100644 --- a/Private/NewBoot/Source/bundle.mk +++ b/Private/NewBoot/Source/bundle.mk @@ -22,8 +22,7 @@ bootloader-amd64: $(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.DLL - cp ../../Root/System/LookAndFeel.css CDROM/LOOK.CSS + cp ../../HCoreKrnl.dll CDROM/HCOREKRNL.DLL .PHONY: run-efi-amd64 run-efi-amd64: diff --git a/Private/NewBoot/Source/standard.mk b/Private/NewBoot/Source/standard.mk index 2ca70592..1177a437 100644 --- a/Private/NewBoot/Source/standard.mk +++ b/Private/NewBoot/Source/standard.mk @@ -22,6 +22,7 @@ bootloader-amd64: $(ASM) $(FLAG_ASM) HEl/AMD64/AMD64-VirtualMemory.asm $(LD_GNU) $(OBJ) $(LD_FLAGS) -o HCoreLdr.exe cp HCoreLdr.exe CDROM/EFI/BOOT/BOOTX64.EFI + cp ../../HCoreKrnl.dll CDROM/HCOREKRNL.DLL .PHONY: run-efi-amd64 run-efi-amd64: diff --git a/Private/Source/KernelCheck.cxx b/Private/Source/KernelCheck.cxx index 4fc24918..6ce4f4fa 100644 --- a/Private/Source/KernelCheck.cxx +++ b/Private/Source/KernelCheck.cxx @@ -25,7 +25,7 @@ extern "C" [[noreturn]] void ke_wait_for_debugger() { namespace HCore { void ke_stop(const HCore::Int &id) { kcout << "*** STOP *** \r\n"; - kcout << "*** HCoreKrnl.exe has trigerred a runtime stop. *** \r\n"; + kcout << "*** HCoreKrnl.dll has trigerred a runtime stop. *** \r\n"; switch (id) { case RUNTIME_CHECK_PROCESS: { diff --git a/Private/Source/KernelMain.cxx b/Private/Source/KernelMain.cxx index 6050c95f..e1fba478 100644 --- a/Private/Source/KernelMain.cxx +++ b/Private/Source/KernelMain.cxx @@ -35,7 +35,7 @@ EXTERN_C void RuntimeMain( HCore::IFilesystemManager::Mount(new HCore::NewFilesystemManager()); // Open file from first hard-drive. - HCore::PEFLoader img("A:/System/HCoreShell.exe"); + HCore::PEFLoader img("A:/System/HCoreServer.exe"); /// Run the shell. if (!HCore::Utils::execute_from_image(img)) { @@ -43,6 +43,6 @@ EXTERN_C void RuntimeMain( } } else { HCore::kcout << "HCoreKrnl: Setup is starting...\n"; - HCore::kcout << "HCoreKrnl: Mounting drive A:...\n"; + HCore::kcout << "HCoreKrnl: Mounting drive A: ...\n"; } } -- cgit v1.2.3