From 64fa0db684db306766280593b0a9717132e636d4 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Wed, 7 Aug 2024 22:55:34 +0200 Subject: [IMP] - Updated the PEF header for NDK. - Adding ICL parser for SCM (ToDo) - Updated extensions of PEF. - Updated start address for exes in PEF. Signed-off-by: Amlal EL Mahrouss --- Boot/Sources/HEL/AMD64/BootMain.cxx | 4 +-- Boot/Sources/Root/bootloader.json | 2 +- Boot/amd64-efi.make | 8 ++--- DDKit/build.json | 2 +- DDKit/x86_64.make | 2 +- Kernel/KernelKit/PEF.hxx | 14 ++++---- Kernel/KernelRsrc.rsrc | 2 +- Kernel/Linker/16x0.json | 2 +- Kernel/Linker/32x0.json | 2 +- Kernel/Linker/64x0.json | 2 +- Kernel/Linker/arm64.json | 2 +- Kernel/Sources/KernelCheck.cxx | 2 +- Kernel/amd64-efi.make | 2 +- Kernel/arm64-efi.make | 2 +- SCIKit/SCIBase.hxx | 2 +- SCIKit/SCM.drawio | 16 ++------- SCIKit/build.json | 2 +- SCIKit/makefile | 2 +- SCIKit/rtl.internal.inl | 67 ------------------------------------- SCIKit/scm.iclparser.inl | 18 ++++++++++ SCIKit/scm.internal.inl | 67 +++++++++++++++++++++++++++++++++++++ 21 files changed, 115 insertions(+), 107 deletions(-) delete mode 100644 SCIKit/rtl.internal.inl create mode 100644 SCIKit/scm.iclparser.inl create mode 100644 SCIKit/scm.internal.inl diff --git a/Boot/Sources/HEL/AMD64/BootMain.cxx b/Boot/Sources/HEL/AMD64/BootMain.cxx index d2a478c6..2bc2aca1 100644 --- a/Boot/Sources/HEL/AMD64/BootMain.cxx +++ b/Boot/Sources/HEL/AMD64/BootMain.cxx @@ -201,7 +201,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, // format the disk. // ---------------------------------------------------- // - BFileReader readerKernel(L"newoskrnl.lib", ImageHandle); + BFileReader readerKernel(L"newoskrnl.dll", ImageHandle); readerKernel.ReadAll(0); @@ -214,7 +214,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, if (readerKernel.Blob()) { loader = new Boot::ProgramLoader(readerKernel.Blob()); - loader->SetName("\"newoskrnl.lib\" (64-bit SMP DLL)"); + loader->SetName("\"newoskrnl.dll\" (64-bit SMP DLL)"); } writer.Write("newosldr: Running: ").Write(loader->GetName()).Write("\r"); diff --git a/Boot/Sources/Root/bootloader.json b/Boot/Sources/Root/bootloader.json index 51cb36b5..fe1a57d4 100644 --- a/Boot/Sources/Root/bootloader.json +++ b/Boot/Sources/Root/bootloader.json @@ -1,4 +1,4 @@ { - "newoskrnl.lib": "kernel", + "newoskrnl.dll": "kernel", "ZETA/fonts.json": "rsrc" } diff --git a/Boot/amd64-efi.make b/Boot/amd64-efi.make index a0bec415..12bd4941 100644 --- a/Boot/amd64-efi.make +++ b/Boot/amd64-efi.make @@ -50,9 +50,9 @@ FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mno-red-zone -D__NEWOSKRNL__ -D__NEWOSL -std=c++20 -D__HAVE_MAHROUSS_APIS__ -D__NEWOS_AMD64__ -D__MAHROUSS__ -D__BOOTLOADER__ -I../ BOOT_LOADER=newosldr.exe -KERNEL=newoskrnl.lib -DDK=libDDK.lib -SCI=libSCI.lib +KERNEL=newoskrnl.dll +DDK=libDDK.dll +SCI=libSCI.dll .PHONY: invalid-recipe invalid-recipe: @@ -97,7 +97,7 @@ download-edk: $(HTTP_GET) https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd BINS=*.bin -EXECUTABLES=newosldr.exe newoskrnl.lib OVMF.fd +EXECUTABLES=newosldr.exe newoskrnl.dll OVMF.fd TARGETS=$(REM_FLAG) $(OBJ) $(BIN) $(IMG) $(IMG_2) $(EXECUTABLES) diff --git a/DDKit/build.json b/DDKit/build.json index 8fbde6ac..bfa2b829 100644 --- a/DDKit/build.json +++ b/DDKit/build.json @@ -3,7 +3,7 @@ "compiler_std": "c++20", "headers_path": ["../", "./"], "sources_path": ["*.c", "*.cxx", "*.S"], - "output_name": "libDDK.lib", + "output_name": "libDDK.dll", "compiler_flags": ["-ffreestanding", "-shared", "-std=c17", "-std=c++20", "-fno-rtti", "-fno-exceptions", " -Wl,--subsystem=17"], "cpp_macros": ["__NEWOSKRNL__", "__DDK_AMD64__", "cDDKVersionHighest=1", "cDDKVersionLowest=1"] } diff --git a/DDKit/x86_64.make b/DDKit/x86_64.make index 4e641acd..b79d74f0 100644 --- a/DDKit/x86_64.make +++ b/DDKit/x86_64.make @@ -7,7 +7,7 @@ CC=x86_64-w64-mingw32-gcc INC=-I./ -I../ FLAGS=-ffreestanding -shared -std=c17 -std=c++20 -D__NEWOSKRNL__ -fno-rtti -fno-exceptions -D__DDK_AMD64__ -Wl,--subsystem=17 VERSION=-DcDDKVersionLowest=1 -DcDDKVersionHighest=1 -OUTPUT=libDDK.lib +OUTPUT=libDDK.dll .PHONY: x86_64-build x86_64-build: diff --git a/Kernel/KernelKit/PEF.hxx b/Kernel/KernelKit/PEF.hxx index b560c572..70320103 100644 --- a/Kernel/KernelKit/PEF.hxx +++ b/Kernel/KernelKit/PEF.hxx @@ -23,7 +23,7 @@ #define kPefMagicLen 5 -#define kPefVersion 1 +#define kPefVersion 3 #define kPefNameLen 255 namespace Kernel @@ -96,16 +96,18 @@ namespace Kernel } // namespace Kernel /* not mandatory, only for non fork based filesystems */ -#define kPefExt ".exec" -#define kPefDylibExt ".lib" -#define kPefLibExt ".slib" +#define kPefExt ".exe" +#define kPefDylibExt ".dll" +#define kPefLibExt ".lib" #define kPefObjectExt ".obj" #define kPefDebugExt ".dbg" // Kernel System Binary Interface. -#define kPefAbi (0x5046) +#define kPefAbi (0x5046) -#define kPefStart "__ImageStart" +#define kPefBaseOrigin (0x40000000) + +#define kPefStart "__ImageStart" #define kPefForkKind kPefMagic #define kPefForkKindFAT kPefMagicFat diff --git a/Kernel/KernelRsrc.rsrc b/Kernel/KernelRsrc.rsrc index f7b42292..4cf7e352 100644 --- a/Kernel/KernelRsrc.rsrc +++ b/Kernel/KernelRsrc.rsrc @@ -15,7 +15,7 @@ BEGIN VALUE "FileVersion", KERNEL_VERSION VALUE "InternalName", "newoskrnl" VALUE "LegalCopyright", "(c) ZKA Technologies, all rights reserved." - VALUE "OriginalFilename", "newoskrnl.lib" + VALUE "OriginalFilename", "newoskrnl.dll" VALUE "ProductName", "newoskrnl" VALUE "ProductVersion", KERNEL_VERSION END diff --git a/Kernel/Linker/16x0.json b/Kernel/Linker/16x0.json index 1f769a4c..9c284b53 100644 --- a/Kernel/Linker/16x0.json +++ b/Kernel/Linker/16x0.json @@ -1,7 +1,7 @@ { "linker": "link.exe", "executable_type": "kernel", - "output_name": "newoskrnl.lib", + "output_name": "newoskrnl.dll", "start_proc": "__ImageStart", "arch": "16x0", "format": "PEF" diff --git a/Kernel/Linker/32x0.json b/Kernel/Linker/32x0.json index a78a1090..05a3db9b 100644 --- a/Kernel/Linker/32x0.json +++ b/Kernel/Linker/32x0.json @@ -1,7 +1,7 @@ { "linker": "link.exe", "executable_type": "kernel", - "output_name": "newoskrnl.lib", + "output_name": "newoskrnl.dll", "start_proc": "__ImageStart", "arch": "32x0", "format": "PEF" diff --git a/Kernel/Linker/64x0.json b/Kernel/Linker/64x0.json index b9b9a34e..c1d0e388 100644 --- a/Kernel/Linker/64x0.json +++ b/Kernel/Linker/64x0.json @@ -1,7 +1,7 @@ { "linker": "link.exe", "executable_type": "kernel", - "output_name": "newoskrnl.lib", + "output_name": "newoskrnl.dll", "start_proc": "__ImageStart", "arch": "64x0", "format": "PEF" diff --git a/Kernel/Linker/arm64.json b/Kernel/Linker/arm64.json index 2e75f9fd..99c190bf 100644 --- a/Kernel/Linker/arm64.json +++ b/Kernel/Linker/arm64.json @@ -1,7 +1,7 @@ { "linker": "link.exe", "executable_type": "kernel", - "output_name": "newoskrnl.lib", + "output_name": "newoskrnl.dll", "start_proc": "__ImageStart", "arch": "arm64", "format": "PEF" diff --git a/Kernel/Sources/KernelCheck.cxx b/Kernel/Sources/KernelCheck.cxx index cd8e8ef9..b9843cd0 100644 --- a/Kernel/Sources/KernelCheck.cxx +++ b/Kernel/Sources/KernelCheck.cxx @@ -40,7 +40,7 @@ namespace Kernel auto start_y = 10; auto x = 10; - cg_write_text("*** Kernel panic! ***\rnewoskrnl.lib stopped working properly so we had to shut it down.", start_y, x, panicTxt); + cg_write_text("*** Kernel panic! ***\rnewoskrnl.dll stopped working properly so we had to shut it down.", start_y, x, panicTxt); CGFini(); diff --git a/Kernel/amd64-efi.make b/Kernel/amd64-efi.make index e233ebdc..52532223 100644 --- a/Kernel/amd64-efi.make +++ b/Kernel/amd64-efi.make @@ -39,7 +39,7 @@ LDFLAGS = -e ke_startup_platform --subsystem=17 --image-base 0x10000000 LDOBJ = Objects/*.obj # This file is the kernel, responsible of task management and memory. -KERNEL = newoskrnl.lib +KERNEL = newoskrnl.dll .PHONY: error error: diff --git a/Kernel/arm64-efi.make b/Kernel/arm64-efi.make index 92324d46..410e7789 100644 --- a/Kernel/arm64-efi.make +++ b/Kernel/arm64-efi.make @@ -27,7 +27,7 @@ LDFLAGS = -subsystem:efi_application -entry:hal_init_platform /nodefaultlib LDOBJ = Objects/*.obj # This file is the kernel, responsible of task management and memory. -KERNEL = newoskrnl.lib +KERNEL = newoskrnl.dll .PHONY: error error: diff --git a/SCIKit/SCIBase.hxx b/SCIKit/SCIBase.hxx index b084a17b..e8208c49 100644 --- a/SCIKit/SCIBase.hxx +++ b/SCIKit/SCIBase.hxx @@ -52,7 +52,7 @@ inline constexpr auto cLPCCloseMsgSyscall = 0x27; inline constexpr auto cLPCSanitizeMsgSyscall = 0x28; #ifdef __NEWOS_SYMS__ -#include +#include #else class UnknownInterface; // Refrenced from an IDB entry. class UnknownUCLSID; // From the IDB, the constructor of the object, e.g: WordUCLSID. diff --git a/SCIKit/SCM.drawio b/SCIKit/SCM.drawio index 56974466..978ebb6d 100644 --- a/SCIKit/SCM.drawio +++ b/SCIKit/SCM.drawio @@ -1,15 +1,9 @@ - + - - - - - - @@ -19,20 +13,14 @@ - - - - - - - + diff --git a/SCIKit/build.json b/SCIKit/build.json index 91e64384..770d1622 100644 --- a/SCIKit/build.json +++ b/SCIKit/build.json @@ -3,7 +3,7 @@ "compiler_std": "c++20", "headers_path": ["../"], "sources_path": ["*.cxx"], - "output_name": "libSCI.lib", + "output_name": "libSCI.dll", "compiler_flags": ["-fPIC", "-shared", "-std=c++20"], "cpp_macros": ["__NEWOS_SYMS__"] } diff --git a/SCIKit/makefile b/SCIKit/makefile index 9a2b836e..7757440e 100644 --- a/SCIKit/makefile +++ b/SCIKit/makefile @@ -5,7 +5,7 @@ CC=g++ FLAGS=-I../ -shared -fPIC -D__NEWOS_SYMS__ -OUTPUT=libSCI.lib +OUTPUT=libSCI.dll .PHONY: build-sci build-sci: diff --git a/SCIKit/rtl.internal.inl b/SCIKit/rtl.internal.inl deleted file mode 100644 index b4e8e7dd..00000000 --- a/SCIKit/rtl.internal.inl +++ /dev/null @@ -1,67 +0,0 @@ -/* ------------------------------------------- - -Copyright ZKA Technologies. - -File: rt.internal.inl -Purpose: Base code of SCM. - -------------------------------------------- */ - -/// @internal - -#ifndef __ZECC__ -#define object class -#define protocol class -#define clsid(X) __attribute__((uuid(X))) - -#warning ! you may be using the clang version of the newos kit, please be cautious that some thing mayn't be present. ! -#endif // !__ZECC__ - -// Interfaces are divided between classes. -// So that they aren't too big. - -protocol UnknownInterface; // Refrenced from an IDB entry. -class UnknownUCLSID; // From the IDB, the constructor of the object, e.g: TextUCLSID. -object UUID; - -protocol clsid("d7c144b6-0792-44b8-b06b-02b227b547df") UnknownInterface -{ -public: - explicit UnknownInterface() = default; - virtual ~UnknownInterface() = default; - - UnknownInterface& operator=(const UnknownInterface&) = default; - UnknownInterface(const UnknownInterface&) = default; - - virtual SInt32 Release() = 0; - virtual void DecrementRef() = 0; - virtual UnknownInterface* IncrementRef() = 0; - virtual VoidPtr QueryInterface(UUID* p_uuid) = 0; -}; - -/// @brief Allocate new SCM object. -/// @tparam TCLS -/// @tparam UCLSID -/// @param uclsidOfCls -/// @return -template -inline TCLS* ScmQueryInterface(UCLSID* uclsidOfCls, Args&&... args) -{ - return uclsidOfCls->QueryInterfaceWithArgs(args...); -} - -/// @brief Release SCM object. -/// @tparam TCLS -/// @param cls -/// @return -template -inline SInt32 ScmReleaseClass(TCLS* cls) -{ - if (!cls) - return -1; - - cls->DecrementRef(); - cls->Release(); - - return 0; -} diff --git a/SCIKit/scm.iclparser.inl b/SCIKit/scm.iclparser.inl new file mode 100644 index 00000000..acedc9d8 --- /dev/null +++ b/SCIKit/scm.iclparser.inl @@ -0,0 +1,18 @@ +/* ------------------------------------------- + +Copyright ZKA Technologies. + +File: rt.internal.inl +Purpose: Base code of SCM. + +------------------------------------------- */ + +/// @internal + +#ifndef __ZECC__ +#define object class +#define protocol class +#define clsid(X) __attribute__((uuid(X))) + +#warning ! you may be using the clang version of the newos kit, please be cautious that some thing mayn't be present. ! +#endif // !__ZECC__ \ No newline at end of file diff --git a/SCIKit/scm.internal.inl b/SCIKit/scm.internal.inl new file mode 100644 index 00000000..b4e8e7dd --- /dev/null +++ b/SCIKit/scm.internal.inl @@ -0,0 +1,67 @@ +/* ------------------------------------------- + +Copyright ZKA Technologies. + +File: rt.internal.inl +Purpose: Base code of SCM. + +------------------------------------------- */ + +/// @internal + +#ifndef __ZECC__ +#define object class +#define protocol class +#define clsid(X) __attribute__((uuid(X))) + +#warning ! you may be using the clang version of the newos kit, please be cautious that some thing mayn't be present. ! +#endif // !__ZECC__ + +// Interfaces are divided between classes. +// So that they aren't too big. + +protocol UnknownInterface; // Refrenced from an IDB entry. +class UnknownUCLSID; // From the IDB, the constructor of the object, e.g: TextUCLSID. +object UUID; + +protocol clsid("d7c144b6-0792-44b8-b06b-02b227b547df") UnknownInterface +{ +public: + explicit UnknownInterface() = default; + virtual ~UnknownInterface() = default; + + UnknownInterface& operator=(const UnknownInterface&) = default; + UnknownInterface(const UnknownInterface&) = default; + + virtual SInt32 Release() = 0; + virtual void DecrementRef() = 0; + virtual UnknownInterface* IncrementRef() = 0; + virtual VoidPtr QueryInterface(UUID* p_uuid) = 0; +}; + +/// @brief Allocate new SCM object. +/// @tparam TCLS +/// @tparam UCLSID +/// @param uclsidOfCls +/// @return +template +inline TCLS* ScmQueryInterface(UCLSID* uclsidOfCls, Args&&... args) +{ + return uclsidOfCls->QueryInterfaceWithArgs(args...); +} + +/// @brief Release SCM object. +/// @tparam TCLS +/// @param cls +/// @return +template +inline SInt32 ScmReleaseClass(TCLS* cls) +{ + if (!cls) + return -1; + + cls->DecrementRef(); + cls->Release(); + + return 0; +} -- cgit v1.2.3