2 * Copyright (c) 2007 Matthew T. Emmerton <matt@gsicomp.on.ca>
4 * Copyright (c) 2007 Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Neither the name of the author nor the names of its contributors
13 * may be used to endorse or promote products derived from this software
14 * without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * $DragonFly: src/lib/libc/i386/gen/mcontext.S,v 1.2 2007/04/13 12:12:27 corecode Exp $
31 #include <machine/asm.h>
32 #include <asmcontext.h>
35 * int get_mcontext(mcontext_t *mcp)
37 * Copy the caller's context into the mcontext, %eax excepted.
40 .set get_mcontext,_get_mcontext
43 /* mc_onstack,0*4(%eax) */
55 /* mc_eax: 12*4(%eax) */
56 /* mc_xflags: 13*4(%eax) */
57 /* mc_trapno: 14*4(%eax) */
58 /* mc_err: 15*4(%eax) */
59 /* mc_eip: 16*4(%eax) */
60 /* mc_cs: 17*4(%eax) */
61 /* mc_eflags: 18*4(%eax) */
62 /* mc_esp: 19*4(%eax) */
65 * Saved stack pointer as if we had returned from this
78 * Saved instruction pointer as if we had returned from
85 * On restore as if procedure returned the value 1
92 movl $SIZEOF_MCONTEXT_T,MC_LEN(%eax)
102 * int set_mcontext(mcontext_t *mcp)
104 * Load the register context, effectively switching to the
108 .set set_mcontext,_set_mcontext
111 /* 0*4(%eax),mc_onstack */
123 /* mc_eax: 12*4(%eax) */
124 /* mc_xflags: 13*4(%eax) */
125 /* mc_trapno: 14*4(%eax) */
126 /* mc_err: 15*4(%eax) */
127 /* mc_eip: 16*4(%eax) */
128 /* mc_cs: 17*4(%eax) */
129 /* mc_eflags: 18*4(%eax) */
130 /* mc_esp: 19*4(%eax) */
133 * Load the new stack pointer
144 * Push the return pc so we can 'ret' to it.
149 * Load %eax last, and return.