summaryrefslogtreecommitdiff
path: root/Source/Library/Userland
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-10-18 17:17:36 +0200
committerAlexis211 <alexis211@gmail.com>2009-10-18 17:17:36 +0200
commite589a45295a871f38d4a1d1f23b370b612f99be5 (patch)
treeb59f1190633368d78b23d78e011c99fa8fa3cc90 /Source/Library/Userland
parent323e12f1f9ab33df15dcfed210e807561d98fa8c (diff)
downloadMelon-e589a45295a871f38d4a1d1f23b370b612f99be5.tar.gz
Melon-e589a45295a871f38d4a1d1f23b370b612f99be5.zip
Syscall interface starts being implemented !
Diffstat (limited to 'Source/Library/Userland')
-rw-r--r--Source/Library/Userland/Start.cpp8
-rw-r--r--Source/Library/Userland/Syscall/RessourceCaller.class.cpp18
-rw-r--r--Source/Library/Userland/Syscall/RessourceCaller.class.h22
-rw-r--r--Source/Library/Userland/Syscall/Syscall.wtf.cpp23
-rw-r--r--Source/Library/Userland/Syscall/Syscall.wtf.h6
-rw-r--r--Source/Library/Userland/VirtualTerminal.class.h22
6 files changed, 87 insertions, 12 deletions
diff --git a/Source/Library/Userland/Start.cpp b/Source/Library/Userland/Start.cpp
new file mode 100644
index 0000000..02eb951
--- /dev/null
+++ b/Source/Library/Userland/Start.cpp
@@ -0,0 +1,8 @@
+#include <types.h>
+
+int main();
+
+extern "C" void start() {
+ u32int r = main();
+ asm volatile("int $66" : : "a"(r));
+}
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
diff --git a/Source/Library/Userland/VirtualTerminal.class.h b/Source/Library/Userland/VirtualTerminal.class.h
new file mode 100644
index 0000000..a7bb4c2
--- /dev/null
+++ b/Source/Library/Userland/VirtualTerminal.class.h
@@ -0,0 +1,22 @@
+#include <Syscall/RessourceCaller.class.h>
+
+#include <VirtualTerminal.iface.h>
+
+#include <WChar.class.h>
+
+class VirtualTerminal : public RessourceCaller {
+ public:
+ static VirtualTerminal get() {
+ u32int id = RessourceCaller::getObjId(VT_IFACE_OBJTYPE);
+ return VirtualTerminal(id);
+ }
+ VirtualTerminal(u32int id) : RessourceCaller(id, VT_IFACE_OBJTYPE) {}
+
+ void writeHex(u32int number) {
+ doCall(VT_IFACE_WRITEHEX, number);
+ }
+
+ void put(WChar c) {
+ doCall(VT_IFACE_PUT, c);
+ }
+};