From 90b49b6f171108f272ff529f7546bd9625ca7d17 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Tue, 20 Oct 2009 18:30:50 +0200 Subject: Implemented static syscalls, specific to a class and not an object. --- Source/Kernel/SyscallManager/Res.ns.cpp | 20 +++++++++++++++++--- Source/Kernel/TaskManager/Process.class.cpp | 5 +++++ Source/Kernel/TaskManager/Process.class.h | 2 ++ Source/Kernel/TaskManager/Thread.class.cpp | 5 +++++ Source/Kernel/TaskManager/Thread.class.h | 2 ++ Source/Kernel/VTManager/VirtualTerminal.proto.cpp | 6 ++++++ Source/Kernel/VTManager/VirtualTerminal.proto.h | 2 ++ 7 files changed, 39 insertions(+), 3 deletions(-) (limited to 'Source/Kernel') diff --git a/Source/Kernel/SyscallManager/Res.ns.cpp b/Source/Kernel/SyscallManager/Res.ns.cpp index 7902f2d..98d3ac3 100644 --- a/Source/Kernel/SyscallManager/Res.ns.cpp +++ b/Source/Kernel/SyscallManager/Res.ns.cpp @@ -7,6 +7,20 @@ namespace Res { +typedef u32int (*staticcall)(u8int, u32int, u32int, u32int, u32int); + +struct static_call_t { + u32int id; + staticcall call; +}; + +static_call_t staticCalls[] = { + {VTIF_OBJTYPE, VirtualTerminal::scall}, + {PRIF_OBJTYPE, Process::scall}, + {THIF_OBJTYPE, Thread::scall}, + {0, 0} +}; + Ressource** ressources = 0; u32int size = 0; @@ -43,9 +57,9 @@ void unregisterRes(u32int id) { u32int call(u32int ressource, u8int wat, u32int a, u32int b, u32int c, u32int d, u32int e) { if (ressource == 0xFFFFFE) { //TODO : return ressource id for some stuff for current process - if (a == VTIF_OBJTYPE) return Task::currProcess()->getVirtualTerminal()->resId(); - if (a == PRIF_OBJTYPE) return Task::currProcess()->resId(); - if (a == THIF_OBJTYPE) return Task::currThread()->resId(); + for (u32int i = 0; staticCalls[i].id != 0; i++) { + if (staticCalls[i].id == a) return staticCalls[i].call(wat, b, c, d, e); + } return 0; } else { if (ressource > size or ressources[ressource] == 0) { diff --git a/Source/Kernel/TaskManager/Process.class.cpp b/Source/Kernel/TaskManager/Process.class.cpp index 7ebac72..a2bbfb4 100644 --- a/Source/Kernel/TaskManager/Process.class.cpp +++ b/Source/Kernel/TaskManager/Process.class.cpp @@ -16,6 +16,11 @@ call_t Process::m_callTable[] = { CALL0(0, 0) }; +u32int Process::scall(u8int wat, u32int a, u32int b, u32int c, u32int d) { + if (wat == PRIF_SGETCPR) return Task::currProcess()->resId(); + return (u32int) - 1; +} + Process::Process() : Ressource(PRIF_OBJTYPE, m_callTable) { //Private constructor, does nothing } diff --git a/Source/Kernel/TaskManager/Process.class.h b/Source/Kernel/TaskManager/Process.class.h index 0013dfb..89efd0c 100644 --- a/Source/Kernel/TaskManager/Process.class.h +++ b/Source/Kernel/TaskManager/Process.class.h @@ -53,6 +53,8 @@ class Process : public Ressource { u32int allocPageSC(u32int); public: + static u32int scall(u8int, u32int, u32int, u32int, u32int); + static Process* createKernel(String cmdline, VirtualTerminal *vt); //Also creates a Thread for what's curently happening static Process* run(String filename, FSNode* cwd, u32int uid); Process(String cmdline, u32int uid); diff --git a/Source/Kernel/TaskManager/Thread.class.cpp b/Source/Kernel/TaskManager/Thread.class.cpp index d846630..21ef954 100644 --- a/Source/Kernel/TaskManager/Thread.class.cpp +++ b/Source/Kernel/TaskManager/Thread.class.cpp @@ -12,6 +12,11 @@ call_t Thread::m_callTable[] = { CALL0(0, 0) }; +u32int Thread::scall(u8int wat, u32int a, u32int b, u32int c, u32int d) { + if (wat == THIF_SGETCTH) return Task::currThread()->resId(); + return (u32int) - 1; +} + void runThread(Thread* thread, void* data, thread_entry_t entry_point) { if (thread->m_isKernel) { asm volatile("sti"); diff --git a/Source/Kernel/TaskManager/Thread.class.h b/Source/Kernel/TaskManager/Thread.class.h index 5938e2e..35a9fd6 100644 --- a/Source/Kernel/TaskManager/Thread.class.h +++ b/Source/Kernel/TaskManager/Thread.class.h @@ -43,6 +43,8 @@ class Thread : public Ressource { u32int finishSC(u32int errcode); public: + static u32int scall(u8int, u32int, u32int, u32int, u32int); + Thread(thread_entry_t entry_point, void* data, bool iskernel = false); //Assumes process is current process, or is kprocess if isk Thread(Process* process, thread_entry_t entry_point, void* data); ~Thread(); diff --git a/Source/Kernel/VTManager/VirtualTerminal.proto.cpp b/Source/Kernel/VTManager/VirtualTerminal.proto.cpp index 348113d..9b0b862 100644 --- a/Source/Kernel/VTManager/VirtualTerminal.proto.cpp +++ b/Source/Kernel/VTManager/VirtualTerminal.proto.cpp @@ -1,6 +1,7 @@ #include "VirtualTerminal.proto.h" #include #include +#include #include @@ -17,6 +18,11 @@ call_t VirtualTerminal::m_callTable[] = { CALL0(0, 0) }; +u32int VirtualTerminal::scall(u8int wat, u32int a, u32int b, u32int c, u32int d) { + if (wat == VTIF_SGETPRVT) return Task::currProcess()->getVirtualTerminal()->resId(); + return (u32int) - 1; +} + VirtualTerminal::VirtualTerminal() : Ressource(VTIF_OBJTYPE, m_callTable), m_kbdMutex(false), m_kbdbuffMutex(false), m_kbdbuff() { } diff --git a/Source/Kernel/VTManager/VirtualTerminal.proto.h b/Source/Kernel/VTManager/VirtualTerminal.proto.h index c81cf1a..936e4d4 100644 --- a/Source/Kernel/VTManager/VirtualTerminal.proto.h +++ b/Source/Kernel/VTManager/VirtualTerminal.proto.h @@ -32,6 +32,8 @@ class VirtualTerminal : public Ressource { u32int isBoxedSC(); public: + static u32int scall(u8int, u32int, u32int, u32int, u32int); + VirtualTerminal(); virtual ~VirtualTerminal(); -- cgit v1.2.3