From d8a80cb31fd8a7a0e6e07df7d5a6aeff6609507e Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 28 Sep 2011 12:26:36 -0700 Subject: rt: Add a call stub that switches to the C stack, untested as of yet --- src/rt/arch/i386/ccall.S | 14 ++++++++++++++ src/rt/arch/i386/context.h | 1 + 2 files changed, 15 insertions(+) create mode 100644 src/rt/arch/i386/ccall.S (limited to 'src/rt/arch') diff --git a/src/rt/arch/i386/ccall.S b/src/rt/arch/i386/ccall.S new file mode 100644 index 00000000000..7adecc4c5d2 --- /dev/null +++ b/src/rt/arch/i386/ccall.S @@ -0,0 +1,14 @@ + .text + +// upcall_call_c_stack(void (*fn)(), void *new_esp) +.globl _upcall_call_c_stack +_upcall_call_c_stack: + movl %esp,%ecx // grab esp + movl 8(%esp),%eax // save fn + movl 12(%esp),%esp // switch stack + pushl %ecx // save esp on stack + calll *%eax + popl %esp // restore esp + ret + + diff --git a/src/rt/arch/i386/context.h b/src/rt/arch/i386/context.h index a31b4c48d14..9a225b79606 100644 --- a/src/rt/arch/i386/context.h +++ b/src/rt/arch/i386/context.h @@ -37,6 +37,7 @@ public: void swap(context &out); void call(void *f, void *arg, void *sp); + void call(void *f, void *sp); // Note that this doesn't actually adjust esp. Instead, we adjust esp when // we actually do the call. This is needed for exception safety -- if the -- cgit 1.4.1-3-g733a5