From 55059428bfd6a18451bc1ed3ee64e7bb04c395cd Mon Sep 17 00:00:00 2001 From: amlal Date: Sat, 16 Mar 2024 14:22:21 +0100 Subject: HCR-14: See below. - Pretty big modifications, add kernel mouse. Signed-off-by: amlal --- Private/Drivers/AHCI/Defines.hxx | 2 +- Private/Drivers/PS2/Mouse.hxx | 80 ----------- Private/Drivers/PS2/PS2KernelMouse.hxx | 104 +++++++++++++++ Private/HALKit/AMD64/HalControlRegister.s | 4 +- .../HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp | 14 +- Private/HALKit/AMD64/HalDescriptorLoader.cpp | 91 +++++++------ Private/HALKit/AMD64/HalInterruptRouting.asm | 148 +++++++++++++++++++-- Private/HALKit/AMD64/HalKernelMain.cxx | 37 ++++-- Private/HALKit/AMD64/HalKernelMouse.cxx | 122 +++++++++++++++++ Private/HALKit/AMD64/HalNewBoot.asm | 3 + Private/HALKit/AMD64/HalPageAlloc.hpp | 12 +- Private/HALKit/AMD64/HalRoutines.s | 4 +- Private/HALKit/AMD64/Processor.hpp | 8 +- Private/KernelKit/FileManager.hpp | 20 +-- Private/KernelKit/LoaderInterface.hpp | 1 + Private/KernelKit/ProcessTeam.hpp | 2 +- Private/KernelKit/Rsrc/Cursor.rsrc | 40 ++++++ Private/KernelKit/Rsrc/Util.hxx | 27 ++++ Private/KernelKit/ThreadLocalStorage.hxx | 10 +- Private/KernelKit/ThreadLocalStorage.inl | 8 +- Private/LinkerScripts/16x0.json | 2 +- Private/LinkerScripts/32x0.json | 2 +- Private/LinkerScripts/64x0.json | 2 +- Private/NewBoot/Source/makefile | 2 +- Private/NewKit/KernelHeap.hpp | 2 +- Private/NewKit/LockDelegate.hpp | 6 +- Private/Source/CxxAbi.cxx | 2 +- Private/Source/FileManager.cxx | 8 +- Private/Source/Framebuffer.cxx | 8 +- Private/Source/PEFSharedObjectRT.cxx | 4 +- Private/Source/ThreadLocalStorage.cxx | 6 +- Public/Kits/System.Core/Containers/XIFF.hxx | 2 +- Public/Kits/System.Core/CoreAPI.hxx | 56 -------- Public/Kits/System.Core/Defs.hxx | 77 +++++++++++ Public/Kits/System.Core/File.hxx | 42 ++++++ Public/Kits/System.Core/FileAPI.hxx | 42 ------ Public/Kits/System.Core/HCoreBase.hxx | 2 +- Public/Kits/System.Core/Heap.cxx | 38 ++++++ Public/Kits/System.Core/Heap.hxx | 62 +++++++++ Public/Kits/System.Core/HeapAPI.cxx | 38 ------ Public/Kits/System.Core/HeapAPI.hxx | 66 --------- Public/Kits/System.Core/System.Core.hxx | 15 +++ Public/Kits/System.Core/System.hxx | 6 +- Public/Kits/System.Core/hcore.h | 15 --- Public/Kits/System.Graphics/Core.hxx | 6 +- Public/Kits/System.Zip/Zip.cxx | 2 +- 46 files changed, 821 insertions(+), 429 deletions(-) delete mode 100644 Private/Drivers/PS2/Mouse.hxx create mode 100644 Private/Drivers/PS2/PS2KernelMouse.hxx create mode 100644 Private/HALKit/AMD64/HalKernelMouse.cxx create mode 100644 Private/KernelKit/Rsrc/Cursor.rsrc delete mode 100644 Public/Kits/System.Core/CoreAPI.hxx create mode 100644 Public/Kits/System.Core/Defs.hxx create mode 100644 Public/Kits/System.Core/File.hxx delete mode 100644 Public/Kits/System.Core/FileAPI.hxx create mode 100644 Public/Kits/System.Core/Heap.cxx create mode 100644 Public/Kits/System.Core/Heap.hxx delete mode 100644 Public/Kits/System.Core/HeapAPI.cxx delete mode 100644 Public/Kits/System.Core/HeapAPI.hxx create mode 100644 Public/Kits/System.Core/System.Core.hxx delete mode 100644 Public/Kits/System.Core/hcore.h diff --git a/Private/Drivers/AHCI/Defines.hxx b/Private/Drivers/AHCI/Defines.hxx index 00510c3e..f3b93660 100644 --- a/Private/Drivers/AHCI/Defines.hxx +++ b/Private/Drivers/AHCI/Defines.hxx @@ -230,7 +230,7 @@ typedef struct HbaPort final { HCore::UInt32 serr; // 0x30, SATA error (SCR1:SError) HCore::UInt32 sact; // 0x34, SATA active (SCR3:SActive) HCore::UInt32 ci; // 0x38, command issue - HCore::UInt32 sntf; // 0x3C, SATA notification (SCR4:SNotification) + HCore::UInt32 sntf; // 0x20, SATA notification (SCR4:SNotification) HCore::UInt32 fbs; // 0x40, FIS-based switch control HCore::UInt32 reserved1[11]; // 0x44 ~ 0x6F, Reserved HCore::UInt32 vendor[4]; // 0x70 ~ 0x7F, vendor specific diff --git a/Private/Drivers/PS2/Mouse.hxx b/Private/Drivers/PS2/Mouse.hxx deleted file mode 100644 index 30fb5620..00000000 --- a/Private/Drivers/PS2/Mouse.hxx +++ /dev/null @@ -1,80 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - - File: Mouse.hxx - Purpose: PS/2 mouse. - - Revision History: - - 03/02/24: Added file (amlel) - -------------------------------------------- */ - -#pragma once - -#include -#include -#include - -namespace HCore { - -class PS2Mouse final { - public: - explicit PS2Mouse() { - HAL::Out8(0x64, 0xa8); - this->Wait(); - auto stat = HAL::In8(0x60); - - stat |= 0b10; - - this->Wait(); - - HAL::Out8(0x64, 0x60); - - this->Wait(); - - HAL::Out8(0x60, stat); - - this->Write(0xF6); - this->Read(); - - this->Write(0xF4); - this->Read(); - } - - ~PS2Mouse() = default; - - HCORE_COPY_DEFAULT(PS2Mouse); - - struct PS2MouseTraits final { - Int16 Status; - Int32 X, Y; - }; - - Boolean operator>>(PS2MouseTraits& stat) noexcept { return true; } - - private: - Bool Wait() noexcept { - while (!(HAL::In8(0x64) & 1)) { - asm("pause"); - } // wait until we can read - - // return the ack bit. - return HAL::In8(0x64); - } - - Void Write(UInt8 port) { - this->Wait(); - HAL::Out8(0x64, 0xD4); - this->Wait(); - - HAL::Out8(0x60, port); - } - - UInt8 Read() { - this->Wait(); - return HAL::In8(0x60); - } -}; -} // namespace HCore diff --git a/Private/Drivers/PS2/PS2KernelMouse.hxx b/Private/Drivers/PS2/PS2KernelMouse.hxx new file mode 100644 index 00000000..ecfc0459 --- /dev/null +++ b/Private/Drivers/PS2/PS2KernelMouse.hxx @@ -0,0 +1,104 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: PS2KernelMouse.hxx + Purpose: PS/2 mouse. + + Revision History: + + 03/02/24: Added file (amlel) + +------------------------------------------- */ + +#pragma once + +#include +#include +#include + +namespace HCore { +/// @brief Enabled for kernel purposes, kernel mouse. +class PS2KernelMouse final { + public: + explicit PS2KernelMouse() = default; + ~PS2KernelMouse() = default; + + HCORE_COPY_DEFAULT(PS2KernelMouse); + + public: + Void Init() noexcept { + HCore::kcout << "HCoreKrnl.exe: Enabling PS/2 mouse...\r\n"; + + this->Write(0xFF); + + this->Wait(); + + HAL::Out8(0x64, 0x20); + + this->Wait(); + + auto status = HAL::In8(0x60); + + status |= 0x12; + + this->Wait(); + + HAL::Out8(0x64, 0x60); + + this->Wait(); + + HAL::Out8(0x60, status); + + HCore::kcout << "HCoreKrnl.exe: PS/2 mouse is OK.\r\n"; + } + + private: + Bool WaitInput() noexcept { + UInt64 timeout = 100000; + + while (timeout) { + if ((HAL::In8(0x64) & 0x1)) { + HCore::kcout << "HCoreKrnl.exe: Wait: OK\r\n"; + return true; + } + + --timeout; + } // wait until we can read + + HCore::kcout << "HCoreKrnl.exe: Wait: Timeout\r\n"; + // return the ack bit. + return false; + } + + Bool Wait() noexcept { + UInt64 timeout = 100000; + + while (timeout) { + if ((HAL::In8(0x64) & 0b10) == 0) { + HCore::kcout << "HCoreKrnl.exe: Wait: OK\r\n"; + return true; + } + + --timeout; + } // wait until we can read + + HCore::kcout << "HCoreKrnl.exe: Wait: Timeout\r\n"; + // return the ack bit. + return false; + } + + Void Write(UInt8 val) { + this->Wait(); + HAL::Out8(0x64, 0xD4); + this->Wait(); + + HAL::Out8(0x60, val); + } + + UInt8 Read() { + this->WaitInput(); + return HAL::In8(0x60); + } +}; +} // namespace HCore diff --git a/Private/HALKit/AMD64/HalControlRegister.s b/Private/HALKit/AMD64/HalControlRegister.s index 2b898211..0504d2fb 100644 --- a/Private/HALKit/AMD64/HalControlRegister.s +++ b/Private/HALKit/AMD64/HalControlRegister.s @@ -14,9 +14,7 @@ .section .text flush_tlb: - mov %rsi, %cr3 - mov %cr3, %rsi - xor %rax, %rax + invlpg (%rcx) ret read_cr3: diff --git a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp index a86499e1..e95e8902 100644 --- a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp +++ b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp @@ -11,10 +11,10 @@ EXTERN_C void idt_handle_gpf(HCore::UIntPtr rsp) { MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); - HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); + HCore::kcout << "HCoreKrnl.exe: Stack Pointer: " << HCore::StringBuilder::FromInt("rsp{%}", rsp); HCore::kcout - << "HCoreKrnl: General Protection Fault, caused by " + << "HCoreKrnl.exe: General Protection Fault, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); @@ -24,13 +24,13 @@ EXTERN_C void idt_handle_scheduler(HCore::UIntPtr rsp) { HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); HCore::kcout - << "HCoreKrnl: Will be scheduled back later " + << "HCoreKrnl.exe: Will be scheduled back later " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName() << HCore::end_line(); /// schedule another process. if (!HCore::ProcessHelper::StartScheduling()) { - HCore::kcout << "HCoreKrnl: Continue schedule this process...\r\n"; + HCore::kcout << "HCoreKrnl.exe: Continue schedule this process...\r\n"; } } @@ -40,7 +40,7 @@ EXTERN_C void idt_handle_pf(HCore::UIntPtr rsp) { MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); HCore::kcout - << "HCoreKrnl: Segmentation Fault, caused by " + << "HCoreKrnl.exe: Segmentation Fault, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); @@ -52,7 +52,7 @@ EXTERN_C void idt_handle_math(HCore::UIntPtr rsp) { MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); HCore::kcout - << "HCoreKrnl: Math error, caused by " + << "HCoreKrnl.exe: Math error, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); @@ -64,7 +64,7 @@ EXTERN_C void idt_handle_generic(HCore::UIntPtr rsp) { MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); HCore::kcout - << "HCoreKrnl: Execution error, caused by " + << "HCoreKrnl.exe: Execution error, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); diff --git a/Private/HALKit/AMD64/HalDescriptorLoader.cpp b/Private/HALKit/AMD64/HalDescriptorLoader.cpp index 1dbe8e9e..595d52e4 100644 --- a/Private/HALKit/AMD64/HalDescriptorLoader.cpp +++ b/Private/HALKit/AMD64/HalDescriptorLoader.cpp @@ -7,63 +7,35 @@ #include namespace HCore::HAL { +namespace Detail { STATIC RegisterGDT kRegGdt; - -void GDTLoader::Load(RegisterGDT &gdt) { - MUST_PASS(gdt.Base != 0); - - kRegGdt.Base = gdt.Base; - kRegGdt.Limit = gdt.Limit; - - rt_load_gdt(kRegGdt); -} - STATIC HAL::Register64 kRegIdt; STATIC ::HCore::Detail::AMD64::InterruptDescriptorAMD64 kInterruptVectorTable[kKernelIdtSize]; -void IDTLoader::Load(Register64 &idt) { - volatile ::HCore::UIntPtr **baseIdt = (volatile ::HCore::UIntPtr **)idt.Base; - - MUST_PASS(baseIdt); - - for (UInt16 i = 0; i < kKernelIdtSize; i++) { - MUST_PASS(baseIdt[i]); - - kInterruptVectorTable[i].Selector = kGdtCodeSelector; - kInterruptVectorTable[i].Ist = 0x0; - kInterruptVectorTable[i].TypeAttributes = kInterruptGate; - kInterruptVectorTable[i].OffsetLow = ((UIntPtr)baseIdt[i] & 0xFFFF); - kInterruptVectorTable[i].OffsetMid = (((UIntPtr)baseIdt[i] >> 16) & 0xFFFF); - kInterruptVectorTable[i].OffsetHigh = - (((UIntPtr)baseIdt[i] >> 32) & 0xFFFFFFFF); - kInterruptVectorTable[i].Zero = 0x0; - } - - kRegIdt.Base = reinterpret_cast(kInterruptVectorTable); - kRegIdt.Limit = sizeof(::HCore::Detail::AMD64::InterruptDescriptorAMD64) * - (kKernelIdtSize - 1); - - rt_load_idt(kRegIdt); - +STATIC Void RemapPIC(Void) noexcept { UInt8 a1, a2; a1 = HAL::In8(0x21); // save masks a2 = HAL::In8(0xA1); // Remap PIC. - HAL::Out8(0x20, 0x11); + HAL::Out8(0x20, 0x10 | 0x01); HAL::rt_wait_400ns(); - HAL::Out8(0xA0, 0x11); + HAL::Out8(0xA0, 0x10 | 0x01); HAL::rt_wait_400ns(); - HAL::Out8(0x21, 0x20); + + HAL::Out8(0x21, 0x28); HAL::rt_wait_400ns(); - HAL::Out8(0xA1, 0x28); + HAL::Out8(0xA1, 0x30); + HAL::rt_wait_400ns(); + HAL::Out8(0x21, 0x04); HAL::rt_wait_400ns(); HAL::Out8(0xA1, 0x02); + HAL::rt_wait_400ns(); HAL::Out8(0x21, 0x01); HAL::rt_wait_400ns(); @@ -72,6 +44,49 @@ void IDTLoader::Load(Register64 &idt) { HAL::Out8(0x21, a1); HAL::rt_wait_400ns(); HAL::Out8(0xA1, a2); + + HAL::Out8(0x21, 0xfd); + HAL::Out8(0xa1, 0xff); +} +} // namespace Detail + +/// @brief Loads the provided Global Descriptor Table. +/// @param gdt +/// @return +Void GDTLoader::Load(RegisterGDT &gdt) { + MUST_PASS(gdt.Base != 0); + + Detail::kRegGdt.Base = gdt.Base; + Detail::kRegGdt.Limit = gdt.Limit; + + hal_load_gdt(Detail::kRegGdt); +} + +Void IDTLoader::Load(Register64 &idt) { + volatile ::HCore::UIntPtr **baseIdt = (volatile ::HCore::UIntPtr **)idt.Base; + + MUST_PASS(baseIdt); + + for (UInt16 i = 0; i < kKernelIdtSize; i++) { + MUST_PASS(baseIdt[i]); + + Detail::kInterruptVectorTable[i].Selector = kGdtCodeSelector; + Detail::kInterruptVectorTable[i].Ist = 0x0; + Detail::kInterruptVectorTable[i].TypeAttributes = kInterruptGate; + Detail::kInterruptVectorTable[i].OffsetLow = ((UIntPtr)baseIdt[i] & 0xFFFF); + Detail::kInterruptVectorTable[i].OffsetMid = (((UIntPtr)baseIdt[i] >> 16) & 0xFFFF); + Detail::kInterruptVectorTable[i].OffsetHigh = + (((UIntPtr)baseIdt[i] >> 32) & 0xFFFFFFFF); + Detail::kInterruptVectorTable[i].Zero = 0x0; + } + + Detail::kRegIdt.Base = reinterpret_cast(Detail::kInterruptVectorTable); + Detail::kRegIdt.Limit = sizeof(::HCore::Detail::AMD64::InterruptDescriptorAMD64) * + (kKernelIdtSize - 1); + + hal_load_idt(Detail::kRegIdt); + + Detail::RemapPIC(); } void GDTLoader::Load(Ref &gdt) { GDTLoader::Load(gdt.Leak()); } diff --git a/Private/HALKit/AMD64/HalInterruptRouting.asm b/Private/HALKit/AMD64/HalInterruptRouting.asm index 99bba00a..6bbc12fd 100644 --- a/Private/HALKit/AMD64/HalInterruptRouting.asm +++ b/Private/HALKit/AMD64/HalInterruptRouting.asm @@ -11,7 +11,7 @@ [bits 64] -%define kInterruptId 0x21 +%define kInterruptId 0x21 %macro IntExp 1 global __HCR_INT_%1 @@ -36,13 +36,18 @@ global _ke_power_on_self_test global ke_handle_irq global kInterruptVectorTable +extern _hal_mouse_handler +extern idt_handle_gpf +extern idt_handle_pf extern ke_io_print section .text IntNormal 0 IntNormal 1 + IntNormal 2 + IntNormal 3 IntNormal 4 IntNormal 5 @@ -52,9 +57,35 @@ IntExp 8 IntNormal 9 IntExp 10 IntExp 11 -IntExp 12 + +__HCR_INT_12: + cli + + push rax + + mov rcx, rsp + call idt_handle_gpf + + pop rax + + sti + iretq + IntExp 13 -IntExp 14 + +__HCR_INT_14: + cli + + push rax + + mov rcx, rsp + call idt_handle_pf + + pop rax + + sti + iretq + IntNormal 15 IntNormal 16 IntExp 17 @@ -97,8 +128,101 @@ __HCR_INT_33: sti iretq -%assign i 34 -%rep 222 +__HCR_INT_34: + cld + + iretq + + +__HCR_INT_35: + cld + + iretq + +__HCR_INT_36: + cld + + iretq + +__HCR_INT_37: + cld + + iretq + +__HCR_INT_38: + cld + + iretq + +__HCR_INT_39: + cld + + iretq + +__HCR_INT_40: + cld + + iretq + +__HCR_INT_41: + cld + + iretq + +__HCR_INT_42: + cld + + iretq + +__HCR_INT_43: + cld + + iretq + +__HCR_INT_44: + cli + + push rax + + call _hal_mouse_handler + + pop rax + + push rax + + ;; Find and execute system call TODO + + mov rcx, kMouseLabelExit + call ke_io_print + + pop rax + + sti + iretq + +__HCR_INT_45: + cld + + iretq + +IntNormal 46 +IntNormal 47 +IntNormal 48 +IntNormal 49 +IntNormal 50 +IntNormal 51 +IntNormal 52 +IntNormal 53 +IntNormal 54 +IntNormal 55 +IntNormal 56 +IntNormal 57 +IntNormal 58 +IntNormal 59 +IntNormal 60 + +%assign i 61 +%rep 195 IntNormal i %assign i i+1 %endrep @@ -114,9 +238,9 @@ _ke_power_on_self_test: ret -[global rt_load_gdt] +[global hal_load_gdt] -rt_load_gdt: +hal_load_gdt: lgdt [rcx] push 0x08 lea rax, [rel rt_reload_segments] @@ -131,9 +255,9 @@ rt_reload_segments: mov ss, ax ret -global rt_load_idt +global hal_load_idt -rt_load_idt: +hal_load_idt: lidt [rcx] sti ret @@ -148,6 +272,8 @@ kInterruptVectorTable: %endrep kSystemCallLabelEnter: - db "HCoreKrnl.exe: SystemCall: Enter", 0xa, 0xd, 0 + db "HCoreKrnl.exe: SystemCall: Enter.", 0xa, 0xd, 0 kSystemCallLabelExit: - db "HCoreKrnl.exe: SystemCall: Exit", 0xa, 0xd, 0 \ No newline at end of file + db "HCoreKrnl.exe: SystemCall: Exit.", 0xa, 0xd, 0 +kMouseLabelExit: + db "HCoreKrnl.exe: KernelMouse: Acknowledge Interrupt.", 0xa, 0xd, 0 \ No newline at end of file diff --git a/Private/HALKit/AMD64/HalKernelMain.cxx b/Private/HALKit/AMD64/HalKernelMain.cxx index 1f4256a9..248ae8cb 100644 --- a/Private/HALKit/AMD64/HalKernelMain.cxx +++ b/Private/HALKit/AMD64/HalKernelMain.cxx @@ -5,22 +5,35 @@ ------------------------------------------- */ #include -#include #include #include #include #include +#include +#include #include #include #include #include -#include -#include ///! @brief Disk contains HCore files. #define kInstalledMedia 0xDD EXTERN_C HCore::VoidPtr kInterruptVectorTable[]; +EXTERN_C HCore::Void _ke_init_mouse(); +EXTERN_C HCore::Void _hal_mouse_draw(); + +namespace Detail { +STATIC HCore::Void ke_page_protect_nullptr(HCore::Void) { + HCore::HAL::PageDirectory64* pageDirNull = nullptr; + + for (HCore::SizeT indexPte = 0; indexPte < kPTEMax; ++indexPte) { + pageDirNull->Pte[indexPte].Rw = false; + } + + flush_tlb(reinterpret_cast(pageDirNull)); +} +} // namespace Detail EXTERN_C void RuntimeMain( HCore::HEL::HandoverInformationHeader* HandoverHeader) { @@ -61,29 +74,31 @@ EXTERN_C void RuntimeMain( HCore::HAL::IDTLoader idt; idt.Load(idtBase); + Detail::ke_page_protect_nullptr(); + KeInitRsrc(); - KeDrawRsrc(MahroussLogic, MAHROUSSLOGIC_HEIGHT, MAHROUSSLOGIC_WIDTH, - ((kHandoverHeader->f_GOP.f_Width - MAHROUSSLOGIC_WIDTH) / 2), - ((kHandoverHeader->f_GOP.f_Height - MAHROUSSLOGIC_HEIGHT) / 2)); + KeDrawRsrc(MahroussLogic, MAHROUSSLOGIC_HEIGHT, MAHROUSSLOGIC_WIDTH, + ((kHandoverHeader->f_GOP.f_Width - MAHROUSSLOGIC_WIDTH) / 2), + ((kHandoverHeader->f_GOP.f_Height - MAHROUSSLOGIC_HEIGHT) / 2)); KeClearRsrc(); /// START POST HCore::HAL::Detail::_ke_power_on_self_test(); - + /// END POST - + /// Mounts a NewFS block. - HCore::IFilesystemManager::Mount(new HCore::NewFilesystemManager()); + HCore::FilesystemManagerInterface::Mount(new HCore::NewFilesystemManager()); /// We already have an install of HCore. if (HandoverHeader->f_Bootloader == kInstalledMedia) { - HCore::kcout << "HCoreKrnl: Running kernel...\r\n"; + HCore::kcout << "HCoreKrnl.exe: Running kernel...\r\n"; /// TODO: Parse system configuration. } else { - HCore::kcout << "HCoreKrnl: Running setup...\r\n"; + HCore::kcout << "HCoreKrnl.exe: Running setup...\r\n"; } HCore::ke_stop(RUNTIME_CHECK_BOOTSTRAP); diff --git a/Private/HALKit/AMD64/HalKernelMouse.cxx b/Private/HALKit/AMD64/HalKernelMouse.cxx new file mode 100644 index 00000000..58c45dfe --- /dev/null +++ b/Private/HALKit/AMD64/HalKernelMouse.cxx @@ -0,0 +1,122 @@ +#include +#include +#include +#include +#include + +STATIC HCore::Int32 kPrevX = 0; +STATIC HCore::Int32 kPrevY = 0; +STATIC HCore::Int32 kX = 0; +STATIC HCore::Int32 kY = 0; +STATIC HCore::Int32 kMouseCycle = 0; +STATIC HCore::PS2KernelMouse kMousePS2; +STATIC HCore::Int32 kMousePacket[4]; +STATIC HCore::Boolean kMousePacketReady = false; + +#define kPS2LeftButton 0b00000001 +#define kPS2MiddleButton 0b00000010 +#define kPS2RightButton 0b00000100 + +#define kPS2XSign 0b00010000 +#define kPS2YSign 0b00100000 +#define kPS2XOverflow 0b01000000 +#define kPS2YOverflow 0b10000000 + +EXTERN_C void _hal_mouse_handler() +{ +#ifdef __DEBUG__ + HCore::UInt8 data = HCore::HAL::In8(0x60); + + switch (kMouseCycle) + { + case 0: + { + if (kMousePacketReady) break; + if ((data & 0b00001000) == 0) break; + + kMousePacket[0] = data; + ++kMouseCycle; + + break; + } + case 1: + { + if (kMousePacketReady) break; + + kMousePacket[1] = data; + ++kMouseCycle; + + break; + } + case 2: + { + if (kMousePacketReady) break; + + kMousePacket[2] = data; + ++kMouseCycle; + kMousePacketReady = true; + kMouseCycle = 0; + + break; + } + default: + break; + } +#endif +} + +EXTERN_C void _hal_mouse_draw() +{ +#ifdef __DEBUG__ + if (!kMousePacketReady) return; + + bool xNeg, yNeg, xOvf, yOvf; + + xNeg = (kMousePacket[0] & kPS2XSign); + yNeg = (kMousePacket[0] & kPS2YSign); + + xOvf = (kMousePacket[0] & kPS2XOverflow); + yOvf = (kMousePacket[0] & kPS2YOverflow); + + kX += xNeg ? (256 - kMousePacket[1]) : (256 - (-kMousePacket[1])); + kY += yNeg ? (256 - kMousePacket[2]) : (256 - (-kMousePacket[2]));; + + if (xOvf) { + kX += xNeg ? 255 : -255; + } + + if (yOvf) { + kY += yNeg ? 255 : -255; + } + + if (kY > kHandoverHeader->f_GOP.f_Height) + { + return; + } + + if (kX > kHandoverHeader->f_GOP.f_Width) + { + return; + } + + KeClearZone(POINTER_HEIGHT, POINTER_WIDTH, kPrevX, kPrevY); + + KeInitRsrc(); + KeDrawRsrc(Pointer, POINTER_HEIGHT, POINTER_WIDTH, kX, kY); + KeClearRsrc(); + + kPrevX = kMousePacket[1]; + kPrevY = kMousePacket[2]; + + kMousePacketReady = false; +#endif +} + +/// @brief Inital kernel mouse initializer +/// @param +EXTERN_C void _ke_init_mouse(void) +{ +#ifdef __DEBUG__ + kMousePS2.Init(); +#endif +} \ No newline at end of file diff --git a/Private/HALKit/AMD64/HalNewBoot.asm b/Private/HALKit/AMD64/HalNewBoot.asm index 881c1728..3a16cd24 100644 --- a/Private/HALKit/AMD64/HalNewBoot.asm +++ b/Private/HALKit/AMD64/HalNewBoot.asm @@ -31,9 +31,12 @@ extern RuntimeMain ;; Just a simple setup, we'd also need to tell some before Main: + push rax push rcx call RuntimeMain pop rcx + pop rax +;; Go to sleep. MainLoop: cli hlt diff --git a/Private/HALKit/AMD64/HalPageAlloc.hpp b/Private/HALKit/AMD64/HalPageAlloc.hpp index f6b57a6d..bea28808 100644 --- a/Private/HALKit/AMD64/HalPageAlloc.hpp +++ b/Private/HALKit/AMD64/HalPageAlloc.hpp @@ -26,13 +26,13 @@ #define kPTESize (0x1000) #endif // !kPTESize -extern "C" void flush_tlb(HCore::UIntPtr VirtualAddr); -extern "C" void write_cr3(HCore::UIntPtr pde); -extern "C" void write_cr0(HCore::UIntPtr bit); +EXTERN_C void flush_tlb(HCore::UIntPtr pde); +EXTERN_C void write_cr3(HCore::UIntPtr pde); +EXTERN_C void write_cr0(HCore::UIntPtr bit); -extern "C" HCore::UIntPtr read_cr0(); // @brief CPU control register. -extern "C" HCore::UIntPtr read_cr2(); // @brief Fault address. -extern "C" HCore::UIntPtr read_cr3(); // @brief Page table. +EXTERN_C HCore::UIntPtr read_cr0(); // @brief CPU control register. +EXTERN_C HCore::UIntPtr read_cr2(); // @brief Fault address. +EXTERN_C HCore::UIntPtr read_cr3(); // @brief Page table. namespace HCore::HAL { struct PageTable64 { diff --git a/Private/HALKit/AMD64/HalRoutines.s b/Private/HALKit/AMD64/HalRoutines.s index a25b25c7..e4944111 100644 --- a/Private/HALKit/AMD64/HalRoutines.s +++ b/Private/HALKit/AMD64/HalRoutines.s @@ -1,5 +1,5 @@ -.globl rt_load_idt -.globl rt_load_gdt +.globl hal_load_idt +.globl hal_load_gdt .globl rt_wait_400ns .globl rt_get_current_context diff --git a/Private/HALKit/AMD64/Processor.hpp b/Private/HALKit/AMD64/Processor.hpp index 02951540..2c4a1c67 100644 --- a/Private/HALKit/AMD64/Processor.hpp +++ b/Private/HALKit/AMD64/Processor.hpp @@ -177,9 +177,9 @@ EXTERN_C void idt_handle_gpf(HCore::UIntPtr rsp); EXTERN_C void idt_handle_math(HCore::UIntPtr rsp); EXTERN_C void idt_handle_pf(HCore::UIntPtr rsp); -EXTERN_C void rt_load_idt(HCore::HAL::Register64 ptr); -EXTERN_C void rt_load_gdt(HCore::HAL::RegisterGDT ptr); +EXTERN_C void hal_load_idt(HCore::HAL::Register64 ptr); +EXTERN_C void hal_load_gdt(HCore::HAL::RegisterGDT ptr); /// @brief Maximum size of the IDT. -#define kKernelIdtSize 256 - +#define kKernelIdtSize 0x100 +#define kKernelInterruptId 0x21 diff --git a/Private/KernelKit/FileManager.hpp b/Private/KernelKit/FileManager.hpp index 3d986ddc..a00476bd 100644 --- a/Private/KernelKit/FileManager.hpp +++ b/Private/KernelKit/FileManager.hpp @@ -50,18 +50,18 @@ typedef VoidPtr NodePtr; @brief Filesystem Manager Interface class @brief Used to provide common I/O for a specific filesystem. */ -class IFilesystemManager { +class FilesystemManagerInterface { public: - IFilesystemManager() = default; - virtual ~IFilesystemManager() = default; + FilesystemManagerInterface() = default; + virtual ~FilesystemManagerInterface() = default; public: - HCORE_COPY_DEFAULT(IFilesystemManager); + HCORE_COPY_DEFAULT(FilesystemManagerInterface); public: - static bool Mount(IFilesystemManager *pMount); - static IFilesystemManager *Unmount(); - static IFilesystemManager *GetMounted(); + static bool Mount(FilesystemManagerInterface *pMount); + static FilesystemManagerInterface *Unmount(); + static FilesystemManagerInterface *GetMounted(); public: virtual NodePtr Create(_Input const char *path) = 0; @@ -91,9 +91,9 @@ class IFilesystemManager { #ifdef __FSKIT_NEWFS__ /** - * @brief Based of IFilesystemManager, takes care of managing NewFS disks. + * @brief Based of FilesystemManagerInterface, takes care of managing NewFS disks. */ -class NewFilesystemManager final : public IFilesystemManager { +class NewFilesystemManager final : public FilesystemManagerInterface { public: explicit NewFilesystemManager(); ~NewFilesystemManager() override; @@ -158,7 +158,7 @@ class NewFilesystemManager final : public IFilesystemManager { * @tparam Encoding file encoding (char, wchar_t...) * @tparam FSClass Filesystem contract who takes care of it. */ -template +template class FileStream final { public: explicit FileStream(const Encoding *path, const Encoding *restrict_type); diff --git a/Private/KernelKit/LoaderInterface.hpp b/Private/KernelKit/LoaderInterface.hpp index 51257e72..5beb403f 100644 --- a/Private/KernelKit/LoaderInterface.hpp +++ b/Private/KernelKit/LoaderInterface.hpp @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include diff --git a/Private/KernelKit/ProcessTeam.hpp b/Private/KernelKit/ProcessTeam.hpp index b60a8a0d..9538bbae 100644 --- a/Private/KernelKit/ProcessTeam.hpp +++ b/Private/KernelKit/ProcessTeam.hpp @@ -6,4 +6,4 @@ #pragma once -#include \ No newline at end of file +#include diff --git a/Private/KernelKit/Rsrc/Cursor.rsrc b/Private/KernelKit/Rsrc/Cursor.rsrc new file mode 100644 index 00000000..94922ca7 --- /dev/null +++ b/Private/KernelKit/Rsrc/Cursor.rsrc @@ -0,0 +1,40 @@ +#pragma once + +#define POINTER_HEIGHT 32 +#define POINTER_WIDTH 32 + +// array size is 3072 +static const unsigned int Pointer[] = { + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0xf7f7f7, 0xb6b6b6, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0xd5d5d5, 0xffffff, 0xa2a2a2, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x7a7a7a, 0xfefefe, 0xfafafa, 0x696969, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0xcacaca, 0xffffff, 0xe1e1e1, 0x272727, 0x767676, 0xececec, 0x878787, 0x000000, 0xf3f3f3, 0x909090, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x4a4a4a, 0xf3f3f3, 0xfefefe, 0xd5d5d5, 0x404040, 0xe2e2e2, 0xfbfbfb, 0xa1a1a1, 0xd5d5d5, 0xf9f9f9, 0x8c8c8c, 0xd9d9d9, 0x353535, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x9d9d9d, 0xfefefe, 0xfefefe, 0xf1f1f1, 0xdfdfdf, 0xfefefe, 0xfefefe, 0xf7f7f7, 0xfefefe, 0xeaeaea, 0xe5e5e5, 0xc8c8c8, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xdbdbdb, 0xfefefe, 0xfefefe, 0xfefefe, 0xfefefe, 0xfefefe, 0xfefefe, 0xfefefe, 0xfefefe, 0xfefefe, 0xfbfbfb, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x636363, 0xf8f8f8, 0xfdfdfd, 0xfdfdfd, 0xfdfdfd, 0xfdfdfd, 0xfdfdfd, 0xfdfdfd, 0xfdfdfd, 0xfdfdfd, 0xfdfdfd, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0xdbdbdb, 0xf9f9f9, 0xdfdfdf, 0xa5a5a5, 0x383838, 0xb0b0b0, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x9b9b9b, 0xd9d9d9, 0xfbfbfb, 0xfcfcfc, 0xf2f2f2, 0xb8b8b8, 0xececec, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x666666, 0xcacaca, 0xf9f9f9, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0xfcfcfc, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x666666, 0xe1e1e1, 0xfbfbfb, 0xfbfbfb, 0xfbfbfb, 0xfbfbfb, 0xfbfbfb, 0xfbfbfb, 0xfbfbfb, 0xfbfbfb, 0xfbfbfb, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x3b3b3b, 0xd9d9d9, 0xfbfbfb, 0xfbfbfb, 0xfbfbfb, 0xfbfbfb, 0xfbfbfb, 0xf9f9f9, 0xd6d6d6, 0x8e8e8e, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x525252, 0xc1c1c1, 0xcecece, 0xd6d6d6, 0xd1d1d1, 0xb5b5b5, 0x5d5d5d, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000 +}; \ No newline at end of file diff --git a/Private/KernelKit/Rsrc/Util.hxx b/Private/KernelKit/Rsrc/Util.hxx index 03013888..2ff81076 100644 --- a/Private/KernelKit/Rsrc/Util.hxx +++ b/Private/KernelKit/Rsrc/Util.hxx @@ -33,4 +33,31 @@ } \ } +/// @brief cleans a resource. +#define KeClearZone(_Height, _Width, BaseX, BaseY) \ + \ + for (HCore::SizeT i = BaseX; i < _Height + BaseX; ++i) { \ + for (HCore::SizeT u = BaseY; u < _Width + BaseY; ++u) { \ + *(((volatile HCore::UInt32*)(kHandoverHeader->f_GOP.f_The + \ + 4 * \ + kHandoverHeader->f_GOP \ + .f_PixelPerLine * \ + i + \ + 4 * u))) = RGB(0, 0, 0); \ + } \ + } + +#define KeDrawZone(_Clr, _Height, _Width, BaseX, BaseY) \ + \ + for (HCore::SizeT i = BaseX; i < _Height + BaseX; ++i) { \ + for (HCore::SizeT u = BaseY; u < _Width + BaseY; ++u) { \ + *(((volatile HCore::UInt32*)(kHandoverHeader->f_GOP.f_The + \ + 4 * \ + kHandoverHeader->f_GOP \ + .f_PixelPerLine * \ + i + \ + 4 * u))) = _Clr; \ + } \ + } + #endif diff --git a/Private/KernelKit/ThreadLocalStorage.hxx b/Private/KernelKit/ThreadLocalStorage.hxx index ba2f021f..25c9c48f 100644 --- a/Private/KernelKit/ThreadLocalStorage.hxx +++ b/Private/KernelKit/ThreadLocalStorage.hxx @@ -16,13 +16,13 @@ #define kCookieMag2 'o' template -T *hcore_tls_new_ptr(void); +T *tls_new_ptr(void); template -bool hcore_tls_delete_ptr(T *ptr); +bool tls_delete_ptr(T *ptr); template -T *hcore_tls_new_class(Args &&...args); +T *tls_new_class(Args &&...args); #define kTLSCookieLen 3 @@ -46,10 +46,10 @@ struct ThreadInformationBlock final { EXTERN_C void rt_install_tib(ThreadInformationBlock *pTib, HCore::VoidPtr pPib); ///! @brief Cookie Sanity check. -HCore::Boolean hcore_tls_check(ThreadInformationBlock *ptr); +HCore::Boolean tls_check(ThreadInformationBlock *ptr); /// @brief TLS check system call -EXTERN_C HCore::Void hcore_tls_check_syscall_impl(HCore::HAL::StackFramePtr stackPtr) noexcept; +EXTERN_C HCore::Void tls_check_syscall_impl(HCore::HAL::StackFramePtr stackPtr) noexcept; #include diff --git a/Private/KernelKit/ThreadLocalStorage.inl b/Private/KernelKit/ThreadLocalStorage.inl index a42c2381..4a8a816a 100644 --- a/Private/KernelKit/ThreadLocalStorage.inl +++ b/Private/KernelKit/ThreadLocalStorage.inl @@ -11,7 +11,7 @@ #endif template -inline T* hcore_tls_new_ptr(void) { +inline T* tls_new_ptr(void) { using namespace HCore; MUST_PASS(ProcessManager::Shared().Leak().GetCurrent()); @@ -24,7 +24,7 @@ inline T* hcore_tls_new_ptr(void) { //! @brief TLS delete implementation. template -inline bool hcore_tls_delete_ptr(T* ptr) { +inline bool tls_delete_ptr(T* ptr) { if (!ptr) return false; using namespace HCore; @@ -38,8 +38,8 @@ inline bool hcore_tls_delete_ptr(T* ptr) { } template -T* hcore_tls_new_class(Args&&... args) { - T* ptr = hcore_tls_new_ptr(); +T* tls_new_class(Args&&... args) { + T* ptr = tls_new_ptr(); if (ptr) { *ptr = T(HCore::forward(args)...); diff --git a/Private/LinkerScripts/16x0.json b/Private/LinkerScripts/16x0.json index f41c0fc7..d5a106ce 100644 --- a/Private/LinkerScripts/16x0.json +++ b/Private/LinkerScripts/16x0.json @@ -1,6 +1,6 @@ { "executable_type": "kernel", - "output_name": "HCoreKrnl.efi", + "output_name": "HCoreKrnl.exe", "start_proc": "Main", "format": "PEF" } diff --git a/Private/LinkerScripts/32x0.json b/Private/LinkerScripts/32x0.json index f41c0fc7..d5a106ce 100644 --- a/Private/LinkerScripts/32x0.json +++ b/Private/LinkerScripts/32x0.json @@ -1,6 +1,6 @@ { "executable_type": "kernel", - "output_name": "HCoreKrnl.efi", + "output_name": "HCoreKrnl.exe", "start_proc": "Main", "format": "PEF" } diff --git a/Private/LinkerScripts/64x0.json b/Private/LinkerScripts/64x0.json index f41c0fc7..d5a106ce 100644 --- a/Private/LinkerScripts/64x0.json +++ b/Private/LinkerScripts/64x0.json @@ -1,6 +1,6 @@ { "executable_type": "kernel", - "output_name": "HCoreKrnl.efi", + "output_name": "HCoreKrnl.exe", "start_proc": "Main", "format": "PEF" } diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile index 511a4894..5e25496b 100644 --- a/Private/NewBoot/Source/makefile +++ b/Private/NewBoot/Source/makefile @@ -35,7 +35,7 @@ bootloader-amd64: .PHONY: run-efi-amd64 run-efi-amd64: - $(EMU) -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -serial stdio + $(EMU) -net none -smp 2 -m 4G -M pc -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -serial stdio .PHONY: download-edk download-edk: diff --git a/Private/NewKit/KernelHeap.hpp b/Private/NewKit/KernelHeap.hpp index 52d019b8..6e2e9dbf 100644 --- a/Private/NewKit/KernelHeap.hpp +++ b/Private/NewKit/KernelHeap.hpp @@ -7,7 +7,7 @@ #pragma once // last-rev 30/01/24 -// file: KHeap.hpp +// file: KernelHeap.hpp // description: heap allocation for the kernel. #include diff --git a/Private/NewKit/LockDelegate.hpp b/Private/NewKit/LockDelegate.hpp index d43d8562..74cd22e5 100644 --- a/Private/NewKit/LockDelegate.hpp +++ b/Private/NewKit/LockDelegate.hpp @@ -14,7 +14,9 @@ namespace HCore { -template +/// @brief Locking delegate class, hangs until limit. +/// @tparam N +template class LockDelegate final { public: @@ -24,6 +26,7 @@ class LockDelegate final explicit LockDelegate(Boolean *expr) { auto spin = 0U; + while (spin != N) { if (*expr) @@ -46,6 +49,7 @@ class LockDelegate final { return m_LockStatus[kLockDone] == kLockDone; } + bool HasTimedOut() { return m_LockStatus[kLockTimedOut] != kLockTimedOut; diff --git a/Private/Source/CxxAbi.cxx b/Private/Source/CxxAbi.cxx index 88272377..2d3a5aec 100644 --- a/Private/Source/CxxAbi.cxx +++ b/Private/Source/CxxAbi.cxx @@ -14,7 +14,7 @@ atexit_func_entry_t __atexit_funcs[DSO_MAX_OBJECTS]; uarch_t __atexit_func_count; extern "C" void __cxa_pure_virtual() { - HCore::kcout << "HCoreKrnl: Placeholder method.\n"; + HCore::kcout << "HCoreKrnl.exe: Placeholder method.\n"; } extern "C" void ___chkstk_ms() { diff --git a/Private/Source/FileManager.cxx b/Private/Source/FileManager.cxx index 0e5499d6..7a09e5cf 100644 --- a/Private/Source/FileManager.cxx +++ b/Private/Source/FileManager.cxx @@ -12,15 +12,15 @@ //! @brief File manager for HCore. namespace HCore { -static IFilesystemManager* kMounted = nullptr; +static FilesystemManagerInterface* kMounted = nullptr; /// @brief FilesystemManager getter. /// @return The mounted filesystem. -IFilesystemManager* IFilesystemManager::GetMounted() { return kMounted; } +FilesystemManagerInterface* FilesystemManagerInterface::GetMounted() { return kMounted; } /// @brief Unmount filesystem. /// @return the unmounted filesystem. -IFilesystemManager* IFilesystemManager::Unmount() { +FilesystemManagerInterface* FilesystemManagerInterface::Unmount() { if (kMounted) { auto mount = kMounted; kMounted = nullptr; @@ -34,7 +34,7 @@ IFilesystemManager* IFilesystemManager::Unmount() { /// @brief Mount filesystem. /// @param pMount the filesystem to mount. /// @return if it succeeded true, otherwise false. -bool IFilesystemManager::Mount(IFilesystemManager* pMount) { +bool FilesystemManagerInterface::Mount(FilesystemManagerInterface* pMount) { if (kMounted == nullptr) { kMounted = pMount; return true; diff --git a/Private/Source/Framebuffer.cxx b/Private/Source/Framebuffer.cxx index 61f946a7..f31bd6dc 100644 --- a/Private/Source/Framebuffer.cxx +++ b/Private/Source/Framebuffer.cxx @@ -16,16 +16,16 @@ /** * @brief Framebuffer object implementation. - * + * */ using namespace HCore; /** * @brief Get Pixel at - * - * @param pos position of pixel. - * @return volatile* + * + * @param pos position of pixel. + * @return volatile* */ volatile UIntPtr *Framebuffer::operator[](const UIntPtr &pos) { return (UIntPtr *)(m_FrameBufferAddr->m_Base * pos); diff --git a/Private/Source/PEFSharedObjectRT.cxx b/Private/Source/PEFSharedObjectRT.cxx index 2284451a..d404819f 100644 --- a/Private/Source/PEFSharedObjectRT.cxx +++ b/Private/Source/PEFSharedObjectRT.cxx @@ -36,7 +36,7 @@ using namespace HCore; /***********************************************************************************/ EXTERN_C SharedObjectPtr rt_library_init(void) { - SharedObjectPtr library = hcore_tls_new_class(); + SharedObjectPtr library = tls_new_class(); if (!library) { ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); @@ -44,7 +44,7 @@ EXTERN_C SharedObjectPtr rt_library_init(void) { return nullptr; } - library->Mount(hcore_tls_new_class()); + library->Mount(tls_new_class()); if (!library->Get()) { ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); diff --git a/Private/Source/ThreadLocalStorage.cxx b/Private/Source/ThreadLocalStorage.cxx index 48e4e0a9..395b9dc6 100644 --- a/Private/Source/ThreadLocalStorage.cxx +++ b/Private/Source/ThreadLocalStorage.cxx @@ -25,7 +25,7 @@ using namespace HCore; * @return if the cookie is enabled. */ -Boolean hcore_tls_check(VoidPtr ptr) { +Boolean tls_check(VoidPtr ptr) { if (!ptr) return false; const char* _ptr = (const char*)ptr; @@ -41,10 +41,10 @@ Boolean hcore_tls_check(VoidPtr ptr) { * @param ptr * @return */ -EXTERN_C Void hcore_tls_check_syscall_impl(HCore::HAL::StackFramePtr stackPtr) noexcept { +EXTERN_C Void tls_check_syscall_impl(HCore::HAL::StackFramePtr stackPtr) noexcept { ThreadInformationBlock* tib = (ThreadInformationBlock*)stackPtr->Gs; - if (!hcore_tls_check(tib->Cookie)) { + if (!tls_check(tib->Cookie)) { kcout << "HCoreKrnl\\TLS: Verification failed, Crashing...\n"; ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); } diff --git a/Public/Kits/System.Core/Containers/XIFF.hxx b/Public/Kits/System.Core/Containers/XIFF.hxx index dbfe5b04..002d05f4 100644 --- a/Public/Kits/System.Core/Containers/XIFF.hxx +++ b/Public/Kits/System.Core/Containers/XIFF.hxx @@ -12,7 +12,7 @@ ------------------------------------------------------- */ -#include +#include /// @brief four-character code for XIFF. #define kFourCCLength_XIFF 4 diff --git a/Public/Kits/System.Core/CoreAPI.hxx b/Public/Kits/System.Core/CoreAPI.hxx deleted file mode 100644 index 66d356d7..00000000 --- a/Public/Kits/System.Core/CoreAPI.hxx +++ /dev/null @@ -1,56 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#ifndef __cplusplus -#error This API is meant to be used with C++ -#endif - -#ifdef CA_MUST_PASS -#undef CA_MUST_PASS -#endif - -// unused by user side, it's a kernel thing. -#define CA_MUST_PASS(e) ((void)e) - -#define CA_EXTERN_C extern "C" - -#define CA_STDCALL __attribute__((stdcall)) -#define CA_CDECL __attribute__((cdecl)) -#define CA_MSCALL __attribute__((ms_abi)) - -#define CA_PASCALL CA_STDCALL - -typedef __UINT8_TYPE__ BYTE; -typedef __UINT16_TYPE__ WORD; -typedef __UINT32_TYPE__ DWORD; -typedef __UINT64_TYPE__ QWORD; - -typedef void* PVOID; -typedef void VOID; - -typedef __WCHAR_TYPE__ WCHAR; -typedef WCHAR* PWCHAR; - -#ifdef __x86_64__ -# define _M_AMD64 2 -#endif - -#ifdef __aarch64__ -# define _M_AARCH64 3 -#endif - -#ifdef __powerpc64__ -# define _M_PPC64 4 -#endif - -#ifdef __64x0__ -# define _M_64000 5 -#endif - -#define CA_STATIC static -#define CA_INLINE inline \ No newline at end of file diff --git a/Public/Kits/System.Core/Defs.hxx b/Public/Kits/System.Core/Defs.hxx new file mode 100644 index 00000000..3ebe5c2c --- /dev/null +++ b/Public/Kits/System.Core/Defs.hxx @@ -0,0 +1,77 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#ifndef __cplusplus +#error This API is meant to be used with C++ +#endif + +#ifdef CA_MUST_PASS +#undef CA_MUST_PASS +#endif + +#define CA_UNREFERENCED_PARAMETER(e) ((void)e) + +/// Assertion macros. + +#ifdef _DEBUG +#define CA_MUST_PASS(e) __assert(e) +#else +#define CA_MUST_PASS(e) CA_UNREFERENCED_PARAMETER(e) +#endif + +#ifdef __cplusplus + +#define CA_EXTERN_C extern "C" + +#else + +#define CA_EXTERN_C extern + +#endif + +#define CA_STDCALL __attribute__((stdcall)) +#define CA_CDECL __attribute__((cdecl)) +#define CA_MSCALL __attribute__((ms_abi)) + +#define CA_PASCALL CA_STDCALL + +typedef __UINT8_TYPE__ BYTE; +typedef __UINT16_TYPE__ WORD; +typedef __UINT32_TYPE__ DWORD; +typedef __UINT64_TYPE__ QWORD; + +typedef void* PVOID; +typedef void VOID; + +typedef __WCHAR_TYPE__ WCHAR; +typedef WCHAR* PWCHAR; + +#ifdef __x86_64__ +# define _M_AMD64 2 +#endif + +#ifdef __aarch64__ +# define _M_AARCH64 3 +#endif + +#ifdef __powerpc64__ +# define _M_PPC64 4 +#endif + +#ifdef __64x0__ +# define _M_64000 5 +#endif + +#define CA_STATIC static +#define CA_INLINE inline + +#ifdef __cplusplus +#define CA_CONSTEXPR constexpr +#else +#define CA_CONSTEXPR +#endif // __cplusplus diff --git a/Public/Kits/System.Core/File.hxx b/Public/Kits/System.Core/File.hxx new file mode 100644 index 00000000..2f799330 --- /dev/null +++ b/Public/Kits/System.Core/File.hxx @@ -0,0 +1,42 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#ifndef _SYSTEM_KIT_HCORE_FILE_HPP +#define _SYSTEM_KIT_HCORE_FILE_HPP + +#include +#include + +using namespace HCore; + +/// @brief SOM class, translated to C++ + +namespace System { +class File final { + public: + explicit File(const char *path); + ~File(); + + public: + HCORE_COPY_DEFAULT(File); + + public: + voidPtr Read(SizeT off, SizeT sz); + void Write(voidPtr buf, SizeT off, SizeT sz); + void Seek(SizeT off); + voidPtr Read(SizeT sz); + void Write(voidPtr buf, SizeT sz); + void Rewind(); + + public: + const char *MIME(); + void MIME(const char *mime); +}; + +typedef File *FilePtr; +} // namespace System + +#endif // ifndef _SYSTEM_KIT_HCORE_FILE_HPP diff --git a/Public/Kits/System.Core/FileAPI.hxx b/Public/Kits/System.Core/FileAPI.hxx deleted file mode 100644 index 2f799330..00000000 --- a/Public/Kits/System.Core/FileAPI.hxx +++ /dev/null @@ -1,42 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#ifndef _SYSTEM_KIT_HCORE_FILE_HPP -#define _SYSTEM_KIT_HCORE_FILE_HPP - -#include -#include - -using namespace HCore; - -/// @brief SOM class, translated to C++ - -namespace System { -class File final { - public: - explicit File(const char *path); - ~File(); - - public: - HCORE_COPY_DEFAULT(File); - - public: - voidPtr Read(SizeT off, SizeT sz); - void Write(voidPtr buf, SizeT off, SizeT sz); - void Seek(SizeT off); - voidPtr Read(SizeT sz); - void Write(voidPtr buf, SizeT sz); - void Rewind(); - - public: - const char *MIME(); - void MIME(const char *mime); -}; - -typedef File *FilePtr; -} // namespace System - -#endif // ifndef _SYSTEM_KIT_HCORE_FILE_HPP diff --git a/Public/Kits/System.Core/HCoreBase.hxx b/Public/Kits/System.Core/HCoreBase.hxx index c8a3a99c..5bb6f9af 100644 --- a/Public/Kits/System.Core/HCoreBase.hxx +++ b/Public/Kits/System.Core/HCoreBase.hxx @@ -4,7 +4,7 @@ #pragma once -#include +#include typedef struct HcObject { void(*Release)(void); diff --git a/Public/Kits/System.Core/Heap.cxx b/Public/Kits/System.Core/Heap.cxx new file mode 100644 index 00000000..c7401aad --- /dev/null +++ b/Public/Kits/System.Core/Heap.cxx @@ -0,0 +1,38 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include +#include + +using namespace HCore; +using namespace System; + +STATIC HcObjectPtr kObjectHeap; + +Heap* Heap::Shared() noexcept { + static Heap* heap = nullptr; + + if (!heap) { + heap = new Heap(); + kObjectHeap = HcGetProcessHeap(); + } + + return heap; +} + +void Heap::Delete(HeapPtr me) noexcept { HcFreeProcessHeap(kObjectHeap, me); } + +SizeT Heap::Size(HeapPtr me) noexcept { + CA_MUST_PASS(me); + return HcProcessHeapSize(kObjectHeap, me); +} + +HeapPtr Heap::New(const SizeT &sz, const Int32 flags) { + SizeT _sz = sz; + if (!_sz) ++_sz; + + return HcAllocateProcessHeap(kObjectHeap, _sz, flags); +} \ No newline at end of file diff --git a/Public/Kits/System.Core/Heap.hxx b/Public/Kits/System.Core/Heap.hxx new file mode 100644 index 00000000..292a1227 --- /dev/null +++ b/Public/Kits/System.Core/Heap.hxx @@ -0,0 +1,62 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include +#include + +namespace System { +class MemoryException; + +typedef PVOID HeapPtr; + +enum { + kHeapExpandable = 2, + kHeapNoExecute = 4, + kHeapShared = 6, + kHeapReadOnly = 8, + kHeapNoFlags = 0 +}; + +class Heap final { + private: + explicit Heap(); + + public: + ~Heap(); + + public: + HCORE_COPY_DEFAULT(Heap); + + public: + static Heap *Shared() noexcept; + + public: + void Delete(HeapPtr me) noexcept; + SizeT Size(HeapPtr me) noexcept; + HeapPtr New(const SizeT &sz, const Int32 flags = kHeapNoFlags); +}; + +class MemoryException final { + public: + explicit MemoryException() = default; + ~MemoryException() = default; + + public: + HCORE_COPY_DEFAULT(MemoryException); + + public: + const char *Name(); + const char *Reason(); + + private: + const char *mReason{"System.Core: Process Heap Exception: Catastrophic failure!"}; + + private: + friend Heap; +}; +} // namespace System \ No newline at end of file diff --git a/Public/Kits/System.Core/HeapAPI.cxx b/Public/Kits/System.Core/HeapAPI.cxx deleted file mode 100644 index 232b4927..00000000 --- a/Public/Kits/System.Core/HeapAPI.cxx +++ /dev/null @@ -1,38 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#include -#include - -using namespace HCore; -using namespace System; - -STATIC HcObjectPtr kObjectHeap; - -Heap* Heap::Shared() noexcept { - static Heap* heap = nullptr; - - if (!heap) { - heap = new Heap(); - kObjectHeap = HcGetProcessHeap(); - } - - return heap; -} - -void Heap::Delete(HeapPtr me) noexcept { HcFreeProcessHeap(kObjectHeap, me); } - -SizeT Heap::Size(HeapPtr me) noexcept { - CA_MUST_PASS(me); - return HcProcessHeapSize(kObjectHeap, me); -} - -HeapPtr Heap::New(const SizeT &sz, const Int32 flags) { - SizeT _sz = sz; - if (!_sz) ++_sz; - - return HcAllocateProcessHeap(kObjectHeap, _sz, flags); -} \ No newline at end of file diff --git a/Public/Kits/System.Core/HeapAPI.hxx b/Public/Kits/System.Core/HeapAPI.hxx deleted file mode 100644 index f50ff6f7..00000000 --- a/Public/Kits/System.Core/HeapAPI.hxx +++ /dev/null @@ -1,66 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include -#include - -/// @brief SOM class, translated to C++ - -using namespace HCore; - -namespace System { -class MemoryException; - -typedef VoidPtr HeapPtr; - -enum { - kHeapExpandable = 2, - kHeapNoExecute = 4, - kHeapShared = 6, - kHeapReadOnly = 8, - kHeapNoFlags = 0 -}; - -class Heap final { - private: - explicit Heap(); - - public: - ~Heap(); - - public: - HCORE_COPY_DEFAULT(Heap); - - public: - static Heap *Shared() noexcept; - - public: - void Delete(HeapPtr me) noexcept; - SizeT Size(HeapPtr me) noexcept; - HeapPtr New(const SizeT &sz, const Int32 flags = kHeapNoFlags); -}; - -class MemoryException final { - public: - explicit MemoryException() = default; - ~MemoryException() = default; - - public: - HCORE_COPY_DEFAULT(MemoryException); - - public: - const char *Name(); - const char *Reason(); - - private: - const char *mReason{"HeapAPI: Memory Exception!"}; - - private: - friend Heap; -}; -} // namespace System \ No newline at end of file diff --git a/Public/Kits/System.Core/System.Core.hxx b/Public/Kits/System.Core/System.Core.hxx new file mode 100644 index 00000000..b368b997 --- /dev/null +++ b/Public/Kits/System.Core/System.Core.hxx @@ -0,0 +1,15 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#pragma once + +/// Core API +#include + +/// Process Heap API +#include + +/// File API & Device API. + +/// Process & Threading API \ No newline at end of file diff --git a/Public/Kits/System.Core/System.hxx b/Public/Kits/System.Core/System.hxx index 97d4bdac..37cab4a4 100644 --- a/Public/Kits/System.Core/System.hxx +++ b/Public/Kits/System.Core/System.hxx @@ -10,9 +10,9 @@ ------------------------------------------------------- */ -#include -#include -#include +#include +#include +#include #include using namespace HCore; diff --git a/Public/Kits/System.Core/hcore.h b/Public/Kits/System.Core/hcore.h deleted file mode 100644 index b368b997..00000000 --- a/Public/Kits/System.Core/hcore.h +++ /dev/null @@ -1,15 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#pragma once - -/// Core API -#include - -/// Process Heap API -#include - -/// File API & Device API. - -/// Process & Threading API \ No newline at end of file diff --git a/Public/Kits/System.Graphics/Core.hxx b/Public/Kits/System.Graphics/Core.hxx index d0f62418..43751891 100644 --- a/Public/Kits/System.Graphics/Core.hxx +++ b/Public/Kits/System.Graphics/Core.hxx @@ -22,7 +22,7 @@ #define $() HCore::GApplication::Shared()->Document() -#ifdef __IMPORT_LIB +#ifndef __EXPORT_LIB #define G_API __attribute__((pef_container(".IMPORT"))) #else #define G_API __attribute__((pef_container(".EXPORT"))) @@ -167,11 +167,11 @@ class GException final { HCORE_COPY_DEFAULT(GException); public: - const char* Name() { return "GUI Error"; } + const char* Name() { return "User Interface error."; } const char* Reason() { return mReason; } private: - const char* mReason{"CoreAPI: GUI Exception!"}; + const char* mReason{"System.Graphics: User Interface error. Check HError."}; }; template diff --git a/Public/Kits/System.Zip/Zip.cxx b/Public/Kits/System.Zip/Zip.cxx index 39818da7..1e4a28cb 100644 --- a/Public/Kits/System.Zip/Zip.cxx +++ b/Public/Kits/System.Zip/Zip.cxx @@ -8,7 +8,7 @@ */ #include -#include +#include #define kInitialSz 4096 -- cgit v1.2.3