_ctx_start.S revision 184548
189177Sdeischen/* 289177Sdeischen * Copyright (c) 2001 Daniel Eischen <deischen@freebsd.org> 389177Sdeischen * All rights reserved. 489177Sdeischen * 589177Sdeischen * Redistribution and use in source and binary forms, with or without 689177Sdeischen * modification, are permitted provided that the following conditions 789177Sdeischen * are met: 889177Sdeischen * 1. Redistributions of source code must retain the above copyright 989177Sdeischen * notice, this list of conditions and the following disclaimer. 1089177Sdeischen * 2. Neither the name of the author nor the names of its contributors 1189177Sdeischen * may be used to endorse or promote products derived from this software 1289177Sdeischen * without specific prior written permission. 1389177Sdeischen * 1489177Sdeischen * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1589177Sdeischen * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1689177Sdeischen * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1789177Sdeischen * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1889177Sdeischen * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1989177Sdeischen * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2089177Sdeischen * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2189177Sdeischen * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2289177Sdeischen * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2389177Sdeischen * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2489177Sdeischen * SUCH DAMAGE. 2589177Sdeischen */ 2689177Sdeischen 2789177Sdeischen#include <machine/asm.h> 2893000Sobrien__FBSDID("$FreeBSD: head/lib/libc/i386/gen/_ctx_start.S 184548 2008-11-02 01:28:47Z peter $"); 2989177Sdeischen 3089177Sdeischen/* 3189177Sdeischen * _ctx_start((void *func)(int arg1, ..., argn), 3289177Sdeischen * int arg1, ..., argn, ucontext_t *ucp) 3389177Sdeischen * 3489177Sdeischen * 0(%esp) - func 3589177Sdeischen * 4(%esp) - arg1 3689177Sdeischen * 8(%esp) - arg2 3789177Sdeischen * ... 3889177Sdeischen * (4*n)(%esp) - argn 3989177Sdeischen * (4*(n + 1))(%esp) - ucp, %ebp setup to point here (base of stack) 4089177Sdeischen */ 4189177SdeischenENTRY(_ctx_start) 4289177Sdeischen popl %eax /* get start function */ 4389177Sdeischen call *%eax /* call start function */ 44159270Skib PIC_PROLOGUE 45131460Sdavidxu movl %esi, %esp /* 4689177Sdeischen * setup stack for completion routine; 4789177Sdeischen * ucp is now at top of stack 4889177Sdeischen */ 49159270Skib call PIC_PLT(_ctx_done) /* should never return */ 50159270Skib call PIC_PLT(abort) /* fubar */ 5189177Sdeischen ret 52184548SpeterEND(_ctx_start) 53