From ecf2a09a48ef029d09075af744c04e643661ec27 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 7 Jan 2025 07:39:26 +0100 Subject: ADD: Moved system call handler in HalCommonAPI.asm (AMD64) ADD: Replace make_container with make_app. ADD: Reference SwapDisk.h and TeamScheduler.h in unix_layer for future POSIX work too. Signed-off-by: Amlal El Mahrouss --- dev/Kernel/HALKit/AMD64/HalCommonAPI.asm | 27 +++++++++++++++++++++++++ dev/Kernel/HALKit/AMD64/HalDescriptorLoader.cc | 8 ++++---- dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm | 28 -------------------------- dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc | 16 +++++++-------- dev/Kernel/POSIXKit/unix_layer.h | 2 ++ 5 files changed, 41 insertions(+), 40 deletions(-) (limited to 'dev/Kernel') diff --git a/dev/Kernel/HALKit/AMD64/HalCommonAPI.asm b/dev/Kernel/HALKit/AMD64/HalCommonAPI.asm index 6339fa8d..dd3901e8 100644 --- a/dev/Kernel/HALKit/AMD64/HalCommonAPI.asm +++ b/dev/Kernel/HALKit/AMD64/HalCommonAPI.asm @@ -51,3 +51,30 @@ rt_in32: mov rdx, rcx in eax, dx ret + +extern hal_system_call_enter +global mp_system_call_handler + +mp_system_call_handler: + + push r8 + push r9 + push r10 + push r11 + push r12 + push r13 + push r14 + push r15 + + jmp hal_system_call_enter + + pop r15 + pop r14 + pop r13 + pop r12 + pop r11 + pop r10 + pop r9 + pop r8 + + o64 sysret diff --git a/dev/Kernel/HALKit/AMD64/HalDescriptorLoader.cc b/dev/Kernel/HALKit/AMD64/HalDescriptorLoader.cc index 680aa6ed..2edbdc60 100644 --- a/dev/Kernel/HALKit/AMD64/HalDescriptorLoader.cc +++ b/dev/Kernel/HALKit/AMD64/HalDescriptorLoader.cc @@ -7,7 +7,7 @@ #include #include -#define kPITDefaultTicks (100U) +#define kPITDefaultTicks (1000U) namespace Kernel::HAL { @@ -26,11 +26,11 @@ namespace Kernel::HAL // Configure PIT to receieve scheduler interrupts. - UInt16 cCommDivisor = kPITFrequency / ticks; // 100 Hz. + UInt16 kPITCommDivisor = kPITFrequency / ticks; // 100 Hz. HAL::rt_out8(kPITControlPort, 0x36); // Command to PIT - HAL::rt_out8(kPITChannel0Port, cCommDivisor & 0xFF); // Send low byte - HAL::rt_out8(kPITChannel0Port, (cCommDivisor >> 8) & 0xFF); // Send high byte + HAL::rt_out8(kPITChannel0Port, kPITCommDivisor & 0xFF); // Send low byte + HAL::rt_out8(kPITChannel0Port, (kPITCommDivisor >> 8) & 0xFF); // Send high byte hal_clear_irq_mask(32); } diff --git a/dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm b/dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm index 02031c4c..53654d08 100644 --- a/dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm +++ b/dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm @@ -369,34 +369,6 @@ hal_reload_segments: ret global hal_load_idt -global hal_user_code_start - -extern hal_system_call_enter -global mp_system_call_handler - -mp_system_call_handler: - - push r8 - push r9 - push r10 - push r11 - push r12 - push r13 - push r14 - push r15 - - jmp hal_system_call_enter - - pop r15 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - pop r9 - pop r8 - - o64 sysret hal_load_idt: lidt [rcx] diff --git a/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc b/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc index 9fc261ef..1829a25a 100644 --- a/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc +++ b/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc @@ -37,18 +37,18 @@ Boolean drv_std_wait_io(UInt16 IO) rt_in8(IO + ATA_REG_STATUS); ATAWaitForIO_Retry: - auto statRdy = rt_in8(IO + ATA_REG_STATUS); + auto rdy = rt_in8(IO + ATA_REG_STATUS); - if ((statRdy & ATA_SR_BSY)) + if ((rdy & ATA_SR_BSY)) goto ATAWaitForIO_Retry; ATAWaitForIO_Retry2: - statRdy = rt_in8(IO + ATA_REG_STATUS); + rdy = rt_in8(IO + ATA_REG_STATUS); - if (statRdy & ATA_SR_ERR) + if (rdy & ATA_SR_ERR) return false; - if (!(statRdy & ATA_SR_DRDY)) + if (!(rdy & ATA_SR_DRDY)) goto ATAWaitForIO_Retry2; return true; @@ -74,16 +74,16 @@ ATAInit_Retry: // identify until it's good - auto statRdy = rt_in8(IO + ATA_REG_STATUS); + auto rdy = rt_in8(IO + ATA_REG_STATUS); - if (statRdy & ATA_SR_ERR) + if (rdy & ATA_SR_ERR) { kcout << "ATA Error, aborting...\r"; return false; } - if ((statRdy & ATA_SR_BSY)) + if ((rdy & ATA_SR_BSY)) { kcout << "Retrying as controller is busy...\r"; goto ATAInit_Retry; diff --git a/dev/Kernel/POSIXKit/unix_layer.h b/dev/Kernel/POSIXKit/unix_layer.h index d6c0fa1c..5da6d24b 100644 --- a/dev/Kernel/POSIXKit/unix_layer.h +++ b/dev/Kernel/POSIXKit/unix_layer.h @@ -9,3 +9,5 @@ #include #include #include +#include +#include \ No newline at end of file -- cgit v1.2.3