From 80039963ff08d1810e22a0ae41497b156e861db0 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Sat, 10 Aug 2024 07:58:47 +0200 Subject: [META] Important refactors and fixes. + FIX SCIBase.hxx header and inline scm.internal.inl header. + Rename targets libSCI, libDDK to sci.dll and ddk.dll. + Don't initialize again the values of heap and such in HalKernelMain.cxx + Add 'STOP code' in ke_stop call. + Updated ReadMe.md. Signed-off-by: Amlal EL Mahrouss --- Boot/amd64-efi.make | 6 +++--- CRTKit/__mpcc_exception.hxx | 2 -- CRTKit/__mpcc_iostream.hxx | 32 -------------------------------- CRTKit/build.json | 4 ++-- DDKit/ReadMe.md | 2 +- DDKit/build.json | 2 +- DDKit/x86_64.make | 2 +- Kernel/HALKit/AMD64/HalKernelMain.cxx | 34 ++++++++-------------------------- Kernel/Sources/KernelCheck.cxx | 28 +++++++++++++++------------- ReadMe.md | 6 +++--- SCIKit/SCIBase.hxx | 19 +++++++++++++++++-- SCIKit/build.json | 2 +- SCIKit/makefile | 2 +- SCIKit/scm.internal.inl | 16 ++++++++-------- 14 files changed, 61 insertions(+), 96 deletions(-) delete mode 100644 CRTKit/__mpcc_iostream.hxx diff --git a/Boot/amd64-efi.make b/Boot/amd64-efi.make index 9f0d2966..c5f51112 100644 --- a/Boot/amd64-efi.make +++ b/Boot/amd64-efi.make @@ -51,9 +51,9 @@ FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mno-red-zone -D__NEWOSKRNL__ -D__NEWOSL BOOT_LOADER=newosldr.exe KERNEL=newoskrnl.dll -DDK=libDDK.dll -SCI=libSCI.dll -CRT=libCRT.dll +DDK=ddk.dll +SCI=sci.dll +CRT=crtcxx.dll .PHONY: invalid-recipe invalid-recipe: diff --git a/CRTKit/__mpcc_exception.hxx b/CRTKit/__mpcc_exception.hxx index 23b4a99a..b515769e 100644 --- a/CRTKit/__mpcc_exception.hxx +++ b/CRTKit/__mpcc_exception.hxx @@ -6,8 +6,6 @@ #pragma once -#include - /// @brief CRT exit, with exit code (!!! exits all threads. !!!) /// @param code /// @return diff --git a/CRTKit/__mpcc_iostream.hxx b/CRTKit/__mpcc_iostream.hxx deleted file mode 100644 index 1d93f1e4..00000000 --- a/CRTKit/__mpcc_iostream.hxx +++ /dev/null @@ -1,32 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - -------------------------------------------- */ - -#pragma once - -/// @brief CRT exit, with exit code (!!! exits all threads. !!!) -/// @param code -/// @return -extern "C" int __exit(int code); - -/// @brief Standard C++ namespace -namespace std -{ - template - class ofstream; - - template - class ostream - { - public: - ostream() = default; - virtual ~ostream() = default; - - virtual ostream& operator<<(const Encoding* input_streamable) = 0; - virtual ostream& operator<<(Encoding* input_streamable) = 0; - }; - - extern ofstream cout; -}; \ No newline at end of file diff --git a/CRTKit/build.json b/CRTKit/build.json index f9d69a57..1ad1303e 100644 --- a/CRTKit/build.json +++ b/CRTKit/build.json @@ -3,8 +3,8 @@ "compiler_std": "c++20", "headers_path": ["../", "./"], "sources_path": ["*.cxx"], - "output_name": "libCRT.dll", - "compiler_flags": ["-ffreestanding", "-shared", "-std=c17", "-std=c++20", "-fno-rtti", "-fno-exceptions", " -Wl,--subsystem=17"], + "output_name": "crtcxx.dll", + "compiler_flags": ["-ffreestanding", "-shared", "-fno-rtti", "-fno-exceptions", " -Wl,--subsystem=17"], "cpp_macros": ["__CRT_AMD64__", "cCRTVersion=0x0100"] } \ No newline at end of file diff --git a/DDKit/ReadMe.md b/DDKit/ReadMe.md index cde81cf7..ee12a9c1 100644 --- a/DDKit/ReadMe.md +++ b/DDKit/ReadMe.md @@ -4,6 +4,6 @@ A kit used to write kernel HALs, using the NDK compiler suite. ## How to use it -Simply link against libDDK. +Simply link against ddk.dll. ###### Copyright 2024 ZKA Technologies, all rights reserved. diff --git a/DDKit/build.json b/DDKit/build.json index bfa2b829..328165ba 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.dll", + "output_name": "ddk.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 b79d74f0..f1f7bb4b 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.dll +OUTPUT=ddk.dll .PHONY: x86_64-build x86_64-build: diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx index 924eb6c9..d24099f2 100644 --- a/Kernel/HALKit/AMD64/HalKernelMain.cxx +++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx @@ -50,16 +50,9 @@ namespace Kernel::HAL { /// @brief Gets the system cores using the MADT. /// @param rsdPtr The 'RSD PTR' data structure. - extern void hal_system_get_cores(Kernel::voidPtr rsdPtr); + EXTERN void hal_system_get_cores(Kernel::voidPtr rsdPtr); } // namespace Kernel::HAL -namespace Kernel -{ - EXTERN SizeT kHeapCount; - EXTERN PageManager kHeapPageManager; - EXTERN Bool kOperationInProgress; -} // namespace Kernel - /* GDT. */ STATIC Kernel::HAL::Detail::NewOSGDT cGdt = { {0, 0, 0, 0x00, 0x00, 0}, // null entry @@ -70,7 +63,7 @@ STATIC Kernel::HAL::Detail::NewOSGDT cGdt = { {0, 0, 0, 0x92, 0xaf, 0}, // user data }; -void hal_real_init(void); +Kernel::Void hal_real_init(Kernel::Void) noexcept; static Kernel::User* cRoot; @@ -90,16 +83,8 @@ EXTERN_C void hal_init_platform( hal_real_init(); } -EXTERN Kernel::Boolean kAllocationInProgress; - -void hal_real_init(void) -{ - Kernel::kHeapPageManager = Kernel::PageManager(); - Kernel::kHeapCount = 0UL; - Kernel::kOperationInProgress = No; - kAllocationInProgress = No; - - // get page size. +Kernel::Void hal_real_init(Kernel::Void) noexcept +{ // get page size. kKernelVirtualSize = kHandoverHeader->f_VirtualSize; // get virtual address start (for the heap) @@ -228,16 +213,13 @@ void hal_real_init(void) cRoot = new Kernel::User(Kernel::RingKind::kRingSuperUser, kSuperUser); #ifdef __DEBUG__ - cRoot->TrySave("6aa162f3-20f6-4143-92f9-5dd37066aedc"); + const auto cPassword = "6aa162f3-20f6-4143-92f9-5dd37066aedc"; #else - cRoot->TrySave("password"); + const auto cPassword = "password"; #endif -#ifdef __DEBUG__ - Kernel::UserManager::The()->TryLogIn(cRoot, "6aa162f3-20f6-4143-92f9-5dd37066aedc"); -#else - Kernel::UserManager::The()->TryLogIn(cRoot, "password"); -#endif + cRoot->TrySave(cPassword); + Kernel::UserManager::The()->TryLogIn(cRoot, cPassword); Kernel::ke_stop(RUNTIME_CHECK_FAILED); } diff --git a/Kernel/Sources/KernelCheck.cxx b/Kernel/Sources/KernelCheck.cxx index cff17077..b65a4114 100644 --- a/Kernel/Sources/KernelCheck.cxx +++ b/Kernel/Sources/KernelCheck.cxx @@ -19,7 +19,7 @@ #define CopyMem(dst, src, sz) Kernel::rt_copy_memory((Kernel::VoidPtr)src, (Kernel::VoidPtr)dst, sz) #define MoveMem(dst, src, sz) Kernel::rt_copy_memory((Kernel::VoidPtr)src, (Kernel::VoidPtr)dst, sz) -#define cWebsiteMacro "https://zka.ma/help" +#define cWebsiteMacro "https://zka.nl/help" #include @@ -65,49 +65,51 @@ namespace Kernel start_y += 10; + // show text according to error id. + switch (id) { case RUNTIME_CHECK_PROCESS: { - cg_write_text("Process scheduler error (Catasrophic failure).", start_y, x, panicTxt); + cg_write_text("0x00000008 Process scheduler error (Catasrophic failure).", start_y, x, panicTxt); break; } case RUNTIME_CHECK_ACPI: { - cg_write_text("ACPI error.", start_y, x, panicTxt); + cg_write_text("0x00000006 ACPI error.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_POINTER: { - cg_write_text("Kernel heap error.", start_y, x, panicTxt); + cg_write_text("0x00000000 Kernel heap error.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_BAD_BEHAVIOR: { - cg_write_text("Undefined Behavior error.", start_y, x, panicTxt); + cg_write_text("0x00000009 Undefined Behavior error.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_BOOTSTRAP: { - cg_write_text("End of code.", start_y, x, panicTxt); + cg_write_text("0x0000000A End of code.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_HANDSHAKE: { - cg_write_text("Handshake error.", start_y, x, panicTxt); + cg_write_text("0x00000005 Handshake error.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_IPC: { - cg_write_text("Kernel IPC error.", start_y, x, panicTxt); + cg_write_text("0x00000003 Kernel IPC error.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_INVALID_PRIVILEGE: { - cg_write_text("Privilege violation.", start_y, x, panicTxt); + cg_write_text("0x00000007 Kernel privilege violation.", start_y, x, panicTxt); break; case RUNTIME_CHECK_UNEXCPECTED: { - cg_write_text("Catasrophic failure.", start_y, x, panicTxt); + cg_write_text("0x0000000B Catasrophic failure.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_FAILED: { - cg_write_text("Assertion failed.", start_y, x, panicTxt); + cg_write_text("0x10000001 Assertion failed.", start_y, x, panicTxt); break; } default: { - cg_write_text("Unknown error.", start_y, x, panicTxt); + cg_write_text("0xFFFFFFFF Unknown error.", start_y, x, panicTxt); break; } } @@ -118,7 +120,7 @@ namespace Kernel Void RecoveryFactory::Recover() noexcept { - while (true) + while (Yes) { asm volatile("cli; hlt"); } diff --git a/ReadMe.md b/ReadMe.md index 5cc77c66..38a3383e 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -4,7 +4,7 @@ # ZKA (ZKA Kernel Architecture) -ZKA is an operating system kernel, also codenamed 'NewOS'. +ZKA is an operating system kernel of New OS. ## Installation: @@ -14,8 +14,8 @@ ZKA is an operating system kernel, also codenamed 'NewOS'. ### Start by cloning: ``` -git clone git@bitbucket.org:mahrouss/newoskrnl.git -cd newoskrnl +git clone git@bitbucket.org:mahrouss/boot-krnl-dll.git +cd boot-krnl-dll ``` ### And then select the makefile to execute: diff --git a/SCIKit/SCIBase.hxx b/SCIKit/SCIBase.hxx index c2241715..88711f7c 100644 --- a/SCIKit/SCIBase.hxx +++ b/SCIKit/SCIBase.hxx @@ -73,7 +73,7 @@ class EventListenerInterface final : public ClsID { public: explicit EventListenerInterface() = default; - virtual ~UnknownInterface() = default; + virtual ~EventListenerInterface() = default; EventListenerInterface& operator=(const EventListenerInterface&) = default; EventListenerInterface(const EventListenerInterface&) = default; @@ -127,4 +127,19 @@ enum eFBGPU, eFBCPU, eFBInvalid, -}; \ No newline at end of file +}; + +/// @brief Allocate new SCM object. +/// @tparam TCLS the class type. +/// @tparam UCLSID UCLS factory class type. +/// @param uclsidOfCls UCLS factory class +/// @return TCLS interface +template +inline TCLS* ScmQueryInterface(UCLSID* uclsidOfCls, Args&&... args); + +/// @brief Release SCM object. +/// @tparam TCLS the class type. +/// @param cls the class to release. +/// @return status code. +template +inline SInt32 ScmReleaseClass(TCLS* cls); \ No newline at end of file diff --git a/SCIKit/build.json b/SCIKit/build.json index 770d1622..ecd8593d 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.dll", + "output_name": "sci.dll", "compiler_flags": ["-fPIC", "-shared", "-std=c++20"], "cpp_macros": ["__NEWOS_SYMS__"] } diff --git a/SCIKit/makefile b/SCIKit/makefile index 7757440e..63753422 100644 --- a/SCIKit/makefile +++ b/SCIKit/makefile @@ -5,7 +5,7 @@ CC=g++ FLAGS=-I../ -shared -fPIC -D__NEWOS_SYMS__ -OUTPUT=libSCI.dll +OUTPUT=sci.dll .PHONY: build-sci build-sci: diff --git a/SCIKit/scm.internal.inl b/SCIKit/scm.internal.inl index 6b3af973..e9c969f1 100644 --- a/SCIKit/scm.internal.inl +++ b/SCIKit/scm.internal.inl @@ -40,10 +40,10 @@ public: }; /// @brief Allocate new SCM object. -/// @tparam TCLS -/// @tparam UCLSID -/// @param uclsidOfCls -/// @return +/// @tparam TCLS the class type. +/// @tparam UCLSID UCLS factory class type. +/// @param uclsidOfCls UCLS factory class +/// @return TCLS interface template inline TCLS* ScmQueryInterface(UCLSID* uclsidOfCls, Args&&... args) { @@ -51,9 +51,9 @@ inline TCLS* ScmQueryInterface(UCLSID* uclsidOfCls, Args&&... args) } /// @brief Release SCM object. -/// @tparam TCLS -/// @param cls -/// @return +/// @tparam TCLS the class type. +/// @param cls the class to release. +/// @return status code. template inline SInt32 ScmReleaseClass(TCLS* cls) { @@ -71,7 +71,7 @@ protocol EventListenerInterface final : public ClsID { public: explicit EventListenerInterface() = default; - virtual ~UnknownInterface() = default; + virtual ~EventListenerInterface() = default; EventListenerInterface& operator=(const EventListenerInterface&) = default; EventListenerInterface(const EventListenerInterface&) = default; -- cgit v1.2.3