feat: wrapper function for bootstraping user program
[lunaix-os.git] / lunaix-os / usr / uwrap.S
diff --git a/lunaix-os/usr/uwrap.S b/lunaix-os/usr/uwrap.S
new file mode 100644 (file)
index 0000000..1f07722
--- /dev/null
@@ -0,0 +1,23 @@
+#define __ASM__
+#include <lunaix/syscall.h>
+
+.section .text
+    .global _u_start
+    _u_start:
+        call usr_pre_init
+        jnz 1f
+
+        popl %eax
+
+        pushl (%eax)    // argc
+        pushl 4(%eax)   // argv
+        
+        xorl %eax, %eax
+        call main
+        
+    1:
+        movl %eax, %ebx
+        movl $__SYSCALL__exit, %eax
+        int $LUNAIX_SYS_CALL
+
+        ud2 // should not reach
\ No newline at end of file