diff options
Diffstat (limited to 'Source/Library/Userland')
-rw-r--r-- | Source/Library/Userland/Binding/Process.class.h | 22 | ||||
-rw-r--r-- | Source/Library/Userland/Start.cpp | 12 |
2 files changed, 32 insertions, 2 deletions
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 { |