diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-25 08:06:38 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-25 08:06:38 +0100 |
| commit | 9be51d883414584db0926ab854d6026e1785048b (patch) | |
| tree | 6afb5cec25c48ac76a8e26b2cc0b09dd1dc2c1ea | |
| parent | 27e0af3ecfe0be226f88837634111299121e5ddb (diff) | |
Kernel: Morning bump.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
28 files changed, 134 insertions, 70 deletions
diff --git a/Private/ArchKit/ArchKit.hpp b/Private/ArchKit/ArchKit.hpp index 20d83ecc..4f24d251 100644 --- a/Private/ArchKit/ArchKit.hpp +++ b/Private/ArchKit/ArchKit.hpp @@ -55,7 +55,7 @@ constexpr static inline SSizeT syscall_hash(const char *seed, int mul) { bool ke_init_hal(); } // namespace HCore -#define kMaxSyscalls 0x100 +#define kMaxSyscalls (0x100 - 1) #define kSyscallGate 0x21 extern HCore::Array<void (*)(HCore::Int32 id, HCore::HAL::StackFrame *), diff --git a/Private/Drivers/PS2/Mouse.hxx b/Private/Drivers/PS2/Mouse.hxx index 20cac560..9e9607e1 100644 --- a/Private/Drivers/PS2/Mouse.hxx +++ b/Private/Drivers/PS2/Mouse.hxx @@ -19,8 +19,30 @@ namespace HCore { -class PS2Mouse { - explicit PS2Mouse() = default; +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); @@ -30,14 +52,10 @@ class PS2Mouse { Int32 X, Y; }; - PS2MouseTraits Read() noexcept { - PS2MouseTraits stat; - - return stat; - } + Boolean operator>>(PS2MouseTraits& stat) noexcept { return true; } private: - UInt8 Wait() { + Bool Wait() noexcept { while (!(HAL::In8(0x64) & 1)) { asm("pause"); } // wait until we can read @@ -45,5 +63,18 @@ class PS2Mouse { // 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/HALKit/AMD64/HalCoreInterruptHandler.cpp b/Private/HALKit/AMD64/HalCoreInterruptHandler.cpp new file mode 100644 index 00000000..a668a0e4 --- /dev/null +++ b/Private/HALKit/AMD64/HalCoreInterruptHandler.cpp @@ -0,0 +1,25 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <ArchKit/ArchKit.hpp> +#include <KernelKit/ProcessManager.hpp> +#include <NewKit/String.hpp> + +extern "C" HCore::UIntPtr rt_handle_interrupts(HCore::UIntPtr &rsp) { + HCore::HAL::rt_cli(); + + HCore::HAL::StackFramePtr sf = (HCore::HAL::StackFramePtr)rsp; + + rt_syscall_handle(sf); + + HCore::kcout << "Krnl\\rt_handle_interrupts: Done\r\n"; + + HCore::HAL::rt_sti(); + return rsp; +} diff --git a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp index caf891d1..98d36f86 100644 --- a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp +++ b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp @@ -25,7 +25,7 @@ extern "C" void idt_handle_gpf(HCore::UIntPtr rsp) { HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); HCore::kcout - << "General Protection Fault, Caused by " + << "General Protection Fault, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); @@ -50,7 +50,7 @@ extern "C" void idt_handle_pf(HCore::UIntPtr rsp) { MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); HCore::kcout - << "Segmentation Fault, Caused by " + << "Segmentation Fault, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); @@ -62,7 +62,7 @@ extern "C" void idt_handle_math(HCore::UIntPtr rsp) { MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); HCore::kcout - << "Math error, Caused by " + << "Math error, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); @@ -74,17 +74,8 @@ extern "C" void idt_handle_generic(HCore::UIntPtr rsp) { MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); HCore::kcout - << "Processor error, Caused by " + << "Execution error, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); } - -extern "C" HCore::UIntPtr rt_handle_interrupts(HCore::UIntPtr &rsp) { - HCore::HAL::rt_cli(); - - HCore::HAL::StackFramePtr sf = (HCore::HAL::StackFramePtr)rsp; - - HCore::HAL::rt_sti(); - return rsp; -} diff --git a/Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp b/Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp index 4f1ed4da..2e75b6cb 100644 --- a/Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp +++ b/Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp @@ -14,10 +14,9 @@ HCore::Array<void (*)(HCore::Int32 id, HCore::HAL::StackFrame *), kMaxSyscalls> kSyscalls; -// IDT System Call Handler. -// NOTE: don't trust the user. +/// @brief Interrupt system call handler. extern "C" void rt_syscall_handle(HCore::HAL::StackFrame *stack) { for (HCore::SizeT index = 0UL; index < kMaxSyscalls; ++index) { - (kSyscalls[index].Leak().Leak())(stack->R15, stack); + if (kSyscalls[index]) (kSyscalls[index].Leak().Leak())(stack->R15, stack); } } diff --git a/Private/HALKit/AMD64/HalHardwareInit.cpp b/Private/HALKit/AMD64/HalHardwareInit.cpp index 1c857ff7..43b15169 100644 --- a/Private/HALKit/AMD64/HalHardwareInit.cpp +++ b/Private/HALKit/AMD64/HalHardwareInit.cpp @@ -11,18 +11,10 @@ // bugs = 0 -extern "C" HCore::VoidPtr __EXEC_IVT; +extern "C" HCore::UIntPtr* __EXEC_IVT; -namespace HCore { -bool ke_init_hal() { - HCore::HAL::Register64 kIdtRegister; - - kIdtRegister.Base = (UIntPtr)__EXEC_IVT; - kIdtRegister.Limit = sizeof(HAL::Register64) * 255; +extern void rt_wait_for_io(void); - HAL::IDTLoader idt; - idt.Load(kIdtRegister); - - return true; -} +namespace HCore { +bool ke_init_hal() { return true; } } // namespace HCore diff --git a/Private/HALKit/AMD64/HalInterruptRouting.asm b/Private/HALKit/AMD64/HalInterruptRouting.asm index 9bc13f15..da0a8d5a 100644 --- a/Private/HALKit/AMD64/HalInterruptRouting.asm +++ b/Private/HALKit/AMD64/HalInterruptRouting.asm @@ -19,6 +19,7 @@ HCoreInterrupt%1: push %1 jmp ke_handle_irq + iretq %endmacro %macro IntNormal 1 @@ -26,6 +27,7 @@ HCoreInterrupt%1: push 0 push %1 jmp ke_handle_irq + iretq %endmacro ; This file handles the core interrupt table @@ -38,8 +40,6 @@ global __EXEC_IVT section .text ke_handle_irq: - cld - push rax push rbx push rcx @@ -76,6 +76,7 @@ ke_handle_irq: pop rbx pop rax + ret section .data diff --git a/Private/HALKit/AMD64/HalPlatformAMD64.cpp b/Private/HALKit/AMD64/HalPlatformAMD64.cpp index 71b7542e..b2e343b6 100644 --- a/Private/HALKit/AMD64/HalPlatformAMD64.cpp +++ b/Private/HALKit/AMD64/HalPlatformAMD64.cpp @@ -35,9 +35,7 @@ void IDTLoader::Load(Register64 &idt) { reg->base = idt.Base; reg->limit = idt.Limit; - rt_cli(); rt_load_idt(reg); - rt_sti(); } void GDTLoader::Load(Ref<Register64> &gdt) { GDTLoader::Load(gdt.Leak()); } diff --git a/Private/HALKit/AMD64/HalRoutines.s b/Private/HALKit/AMD64/HalRoutines.s index 3e70a507..28833c47 100644 --- a/Private/HALKit/AMD64/HalRoutines.s +++ b/Private/HALKit/AMD64/HalRoutines.s @@ -10,7 +10,6 @@ rt_load_gdt: rt_load_idt: lidt (%rcx) - sti ret .section .text diff --git a/Private/HALKit/AMD64/Processor.hpp b/Private/HALKit/AMD64/Processor.hpp index bacfb393..5c79e042 100644 --- a/Private/HALKit/AMD64/Processor.hpp +++ b/Private/HALKit/AMD64/Processor.hpp @@ -56,7 +56,8 @@ using interruptTrap = UIntPtr(UIntPtr sp); typedef UIntPtr Reg; -struct __attribute__((packed)) StackFrame { +struct PACKED StackFrame { + Reg IntNum; Reg Rax; Reg Rbx; Reg Rcx; diff --git a/Private/KernelKit/DeviceManager.hpp b/Private/KernelKit/DeviceManager.hpp index 582d1194..156e76b9 100644 --- a/Private/KernelKit/DeviceManager.hpp +++ b/Private/KernelKit/DeviceManager.hpp @@ -24,7 +24,8 @@ #include <NewKit/ErrorOr.hpp> #include <NewKit/Ref.hpp> -#include "NewKit/KernelCheck.hpp" +// Last Rev +// Sat Feb 24 CET 2024 namespace HCore { template <typename T> diff --git a/Private/KernelKit/MSDOS.hpp b/Private/KernelKit/MSDOS.hpp index 1adf6082..565d77af 100644 --- a/Private/KernelKit/MSDOS.hpp +++ b/Private/KernelKit/MSDOS.hpp @@ -14,9 +14,11 @@ #ifndef __MSDOS_EXEC__ #define __MSDOS_EXEC__ +#include <KernelKit/PE.hpp> #include <NewKit/Defines.hpp> -#include "PE.hpp" +// Last Rev +// Sat Feb 24 CET 2024 typedef HCore::UInt32 DosWord; typedef HCore::Long DosLong; diff --git a/Private/KernelKit/Rsrc/Util.hxx b/Private/KernelKit/Rsrc/Util.hxx index 4322890c..0e52a9a9 100644 --- a/Private/KernelKit/Rsrc/Util.hxx +++ b/Private/KernelKit/Rsrc/Util.hxx @@ -1,7 +1,10 @@ #ifndef __RSRC_UTIL__ #define __RSRC_UTIL__ -/// @brief draws a resource icon. +// Last Rev +// Sat Feb 24 CET 2024 + +/// @brief draws a resource. #define DrawResource(ImgPtr, HandoverHeader, Width, Height, BaseX, BaseY) \ HCore::SizeT uA = 0; \ \ diff --git a/Private/KernelKit/SMPManager.hpp b/Private/KernelKit/SMPManager.hpp index dc3518a7..c7e94a4a 100644 --- a/Private/KernelKit/SMPManager.hpp +++ b/Private/KernelKit/SMPManager.hpp @@ -14,7 +14,8 @@ #include <CompilerKit/CompilerKit.hpp> #include <NewKit/Ref.hpp> -#include "NewKit/Defines.hpp" +// Last Rev +// Sat Feb 24 CET 2024 #define kMaxHarts 8 diff --git a/Private/NewBoot/Source/BootMain.cxx b/Private/NewBoot/Source/BootMain.cxx index 35270b4b..fa8eb46c 100644 --- a/Private/NewBoot/Source/BootMain.cxx +++ b/Private/NewBoot/Source/BootMain.cxx @@ -38,16 +38,16 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, #ifdef __BUNDLE_KERNEL__ writer.WriteString(L"HCoreLite: "); #else - writer.WriteString(L"HCoreLdr:"); + writer.WriteString(L"HCoreLdr: "); #endif #ifndef __DEBUG__ - writer.WriteString(L"Version 1.00 (Release Channel)\r\n"); + writer.WriteString(L"Version 1.12 (Release Channel)\r\n"); #else - writer.WriteString(L"Version 1.00 (Insiders Channel)\r\n"); + writer.WriteString(L"Version 1.12 (Insiders Channel)\r\n"); #endif diff --git a/Private/NewBoot/Source/TextWriter.cxx b/Private/NewBoot/Source/TextWriter.cxx index b35866a5..1191c288 100644 --- a/Private/NewBoot/Source/TextWriter.cxx +++ b/Private/NewBoot/Source/TextWriter.cxx @@ -54,8 +54,8 @@ BTextWriter &BTextWriter::WriteString(const Long &x) { if (y < 0) y = -y; - const char g_numbers[17] = "0123456789ABCDEF"; + const char NUMBERS[17] = "0123456789ABCDEF"; - this->WriteCharacter(g_numbers[h]); + this->WriteCharacter(NUMBERS[h]); return *this; } diff --git a/Private/NewBoot/Source/bundle.mk b/Private/NewBoot/Source/bundle.mk index e0894f94..23bf570e 100644 --- a/Private/NewBoot/Source/bundle.mk +++ b/Private/NewBoot/Source/bundle.mk @@ -27,7 +27,7 @@ bootloader-amd64: .PHONY: run-efi-amd64 run-efi-amd64: wget https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd - qemu-system-x86_64 -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -serial stdio + qemu-system-x86_64 -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -d int .PHONY: clean clean: diff --git a/Private/Source/KernelMain.cxx b/Private/Source/KernelMain.cxx index cfd27748..b4ea817a 100644 --- a/Private/Source/KernelMain.cxx +++ b/Private/Source/KernelMain.cxx @@ -8,6 +8,7 @@ */ #include <ArchKit/ArchKit.hpp> +#include <Drivers/PS2/Mouse.hxx> #include <FirmwareKit/Handover.hxx> #include <KernelKit/FileManager.hpp> #include <KernelKit/Framebuffer.hpp> diff --git a/Private/Source/PEFCodeManager.cxx b/Private/Source/PEFCodeManager.cxx index ee535057..c1340054 100644 --- a/Private/Source/PEFCodeManager.cxx +++ b/Private/Source/PEFCodeManager.cxx @@ -18,9 +18,6 @@ #include <NewKit/OwnPtr.hpp> #include <NewKit/String.hpp> -#include "KernelKit/PEF.hpp" -#include "NewKit/Utils.hpp" - namespace HCore { namespace Detail { UInt32 rt_get_pef_platform(void) noexcept { diff --git a/Public/Kits/GKit/Core.cxx b/Public/Kits/GKit/Core.cxx index 1e694734..4030041f 100644 --- a/Public/Kits/GKit/Core.cxx +++ b/Public/Kits/GKit/Core.cxx @@ -11,4 +11,4 @@ ------------------------------------------- */ -#include <GKit/Core.hpp> +#include <GKit/Core.hxx> diff --git a/Public/Kits/GKit/Core.hpp b/Public/Kits/GKit/Core.hxx index 39eb341b..98a25f72 100644 --- a/Public/Kits/GKit/Core.hpp +++ b/Public/Kits/GKit/Core.hxx @@ -2,7 +2,7 @@ Copyright Mahrouss Logic - File: Core.hpp + File: Core.hxx Purpose: Revision History: @@ -23,9 +23,9 @@ #define $() HCore::GApplication::Shared()->Document() #ifdef __EXPORT_LIB -#define G_API __attribute__((container(".EXPORT"))) +#define G_API __attribute__((pef_container(".EXPORT"))) #else -#define G_API __attribute__((container(".IMPORT"))) +#define G_API __attribute__((pef_container(".IMPORT"))) #endif // ifdef __EXPORT_LIB namespace HCore { @@ -157,4 +157,29 @@ class G_API GDocument final { GFrame* mFrame{nullptr}; GString mString; }; + +class GException final { + public: + explicit GException() = default; + ~GException() = default; + + public: + HCORE_COPY_DEFAULT(GException); + + public: + const char* Name() { return "GUI Error"; } + const char* Reason() { return mReason; } + + private: + const char* mReason{"CoreAPI: GUI Exception!"}; +}; + +template <typename GFrameType, typename GFrameBase> +inline GFrameType* frame_cast(GFrameBase* Frame) { + if (!dynamic_cast<GFrameType*>(Frame)) { + throw GException(); + } + + return dynamic_cast<GFrameType*>(Frame); +} } // namespace HCore diff --git a/Public/Kits/GKit/Dim2d.hpp b/Public/Kits/GKit/Dim2d.hpp index 9ae01aa0..23d1e100 100644 --- a/Public/Kits/GKit/Dim2d.hpp +++ b/Public/Kits/GKit/Dim2d.hpp @@ -14,7 +14,7 @@ #ifndef __GORG__DIM2D_HPP__ #define __GORG__DIM2D_HPP__ -#include <GKit/Core.hpp> +#include <GKit/Core.hxx> namespace HCore { class Dim2d final { diff --git a/Public/Kits/GKit/Frame.cxx b/Public/Kits/GKit/Frame.cxx index 939dfc5a..c1f1df2c 100644 --- a/Public/Kits/GKit/Frame.cxx +++ b/Public/Kits/GKit/Frame.cxx @@ -11,6 +11,6 @@ ------------------------------------------- */ -#include <GKit/Frame.hpp> +#include <GKit/Frame.hxx> namespace HCore {} diff --git a/Public/Kits/GKit/Frame.hpp b/Public/Kits/GKit/Frame.hxx index f71628a7..efa46fa3 100644 --- a/Public/Kits/GKit/Frame.hpp +++ b/Public/Kits/GKit/Frame.hxx @@ -2,7 +2,7 @@ Copyright Mahrouss Logic - File: Frame.hpp + File: Frame.hxx Purpose: Revision History: @@ -13,7 +13,7 @@ #pragma once -#include <GKit/Core.hpp> +#include <GKit/Core.hxx> #include <GKit/Dim2d.hpp> #include <NewKit/MutableArray.hpp> diff --git a/Public/Kits/GKit/Makefile b/Public/Kits/GKit/Makefile index be1586d9..2873f91b 100644 --- a/Public/Kits/GKit/Makefile +++ b/Public/Kits/GKit/Makefile @@ -5,8 +5,6 @@ CC=x86_64-w64-mingw32-g++ CCFLAGS=-shared -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -ASM=nasm -ASMFLAGS=-f elf64 OUTPUT=GKit.dll .PHONY: build-gkit diff --git a/Public/Kits/GKit/Stylesheet.hxx b/Public/Kits/GKit/Stylesheet.hxx index a34dd435..55291f73 100644 --- a/Public/Kits/GKit/Stylesheet.hxx +++ b/Public/Kits/GKit/Stylesheet.hxx @@ -15,12 +15,10 @@ /// TODO: Stylesheets for GUI. -#include <GKit/Core.hpp> +#include <GKit/Core.hxx> #include <GKit/Dim2d.hpp> #include <NewKit/MutableArray.hpp> -#include "NewKit/String.hpp" - namespace HCore { class G_API Stylesheet final { public: diff --git a/Public/Kits/SystemKit/CoreAPI.hxx b/Public/Kits/SystemKit/CoreAPI.hxx index 8fc2d770..46af0cef 100644 --- a/Public/Kits/SystemKit/CoreAPI.hxx +++ b/Public/Kits/SystemKit/CoreAPI.hxx @@ -26,6 +26,7 @@ #define CA_CDECL __attribute__((cdecl)) #define CA_MSCALL __attribute__((ms_abi)) +typedef __UINT8_TYPE__ BYTE; typedef __UINT16_TYPE__ WORD; typedef __UINT32_TYPE__ DWORD; typedef __UINT64_TYPE__ QWORD; diff --git a/Public/Kits/SystemKit/ThreadAPI.hxx b/Public/Kits/SystemKit/ThreadAPI.hxx index 80742ab9..bbdf4779 100644 --- a/Public/Kits/SystemKit/ThreadAPI.hxx +++ b/Public/Kits/SystemKit/ThreadAPI.hxx @@ -24,7 +24,7 @@ struct ThreadInformationBlock final { const UIntPtr StartAddress; // Start Address const UIntPtr StartHeap; // Allocation Heap const UIntPtr StartStack; // Stack Pointer. - const Int32 ARCH; // Architecture and/or platform. + const Int32 Arch; // Architecture and/or platform. }; enum { |
