summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Private/Builtins/HPET/HPET.hxx41
-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
-rw-r--r--Private/NewKit/Application.hxx1
6 files changed, 102 insertions, 12 deletions
diff --git a/Private/Builtins/HPET/HPET.hxx b/Private/Builtins/HPET/HPET.hxx
new file mode 100644
index 00000000..a2c91af8
--- /dev/null
+++ b/Private/Builtins/HPET/HPET.hxx
@@ -0,0 +1,41 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+ File: HPET.hxx
+ Purpose: HPET builtin.
+
+ Revision History:
+
+------------------------------------------- */
+
+#pragma once
+
+#include <NewKit/Defines.hpp>
+#include <Builtins/ACPI/ACPI.hxx>
+
+namespace NewOS {
+struct PACKED HPETAddressStructure final
+{
+ NewOS::UInt8 AddressSpaceId; // 0 - system memory, 1 - system I/O
+ NewOS::UInt8 RegisterBitWidth;
+ NewOS::UInt8 RegisterBitOffset;
+ NewOS::UInt8 Reserved;
+ NewOS::UInt64 Address;
+};
+
+struct PACKED HPETHeader final : public SDT
+{
+ NewOS::UInt8 HardwareRevId;
+ NewOS::UInt8 ComparatorCount : 5;
+ NewOS::UInt8 CounterSize : 1;
+ NewOS::UInt8 Reserved : 1;
+ NewOS::UInt8 LegacyReplacement : 1;
+ NewOS::UInt16 PciVendorId;
+ HPETAddressStructure Address;
+ NewOS::UInt8 HpetNumber;
+ NewOS::UInt16 MinimumTick;
+ NewOS::UInt8 PageProtection;
+};
+
+} // namespace NewOS \ No newline at end of file
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) {
+
}
}
diff --git a/Private/NewKit/Application.hxx b/Private/NewKit/Application.hxx
index 292bb434..8075e8ac 100644
--- a/Private/NewKit/Application.hxx
+++ b/Private/NewKit/Application.hxx
@@ -23,6 +23,7 @@ typedef struct Application final {
/// @brief Invoke a function from the application object.
NewOS::IntPtr(*Invoke)(struct Application* Self, NewOS::Int32 Sel, ...);
/// @brief Query a new application object from a GUID.
+ /// @note this doesn't query a process, it query a registered object withtin that app.
NewOS::Void(*Query)(struct Application* Self, NewOS::VoidPtr* Dst, NewOS::SizeT SzDst, NewOS::XRN::GUIDSequence GuidOf);
} Application, *ApplicationRef;