1/* 2 * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7#include <asm_defs.h> 8#include <commpage_defs.h> 9 10#include "asm_offsets.h" 11#include "syscall_numbers.h" 12 13 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. 17*/ 18FUNCTION(x86_signal_frame_function_beos): 19 // set up a stack frame 20 push %ebp 21 mov %esp, %ebp 22 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. 27 mov 8(%ebp), %esi 28 29 // push the parameters for the handler function 30 31 // make space for the vregs parameter 32 lea -VREGS_sizeof(%esp), %esp 33 mov %esp, %edi 34 35 // copy the vregs via memcpy() 36 pushl $VREGS_sizeof 37 lea SIGNAL_FRAME_DATA_context + UCONTEXT_T_uc_mcontext(%esi), %eax 38 push %eax 39 push %edi 40 movl SIGNAL_FRAME_DATA_commpage_address(%esi), %eax 41 addl 4 * COMMPAGE_ENTRY_X86_MEMCPY(%eax), %eax 42 call *%eax 43 addl $12, %esp 44 45 // the vregs are on the stack -- push user data and signal number 46 movl SIGNAL_FRAME_DATA_user_data(%esi), %eax 47 push %eax 48 movl SIGNAL_FRAME_DATA_info+SIGINFO_T_si_signo(%esi), %eax 49 push %eax 50 51 // call the signal handler 52 movl SIGNAL_FRAME_DATA_handler(%esi), %eax 53 call *%eax 54 addl $8, %esp // pop only signal number and user data arguments 55 56 // copy the vregs back to the frameData structure 57 pushl $VREGS_sizeof 58 push %edi 59 lea SIGNAL_FRAME_DATA_context + UCONTEXT_T_uc_mcontext(%esi), %eax 60 push %eax 61 movl SIGNAL_FRAME_DATA_commpage_address(%esi), %eax 62 addl 4 * COMMPAGE_ENTRY_X86_MEMCPY(%eax), %eax 63 call *%eax 64 addl $12 + VREGS_sizeof, %esp 65 66 // call the _kern_restore_signal_frame() syscall -- does not return (here) 67 pushl %esi 68 pushl $0 // dummy return value 69 movl $SYSCALL_RESTORE_SIGNAL_FRAME, %eax 70 int $99 71 72 // never gets here 73FUNCTION_END(x86_signal_frame_function_beos) 74