Deleted Added
full compact
context.S (132928) context.S (155990)
1/*
2 * Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <machine/asm.h>
1/*
2 * Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <machine/asm.h>
28__FBSDID("$FreeBSD: head/lib/libkse/arch/amd64/amd64/context.S 132928 2004-07-31 14:18:26Z davidxu $");
28__FBSDID("$FreeBSD: head/lib/libkse/arch/amd64/amd64/context.S 155990 2006-02-24 22:03:10Z deischen $");
29
30/*
31 * The following notes ("cheat sheet") was provided by Peter Wemm.
32 *
33 * scratch:
34 * rax (1st return)
35 * rcx (4th arg)
36 * rdx (3rd arg, 2nd return)

--- 120 unchanged lines hidden (view full) ---

157
158/*
159 * _amd64_ctx_restore(mcontext_t *mcp, intptr_t val, intptr_t *loc);
160 */
161ENTRY(_amd64_restore_context)
162 cmpq $0, %rdi /* check for null pointer */
163 jne 1f
164 movq $-1, %rax
29
30/*
31 * The following notes ("cheat sheet") was provided by Peter Wemm.
32 *
33 * scratch:
34 * rax (1st return)
35 * rcx (4th arg)
36 * rdx (3rd arg, 2nd return)

--- 120 unchanged lines hidden (view full) ---

157
158/*
159 * _amd64_ctx_restore(mcontext_t *mcp, intptr_t val, intptr_t *loc);
160 */
161ENTRY(_amd64_restore_context)
162 cmpq $0, %rdi /* check for null pointer */
163 jne 1f
164 movq $-1, %rax
165 jmp 7f
165 jmp 2f
1661: cmpq $MC_SIZE, MC_LEN_OFFSET(%rdi) /* is context valid? */
167 je 2f
168 movq $-1, %rax /* bzzzt, invalid context */
1661: cmpq $MC_SIZE, MC_LEN_OFFSET(%rdi) /* is context valid? */
167 je 2f
168 movq $-1, %rax /* bzzzt, invalid context */
169 jmp 7f
169 ret
1702: movq MC_RCX(%rdi), %rcx
171 movq MC_R8(%rdi), %r8
172 movq MC_R9(%rdi), %r9
173 movq MC_RBX(%rdi), %rbx
174 movq MC_RBP(%rdi), %rbp
175 movq MC_R10(%rdi), %r10
176 movq MC_R11(%rdi), %r11
177 movq MC_R12(%rdi), %r12

--- 30 unchanged lines hidden (view full) ---

208 /* At this point we're done with the context. */
209 cmpq $0, %rdx /* set *loc to val */
210 je 6f
211 movq %rsi, (%rdx)
2126: popfq /* restore flags */
213 popq %rsi /* restore rsi, rdx, and rdi */
214 popq %rdx
215 popq %rdi
1702: movq MC_RCX(%rdi), %rcx
171 movq MC_R8(%rdi), %r8
172 movq MC_R9(%rdi), %r9
173 movq MC_RBX(%rdi), %rbx
174 movq MC_RBP(%rdi), %rbp
175 movq MC_R10(%rdi), %r10
176 movq MC_R11(%rdi), %r11
177 movq MC_R12(%rdi), %r12

--- 30 unchanged lines hidden (view full) ---

208 /* At this point we're done with the context. */
209 cmpq $0, %rdx /* set *loc to val */
210 je 6f
211 movq %rsi, (%rdx)
2126: popfq /* restore flags */
213 popq %rsi /* restore rsi, rdx, and rdi */
214 popq %rdx
215 popq %rdi
216 leaq (8 + REDZONE)(%rsp), %rsp
217 jmp *-(8 + REDZONE)(%rsp) /* jump to return address */
2187: ret
216 ret $REDZONE
217