summaryrefslogtreecommitdiffhomepage
path: root/Private
diff options
context:
space:
mode:
Diffstat (limited to 'Private')
-rw-r--r--Private/Drivers/AHCI/Defines.hxx2
-rw-r--r--Private/Drivers/PS2/Mouse.hxx80
-rw-r--r--Private/Drivers/PS2/PS2KernelMouse.hxx104
-rw-r--r--Private/HALKit/AMD64/HalControlRegister.s4
-rw-r--r--Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp14
-rw-r--r--Private/HALKit/AMD64/HalDescriptorLoader.cpp91
-rw-r--r--Private/HALKit/AMD64/HalInterruptRouting.asm148
-rw-r--r--Private/HALKit/AMD64/HalKernelMain.cxx37
-rw-r--r--Private/HALKit/AMD64/HalKernelMouse.cxx122
-rw-r--r--Private/HALKit/AMD64/HalNewBoot.asm3
-rw-r--r--Private/HALKit/AMD64/HalPageAlloc.hpp12
-rw-r--r--Private/HALKit/AMD64/HalRoutines.s4
-rw-r--r--Private/HALKit/AMD64/Processor.hpp8
-rw-r--r--Private/KernelKit/FileManager.hpp20
-rw-r--r--Private/KernelKit/LoaderInterface.hpp1
-rw-r--r--Private/KernelKit/ProcessTeam.hpp2
-rw-r--r--Private/KernelKit/Rsrc/Cursor.rsrc40
-rw-r--r--Private/KernelKit/Rsrc/Util.hxx27
-rw-r--r--Private/KernelKit/ThreadLocalStorage.hxx10
-rw-r--r--Private/KernelKit/ThreadLocalStorage.inl8
-rw-r--r--Private/LinkerScripts/16x0.json2
-rw-r--r--Private/LinkerScripts/32x0.json2
-rw-r--r--Private/LinkerScripts/64x0.json2
-rw-r--r--Private/NewBoot/Source/makefile2
-rw-r--r--Private/NewKit/KernelHeap.hpp2
-rw-r--r--Private/NewKit/LockDelegate.hpp6
-rw-r--r--Private/Source/CxxAbi.cxx2
-rw-r--r--Private/Source/FileManager.cxx8
-rw-r--r--Private/Source/Framebuffer.cxx8
-rw-r--r--Private/Source/PEFSharedObjectRT.cxx4
-rw-r--r--Private/Source/ThreadLocalStorage.cxx6
31 files changed, 578 insertions, 203 deletions
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 <ArchKit/ArchKit.hpp>
-#include <CompilerKit/CompilerKit.hxx>
-#include <NewKit/Defines.hpp>
-
-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 <ArchKit/ArchKit.hpp>
+#include <CompilerKit/CompilerKit.hxx>
+#include <NewKit/Defines.hpp>
+
+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 <ArchKit/ArchKit.hpp>
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<UIntPtr>(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<UIntPtr>(Detail::kInterruptVectorTable);
+ Detail::kRegIdt.Limit = sizeof(::HCore::Detail::AMD64::InterruptDescriptorAMD64) *
+ (kKernelIdtSize - 1);
+
+ hal_load_idt(Detail::kRegIdt);
+
+ Detail::RemapPIC();
}
void GDTLoader::Load(Ref<RegisterGDT> &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 <ArchKit/ArchKit.hpp>
-#include <Drivers/PS2/Mouse.hxx>
#include <FirmwareKit/Handover.hxx>
#include <KernelKit/FileManager.hpp>
#include <KernelKit/Framebuffer.hpp>
#include <KernelKit/PEFCodeManager.hxx>
+#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/Rsrc/Splash.rsrc>
#include <KernelKit/Rsrc/Util.hxx>
#include <NewKit/Json.hpp>
#include <NewKit/KernelHeap.hpp>
#include <NewKit/UserHeap.hpp>
-#include <KernelKit/ProcessScheduler.hpp>
-#include <KernelKit/Rsrc/Splash.rsrc>
///! @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<HCore::UIntPtr>(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 <KernelKit/Rsrc/Util.hxx>
+#include <KernelKit/Rsrc/Cursor.rsrc>
+#include <Drivers/PS2/PS2KernelMouse.hxx>
+#include <NewKit/Defines.hpp>
+#include <KernelKit/Framebuffer.hpp>
+
+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 <typename Encoding = char, typename FSClass = IFilesystemManager>
+template <typename Encoding = char, typename FSClass = FilesystemManagerInterface>
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 <CompilerKit/CompilerKit.hxx>
+#include <HintKit/CompilerHint.hxx>
#include <NewKit/Defines.hpp>
#include <NewKit/ErrorOr.hpp>
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 <KernelKit/ProcessScheduler.hpp> \ No newline at end of file
+#include <KernelKit/ProcessScheduler.hpp>
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 <typename T>
-T *hcore_tls_new_ptr(void);
+T *tls_new_ptr(void);
template <typename T>
-bool hcore_tls_delete_ptr(T *ptr);
+bool tls_delete_ptr(T *ptr);
template <typename T, typename... Args>
-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 <KernelKit/ThreadLocalStorage.inl>
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 <typename T>
-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 <typename T>
-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 <typename T, typename... Args>
-T* hcore_tls_new_class(Args&&... args) {
- T* ptr = hcore_tls_new_ptr<T>();
+T* tls_new_class(Args&&... args) {
+ T* ptr = tls_new_ptr<T>();
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 <NewKit/Defines.hpp>
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 <Size N>
+/// @brief Locking delegate class, hangs until limit.
+/// @tparam N
+template <SizeT N>
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<SharedObject>();
+ SharedObjectPtr library = tls_new_class<SharedObject>();
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<SharedObject::SharedObjectTraits>());
+ library->Mount(tls_new_class<SharedObject::SharedObjectTraits>());
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();
}