summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/Kernel/SyscallManager/Res.ns.cpp20
-rw-r--r--Source/Kernel/TaskManager/Process.class.cpp5
-rw-r--r--Source/Kernel/TaskManager/Process.class.h2
-rw-r--r--Source/Kernel/TaskManager/Thread.class.cpp5
-rw-r--r--Source/Kernel/TaskManager/Thread.class.h2
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.proto.cpp6
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.proto.h2
-rw-r--r--Source/Library/Interface/Process.iface.h4
-rw-r--r--Source/Library/Interface/Thread.iface.h4
-rw-r--r--Source/Library/Interface/VirtualTerminal.iface.h4
-rw-r--r--Source/Library/Userland/Binding/Process.class.h2
-rw-r--r--Source/Library/Userland/Binding/Thread.class.h2
-rw-r--r--Source/Library/Userland/Binding/VirtualTerminal.class.h2
-rw-r--r--Source/Library/Userland/Syscall/RessourceCaller.class.cpp4
-rw-r--r--Source/Library/Userland/Syscall/RessourceCaller.class.h5
15 files changed, 60 insertions, 9 deletions
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 <DeviceManager/Disp.ns.h>
#include <VTManager/VT.ns.h>
+#include <TaskManager/Task.ns.h>
#include <VirtualTerminal.iface.h>
@@ -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();
diff --git a/Source/Library/Interface/Process.iface.h b/Source/Library/Interface/Process.iface.h
index fe70833..2126dc6 100644
--- a/Source/Library/Interface/Process.iface.h
+++ b/Source/Library/Interface/Process.iface.h
@@ -2,6 +2,10 @@
#define DEF_PROCESS_IFACE_H
#define PRIF_OBJTYPE 0x20
+
+//S = static, GET = get, C = current, PR = process
+#define PRIF_SGETCPR 0
+
#define PRIF_EXIT 0x01
#define PRIF_ALLOCPAGE 0x02
#define PRIF_FREEPAGE 0x03
diff --git a/Source/Library/Interface/Thread.iface.h b/Source/Library/Interface/Thread.iface.h
index ac572b4..0dac2e1 100644
--- a/Source/Library/Interface/Thread.iface.h
+++ b/Source/Library/Interface/Thread.iface.h
@@ -2,6 +2,10 @@
#define DEF_THREAD_IFACE_H
#define THIF_OBJTYPE 0x21
+
+//S = static, GET = get, C = current, TH = thread
+#define THIF_SGETCTH 0
+
#define THIF_SLEEP 0x01
#define THIF_FINISH 0x02
diff --git a/Source/Library/Interface/VirtualTerminal.iface.h b/Source/Library/Interface/VirtualTerminal.iface.h
index 528e9e5..412cf8f 100644
--- a/Source/Library/Interface/VirtualTerminal.iface.h
+++ b/Source/Library/Interface/VirtualTerminal.iface.h
@@ -2,6 +2,10 @@
#define DEF_VITRUALTERMINAL_IFACE_H
#define VTIF_OBJTYPE 0x10
+
+//S = static, GET = get, PR = process, VT = virtualterminal
+#define VTIF_SGETPRVT 0
+
#define VTIF_PUT 0x01
#define VTIF_WRITEHEX 0x02
#define VTIF_WRITEDEC 0x03
diff --git a/Source/Library/Userland/Binding/Process.class.h b/Source/Library/Userland/Binding/Process.class.h
index e532ad3..00afe27 100644
--- a/Source/Library/Userland/Binding/Process.class.h
+++ b/Source/Library/Userland/Binding/Process.class.h
@@ -5,7 +5,7 @@
class Process : public RessourceCaller {
public:
static Process get() {
- u32int id = RessourceCaller::getObjId(PRIF_OBJTYPE);
+ u32int id = RessourceCaller::sCall(PRIF_OBJTYPE, PRIF_SGETCPR);
return Process(id);
}
Process(u32int id) : RessourceCaller(id, PRIF_OBJTYPE) {}
diff --git a/Source/Library/Userland/Binding/Thread.class.h b/Source/Library/Userland/Binding/Thread.class.h
index 1a354d3..a19c256 100644
--- a/Source/Library/Userland/Binding/Thread.class.h
+++ b/Source/Library/Userland/Binding/Thread.class.h
@@ -5,7 +5,7 @@
class Thread : public RessourceCaller {
public:
static Thread get() {
- u32int id = RessourceCaller::getObjId(THIF_OBJTYPE);
+ u32int id = RessourceCaller::sCall(THIF_OBJTYPE, THIF_SGETCTH);
return Thread(id);
}
Thread(u32int id) : RessourceCaller(id, THIF_OBJTYPE) {}
diff --git a/Source/Library/Userland/Binding/VirtualTerminal.class.h b/Source/Library/Userland/Binding/VirtualTerminal.class.h
index 4329c86..0da1be4 100644
--- a/Source/Library/Userland/Binding/VirtualTerminal.class.h
+++ b/Source/Library/Userland/Binding/VirtualTerminal.class.h
@@ -8,7 +8,7 @@
class VirtualTerminal : public RessourceCaller {
public:
static VirtualTerminal get() {
- u32int id = RessourceCaller::getObjId(VTIF_OBJTYPE);
+ u32int id = RessourceCaller::sCall(VTIF_OBJTYPE, VTIF_SGETPRVT);
return VirtualTerminal(id);
}
VirtualTerminal(u32int id) : RessourceCaller(id, VTIF_OBJTYPE) {}
diff --git a/Source/Library/Userland/Syscall/RessourceCaller.class.cpp b/Source/Library/Userland/Syscall/RessourceCaller.class.cpp
index 2d7b6ba..f3b61a8 100644
--- a/Source/Library/Userland/Syscall/RessourceCaller.class.cpp
+++ b/Source/Library/Userland/Syscall/RessourceCaller.class.cpp
@@ -7,8 +7,8 @@ RessourceCaller::RessourceCaller(u32int id, u32int type) {
if (m_type != type) m_type = 0;
}
-u32int RessourceCaller::getObjId(u32int type) {
- return syscall(0xFFFFFE00, type);
+u32int RessourceCaller::sCall(u32int type, u8int wat, u32int a, u32int b, u32int c, u32int d) {
+ return syscall(0xFFFFFE00 | wat, type, a, b, c, d);
}
u32int RessourceCaller::doCall(u8int call, u32int a, u32int b, u32int c, u32int d, u32int e) {
diff --git a/Source/Library/Userland/Syscall/RessourceCaller.class.h b/Source/Library/Userland/Syscall/RessourceCaller.class.h
index 3602ef0..85beacf 100644
--- a/Source/Library/Userland/Syscall/RessourceCaller.class.h
+++ b/Source/Library/Userland/Syscall/RessourceCaller.class.h
@@ -21,7 +21,10 @@ class RessourceCaller {
protected:
RessourceCaller(u32int id, u32int type);
- static u32int getObjId(u32int type);
+
+ //Static call -- a call specific to a class and not an object
+ static u32int sCall(u32int type, u8int wat, u32int a = 0, u32int b = 0, u32int c = 0, u32int d = 0);
+
u32int doCall(u8int call, u32int a = 0, u32int b = 0, u32int c = 0, u32int d = 0, u32int e = 0);
public: