2 * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
8 #include <commpage_defs.h>
10 #include "asm_offsets.h"
11 #include "syscall_numbers.h"
14 /*! \fn void x86_signal_frame_function_beos(signal_frame_data* frameData)
15 \brief Wrapper function for BeOS-style signal handler functions.
16 \param frameData The signal frame data.
18 FUNCTION(x86_signal_frame_function_beos):
19 // set up a stack frame
23 // Move our parameter to %esi, so we can conveniently work with it. Note
24 // that we're free to use non-scratch registers without saving them, since
25 // we don't have any caller to save them for. The caller will restore the
26 // interrupted environment anyway.
29 // push the parameters for the handler function
31 // make space for the vregs parameter
32 lea -VREGS_sizeof(%esp), %esp
35 // copy the vregs via memcpy()
37 lea SIGNAL_FRAME_DATA_context + UCONTEXT_T_uc_mcontext(%esi), %eax
40 movl SIGNAL_FRAME_DATA_commpage_address(%esi), %eax
41 addl 4 * COMMPAGE_ENTRY_X86_MEMCPY(%eax), %eax
45 // the vregs are on the stack -- push user data and signal number
46 movl SIGNAL_FRAME_DATA_user_data(%esi), %eax
48 movl SIGNAL_FRAME_DATA_info+SIGINFO_T_si_signo(%esi), %eax
51 // call the signal handler
52 movl SIGNAL_FRAME_DATA_handler(%esi), %eax
54 addl $8, %esp // pop only signal number and user data arguments
56 // copy the vregs back to the frameData structure
59 lea SIGNAL_FRAME_DATA_context + UCONTEXT_T_uc_mcontext(%esi), %eax
61 movl SIGNAL_FRAME_DATA_commpage_address(%esi), %eax
62 addl 4 * COMMPAGE_ENTRY_X86_MEMCPY(%eax), %eax
64 addl $12 + VREGS_sizeof, %esp
66 // call the _kern_restore_signal_frame() syscall -- does not return (here)
68 pushl $0 // dummy return value
69 movl $SYSCALL_RESTORE_SIGNAL_FRAME, %eax
73 FUNCTION_END(x86_signal_frame_function_beos)