summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/boot/amd64-desktop.make2
-rw-r--r--src/kernel/HALKit/AMD64/HalCommonAPI.asm6
-rw-r--r--src/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc42
-rw-r--r--src/kernel/HALKit/AMD64/HalInterruptAPI.asm19
-rw-r--r--src/kernel/src/BitMapMgr.cc10
-rw-r--r--src/kernel/src/Storage/AHCIDeviceInterface.cc6
-rw-r--r--src/kernel/src/Storage/ATADeviceInterface.cc6
-rw-r--r--src/kernel/src/ZXDCodeMgr.cc (renamed from src/kernel/src/ZXD.cc)1
8 files changed, 64 insertions, 28 deletions
diff --git a/src/boot/amd64-desktop.make b/src/boot/amd64-desktop.make
index 26877369..d1043d56 100644
--- a/src/boot/amd64-desktop.make
+++ b/src/boot/amd64-desktop.make
@@ -117,7 +117,7 @@ compile-amd64:
.PHONY: run-efi-amd64-ahci
run-efi-amd64-ahci:
- $(EMU) $(EMU_FLAGS) -monitor stdio -hda $(IMG) -s -boot menu=on
+ $(EMU) $(EMU_FLAGS) -d int -hda $(IMG) -s -boot menu=on
.PHONY: run-efi-amd64-ata-pio
run-efi-amd64-ata-pio:
diff --git a/src/kernel/HALKit/AMD64/HalCommonAPI.asm b/src/kernel/HALKit/AMD64/HalCommonAPI.asm
index 144e5e7a..f571aba7 100644
--- a/src/kernel/HALKit/AMD64/HalCommonAPI.asm
+++ b/src/kernel/HALKit/AMD64/HalCommonAPI.asm
@@ -92,7 +92,7 @@ sched_jump_to_task:
push rbp
mov rbp, rsp
- mov ax, 0x30
+ mov ax, 0x33
mov ds, ax
mov es, ax
mov fs, ax
@@ -101,11 +101,11 @@ sched_jump_to_task:
mov ax, 0x18
ltr ax
- push 0x30
+ push 0x33
mov rdx, [rcx + 0x08]
push rdx
o64 pushf
- push 0x28
+ push 0x2B
mov rdx, [rcx + 0x00]
push rdx
diff --git a/src/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc b/src/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc
index 14ec5f60..040f5daa 100644
--- a/src/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc
+++ b/src/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc
@@ -31,26 +31,32 @@ static void hal_idt_send_eoi(UInt8 vector) {
/// @param rsp
EXTERN_C Kernel::Void idt_handle_gpf(Kernel::UIntPtr rsp) {
auto process = Kernel::UserProcessScheduler::The().TheCurrentProcess();
- process.Crash();
+
+ if (process) process.Crash();
hal_idt_send_eoi(13);
- process.Signal.SignalArg = rsp;
- process.Signal.SignalID = SIGKILL;
- process.Signal.Status = process.Status;
+ if (process) {
+ process.Signal.SignalArg = rsp;
+ process.Signal.SignalID = SIGKILL;
+ process.Signal.Status = process.Status;
+ }
}
/// @brief Handle page fault.
/// @param rsp
EXTERN_C void idt_handle_pf(Kernel::UIntPtr rsp) {
auto process = Kernel::UserProcessScheduler::The().TheCurrentProcess();
- process.Crash();
+
+ if (process) process.Crash();
hal_idt_send_eoi(14);
- process.Signal.SignalArg = rsp;
- process.Signal.SignalID = SIGKILL;
- process.Signal.Status = process.Status;
+ if (process) {
+ process.Signal.SignalArg = rsp;
+ process.Signal.SignalID = SIGKILL;
+ process.Signal.Status = process.Status;
+ }
}
/// @brief Handle scheduler interrupt.
@@ -73,21 +79,24 @@ EXTERN_C void idt_handle_scheduler(Kernel::UIntPtr rsp) {
/// @param rsp
EXTERN_C void idt_handle_math(Kernel::UIntPtr rsp) {
auto process = Kernel::UserProcessScheduler::The().TheCurrentProcess();
- process.Crash();
+
+ if (process) process.Crash();
hal_idt_send_eoi(8);
- process.Signal.SignalArg = rsp;
- process.Signal.SignalID = sig_generate_unique<SIGKILL>();
- ;
- process.Signal.Status = process.Status;
+ if (process) {
+ process.Signal.SignalArg = rsp;
+ process.Signal.SignalID = sig_generate_unique<SIGKILL>();
+ process.Signal.Status = process.Status;
+ }
}
/// @brief Handle any generic fault.
/// @param rsp
EXTERN_C void idt_handle_generic(Kernel::UIntPtr rsp) {
auto process = Kernel::UserProcessScheduler::The().TheCurrentProcess();
- process.Crash();
+
+ if (process) process.Crash();
hal_idt_send_eoi(30);
@@ -104,6 +113,8 @@ EXTERN_C void idt_handle_generic(Kernel::UIntPtr rsp) {
EXTERN_C Kernel::Void idt_handle_breakpoint(Kernel::UIntPtr rip) {
auto process = Kernel::UserProcessScheduler::The().TheCurrentProcess();
+ if (process) process.Crash();
+
hal_idt_send_eoi(3);
process.Signal.SignalArg = rip;
@@ -118,7 +129,8 @@ EXTERN_C Kernel::Void idt_handle_breakpoint(Kernel::UIntPtr rip) {
/// @param rsp
EXTERN_C void idt_handle_ud(Kernel::UIntPtr rsp) {
auto process = Kernel::UserProcessScheduler::The().TheCurrentProcess();
- process.Crash();
+
+ if (process) process.Crash();
hal_idt_send_eoi(6);
diff --git a/src/kernel/HALKit/AMD64/HalInterruptAPI.asm b/src/kernel/HALKit/AMD64/HalInterruptAPI.asm
index c761684e..be8675f8 100644
--- a/src/kernel/HALKit/AMD64/HalInterruptAPI.asm
+++ b/src/kernel/HALKit/AMD64/HalInterruptAPI.asm
@@ -206,7 +206,24 @@ __NE_INT_32:
o64 iret
-IntNormal 33
+global __NE_INT_33
+__NE_INT_33:
+ cli
+
+ push rax
+
+ ; Read scancode from keyboard port to acknowledge
+ in al, 0x60
+
+ ; Send EOI to master PIC
+ mov al, 0x20
+ out 0x20, al
+
+ pop rax
+
+ std
+
+ o64 iret
IntNormal 34
IntNormal 35
diff --git a/src/kernel/src/BitMapMgr.cc b/src/kernel/src/BitMapMgr.cc
index 76a6a42f..56c261c2 100644
--- a/src/kernel/src/BitMapMgr.cc
+++ b/src/kernel/src/BitMapMgr.cc
@@ -127,12 +127,14 @@ namespace HAL {
}
UIntPtr raw_base = reinterpret_cast<UIntPtr>(base);
- UIntPtr offset = (ptr_bit_set[kBitMapMagIdx] != kBitMapMagic)
- ? (size + pad)
- : ptr_bit_set[kBitMapSizeIdx];
+
+ if (ptr_bit_set[kBitMapSizeIdx] > kBitMapMaxSz) return nullptr;
+
+ UIntPtr offset = (ptr_bit_set[kBitMapMagIdx] != kBitMapMagic)
+ ? (size + pad)
+ : ptr_bit_set[kBitMapSizeIdx];
base = reinterpret_cast<VoidPtr>(raw_base + offset);
- if (base == nullptr) return nullptr;
}
return nullptr;
diff --git a/src/kernel/src/Storage/AHCIDeviceInterface.cc b/src/kernel/src/Storage/AHCIDeviceInterface.cc
index fd3c30cc..6d910f37 100644
--- a/src/kernel/src/Storage/AHCIDeviceInterface.cc
+++ b/src/kernel/src/Storage/AHCIDeviceInterface.cc
@@ -4,7 +4,7 @@
#include <StorageKit/AHCI.h>
-using namespace Kernel;
+namespace Kernel {
/// @brief Class constructor
/// @param Out Drive output
@@ -82,4 +82,6 @@ const UInt32& AHCIDeviceInterface::GetIndex() {
Void AHCIDeviceInterface::SetIndex(const UInt32& drv) {
MUST_PASS(IMountpoint::kDriveIndexInvalid < drv);
this->fDriveIndex = drv;
-} \ No newline at end of file
+}
+
+} // namespace Kernel \ No newline at end of file
diff --git a/src/kernel/src/Storage/ATADeviceInterface.cc b/src/kernel/src/Storage/ATADeviceInterface.cc
index f360325c..98997579 100644
--- a/src/kernel/src/Storage/ATADeviceInterface.cc
+++ b/src/kernel/src/Storage/ATADeviceInterface.cc
@@ -4,7 +4,7 @@
#include <StorageKit/ATA.h>
-using namespace Kernel;
+namespace Kernel {
/// @brief Class constructor
/// @param Out Drive output
@@ -91,4 +91,6 @@ const UInt16& ATADeviceInterface::GetMaster() {
Void ATADeviceInterface::SetMaster(const UInt16& drv) {
MUST_PASS(0xFFFF != drv);
this->fMaster = drv;
-} \ No newline at end of file
+}
+
+} // namespace Kernel \ No newline at end of file
diff --git a/src/kernel/src/ZXD.cc b/src/kernel/src/ZXDCodeMgr.cc
index 5b2b044c..c8e8041e 100644
--- a/src/kernel/src/ZXD.cc
+++ b/src/kernel/src/ZXDCodeMgr.cc
@@ -2,4 +2,5 @@
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/nekernel-org/nekernel
+#include <KernelKit/CodeMgr.h>
#include <KernelKit/ZXD.h>