diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-09-04 12:56:23 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-09-04 12:56:23 +0200 |
| commit | a0a90c80e5dd17df8f609aebc253b4bf9147f90f (patch) | |
| tree | 459f98ea125db490e887bd85b38fd9165a9491b4 /dev/ZBA | |
| parent | cc9ce57cac59bd443e2319e3b8f427172b93f7da (diff) | |
Created a new branch for the overhaul project.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZBA')
| -rw-r--r-- | dev/ZBA/Modules/NetBoot/build.json | 2 | ||||
| -rw-r--r-- | dev/ZBA/Modules/SysChk/Module.cxx | 2 | ||||
| -rw-r--r-- | dev/ZBA/Modules/SysChk/build.json | 2 | ||||
| -rw-r--r-- | dev/ZBA/Sources/HEL/AMD64/BootAPI.S (renamed from dev/ZBA/Sources/HEL/AMD64/BootJump.S) | 6 | ||||
| -rw-r--r-- | dev/ZBA/Sources/HEL/AMD64/BootMain.cxx | 77 | ||||
| -rw-r--r-- | dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx | 8 | ||||
| -rw-r--r-- | dev/ZBA/Sources/Thread.cxx | 2 | ||||
| -rw-r--r-- | dev/ZBA/amd64-efi.make | 2 |
8 files changed, 56 insertions, 45 deletions
diff --git a/dev/ZBA/Modules/NetBoot/build.json b/dev/ZBA/Modules/NetBoot/build.json index 78336241..c24966d9 100644 --- a/dev/ZBA/Modules/NetBoot/build.json +++ b/dev/ZBA/Modules/NetBoot/build.json @@ -11,7 +11,7 @@ "-fPIC", "-fno-rtti", "-fno-exceptions", - "-Wl,--subsystem=17,--image-base 0x10000000" + "-Wl,--subsystem=17,--image-base,0x1000000" ], "cpp_macros": [ "__NEWOSKRNL__", diff --git a/dev/ZBA/Modules/SysChk/Module.cxx b/dev/ZBA/Modules/SysChk/Module.cxx index 9bc3425c..7bf7fb62 100644 --- a/dev/ZBA/Modules/SysChk/Module.cxx +++ b/dev/ZBA/Modules/SysChk/Module.cxx @@ -15,7 +15,7 @@ EXTERN_C Int32 ModuleMain(Kernel::HEL::HandoverInformationHeader* Handover) cST->ConOut->ClearScreen(cST->ConOut); - cST->ConOut->OutputString(cST->ConOut, L"SYSCHK: CHECKING FOR VALID NEWFS OR EXT4 PARTITIONS...\r\n"); + cST->ConOut->OutputString(cST->ConOut, L"SYSCHK: CHECKING FOR VALID NEWFS OR HPFS PARTITIONS...\r\n"); cST->ConOut->OutputString(cST->ConOut, L"SYSCHK: GOOD TO GO!\r\n"); return kEfiOk; diff --git a/dev/ZBA/Modules/SysChk/build.json b/dev/ZBA/Modules/SysChk/build.json index 67e22955..dac413e0 100644 --- a/dev/ZBA/Modules/SysChk/build.json +++ b/dev/ZBA/Modules/SysChk/build.json @@ -11,7 +11,7 @@ "-fPIC", "-fno-rtti", "-fno-exceptions", - "-Wl,--subsystem=17,--image-base,0x10000000,-e,ModuleMain" + "-Wl,--subsystem=17,--image-base,0x1000000,-e,ModuleMain" ], "cpp_macros": [ "__NEWOSKRNL__", diff --git a/dev/ZBA/Sources/HEL/AMD64/BootJump.S b/dev/ZBA/Sources/HEL/AMD64/BootAPI.S index d8e09d4e..e391351d 100644 --- a/dev/ZBA/Sources/HEL/AMD64/BootJump.S +++ b/dev/ZBA/Sources/HEL/AMD64/BootAPI.S @@ -39,3 +39,9 @@ wait_gate2: mov cr4,rax reset_wait: jmp reset_wait + +.global write_cr3 + +write_cr3: + mov cr3, rcx + ret
\ No newline at end of file diff --git a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx index 576ada08..55f10ea2 100644 --- a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx +++ b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx @@ -79,6 +79,8 @@ STATIC Bool CheckBootDevice(BootDeviceATA& ataDev) return true; } +EXTERN_C Void write_cr3(VoidPtr new_cr3); + /// @brief Main EFI entrypoint. /// @param ImageHandle Handle of this image. /// @param SystemTable The system table of it. @@ -186,17 +188,45 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, handoverHdrPtr->f_FirmwareSpecific[HEL::kHandoverSpecificMemoryEfi] = (UIntPtr)Descriptor; - handoverHdrPtr->f_VirtualStart = - (VoidPtr)Descriptor[cDefaultMemoryMap].VirtualStart; + handoverHdrPtr->f_BitMapStart = 0; - handoverHdrPtr->f_HeapStart = 0; + while (BS->AllocatePool(EfiRuntimeServicesData, kHandoverHeapSz, &handoverHdrPtr->f_BitMapStart) != kEfiOk) + ; - while (BS->AllocatePool(EfiLoaderData, kHandoverHeapSz, &handoverHdrPtr->f_HeapStart) != kEfiOk) + auto extended_heap = (VoidPtr)((UIntPtr)handoverHdrPtr->f_BitMapStart + kHandoverHeapSz); + + while (BS->AllocatePool(EfiRuntimeServicesData, kHandoverHeapSz, &extended_heap) != kEfiOk) ; handoverHdrPtr->f_VirtualSize = Descriptor[cDefaultMemoryMap].NumberOfPages; /* # of pages */ + + handoverHdrPtr->f_FirmwareCustomTables[0] = (VoidPtr)BS; + handoverHdrPtr->f_FirmwareCustomTables[1] = (VoidPtr)ST; + + BFileReader readerSysChk(L"syschk.sys", ImageHandle); + readerSysChk.ReadAll(0); + + Boot::BThread* loaderSysChk = nullptr; + + // ------------------------------------------ // + // If we succeed in reading the blob, then execute it. + // ------------------------------------------ // + + if (readerSysChk.Blob()) + { + loaderSysChk = new Boot::BThread(readerSysChk.Blob()); + loaderSysChk->SetName("System Check SYS."); + } + + loaderSysChk->Start(handoverHdrPtr); + + // nullify these fields, to avoid being reused later. + + handoverHdrPtr->f_FirmwareCustomTables[0] = nullptr; + handoverHdrPtr->f_FirmwareCustomTables[1] = nullptr; + handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor); handoverHdrPtr->f_Magic = kHandoverMagic; @@ -213,6 +243,12 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, BDiskFormatFactory<BootDeviceATA> checkPart; + // ---------------------------------------------------- // + // The following checks for an exisiting partition + // inside the disk, if it doesn't have one, + // format the disk. + // ---------------------------------------------------- // + if (!checkPart.IsPartitionValid()) { BDiskFormatFactory<BootDeviceATA>::BFileDescriptor root; @@ -226,37 +262,6 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, rt_reset_hardware(); } - // ---------------------------------------------------- // - // The following checks for an exisiting partition - // inside the disk, if it doesn't have one, - // format the disk. - // ---------------------------------------------------- // - - handoverHdrPtr->f_FirmwareCustomTables[0] = (VoidPtr)BS; - handoverHdrPtr->f_FirmwareCustomTables[1] = (VoidPtr)ST; - - BFileReader readerSysChk(L"syschk.sys", ImageHandle); - readerSysChk.ReadAll(0); - - Boot::BThread* loaderSysChk = nullptr; - - // ------------------------------------------ // - // If we succeed in reading the blob, then execute it. - // ------------------------------------------ // - - if (readerSysChk.Blob()) - { - loaderSysChk = new Boot::BThread(readerSysChk.Blob()); - loaderSysChk->SetName("64-bit System Check DLL."); - } - - loaderSysChk->Start(handoverHdrPtr); - - // nullify these fields, to avoid being reused later. - - handoverHdrPtr->f_FirmwareCustomTables[0] = nullptr; - handoverHdrPtr->f_FirmwareCustomTables[1] = nullptr; - BFileReader readerKernel(L"newoskrnl.exe", ImageHandle); readerKernel.ReadAll(0); @@ -270,7 +275,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, if (readerKernel.Blob()) { loader = new Boot::BThread(readerKernel.Blob()); - loader->SetName("64-bit Kernel DLL."); + loader->SetName("64-Bit Kernel EXE."); handoverHdrPtr->f_KernelImage = readerKernel.Blob(); } diff --git a/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx b/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx index 467f4303..65ea3d89 100644 --- a/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx +++ b/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx @@ -25,7 +25,7 @@ */ BTextWriter& BTextWriter::Write(const CharacterTypeUTF16* str) { -#ifdef __DEBUG__ +#ifdef __DEBUG_OUTPUT__ if (!str || *str == 0) return *this; @@ -57,7 +57,7 @@ BTextWriter& BTextWriter::Write(const CharacterTypeUTF16* str) /// @param str the input string. BTextWriter& BTextWriter::Write(const Char* str) { -#ifdef __DEBUG__ +#ifdef __DEBUG_OUTPUT__ if (!str || *str == 0) return *this; @@ -87,7 +87,7 @@ BTextWriter& BTextWriter::Write(const Char* str) BTextWriter& BTextWriter::Write(const UChar* str) { -#ifdef __DEBUG__ +#ifdef __DEBUG_OUTPUT__ if (!str || *str == 0) return *this; @@ -120,7 +120,7 @@ BTextWriter& BTextWriter::Write(const UChar* str) */ BTextWriter& BTextWriter::WriteCharacter(CharacterTypeUTF16 c) { -#ifdef __DEBUG__ +#ifdef __DEBUG_OUTPUT__ EfiCharType str[2]; str[0] = c; diff --git a/dev/ZBA/Sources/Thread.cxx b/dev/ZBA/Sources/Thread.cxx index 1ea83618..13b02b92 100644 --- a/dev/ZBA/Sources/Thread.cxx +++ b/dev/ZBA/Sources/Thread.cxx @@ -165,7 +165,7 @@ namespace Boot err_fn(handover); } - rt_jump_to_address(fStartAddress, handover); + reinterpret_cast<HEL::HandoverProc>(fStartAddress)(handover); } const Char* BThread::GetName() diff --git a/dev/ZBA/amd64-efi.make b/dev/ZBA/amd64-efi.make index d75f2aaf..55ce3f1c 100644 --- a/dev/ZBA/amd64-efi.make +++ b/dev/ZBA/amd64-efi.make @@ -36,7 +36,7 @@ EMU_FLAGS=-net none -m 8G -M q35 -cpu qemu64 \ file=fat:rw:Sources/Root/,index=2,format=raw \ -drive id=disk_2,file=$(IMG_2),if=none \ -device ahci,id=ahci \ - -device ide-hd,drive=disk_2,bus=ahci.0 -d int + -device ide-hd,drive=disk_2,bus=ahci.0 -d int -no-reboot -no-shutdown LD_FLAGS=-e Main --subsystem=10 |
