summaryrefslogtreecommitdiffhomepage
path: root/Kernel/HALKit
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-06-18 13:04:01 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-06-18 13:04:11 +0200
commit90faf32f29b5482b52ab90f416528ed8f4e8f130 (patch)
tree7c4c08d0d07a2ae148434b9ef508ec752e7274a8 /Kernel/HALKit
parent1a3b924f62346cc76bd183883825c5541834c90c (diff)
MHR-31
IMP: Add TLS, a new/delete syscall. TODO: File I/O and network syscalls as well. Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel/HALKit')
-rw-r--r--Kernel/HALKit/AMD64/HalInstallTIB.asm2
-rw-r--r--Kernel/HALKit/AMD64/HalKernelMain.cxx44
2 files changed, 45 insertions, 1 deletions
diff --git a/Kernel/HALKit/AMD64/HalInstallTIB.asm b/Kernel/HALKit/AMD64/HalInstallTIB.asm
index f53fb14e..9111c835 100644
--- a/Kernel/HALKit/AMD64/HalInstallTIB.asm
+++ b/Kernel/HALKit/AMD64/HalInstallTIB.asm
@@ -11,6 +11,8 @@
[global rt_install_tib]
+section .text
+
;; changed: rs, fs
;; expected: rcx, rdx
diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx
index 3fac40ca..701439f1 100644
--- a/Kernel/HALKit/AMD64/HalKernelMain.cxx
+++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx
@@ -74,10 +74,13 @@ EXTERN_C void hal_init_platform(
NewOS::HAL::IDTLoader idt;
idt.Load(idtBase);
- /* install basic hooks. */
+ /* install basic syscalls. */
constexpr auto cSerialWriteInterrupt = 0x10; // 16
constexpr auto cTlsInterrupt = 0x11; // 17
+ constexpr auto cTlsInstallInterrupt = 0x12; // 18
+ constexpr auto cNewInterrupt = 0x13; // 19
+ constexpr auto cDeleteInterrupt = 0x14; // 20
kSyscalls[cSerialWriteInterrupt].Leak().Leak()->fProc = [](NewOS::VoidPtr rdx) -> void {
const char* msg = (const char*)rdx;
@@ -88,8 +91,47 @@ EXTERN_C void hal_init_platform(
tls_check_syscall_impl(rdx);
};
+ struct PACKED HeapAllocInfo final
+ {
+ NewOS::VoidPtr fThe;
+ NewOS::Size fTheSz;
+ };
+
+ struct PACKED ProcessBlockInfo final
+ {
+ ThreadInformationBlock* fTIB;
+ ThreadInformationBlock* fPIB;
+ };
+
+ kSyscalls[cNewInterrupt].Leak().Leak()->fProc = [](NewOS::VoidPtr rdx)->void {
+
+ /// get HAC struct.
+ HeapAllocInfo* rdxInf = (HeapAllocInfo*)rdx;
+
+ /// assign the fThe field with the pointer.
+ rdxInf->fThe = NewOS::ProcessScheduler::The().Leak().TheCurrent().Leak().New(rdxInf->fTheSz);
+ };
+
+ kSyscalls[cDeleteInterrupt].Leak().Leak()->fProc = [](NewOS::VoidPtr rdx)->void {
+ /// get HAC struct.
+ HeapAllocInfo* rdxInf = (HeapAllocInfo*)rdx;
+
+ /// delete ptr with sz in mind.
+ NewOS::ProcessScheduler::The().Leak().TheCurrent().Leak().Delete(rdxInf->fThe, rdxInf->fTheSz);
+ };
+
+ kSyscalls[cTlsInstallInterrupt].Leak().Leak()->fProc = [](NewOS::VoidPtr rdx)->void {
+ ProcessBlockInfo* rdxPb = (ProcessBlockInfo*)rdx;
+
+ /// install the process's fTIB and fPIB.
+ rt_install_tib(rdxPb->fTIB, rdxPb->fPIB);
+ };
+
kSyscalls[cSerialWriteInterrupt].Leak().Leak()->fHooked = true;
kSyscalls[cTlsInterrupt].Leak().Leak()->fHooked = true;
+ kSyscalls[cTlsInstallInterrupt].Leak().Leak()->fHooked = true;
+ kSyscalls[cDeleteInterrupt].Leak().Leak()->fHooked = true;
+ kSyscalls[cNewInterrupt].Leak().Leak()->fHooked = true;
NewOS::HAL::Detail::_ke_power_on_self_test();