summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal <amlal@el-mahrouss-logic.com>2024-10-23 10:08:05 +0200
committerAmlal <amlal@el-mahrouss-logic.com>2024-10-23 10:08:05 +0200
commit08e69a55cfda4722277d16ddb632669edde3580b (patch)
treec84511296c0a8d290673df8ffaa52ef75a65a877 /dev
parent1742d940e54696432459b8ced18b99bcafeb2178 (diff)
IMP: Process scheduler timer interrupt have been implemented, fixes regarding interrupt API and use __TOOLCHAINKIT__ instead of __NDK__
Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'dev')
-rw-r--r--dev/crt/defines.h8
-rw-r--r--dev/sci/xpcom_core.h4
-rw-r--r--dev/zba/amd64-efi.make2
-rw-r--r--dev/zka/HALKit/AMD64/HalInterruptAPI.asm95
-rw-r--r--dev/zka/KernelKit/UserProcessScheduler.h1
-rw-r--r--dev/zka/NewKit/CxxAbi.h2
-rw-r--r--dev/zka/src/ACPIFactoryInterface.cc13
-rw-r--r--dev/zka/src/UserProcessScheduler.cc16
8 files changed, 106 insertions, 35 deletions
diff --git a/dev/crt/defines.h b/dev/crt/defines.h
index 38fe2b6c..ea821505 100644
--- a/dev/crt/defines.h
+++ b/dev/crt/defines.h
@@ -4,8 +4,8 @@
------------------------------------------- */
-#ifndef __NDK_DEFINES_HXX__
-#define __NDK_DEFINES_HXX__
+#ifndef __TOOLCHAINKIT_DEFINES_HXX__
+#define __TOOLCHAINKIT_DEFINES_HXX__
#include <stdint.h>
#include <stddef.h>
@@ -25,7 +25,7 @@ typedef char* caddr_t;
#ifdef __GNUC__
#include <crt/alloca.h>
-#elif defined(__NDK__)
+#elif defined(__TOOLCHAINKIT__)
#define __alloca(sz) __ndk_alloca(sz)
#endif
@@ -103,4 +103,4 @@ namespace std
}
} // namespace std
-#endif /* __NDK_DEFINES_HXX__ */
+#endif /* __TOOLCHAINKIT_DEFINES_HXX__ */
diff --git a/dev/sci/xpcom_core.h b/dev/sci/xpcom_core.h
index c86210b5..45c13d1f 100644
--- a/dev/sci/xpcom_core.h
+++ b/dev/sci/xpcom_core.h
@@ -9,13 +9,13 @@ Purpose: Base code of XPCOM.
/// @internal Reserved for internal definitions only.
-#ifndef __NDK__
+#ifndef __TOOLCHAINKIT__
#define object class
#define protocol class
#define clsid(X)
#warning ! You may be using the clang compiler, please be cautious that some features mayn't be present. !
-#endif // !__NDK__
+#endif // !__TOOLCHAINKIT__
protocol IUnknown; // Refrenced from an IDB entry.
protocol ICLSID; // From the IDB, the constructor of the object, e.g: TextUCLSID.
diff --git a/dev/zba/amd64-efi.make b/dev/zba/amd64-efi.make
index 1af31f2e..24ffeb95 100644
--- a/dev/zba/amd64-efi.make
+++ b/dev/zba/amd64-efi.make
@@ -34,7 +34,7 @@ EMU_FLAGS=-net none -smp 4 -m 8G -M q35 \
file=fat:rw:src/Root/,index=2,format=raw \
-drive id=disk_2,file=$(IMG),if=none \
-device ahci,id=ahci \
- -device ide-hd,drive=disk_2,bus=ahci.0 -serial stdio
+ -device ide-hd,drive=disk_2,bus=ahci.0 -d int
LD_FLAGS=-e Main --subsystem=10
diff --git a/dev/zka/HALKit/AMD64/HalInterruptAPI.asm b/dev/zka/HALKit/AMD64/HalInterruptAPI.asm
index e611fdf1..06066f41 100644
--- a/dev/zka/HALKit/AMD64/HalInterruptAPI.asm
+++ b/dev/zka/HALKit/AMD64/HalInterruptAPI.asm
@@ -16,18 +16,26 @@
%macro IntExp 1
global __ZKA_INT_%1
__ZKA_INT_%1:
+ cli
+
mov al, 0x20
- out 0x21, al
+ out 0x20, al
+ out 0xA0, al
+ sti
o64 iret
%endmacro
%macro IntNormal 1
global __ZKA_INT_%1
__ZKA_INT_%1:
+ cli
+
mov al, 0x20
- out 0x21, al
+ out 0x20, al
+ out 0xA0, al
+ sti
o64 iret
%endmacro
@@ -56,24 +64,42 @@ IntNormal 5
;; Invalid opcode interrupt
__ZKA_INT_6:
+ cli
+
mov al, 0x20
out 0x20, al
+ out 0xA0, al
+
+ push rax
+ mov rax, idt_handle_ud
mov rcx, rsp
- call idt_handle_ud
+ call rax
+ pop rax
+
+ sti
o64 iret
IntNormal 7
;; Invalid opcode interrupt
__ZKA_INT_8:
+ cli
+
mov al, 0x20
- out 0x21, al
+ out 0x20, al
+ out 0xA0, al
+
+ push rax
+ mov rax, idt_handle_generic
mov rcx, rsp
- call idt_handle_generic
+ call rax
+ pop rax
+
+ sti
o64 iret
IntNormal 9
@@ -83,21 +109,38 @@ IntExp 11
IntExp 12
__ZKA_INT_13:
+ cli
+
mov al, 0x20
- out 0x21, al
+ out 0x20, al
+ out 0xA0, al
+
+ push rax
+ mov rax, idt_handle_gpf
mov rcx, rsp
- call idt_handle_gpf
+ call rax
+ pop rax
+
+ sti
o64 iret
__ZKA_INT_14:
+ cli
+
mov al, 0x20
- out 0x21, al
+ out 0x20, al
+ out 0xA0, al
+ push rax
+ mov rax, idt_handle_pf
mov rcx, rsp
- call idt_handle_pf
+ call rax
+ pop rax
+
+ sti
o64 iret
IntNormal 15
@@ -123,12 +166,19 @@ IntNormal 31
[extern idt_handle_scheduler]
__ZKA_INT_32:
+ cli
+
mov al, 0x20
- out 0x21, al
+ out 0x20, al
+ out 0xA0, al
+ push rax
mov rcx, rsp
- call idt_handle_scheduler
+ mov rax, idt_handle_scheduler
+ call rax
+ pop rax
+ sti
o64 iret
IntNormal 33
@@ -159,12 +209,17 @@ __ZKA_INT_50:
cli
mov al, 0x20
- out 0x21, al
+ out 0x20, al
+ out 0xA0, al
+
+ push rax
+ mov rax, hal_system_call_enter
mov rcx, r8
mov rdx, r9
- jmp hal_system_call_enter
+ call rax
+ pop rax
sti
@@ -174,12 +229,17 @@ __ZKA_INT_51:
cli
mov al, 0x20
- out 0x21, al
+ out 0x20, al
+ out 0xA0, al
+
+ push rax
+ mov rax, hal_kernel_call_enter
mov rcx, r8
mov rdx, r9
- call hal_kernel_call_enter
+ call rax
+ pop rax
sti
@@ -229,10 +289,9 @@ extern hal_real_init
hal_reload_segments:
std
;; Write address of syscall handler.
-
- mov rdx, [mp_system_call_handler]
+ mov rdx, [mp_system_call_handler]
shr rdx, 32
- mov rcx, 0xC0000082
+ mov rcx, 0xC0000082
wrmsr
;; Set segments of syscall handler.
diff --git a/dev/zka/KernelKit/UserProcessScheduler.h b/dev/zka/KernelKit/UserProcessScheduler.h
index 92a698b6..5faafc0b 100644
--- a/dev/zka/KernelKit/UserProcessScheduler.h
+++ b/dev/zka/KernelKit/UserProcessScheduler.h
@@ -292,6 +292,7 @@ namespace Kernel
private:
UserProcessTeam mTeam;
+
};
/*
diff --git a/dev/zka/NewKit/CxxAbi.h b/dev/zka/NewKit/CxxAbi.h
index 36dcf0b3..c6408af1 100644
--- a/dev/zka/NewKit/CxxAbi.h
+++ b/dev/zka/NewKit/CxxAbi.h
@@ -7,7 +7,7 @@
#include <NewKit/Defines.h>
-#ifndef __NDK__
+#ifndef __TOOLCHAINKIT__
#define kDSOMaxObjects (128)
diff --git a/dev/zka/src/ACPIFactoryInterface.cc b/dev/zka/src/ACPIFactoryInterface.cc
index c7d2914f..230b6ed6 100644
--- a/dev/zka/src/ACPIFactoryInterface.cc
+++ b/dev/zka/src/ACPIFactoryInterface.cc
@@ -29,11 +29,11 @@ namespace Kernel
RSDT* xsdt = reinterpret_cast<RSDT*>(rsp_ptr->RsdtAddress);
- Int64 num = (xsdt->Length - sizeof(SDT)) / sizeof(UInt32);
+ Int64 num = (xsdt->Length - sizeof(SDT)) / sizeof(Int64);
/***
- crucial to avoid - overflows.
- */
+ crucial to avoid underflows.
+ */
if (num < 1)
{
/// stop here, we should have entries...
@@ -64,7 +64,8 @@ namespace Kernel
if (signature_index == (cAcpiSignatureLength - 1))
{
- kcout << "ACPI: Found the SDT" << endl;
+ kcout << "ACPI: SDT Signature: " << sdt->Signature << endl;
+ kcout << "ACPI: SDT OEM ID: " << sdt->OemId << endl;
return ErrorOr<voidPtr>(reinterpret_cast<voidPtr>(xsdt->AddressArr[index]));
}
}
@@ -74,10 +75,10 @@ namespace Kernel
}
/***
- @brief check SDT header
+ @brief Checksum on SDT header.
@param checksum the header to checksum
@param len the length of it.
-*/
+ */
bool ACPIFactoryInterface::Checksum(const Char* checksum, SSizeT len)
{
if (len == 0)
diff --git a/dev/zka/src/UserProcessScheduler.cc b/dev/zka/src/UserProcessScheduler.cc
index bbe644dc..0081367a 100644
--- a/dev/zka/src/UserProcessScheduler.cc
+++ b/dev/zka/src/UserProcessScheduler.cc
@@ -423,6 +423,12 @@ namespace Kernel
SizeT process_index = 0; //! we store this guy to tell the scheduler how many
//! things we have scheduled.
+ if (mTeam.mProcessAmount < 1)
+ {
+ kcout << "UserProcessScheduler::Run(): This team doesn't have any process!\r";
+ return 0;
+ }
+
for (; process_index < mTeam.AsArray().Capacity(); ++process_index)
{
auto& process = mTeam.AsArray()[process_index];
@@ -430,9 +436,6 @@ namespace Kernel
//! check if process needs to be scheduled.
if (UserProcessHelper::CanBeScheduled(process))
{
- // Set current process header.
- this->CurrentProcess() = process;
-
process.PTime = static_cast<Int32>(process.Affinity);
UserProcessScheduler::The().CurrentProcess().Leak().Status = ProcessStatusKind::kFrozen;
@@ -440,6 +443,9 @@ namespace Kernel
kcout << "Switch to '" << process.Name << "'.\r";
+ // Set current process header.
+ this->CurrentProcess() = process;
+
// tell helper to find a core to schedule on.
if (!UserProcessHelper::Switch(process.Image, &process.StackReserve[process.StackSize - 1], process.StackFrame,
process.ProcessId))
@@ -494,6 +500,10 @@ namespace Kernel
process.Status == ProcessStatusKind::kDead)
return No;
+ if (process.Status == ProcessStatusKind::kStarting &&
+ process.Image)
+ return Yes;
+
if (!process.Image &&
process.Kind == UserProcess::kExectuableKind)
return No;