summaryrefslogtreecommitdiffhomepage
path: root/Private
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-25 08:06:38 +0100
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-25 08:06:38 +0100
commit9be51d883414584db0926ab854d6026e1785048b (patch)
tree6afb5cec25c48ac76a8e26b2cc0b09dd1dc2c1ea /Private
parent27e0af3ecfe0be226f88837634111299121e5ddb (diff)
Kernel: Morning bump.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private')
-rw-r--r--Private/ArchKit/ArchKit.hpp2
-rw-r--r--Private/Drivers/PS2/Mouse.hxx47
-rw-r--r--Private/HALKit/AMD64/HalCoreInterruptHandler.cpp25
-rw-r--r--Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp17
-rw-r--r--Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp5
-rw-r--r--Private/HALKit/AMD64/HalHardwareInit.cpp16
-rw-r--r--Private/HALKit/AMD64/HalInterruptRouting.asm5
-rw-r--r--Private/HALKit/AMD64/HalPlatformAMD64.cpp2
-rw-r--r--Private/HALKit/AMD64/HalRoutines.s1
-rw-r--r--Private/HALKit/AMD64/Processor.hpp3
-rw-r--r--Private/KernelKit/DeviceManager.hpp3
-rw-r--r--Private/KernelKit/MSDOS.hpp4
-rw-r--r--Private/KernelKit/Rsrc/Util.hxx5
-rw-r--r--Private/KernelKit/SMPManager.hpp3
-rw-r--r--Private/NewBoot/Source/BootMain.cxx6
-rw-r--r--Private/NewBoot/Source/TextWriter.cxx4
-rw-r--r--Private/NewBoot/Source/bundle.mk2
-rw-r--r--Private/Source/KernelMain.cxx1
-rw-r--r--Private/Source/PEFCodeManager.cxx3
19 files changed, 98 insertions, 56 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 {