xref: /haiku/src/system/kernel/arch/x86/32/signals_asm.S (revision 77d95e1d47ef811b7c30cf79d7f6be1c3f08575a)
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	USER_COMMPAGE_ADDR + 4 * COMMPAGE_ENTRY_X86_MEMCPY, %eax
41	call	*%eax
42	addl	$12, %esp
43
44	// the vregs are on the stack -- push user data and signal number
45	movl	SIGNAL_FRAME_DATA_user_data(%esi), %eax
46	push	%eax
47	movl	SIGNAL_FRAME_DATA_info+SIGINFO_T_si_signo(%esi), %eax
48	push	%eax
49
50	// call the signal handler
51	movl	SIGNAL_FRAME_DATA_handler(%esi), %eax
52	call	*%eax
53	addl	$8, %esp	// pop only signal number and user data arguments
54
55	// copy the vregs back to the frameData structure
56	pushl	$VREGS_sizeof
57	push	%edi
58	lea		SIGNAL_FRAME_DATA_context + UCONTEXT_T_uc_mcontext(%esi), %eax
59	push	%eax
60	movl	USER_COMMPAGE_ADDR + 4 * COMMPAGE_ENTRY_X86_MEMCPY, %eax
61	call	*%eax
62	addl	$12 + VREGS_sizeof, %esp
63
64	// call the _kern_restore_signal_frame() syscall -- does not return (here)
65	pushl	%esi
66	pushl	$0	// dummy return value
67	movl	$SYSCALL_RESTORE_SIGNAL_FRAME, %eax
68	int		$99
69
70	// never gets here
71FUNCTION_END(x86_signal_frame_function_beos)
72