Architectural Support: x86_64 (#37)
[lunaix-os.git] / lunaix-os / arch / x86 / exec / exec.c
diff --git a/lunaix-os/arch/x86/exec/exec.c b/lunaix-os/arch/x86/exec/exec.c
new file mode 100644 (file)
index 0000000..81ad0ec
--- /dev/null
@@ -0,0 +1,23 @@
+#include <lunaix/exec.h>
+#include <lunaix/mm/valloc.h>
+#include <klibc/string.h>
+
+int
+exec_arch_prepare_entry(struct thread* thread, struct exec_host* container)
+{
+    struct hart_state* hstate;
+
+    hstate = thread->hstate;
+
+#ifdef CONFIG_ARCH_X86_64
+    hstate->execp->rip = container->exe.entry;
+    hstate->execp->rsp = container->stack_top;
+
+#else
+    hstate->execp->eip = container->exe.entry;
+    hstate->execp->esp = container->stack_top;
+
+#endif
+
+    return 0;
+}
\ No newline at end of file