Deleted Added
full compact
cpu_switch.S (115006) cpu_switch.S (122292)
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * $FreeBSD: head/sys/amd64/amd64/cpu_switch.S 115006 2003-05-15 00:23:40Z peter $
36 * $FreeBSD: head/sys/amd64/amd64/cpu_switch.S 122292 2003-11-08 03:33:38Z peter $
37 */
38
39#include <machine/asmacros.h>
40
41#include "assym.s"
42
43/*****************************************************************************/
44/* Scheduling */

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

126
127 /* have we used fp, and need a save? */
128 cmpq %rdi,PCPU(FPCURTHREAD)
129 jne 1f
130 pushq %rdi
131 pushq %rsi
132 addq $PCB_SAVEFPU,%r8 /* h/w bugs make saving complicated */
133 movq %r8, %rdi
37 */
38
39#include <machine/asmacros.h>
40
41#include "assym.s"
42
43/*****************************************************************************/
44/* Scheduling */

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

126
127 /* have we used fp, and need a save? */
128 cmpq %rdi,PCPU(FPCURTHREAD)
129 jne 1f
130 pushq %rdi
131 pushq %rsi
132 addq $PCB_SAVEFPU,%r8 /* h/w bugs make saving complicated */
133 movq %r8, %rdi
134 call npxsave /* do it in a big C function */
134 call fpusave /* do it in a big C function */
135 popq %rsi
136 popq %rdi
1371:
138
139 /* Save is done. Now fire up new thread. Leave old vmspace. */
140#ifdef INVARIANTS
141 testq %rsi,%rsi /* no thread? */
142 jz badsw3 /* no, panic */

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

296 movq %r12,PCB_R12(%rcx)
297 movq %r13,PCB_R13(%rcx)
298 movq %r14,PCB_R14(%rcx)
299 movq %r15,PCB_R15(%rcx)
300 pushfq
301 popq PCB_RFLAGS(%rcx)
302
303 /*
135 popq %rsi
136 popq %rdi
1371:
138
139 /* Save is done. Now fire up new thread. Leave old vmspace. */
140#ifdef INVARIANTS
141 testq %rsi,%rsi /* no thread? */
142 jz badsw3 /* no, panic */

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

296 movq %r12,PCB_R12(%rcx)
297 movq %r13,PCB_R13(%rcx)
298 movq %r14,PCB_R14(%rcx)
299 movq %r15,PCB_R15(%rcx)
300 pushfq
301 popq PCB_RFLAGS(%rcx)
302
303 /*
304 * If fpcurthread == NULL, then the npx h/w state is irrelevant and the
304 * If fpcurthread == NULL, then the fpu h/w state is irrelevant and the
305 * state had better already be in the pcb. This is true for forks
306 * but not for dumps (the old book-keeping with FP flags in the pcb
307 * always lost for dumps because the dump pcb has 0 flags).
308 *
305 * state had better already be in the pcb. This is true for forks
306 * but not for dumps (the old book-keeping with FP flags in the pcb
307 * always lost for dumps because the dump pcb has 0 flags).
308 *
309 * If fpcurthread != NULL, then we have to save the npx h/w state to
309 * If fpcurthread != NULL, then we have to save the fpu h/w state to
310 * fpcurthread's pcb and copy it to the requested pcb, or save to the
311 * requested pcb and reload. Copying is easier because we would
312 * have to handle h/w bugs for reloading. We used to lose the
310 * fpcurthread's pcb and copy it to the requested pcb, or save to the
311 * requested pcb and reload. Copying is easier because we would
312 * have to handle h/w bugs for reloading. We used to lose the
313 * parent's npx state for forks by forgetting to reload.
313 * parent's fpu state for forks by forgetting to reload.
314 */
315 pushfq
316 cli
317 movq PCPU(FPCURTHREAD),%rax
318 testq %rax,%rax
319 je 1f
320
321 pushq %rcx
322 pushq %rax
323 movq TD_PCB(%rax),%rdi
324 leaq PCB_SAVEFPU(%rdi),%rdi
314 */
315 pushfq
316 cli
317 movq PCPU(FPCURTHREAD),%rax
318 testq %rax,%rax
319 je 1f
320
321 pushq %rcx
322 pushq %rax
323 movq TD_PCB(%rax),%rdi
324 leaq PCB_SAVEFPU(%rdi),%rdi
325 call npxsave
325 call fpusave
326 popq %rax
327 popq %rcx
328
329 movq $PCB_SAVEFPU_SIZE,%rdx /* arg 3 */
330 leaq PCB_SAVEFPU(%rcx),%rsi /* arg 2 */
331 movq %rax,%rdi /* arg 1 */
332 call bcopy
3331:
334 popfq
335
336 ret
326 popq %rax
327 popq %rcx
328
329 movq $PCB_SAVEFPU_SIZE,%rdx /* arg 3 */
330 leaq PCB_SAVEFPU(%rcx),%rsi /* arg 2 */
331 movq %rax,%rdi /* arg 1 */
332 call bcopy
3331:
334 popfq
335
336 ret