diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-24 08:51:21 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-24 08:54:22 +0200 |
| commit | 4185fcc698e237225902646736c6b23f6b5e54be (patch) | |
| tree | 7b0fc0bb58cb20c61e676b13e3e0f7fd52c73a56 /dev/ZBA | |
| parent | b31d81cd939ed3e8bb5fade029b32876e71ed54c (diff) | |
[IMP+REFACTORS] See below.
+ Add SysChk driver instead of BootScr.
+ Working on AHCI driver, did progress on detection, need to find out
why the signature are set to zero.
+ Refactor PE loader structures.
Add BecomeBusMaster call when probing AHCI disk.
+ Alongside some other modifications.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZBA')
| -rw-r--r-- | dev/ZBA/Modules/SysChk/.hgkeep (renamed from dev/ZBA/Modules/BootScr/.hgkeep) | 0 | ||||
| -rw-r--r-- | dev/ZBA/Modules/SysChk/Boot.S (renamed from dev/ZBA/Modules/BootScr/Boot.S) | 0 | ||||
| -rw-r--r-- | dev/ZBA/Modules/SysChk/Module.cxx (renamed from dev/ZBA/Modules/BootScr/Module.cxx) | 0 | ||||
| -rw-r--r-- | dev/ZBA/Modules/SysChk/build.json (renamed from dev/ZBA/Modules/BootScr/build.json) | 2 | ||||
| -rw-r--r-- | dev/ZBA/Modules/SysChk/compile_flags.txt (renamed from dev/ZBA/Modules/BootScr/compile_flags.txt) | 0 | ||||
| -rw-r--r-- | dev/ZBA/Sources/HEL/AMD64/BootMain.cxx | 10 | ||||
| -rw-r--r-- | dev/ZBA/Sources/Thread.cxx | 30 | ||||
| -rw-r--r-- | dev/ZBA/amd64-efi.make | 11 |
8 files changed, 21 insertions, 32 deletions
diff --git a/dev/ZBA/Modules/BootScr/.hgkeep b/dev/ZBA/Modules/SysChk/.hgkeep index e69de29b..e69de29b 100644 --- a/dev/ZBA/Modules/BootScr/.hgkeep +++ b/dev/ZBA/Modules/SysChk/.hgkeep diff --git a/dev/ZBA/Modules/BootScr/Boot.S b/dev/ZBA/Modules/SysChk/Boot.S index ce9f36b1..ce9f36b1 100644 --- a/dev/ZBA/Modules/BootScr/Boot.S +++ b/dev/ZBA/Modules/SysChk/Boot.S diff --git a/dev/ZBA/Modules/BootScr/Module.cxx b/dev/ZBA/Modules/SysChk/Module.cxx index 15758599..15758599 100644 --- a/dev/ZBA/Modules/BootScr/Module.cxx +++ b/dev/ZBA/Modules/SysChk/Module.cxx diff --git a/dev/ZBA/Modules/BootScr/build.json b/dev/ZBA/Modules/SysChk/build.json index c53c6faa..aff1e78a 100644 --- a/dev/ZBA/Modules/BootScr/build.json +++ b/dev/ZBA/Modules/SysChk/build.json @@ -3,7 +3,7 @@ "compiler_std": "c++20", "headers_path": ["../", "../../", "../../../ZKA", "../../../", "./"], "sources_path": ["*.cxx", "*.S"], - "output_name": "bootscr.sys", + "output_name": "syschk.sys", "compiler_flags": [ "-ffreestanding", "-nostdlib", diff --git a/dev/ZBA/Modules/BootScr/compile_flags.txt b/dev/ZBA/Modules/SysChk/compile_flags.txt index 6ab76da0..6ab76da0 100644 --- a/dev/ZBA/Modules/BootScr/compile_flags.txt +++ b/dev/ZBA/Modules/SysChk/compile_flags.txt diff --git a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx index c5ee3fb3..c98f700c 100644 --- a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx +++ b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx @@ -226,8 +226,8 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, // format the disk. // ---------------------------------------------------- // - BFileReader readerBootScr(L"bootscr.sys", ImageHandle); - readerBootScr.ReadAll(0); + BFileReader readerSysChk(L"syschk.sys", ImageHandle); + readerSysChk.ReadAll(0); Boot::BThread* loaderBootScr = nullptr; @@ -235,10 +235,10 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, // If we succeed in reading the blob, then execute it. // ------------------------------------------ // - if (readerBootScr.Blob()) + if (readerSysChk.Blob()) { - loaderBootScr = new Boot::BThread(readerBootScr.Blob()); - loaderBootScr->SetName("64-bit Boot Screen DLL."); + loaderBootScr = new Boot::BThread(readerSysChk.Blob()); + loaderBootScr->SetName("64-bit System Check DLL."); } loaderBootScr->Start(handoverHdrPtr); diff --git a/dev/ZBA/Sources/Thread.cxx b/dev/ZBA/Sources/Thread.cxx index 58937213..610d45b8 100644 --- a/dev/ZBA/Sources/Thread.cxx +++ b/dev/ZBA/Sources/Thread.cxx @@ -12,34 +12,20 @@ #include <KernelKit/PEF.hxx> #include <KernelKit/PE.hxx> #include <KernelKit/MSDOS.hxx> -#include <Modules/CoreCG/TextRenderer.hxx> #include <CFKit/LoaderUtils.hxx> +#include <Modules/CoreCG/TextRenderer.hxx> + +#include <SIGG/Drv.hxx> EXTERN_C{ #include <string.h> } -// External boot services record. +// External boot services symbol. EXTERN EfiBootServices* BS; namespace Boot { - namespace Detail - { - /// @brief Instablle Secure Driver record. - struct SIGNED_DRIVER_HEADER final - { - // doesn't change. - char d_binary_magic[5]; - int d_binary_version; - // can change. - char d_binary_name[4096]; - UInt64 d_binary_checksum; - UInt64 d_binary_size; - char d_binary_padding[512]; - }; - } // namespace Detail - BThread::BThread(VoidPtr blob) : fBlob(blob), fStartAddress(nullptr) { @@ -57,8 +43,8 @@ namespace Boot if (firstBytes[0] == kMagMz0 && firstBytes[1] == kMagMz1) { - ExecHeaderPtr hdrPtr = ldr_find_exec_header(firstBytes); - ExecOptionalHeaderPtr optHdr = ldr_find_opt_exec_header(firstBytes); + LDR_EXEC_HEADER_PTR hdrPtr = ldr_find_exec_header(firstBytes); + LDR_OPTIONAL_HEADER_PTR optHdr = ldr_find_opt_exec_header(firstBytes); if (hdrPtr->mMachine != kPeMachineAMD64 || hdrPtr->mSignature != kPeMagic) @@ -93,7 +79,7 @@ namespace Boot auto numPages = optHdr->mSizeOfImage / cPageSize; BS->AllocatePages(AllocateAddress, EfiLoaderData, numPages, &loadStartAddress); - ExecSectionHeaderPtr sectPtr = (ExecSectionHeaderPtr)(((Char*)optHdr) + hdrPtr->mSizeOfOptionalHeader); + LDR_SECTION_HEADER_PTR sectPtr = (LDR_SECTION_HEADER_PTR)(((Char*)optHdr) + hdrPtr->mSizeOfOptionalHeader); constexpr auto sectionForCode = ".text"; constexpr auto sectionForNewLdr = ".ldr"; @@ -101,7 +87,7 @@ namespace Boot for (SizeT sectIndex = 0; sectIndex < numSecs; ++sectIndex) { - ExecSectionHeaderPtr sect = §Ptr[sectIndex]; + LDR_SECTION_HEADER_PTR sect = §Ptr[sectIndex]; if (StrCmp(sectionForCode, sect->mName) == 0) { diff --git a/dev/ZBA/amd64-efi.make b/dev/ZBA/amd64-efi.make index ef54c12c..f5c19801 100644 --- a/dev/ZBA/amd64-efi.make +++ b/dev/ZBA/amd64-efi.make @@ -32,8 +32,11 @@ IMG_3=epm-master-2.img EMU_FLAGS=-net none -smp 4 -m 8G -M q35 \ -bios $(BIOS) -device piix3-ide,id=ide \ -drive id=disk,file=$(IMG),format=raw,if=none \ - -device ide-hd,drive=disk,bus=ide.0 -hdd $(IMG_2) -drive \ - file=fat:rw:Sources/Root/,index=2,format=raw -d int + -device ide-hd,drive=disk,bus=ide.0 -drive \ + file=fat:rw:Sources/Root/,index=2,format=raw -d int \ + -drive id=disk_2,file=$(IMG_2),if=none \ + -device ahci,id=ahci \ + -device ide-hd,drive=disk_2,bus=ahci.0 LD_FLAGS=-e Main --subsystem=10 @@ -53,7 +56,7 @@ KERNEL=newoskrnl.dll DDK=ddk.dll SCI=sci.dll CRT=ndkcrt.dll -BOOT_SCR=bootscr.sys +SYS_CHK=syschk.sys .PHONY: invalid-recipe invalid-recipe: @@ -68,7 +71,7 @@ all: compile-amd64 $(COPY) ../ZKA/$(KERNEL) Sources/Root/$(KERNEL) $(COPY) ../SCI/$(SCI) Sources/Root/$(SCI) $(COPY) ../DDK/$(DDK) Sources/Root/$(DDK) - $(COPY) ./Modules/BootScr/$(BOOT_SCR) Sources/Root/$(BOOT_SCR) + $(COPY) ./Modules/SysChk/$(SYS_CHK) Sources/Root/$(SYS_CHK) $(COPY) ../CRT/$(CRT) Sources/Root/$(CRT) $(COPY) Sources/$(BOOT_LOADER) Sources/Root/$(BOOT_LOADER) |
