summaryrefslogtreecommitdiff
path: root/Source/Library/Userland/Start.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Library/Userland/Start.cpp')
-rw-r--r--Source/Library/Userland/Start.cpp37
1 files changed, 14 insertions, 23 deletions
diff --git a/Source/Library/Userland/Start.cpp b/Source/Library/Userland/Start.cpp
index f1d1771..cb9faf9 100644
--- a/Source/Library/Userland/Start.cpp
+++ b/Source/Library/Userland/Start.cpp
@@ -1,46 +1,37 @@
#include <types.h>
#include <Syscall/Syscall.wtf.h>
-#include <Binding/VirtualTerminal.class.h>
+
+#include <App/Application.proto.h>
#include <Heap.class.h>
-extern u32int start_ctors, end_ctors, start_dtors, end_dtors;
+extern u32int start_ctors, end_ctors;
-Heap heap;
+Heap *heap;
VirtualTerminal invt(0), outvt(0);
int main(const Vector<String>& args);
extern "C" void start() {
- heap.create(0x40000000, 0x00040000, 0x00004000); //Initially create a 256ko heap with 16ko index
+ Heap h;
+ h.create(0x40000000, 0x00040000, 0x00004000); //Initially create a 256ko heap with 16ko index
+ heap = &h;
- //Call static constructors
+ //Call static constructors (this will construct the Application object and get some stuff (arguments, ...))
u32int i = 0;
for(u32int * call = &start_ctors; call < &end_ctors; call++) {
((void (*)(void))*call)();
}
- invt = VirtualTerminal::getIn(); outvt = VirtualTerminal::getOut();
- if (!invt.valid()) threadFinishedSyscall(1);
- if (!outvt.valid()) threadFinishedSyscall(2);
-
- u32int argc = Process::get().argc();
- Vector<String> args(argc);
- for (u32int i = 0; i < argc; i++) args[i] = Process::get().argv(i);
-
- u32int r = main(args);
-
- //Call static destructors
- for(u32int * call = &start_dtors; call < &end_dtors; call++) {
- ((void (*)(void))*call)();
- }
-
- threadFinishedSyscall(r);
+ app->doEvents();
+ u32int r = app->run();
+ app->doEvents();
+ app->exit(r); //Will call static destructors
}
namespace Mem {
- void* alloc (size_t sz) { return heap.alloc(sz); }
- void free(void* ptr) { heap.free(ptr); }
+ void* alloc (size_t sz) { return heap->alloc(sz); }
+ void free(void* ptr) { heap->free(ptr); }
void* mkXchgSpace (size_t sz) { return alloc(sz); }
}