Permalink
Browse files

more documentation of how entry works

  • Loading branch information...
1 parent 800f401 commit 815fa118eb386139358142962d19565a2f05145b @wolfwood wolfwood committed Oct 9, 2011
Showing with 36 additions and 9 deletions.
  1. +36 −9 runtimes/mindrt/entry.d
@@ -15,28 +15,53 @@ import user.ipc;
import libos.console;
import libos.keyboard;
-extern(C) void start3(char[][]);
+
+/*
+ * --- Upcall Vector Table ---
+ * all control transfers jump to _start (in entry.S). it redirects control, based on RAX
+ *
+ * 0 - Initial Entry (from parent, should only happen once)
+ * 1 - CPU Allocation/Donation (give cpu to thread scheduler)
+ * 2 - Child Exit (should trigger cleanup, along with the next one)
+ * 3 - Child Error (from kernel, rather than yield)
+ * ? - Inter Process Communication
+*/
+void function()[4] UVT = [&start,
+ &XombThread._enterThreadScheduler,
+ &XombThread._enterThreadScheduler,
+ &XombThread._enterThreadScheduler];
+
+// used by asm function _start to route upcalls
+extern(C) ubyte* UVTbase = cast(ubyte*)UVT.ptr;
+extern(C) ulong UVTlimit = UVT.length;
+
+
+/*
+ * --- Initial Entry Chain ---
+ * split into 3 functions:
+ *
+ * start - stackless, zeros bss
+ * start2 - static stack, libos initialization and thread creation
+ * start3 - thread stack, runtime specific initialization, calls main()
+ */
-extern(C) ubyte _edata;
+// Declarations used to find and zero BSS
extern(C) ubyte _bss;
extern(C) ubyte _end;
-
ubyte* startBSS = &_bss;
ubyte* endBSS = &_end;
-// Upcall Vector Table -- first entry, cpu allocation, child exit, child error (from kernel)
-void function()[4] UVT = [&start, &XombThread._enterThreadScheduler, &XombThread._enterThreadScheduler, &XombThread._enterThreadScheduler];
-extern(C) ubyte* UVTbase = cast(ubyte*)UVT.ptr;
-
+// temporary stack
ubyte[1024] tempStack;
ubyte* tempStackTop = &tempStack[tempStack.length - 8];
+// provided by runtime, calls main
+extern(C) void start3(char[][]);
+
// zeros BSS and gives us a temporary (statically allocated) stack
void start(){
- // Zero the BSS, equivalent to start2()
-
asm {
naked;
@@ -66,6 +91,8 @@ void start(){
call start2;
}
+
+ // >>> Never reached <<<
}
// initializes console and keyboard, umm and threading, chain loads a thread

0 comments on commit 815fa11

Please sign in to comment.