summaryrefslogtreecommitdiffhomepage
path: root/dev/zka
diff options
context:
space:
mode:
Diffstat (limited to 'dev/zka')
-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
5 files changed, 99 insertions, 28 deletions
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;