_ctx_start.S revision 131460
1243789Sdim/*
2243789Sdim * Copyright (c) 2001 Daniel Eischen <deischen@freebsd.org>
3243789Sdim * All rights reserved.
4243789Sdim *
5243789Sdim * Redistribution and use in source and binary forms, with or without
6243789Sdim * modification, are permitted provided that the following conditions
7243789Sdim * are met:
8243789Sdim * 1. Redistributions of source code must retain the above copyright
9243789Sdim *    notice, this list of conditions and the following disclaimer.
10243789Sdim * 2. Neither the name of the author nor the names of its contributors
11243789Sdim *    may be used to endorse or promote products derived from this software
12243789Sdim *    without specific prior written permission.
13243789Sdim *
14243789Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15243789Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16243789Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17243789Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18249423Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19243789Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20243789Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21243789Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22243789Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23243789Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24243789Sdim * SUCH DAMAGE.
25243789Sdim */
26243789Sdim
27243789Sdim#include <machine/asm.h>
28243789Sdim__FBSDID("$FreeBSD: head/lib/libc/i386/gen/_ctx_start.S 131460 2004-07-02 14:19:44Z davidxu $");
29243789Sdim
30243789Sdim/*
31243789Sdim * _ctx_start((void *func)(int arg1, ..., argn),
32243789Sdim *            int arg1, ..., argn, ucontext_t *ucp)
33243789Sdim *
34243789Sdim * 0(%esp)		- func
35243789Sdim * 4(%esp)		- arg1
36243789Sdim * 8(%esp)		- arg2
37243789Sdim * ...
38243789Sdim * (4*n)(%esp)		- argn
39243789Sdim * (4*(n + 1))(%esp)	- ucp, %ebp setup to point here (base of stack)
40243789Sdim */
41243789SdimENTRY(_ctx_start)
42243789Sdim	popl	%eax		/* get start function */
43243789Sdim	call	*%eax		/* call start function */
44263508Sdim	movl	%esi, %esp	/*
45263508Sdim				 * setup stack for completion routine;
46263508Sdim				 * ucp is now at top of stack
47243789Sdim				 */
48243789Sdim	call	_ctx_done	/* should never return */
49243789Sdim	call	abort		/* fubar */
50243789Sdim	ret
51243789Sdim