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/Library/Userland/Syscall | |
parent | 323e12f1f9ab33df15dcfed210e807561d98fa8c (diff) | |
download | Melon-e589a45295a871f38d4a1d1f23b370b612f99be5.tar.gz Melon-e589a45295a871f38d4a1d1f23b370b612f99be5.zip |
Syscall interface starts being implemented !
Diffstat (limited to 'Source/Library/Userland/Syscall')
4 files changed, 57 insertions, 12 deletions
diff --git a/Source/Library/Userland/Syscall/RessourceCaller.class.cpp b/Source/Library/Userland/Syscall/RessourceCaller.class.cpp new file mode 100644 index 0000000..2d7b6ba --- /dev/null +++ b/Source/Library/Userland/Syscall/RessourceCaller.class.cpp @@ -0,0 +1,18 @@ +#include "RessourceCaller.class.h" + +RessourceCaller::RessourceCaller(u32int id, u32int type) { + m_id = id; + m_type = 1; + m_type = doCall(0); + if (m_type != type) m_type = 0; +} + +u32int RessourceCaller::getObjId(u32int type) { + return syscall(0xFFFFFE00, type); +} + +u32int RessourceCaller::doCall(u8int call, u32int a, u32int b, u32int c, u32int d, u32int e) { + if (m_type == 0) return (u32int) - 1; //Type 0 = invalid object + u32int x = ((m_id << 8) | call); + return syscall(x, a, b, c, d, e); +} diff --git a/Source/Library/Userland/Syscall/RessourceCaller.class.h b/Source/Library/Userland/Syscall/RessourceCaller.class.h new file mode 100644 index 0000000..3ad8900 --- /dev/null +++ b/Source/Library/Userland/Syscall/RessourceCaller.class.h @@ -0,0 +1,22 @@ +#ifndef DEF_RESSOURCECALLER_CLASS_H +#define DEF_RESSOURCECALLER_CLASS_H + +#include <Syscall/Syscall.wtf.h> + +class RessourceCaller { + private: + u32int m_id; + u32int m_type; + + protected: + RessourceCaller(u32int id, u32int type); + static u32int getObjId(u32int type); + u32int doCall(u8int call, u32int a = 0, u32int b = 0, u32int c = 0, u32int d = 0, u32int e = 0); + + public: + u32int resId() { return m_id; } + u32int resType() { return m_type; } + bool valid() { return m_type != 0; } +}; + +#endif diff --git a/Source/Library/Userland/Syscall/Syscall.wtf.cpp b/Source/Library/Userland/Syscall/Syscall.wtf.cpp index 2c03b20..a28c202 100644 --- a/Source/Library/Userland/Syscall/Syscall.wtf.cpp +++ b/Source/Library/Userland/Syscall/Syscall.wtf.cpp @@ -1,20 +1,21 @@ #include "Syscall.wtf.h" -int main(); - -unsigned int syscall(unsigned int n, unsigned int a, unsigned int b, unsigned int c) { - unsigned int r; +u32int syscall(u32int n, u32int a, u32int b, u32int c, u32int d, u32int e) { + u32int r; asm volatile ("int $64;" - : "=a"(r) : "a"(n), "b"(a), "c"(b), "d"(c)); + : "=a"(r) : "a"(n), "b"(a), "c"(b), "d"(c), "D"(d), "S"(e)); return r; } -extern "C" void start() { - unsigned int r = main(); - asm volatile("int $66" : : "a"(r)); -} - void putch(char c) { - unsigned int x = c; + u32int x = c; syscall(0xFFFFFF01, x); } + +void sleep(u32int t) { + syscall(0xFFFFFF02, t); +} + +void write_hex(u32int n) { + syscall(0XFFFFFF03, n); +} diff --git a/Source/Library/Userland/Syscall/Syscall.wtf.h b/Source/Library/Userland/Syscall/Syscall.wtf.h index b220d14..0401a89 100644 --- a/Source/Library/Userland/Syscall/Syscall.wtf.h +++ b/Source/Library/Userland/Syscall/Syscall.wtf.h @@ -3,7 +3,11 @@ #include <types.h> +//Three basic syscalls, just for testing void putch(char); -unsigned int syscall(unsigned int n, unsigned int a, unsigned int b = 0, unsigned int c = 0); +void sleep(u32int); +void write_hex(u32int); + +u32int syscall(u32int n, u32int a, u32int b = 0, u32int c = 0, u32int d = 0, u32int e = 0); #endif |