summaryrefslogtreecommitdiffhomepage
path: root/Private/HALKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-29 19:16:19 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-29 19:16:19 +0100
commit43ae417266c3127bbae35527c95c26e01ed50bd9 (patch)
treeefbbaa92ab7e11a69bd295cba7da65f487572836 /Private/HALKit
parent7e5be1572c043484293ee0cdd840dd41f54e87ee (diff)
Kernel: See below.
- Add HPET header. - Add note for ApplicationRef. - Update PowerPC and x86 Stackframes. - Add #UD handler inside interrupt descriptor in x86. Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Private/HALKit')
-rw-r--r--Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp34
-rw-r--r--Private/HALKit/AMD64/HalInterruptAPI.asm17
-rw-r--r--Private/HALKit/AMD64/Processor.hpp4
-rw-r--r--Private/HALKit/PowerPC/Processor.hpp17
4 files changed, 60 insertions, 12 deletions
diff --git a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp
index 9ac3f3e1..e87459ac 100644
--- a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp
+++ b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp
@@ -8,6 +8,8 @@
#include <KernelKit/ProcessScheduler.hpp>
#include <NewKit/String.hpp>
+/// @brief Handle GPF fault.
+/// @param rsp
EXTERN_C void idt_handle_gpf(NewOS::UIntPtr rsp) {
MUST_PASS(NewOS::ProcessScheduler::Shared().Leak().GetCurrent());
@@ -21,6 +23,8 @@ EXTERN_C void idt_handle_gpf(NewOS::UIntPtr rsp) {
NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().Crash();
}
+/// @brief Handle the scheduler interrupt, raised from the HPET timer.
+/// @param rsp
EXTERN_C void idt_handle_scheduler(NewOS::UIntPtr rsp) {
NewOS::kcout << NewOS::StringBuilder::FromInt("rsp{%}", rsp);
@@ -35,10 +39,11 @@ EXTERN_C void idt_handle_scheduler(NewOS::UIntPtr rsp) {
}
}
+/// @brief Handle page fault.
+/// @param rsp
EXTERN_C void idt_handle_pf(NewOS::UIntPtr rsp) {
- NewOS::kcout << NewOS::StringBuilder::FromInt("rsp{%}", rsp);
-
MUST_PASS(NewOS::ProcessScheduler::Shared().Leak().GetCurrent());
+ NewOS::kcout << NewOS::StringBuilder::FromInt("rsp{%}", rsp);
NewOS::kcout
<< "NewKernel.exe: Segmentation Fault, caused by "
@@ -47,10 +52,11 @@ EXTERN_C void idt_handle_pf(NewOS::UIntPtr rsp) {
NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().Crash();
}
+/// @brief Handle math fault.
+/// @param rsp
EXTERN_C void idt_handle_math(NewOS::UIntPtr rsp) {
- NewOS::kcout << NewOS::StringBuilder::FromInt("rsp{%}", rsp);
-
MUST_PASS(NewOS::ProcessScheduler::Shared().Leak().GetCurrent());
+ NewOS::kcout << NewOS::StringBuilder::FromInt("rsp{%}", rsp);
NewOS::kcout
<< "NewKernel.exe: Math error, caused by "
@@ -59,10 +65,11 @@ EXTERN_C void idt_handle_math(NewOS::UIntPtr rsp) {
NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().Crash();
}
+/// @brief Handle any generic fault.
+/// @param rsp
EXTERN_C void idt_handle_generic(NewOS::UIntPtr rsp) {
- NewOS::kcout << NewOS::StringBuilder::FromInt("sp{%}", rsp);
-
MUST_PASS(NewOS::ProcessScheduler::Shared().Leak().GetCurrent());
+ NewOS::kcout << NewOS::StringBuilder::FromInt("sp{%}", rsp);
NewOS::kcout
<< "NewKernel.exe: Execution error, caused by "
@@ -70,3 +77,18 @@ EXTERN_C void idt_handle_generic(NewOS::UIntPtr rsp) {
NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().Crash();
}
+
+/// @brief Handle #UD fault.
+/// @param rsp
+EXTERN_C void idt_handle_ud(NewOS::UIntPtr rsp) {
+ MUST_PASS(NewOS::ProcessScheduler::Shared().Leak().GetCurrent());
+
+ NewOS::kcout << "NewKernel.exe: Stack Pointer: "
+ << NewOS::StringBuilder::FromInt("rsp{%}", rsp);
+
+ NewOS::kcout
+ << "NewKernel.exe: Invalid interrupt, caused by "
+ << NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().GetName();
+
+ NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().Crash();
+} \ No newline at end of file
diff --git a/Private/HALKit/AMD64/HalInterruptAPI.asm b/Private/HALKit/AMD64/HalInterruptAPI.asm
index 0abf463d..1a3ca796 100644
--- a/Private/HALKit/AMD64/HalInterruptAPI.asm
+++ b/Private/HALKit/AMD64/HalInterruptAPI.asm
@@ -40,6 +40,7 @@ extern _hal_handle_mouse
extern idt_handle_gpf
extern idt_handle_pf
extern ke_io_write
+extern idt_handle_ud
section .text
@@ -51,7 +52,21 @@ IntNormal 2
IntNormal 3
IntNormal 4
IntNormal 5
-IntNormal 6
+
+;; Invalid opcode interrupt
+__HCR_INT_6:
+ cli
+
+ push rax
+
+ mov rcx, rsp
+ call idt_handle_ud
+
+ pop rax
+
+ sti
+ iretq
+
IntNormal 7
IntExp 8
IntNormal 9
diff --git a/Private/HALKit/AMD64/Processor.hpp b/Private/HALKit/AMD64/Processor.hpp
index 78d45c2e..472fd6df 100644
--- a/Private/HALKit/AMD64/Processor.hpp
+++ b/Private/HALKit/AMD64/Processor.hpp
@@ -3,7 +3,7 @@
Copyright Mahrouss Logic
File: Prcoessor.hxx
- Purpose: AMD processor abstraction.
+ Purpose: AMD64 processor abstraction.
Revision History:
@@ -82,7 +82,7 @@ using interruptTrap = UIntPtr(UIntPtr sp);
typedef UIntPtr Reg;
struct PACKED StackFrame final {
- Reg IntNum, ErrCode;
+ Reg IntNum, Excpetion;
Reg Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax;
Reg R8, R9, R10, R11, R12, R13, R14, R15;
Reg Gs, Fs;
diff --git a/Private/HALKit/PowerPC/Processor.hpp b/Private/HALKit/PowerPC/Processor.hpp
index be929fd7..36731d57 100644
--- a/Private/HALKit/PowerPC/Processor.hpp
+++ b/Private/HALKit/PowerPC/Processor.hpp
@@ -2,6 +2,8 @@
Copyright Mahrouss Logic
+ Purpose: PowerPC processor header.
+
------------------------------------------- */
#pragma once
@@ -9,12 +11,14 @@
#include <NewKit/Defines.hpp>
#include <NewKit/Utils.hpp>
-#define __aligned __attribute__((aligned(4)))
+#define __PPC_ALIGN __attribute__((aligned(4)))
namespace NewOS::HAL {
typedef UIntPtr Reg;
-struct __aligned StackFrame {
+struct __PPC_ALIGN StackFrame {
+ Reg IntNum;
+ Reg Exception;
Reg R0;
Reg R1;
Reg R2;
@@ -23,13 +27,20 @@ struct __aligned StackFrame {
Reg R5;
Reg R6;
Reg R7;
- Reg ID; // R8
+ Reg R8;
+ Reg ProgramCounter;
+ Reg StackPointer;
+ /// @brief Process Context
+ Reg PC;
+ /// @brief General Context
+ Reg GC;
};
typedef StackFrame* StackFramePtr;
inline void rt_halt() {
while (1) {
+
}
}