1b66b8326SDaniel Eischen/* 2b66b8326SDaniel Eischen * Copyright (c) 2001 Daniel Eischen <deischen@freebsd.org> 3b66b8326SDaniel Eischen * All rights reserved. 4b66b8326SDaniel Eischen * 5b66b8326SDaniel Eischen * Redistribution and use in source and binary forms, with or without 6b66b8326SDaniel Eischen * modification, are permitted provided that the following conditions 7b66b8326SDaniel Eischen * are met: 8b66b8326SDaniel Eischen * 1. Redistributions of source code must retain the above copyright 9b66b8326SDaniel Eischen * notice, this list of conditions and the following disclaimer. 10b66b8326SDaniel Eischen * 2. Neither the name of the author nor the names of its contributors 11b66b8326SDaniel Eischen * may be used to endorse or promote products derived from this software 12b66b8326SDaniel Eischen * without specific prior written permission. 13b66b8326SDaniel Eischen * 14b66b8326SDaniel Eischen * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15b66b8326SDaniel Eischen * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16b66b8326SDaniel Eischen * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17b66b8326SDaniel Eischen * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18b66b8326SDaniel Eischen * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19b66b8326SDaniel Eischen * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20b66b8326SDaniel Eischen * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21b66b8326SDaniel Eischen * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22b66b8326SDaniel Eischen * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23b66b8326SDaniel Eischen * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24b66b8326SDaniel Eischen * SUCH DAMAGE. 25b66b8326SDaniel Eischen */ 26b66b8326SDaniel Eischen 27b66b8326SDaniel Eischen#include <machine/asm.h> 28b66b8326SDaniel Eischen/* 29b66b8326SDaniel Eischen * _ctx_start((void *func)(int arg1, ..., argn), 30b66b8326SDaniel Eischen * int arg1, ..., argn, ucontext_t *ucp) 31b66b8326SDaniel Eischen * 32b66b8326SDaniel Eischen * 0(%esp) - func 33b66b8326SDaniel Eischen * 4(%esp) - arg1 34b66b8326SDaniel Eischen * 8(%esp) - arg2 35b66b8326SDaniel Eischen * ... 36b66b8326SDaniel Eischen * (4*n)(%esp) - argn 37b66b8326SDaniel Eischen * (4*(n + 1))(%esp) - ucp, %ebp setup to point here (base of stack) 38b66b8326SDaniel Eischen */ 39b66b8326SDaniel EischenENTRY(_ctx_start) 40b66b8326SDaniel Eischen popl %eax /* get start function */ 41b66b8326SDaniel Eischen call *%eax /* call start function */ 423d5fa035SKonstantin Belousov PIC_PROLOGUE 43a5a5d847SDavid Xu movl %esi, %esp /* 44b66b8326SDaniel Eischen * setup stack for completion routine; 45b66b8326SDaniel Eischen * ucp is now at top of stack 46b66b8326SDaniel Eischen */ 473d5fa035SKonstantin Belousov call PIC_PLT(_ctx_done) /* should never return */ 483d5fa035SKonstantin Belousov call PIC_PLT(abort) /* fubar */ 49b66b8326SDaniel Eischen ret 50ed820052SPeter WemmEND(_ctx_start) 51*93ab7586SKonstantin Belousov 52*93ab7586SKonstantin Belousov .section .note.GNU-stack,"",%progbits 53