diff options
author | Alexis211 <alexis211@gmail.com> | 2009-10-24 22:58:28 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-10-24 22:58:28 +0200 |
commit | d1ac6fb03e3110e35023f60f643f0c4d02c3d8b6 (patch) | |
tree | b7f693ab8ea9d320f5bd1b838e8eb3d3bcd690f4 /Source/Library | |
parent | b639b99b3e8f4cf77560d8d473b13d992ac8eb10 (diff) | |
download | Melon-d1ac6fb03e3110e35023f60f643f0c4d02c3d8b6.tar.gz Melon-d1ac6fb03e3110e35023f60f643f0c4d02c3d8b6.zip |
More work on syscalls : userland applications can run other apps.
Diffstat (limited to 'Source/Library')
-rw-r--r-- | Source/Library/Interface/Process.iface.h | 10 | ||||
-rw-r--r-- | Source/Library/Userland/Binding/Process.class.h | 22 | ||||
-rw-r--r-- | Source/Library/Userland/Start.cpp | 12 |
3 files changed, 42 insertions, 2 deletions
diff --git a/Source/Library/Interface/Process.iface.h b/Source/Library/Interface/Process.iface.h index 52543aa..0152947 100644 --- a/Source/Library/Interface/Process.iface.h +++ b/Source/Library/Interface/Process.iface.h @@ -1,10 +1,14 @@ #ifndef DEF_PROCESS_IFACE_H #define DEF_PROCESS_IFACE_H +#define E_AUTODELETE 0x0FFFFF03 + #define PRIF_OBJTYPE 0x20 //S = static, GET = get, C = current, PR = process #define PRIF_SGETCPR 0 +#define PRIF_SRUN 1 +#define PRIF_SWAIT 2 #define PRIF_EXIT 0x01 #define PRIF_ALLOCPAGE 0x02 @@ -15,4 +19,10 @@ #define PRIF_ARGC 0x10 #define PRIF_ARGV 0x11 +#define PRIF_START 0x20 +#define PRIF_AUTODELETE 0x21 +#define PRIF_PUSHARG 0x28 +#define PRIF_SETOUTVT 0x29 +#define PRIF_SETINVT 0x30 + #endif diff --git a/Source/Library/Userland/Binding/Process.class.h b/Source/Library/Userland/Binding/Process.class.h index 9687ea9..a3fc569 100644 --- a/Source/Library/Userland/Binding/Process.class.h +++ b/Source/Library/Userland/Binding/Process.class.h @@ -2,6 +2,7 @@ #define DEF_PROCESS_CLASS_H #include <Syscall/RessourceCaller.class.h> +#include <Binding/VirtualTerminal.class.h> #include <Process.iface.h> #include <String.class.h> @@ -12,6 +13,9 @@ class Process : public RessourceCaller { u32int id = RessourceCaller::sCall(PRIF_OBJTYPE, PRIF_SGETCPR); return Process(id); } + static Process run(const String& app) { + return Process(sCall(PRIF_OBJTYPE, PRIF_SRUN, (u32int)&app)); + } Process(u32int id) : RessourceCaller(id, PRIF_OBJTYPE) {} void exit() { @@ -35,6 +39,24 @@ class Process : public RessourceCaller { String argv(u32int idx) { return String::unserialize(doCall(PRIF_ARGV, idx)); } + void start() { + doCall(PRIF_START); + } + s32int wait() { + return sCall(PRIF_OBJTYPE, PRIF_SWAIT, resId()); + } + void autoDelete(bool ad = true) { + doCall(PRIF_AUTODELETE, (ad ? 1 : 0)); + } + void pushArg(const String& arg) { + doCall(PRIF_PUSHARG, (u32int)&arg); + } + void setInVT(VirtualTerminal vt) { + doCall(PRIF_SETINVT, vt.resId()); + } + void setOutVT(VirtualTerminal vt) { + doCall(PRIF_SETOUTVT, vt.resId()); + } }; #endif diff --git a/Source/Library/Userland/Start.cpp b/Source/Library/Userland/Start.cpp index be4f81e..930c4dd 100644 --- a/Source/Library/Userland/Start.cpp +++ b/Source/Library/Userland/Start.cpp @@ -1,4 +1,5 @@ #include <types.h> +#include <Syscall/Syscall.wtf.h> #include <Binding/VirtualTerminal.class.h> #include <Heap.class.h> @@ -15,14 +16,21 @@ VirtualTerminal invt(0), outvt(0); int main(const Vector<String>& args); +void doExit(u32int v) { + asm volatile("int $66" : : "a"(v)); +} + extern "C" void start() { //Call static constructors + u32int i = 0; for(u32int * call = &start_ctors; call < &end_ctors; call++) { ((void (*)(void))*call)(); } - heap.create(0x40000000, 0x00100000, 0x00004000); //Initially create a 1M heap with 16ko index + heap.create(0x40000000, 0x00040000, 0x00004000); //Initially create a 256ko heap with 16ko index invt = VirtualTerminal::getIn(); outvt = VirtualTerminal::getOut(); + if (!invt.valid()) doExit(1); + if (!outvt.valid()) doExit(2); u32int argc = Process::get().argc(); Vector<String> args(argc); @@ -35,7 +43,7 @@ extern "C" void start() { ((void (*)(void))*call)(); } - asm volatile("int $66" : : "a"(r)); + doExit(r); } namespace Mem { |