summaryrefslogtreecommitdiffhomepage
path: root/Private/HALKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-26 20:01:37 +0100
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-26 20:01:37 +0100
commitddb6c818256ad817ba8b5e93e7868571739ae49c (patch)
treee5105de6ec9ff2e90528033f51e950fd4dac2f30 /Private/HALKit
parentef334847f61125e610e719f8dc1580d7f07e6c1d (diff)
Kernel:HAL: getting IDT to work...
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/HALKit')
-rw-r--r--Private/HALKit/AMD64/HalCoreInterruptHandler.cpp27
-rw-r--r--Private/HALKit/AMD64/HalDebugOutput.cxx2
-rw-r--r--Private/HALKit/AMD64/HalInterruptRouting.asm68
-rw-r--r--Private/HALKit/AMD64/HalKernelMain.cxx12
-rw-r--r--Private/HALKit/AMD64/HalNewBoot.asm6
-rw-r--r--Private/HALKit/AMD64/HalPlatformAMD64.cpp6
-rw-r--r--Private/HALKit/AMD64/HalRoutines.s1
7 files changed, 26 insertions, 96 deletions
diff --git a/Private/HALKit/AMD64/HalCoreInterruptHandler.cpp b/Private/HALKit/AMD64/HalCoreInterruptHandler.cpp
index b161f1db..5a353b6e 100644
--- a/Private/HALKit/AMD64/HalCoreInterruptHandler.cpp
+++ b/Private/HALKit/AMD64/HalCoreInterruptHandler.cpp
@@ -33,9 +33,9 @@ static const char* kExceptionMessage[32] = {
"Machine check",
"Reserved",
"Reserved",
- "System Process Switch Issued",
- "System was interrupted by kernel",
- "System hang by kernel",
+ "Reserved",
+ "Reserved",
+ "Reservedl",
"Reserved",
"Reserved",
"Reserved",
@@ -46,24 +46,9 @@ static const char* kExceptionMessage[32] = {
"Reserved",
};
-extern "C" HCore::UIntPtr rt_handle_interrupts(HCore::UIntPtr& rsp) {
- HCore::HAL::rt_cli();
-
- HCore::HAL::StackFramePtr sf = (HCore::HAL::StackFramePtr)rsp;
-
- if (sf->IntNum == 0x21) {
- rt_syscall_handle(sf);
- }
-
- if (sf->IntNum < 32) {
- HCore::kcout << "Exception:" << kExceptionMessage[sf->IntNum] << "\n";
- }
-
- if (sf->IntNum >= 40) HCore::HAL::Out8(0x20, 0x20); // ACK MASTER
-
- HCore::HAL::Out8(0xA0, 0x20); // ACK SLAVE
-
- HCore::HAL::rt_sti();
+/// @brief System call interrupt (like DOS and NT)
+#define kKernelSyscallInterrupt (0x21)
+EXTERN_C HCore::UIntPtr rt_handle_interrupts(HCore::UIntPtr rsp) {
return rsp;
}
diff --git a/Private/HALKit/AMD64/HalDebugOutput.cxx b/Private/HALKit/AMD64/HalDebugOutput.cxx
index 37beb912..6b2c772e 100644
--- a/Private/HALKit/AMD64/HalDebugOutput.cxx
+++ b/Private/HALKit/AMD64/HalDebugOutput.cxx
@@ -72,7 +72,7 @@ void ke_io_print(const char* bytes) {
Detail::kState = kStateReady;
}
-TerminalDevice& TerminalDevice::Shared() noexcept {
+TerminalDevice TerminalDevice::Shared() noexcept {
static TerminalDevice out(HCore::ke_io_print, nullptr);
return out;
}
diff --git a/Private/HALKit/AMD64/HalInterruptRouting.asm b/Private/HALKit/AMD64/HalInterruptRouting.asm
index a1d532cb..33077e68 100644
--- a/Private/HALKit/AMD64/HalInterruptRouting.asm
+++ b/Private/HALKit/AMD64/HalInterruptRouting.asm
@@ -17,68 +17,30 @@
%macro IntExp 1
HCoreInterrupt%1:
- push 1
+ cli
push %1
- jmp ke_handle_irq
- iretq
+ call ke_handle_irq
%endmacro
%macro IntNormal 1
HCoreInterrupt%1:
+ cli
push 0
push %1
- jmp ke_handle_irq
- iretq
+ call ke_handle_irq
%endmacro
; This file handles the core interrupt table
; Last edited 31/01/24
extern rt_handle_interrupts
-global rt_install_idt
global __EXEC_IVT
section .text
ke_handle_irq:
- push rax
- push rbx
- push rcx
- push rdx
- push rsi
- push rdi
- push rbp
- push r8
- push r9
- push r10
- push r11
- push r12
- push r13
- push r14
- push r15
-
- mov rcx, rsp
- call rt_handle_interrupts
- add rsp, 8
-
- pop r15
- pop r14
- pop r13
- pop r12
- pop r11
- pop r10
- pop r9
- pop r8
- pop rbp
- pop rdi
- pop rsi
- pop rdx
- pop rcx
- pop rbx
- pop rax
-
sti
- retf
+ iretq
__IVT:
IntNormal 0
@@ -114,18 +76,18 @@ __IVT:
IntExp 30
IntNormal 31
IntNormal 32
-
- %assign i 33
- %rep 223
- IntNormal i
- %assign i i+1
- %endrep
-
-section .data
-
+
__EXEC_IVT:
%assign i 0
- %rep 256
+ %rep 32
IntDecl i
%assign i i+1
%endrep
+
+section .text
+
+global PowerOnSelfTest
+
+PowerOnSelfTest:
+ int 0x21
+ ret \ No newline at end of file
diff --git a/Private/HALKit/AMD64/HalKernelMain.cxx b/Private/HALKit/AMD64/HalKernelMain.cxx
index 9cced576..686abe9e 100644
--- a/Private/HALKit/AMD64/HalKernelMain.cxx
+++ b/Private/HALKit/AMD64/HalKernelMain.cxx
@@ -25,12 +25,7 @@ extern "C" HCore::VoidPtr __EXEC_IVT;
namespace Detail {
using namespace HCore;
-/// @brief kernel POST.
-Void PowerOnSelfTest() {
- kcout << "POST: Starting PowerOn-Self Test...\r\n";
- asm("int $0x21"); // dummy 21h interrupt.
- kcout << "POST: Successfuly Done!\r\n";
-}
+extern "C" void PowerOnSelfTest();
/**
@brief Global descriptor table entry, either null, code or data.
@@ -56,8 +51,7 @@ struct PACKED ALIGN(0x1000) HC_GDT final {
EXTERN_C void RuntimeMain(
HCore::HEL::HandoverInformationHeader* HandoverHeader) {
- HCore::kcout << "HCoreKrnl: (R) Version 1.00, (C) MahroussLogic all rights "
- "reserved.\n";
+
/// Setup kernel globals.
kKernelVirtualSize = HandoverHeader->f_VirtualSize;
@@ -85,7 +79,7 @@ EXTERN_C void RuntimeMain(
HCore::HAL::Register64 idtBase;
idtBase.Base = (HCore::UIntPtr)__EXEC_IVT;
- idtBase.Limit = 0x0FFF;
+ idtBase.Limit = kKernelMaxSystemCalls;
HCore::HAL::IDTLoader idt;
idt.Load(idtBase);
diff --git a/Private/HALKit/AMD64/HalNewBoot.asm b/Private/HALKit/AMD64/HalNewBoot.asm
index 8c7d7d1a..d84e1956 100644
--- a/Private/HALKit/AMD64/HalNewBoot.asm
+++ b/Private/HALKit/AMD64/HalNewBoot.asm
@@ -26,8 +26,6 @@ HandoverStart: dq Main
section .text
-[bits 64]
-
extern rt_load_gdt
extern rt_load_ivt
@@ -38,11 +36,7 @@ extern MainLong
;; Just a simple setup, we'd also need to tell some before
Main:
push rcx
- jmp MainLong
-
-MainLong:
jmp RuntimeMain
- pop rcx
L0:
cli
hlt
diff --git a/Private/HALKit/AMD64/HalPlatformAMD64.cpp b/Private/HALKit/AMD64/HalPlatformAMD64.cpp
index 80721aed..ab6de613 100644
--- a/Private/HALKit/AMD64/HalPlatformAMD64.cpp
+++ b/Private/HALKit/AMD64/HalPlatformAMD64.cpp
@@ -61,13 +61,7 @@ void IDTLoader::Load(Register64 &idt) {
kRegIdt.Limit =
sizeof(Detail::AMD64::InterruptDescriptorAMD64) * idt.Limit - 1;
- kcout << "HCoreKrnl: Installing Interrupt vector...\n";
-
rt_load_idt(kRegIdt);
-
- rt_sti();
-
- kcout << "HCoreKrnl: Interrupt Vector installed.\n";
}
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 d809541f..80a6b122 100644
--- a/Private/HALKit/AMD64/HalRoutines.s
+++ b/Private/HALKit/AMD64/HalRoutines.s
@@ -20,6 +20,7 @@ rt_load_gdt:
rt_load_idt:
lidt (%rcx)
+ sti
ret
.section .text