diff options
author | Alexis211 <alexis211@gmail.com> | 2009-10-18 17:17:36 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-10-18 17:17:36 +0200 |
commit | e589a45295a871f38d4a1d1f23b370b612f99be5 (patch) | |
tree | b59f1190633368d78b23d78e011c99fa8fa3cc90 /Source/Kernel/SyscallManager/Res.ns.cpp | |
parent | 323e12f1f9ab33df15dcfed210e807561d98fa8c (diff) | |
download | Melon-e589a45295a871f38d4a1d1f23b370b612f99be5.tar.gz Melon-e589a45295a871f38d4a1d1f23b370b612f99be5.zip |
Syscall interface starts being implemented !
Diffstat (limited to 'Source/Kernel/SyscallManager/Res.ns.cpp')
-rw-r--r-- | Source/Kernel/SyscallManager/Res.ns.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Source/Kernel/SyscallManager/Res.ns.cpp b/Source/Kernel/SyscallManager/Res.ns.cpp new file mode 100644 index 0000000..aceadf7 --- /dev/null +++ b/Source/Kernel/SyscallManager/Res.ns.cpp @@ -0,0 +1,55 @@ +#include "Res.ns.h" + +#include <VirtualTerminal.iface.h> +#include <TaskManager/Task.ns.h> + +namespace Res { + +Ressource** ressources = 0; +u32int size = 0; + +void expand() { //Expands size of ressources array of 20 entries + size += 20; + Ressource** tmp = (Ressource**)Mem::kalloc(size * sizeof(Ressource*)); + for (u32int i = 0; i < size; i++) { + if (i < size - 20) tmp[i] = ressources[i]; + else tmp[i] = 0; + } + Mem::kfree(ressources); + ressources = tmp; +} + +u32int registerRes(Ressource* r) { + if (ressources == 0 or size == 0) { + ressources = (Ressource**)Mem::kalloc(20 * sizeof(Ressource*)); + size = 20; + for (u32int i = 0; i < 20; i++) ressources[i] = 0; + } + for (u32int i = 0; i < size; i++) { + if (ressources[i] == 0) { + ressources[i] = r; + return i; + } + } + expand(); + return registerRes(r); +} + +void unregisterRes(u32int id) { + ressources[id] = 0; +} + +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 == VT_IFACE_OBJTYPE) return Task::currProcess()->getVirtualTerminal()->resId(); + return 0; + } else { + if (ressource > size or ressources[ressource] == 0) { + return (u32int) - 1; + } else { + return ressources[ressource]->doCall(wat, a, b, c, d, e); + } + } +} + +} |