summaryrefslogtreecommitdiff
path: root/Source/Kernel/SyscallManager
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Kernel/SyscallManager')
-rw-r--r--Source/Kernel/SyscallManager/IDT.ns.cpp2
-rw-r--r--Source/Kernel/SyscallManager/Res.ns.cpp4
-rw-r--r--Source/Kernel/SyscallManager/Ressource.class.cpp11
-rw-r--r--Source/Kernel/SyscallManager/Ressource.class.h10
4 files changed, 24 insertions, 3 deletions
diff --git a/Source/Kernel/SyscallManager/IDT.ns.cpp b/Source/Kernel/SyscallManager/IDT.ns.cpp
index f447e6f..042ef92 100644
--- a/Source/Kernel/SyscallManager/IDT.ns.cpp
+++ b/Source/Kernel/SyscallManager/IDT.ns.cpp
@@ -76,6 +76,7 @@ extern "C" void interrupt_handler(registers_t regs) {
doSwitch = doSwitch or Task::IRQwakeup(regs.int_no - 32);
}
if (regs.int_no == 64) {
+ asm volatile("sti"); //Make syscalls preemtible
u32int res = (regs.eax >> 8);
u8int wat = (regs.eax & 0xFF);
if (res == 0xFFFFFF) {
@@ -91,6 +92,7 @@ extern "C" void interrupt_handler(registers_t regs) {
}
//Some syscalls have maybee modified current page directory, set it back to one for current process
Task::currProcess()->getPagedir()->switchTo();
+ asm volatile("cli");
}
if (regs.int_no == 66) { //This syscall signals to kernel that thread ended.
Task::currentThreadExits(regs.eax); //DO NOT COUNT ON COMMING BACK FROM HERE
diff --git a/Source/Kernel/SyscallManager/Res.ns.cpp b/Source/Kernel/SyscallManager/Res.ns.cpp
index 048d17a..c554166 100644
--- a/Source/Kernel/SyscallManager/Res.ns.cpp
+++ b/Source/Kernel/SyscallManager/Res.ns.cpp
@@ -4,6 +4,7 @@
#include <Process.iface.h>
#include <Thread.iface.h>
#include <FSNode.iface.h>
+#include <Sys.iface.h>
#include <TaskManager/Task.ns.h>
namespace Res {
@@ -20,6 +21,7 @@ static_call_t staticCalls[] = {
{PRIF_OBJTYPE, Process::scall},
{THIF_OBJTYPE, Thread::scall},
{FNIF_OBJTYPE, FSNode::scall},
+ {SYIF_IFID, Sys::scall},
{0, 0}
};
@@ -67,7 +69,7 @@ u32int call(u32int ressource, u8int wat, u32int a, u32int b, u32int c, u32int d,
if (ressource > size or ressources[ressource] == 0) {
return (u32int) - 1;
} else {
- return ressources[ressource]->doCall(wat, a, b, c, d, e);
+ return ressources[ressource]->call(wat, a, b, c, d, e);
}
}
}
diff --git a/Source/Kernel/SyscallManager/Ressource.class.cpp b/Source/Kernel/SyscallManager/Ressource.class.cpp
index f2aaccb..8862bca 100644
--- a/Source/Kernel/SyscallManager/Ressource.class.cpp
+++ b/Source/Kernel/SyscallManager/Ressource.class.cpp
@@ -1,7 +1,8 @@
#include "Ressource.class.h"
#include <SyscallManager/Res.ns.h>
+#include <UserManager/Usr.ns.h>
-Ressource::Ressource(u8int type, call_t* callTable) {
+Ressource::Ressource(u8int type, call_t* callTable) : m_lock(MUTEX_FALSE) {
m_id = Res::registerRes(this);
m_type = type;
m_callTables = 0;
@@ -39,3 +40,11 @@ u32int Ressource::doCall(u8int id, u32int a, u32int b, u32int c, u32int d, u32in
}
return (u32int) - 1;
}
+
+u32int Ressource::call(u8int id, u32int a, u32int b, u32int c, u32int d, u32int e) {
+ if (!ISROOT && !accessible()) return (u32int) - 1;
+ m_lock.waitLock();
+ u32int r = doCall(id, a, b, c, d, e);
+ m_lock.unlock();
+ return r;
+}
diff --git a/Source/Kernel/SyscallManager/Ressource.class.h b/Source/Kernel/SyscallManager/Ressource.class.h
index f58276b..2ccdcc1 100644
--- a/Source/Kernel/SyscallManager/Ressource.class.h
+++ b/Source/Kernel/SyscallManager/Ressource.class.h
@@ -2,6 +2,7 @@
#define DEF_RESSOURCE_CLASS_H
#include <SimpleList.class.h>
+#include <Mutex.class.h>
class Ressource;
@@ -37,18 +38,25 @@ class Ressource {
Ressource(const Ressource&);
Ressource& operator=(const Ressource&);
+ Mutex m_lock;
+
u32int m_id;
u32int m_type;
SimpleList<call_t*> *m_callTables;
+ u32int doCall(u8int id, u32int a, u32int b, u32int c, u32int d, u32int e);
+
protected:
Ressource(u8int type, call_t* callTable = 0);
~Ressource();
+ //This function's role is to tell the Ressource if it is supposed to be accesible from current user or not
+ virtual bool accessible() = 0; //This function should be overloaded by all derivated classes
+
void addCallTable(call_t* callTable);
public:
- u32int doCall(u8int id, u32int a, u32int b, u32int c, u32int d, u32int e);
+ u32int call(u8int id, u32int a, u32int b, u32int c, u32int d, u32int e);
u32int resId() { return m_id; }
u32int resType() { return m_type; }
};