Deleted Added
full compact
swtch.s (210617) swtch.s (235622)
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

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

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
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

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

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * $FreeBSD: head/sys/i386/i386/swtch.s 210617 2010-07-29 17:00:41Z jkim $
32 * $FreeBSD: head/sys/i386/i386/swtch.s 235622 2012-05-18 18:55:58Z iwasaki $
33 */
34
35#include "opt_npx.h"
36#include "opt_sched.h"
37
38#include <machine/asmacros.h>
39
40#include "assym.s"

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

422 call bcopy
423 addl $12,%esp
4241:
425 popfl
426#endif /* DEV_NPX */
427
428 ret
429END(savectx)
33 */
34
35#include "opt_npx.h"
36#include "opt_sched.h"
37
38#include <machine/asmacros.h>
39
40#include "assym.s"

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

422 call bcopy
423 addl $12,%esp
4241:
425 popfl
426#endif /* DEV_NPX */
427
428 ret
429END(savectx)
430
431/*
432 * suspendctx(pcb)
433 * Update pcb, suspending current processor state.
434 */
435ENTRY(suspendctx)
436 /* Fetch PCB. */
437 movl 4(%esp),%ecx
438
439 /* Save context by calling savectx(). */
440 pushl %ecx
441 call savectx
442 addl $4,%esp
443
444 /* Fetch PCB again. */
445 movl 4(%esp),%ecx
446
447 /* Update caller's return address and stack pointer. */
448 movl (%esp),%eax
449 movl %eax,PCB_EIP(%ecx)
450 movl %esp,PCB_ESP(%ecx)
451
452 /* Save other registers and descriptor tables. */
453 movl %cr0,%eax
454 movl %eax,PCB_CR0(%ecx)
455 movl %cr2,%eax
456 movl %eax,PCB_CR2(%ecx)
457 movl %cr4,%eax
458 movl %eax,PCB_CR4(%ecx)
459
460 movl %dr0,%eax
461 movl %eax,PCB_DR0(%ecx)
462 movl %dr1,%eax
463 movl %eax,PCB_DR1(%ecx)
464 movl %dr2,%eax
465 movl %eax,PCB_DR2(%ecx)
466 movl %dr3,%eax
467 movl %eax,PCB_DR3(%ecx)
468 movl %dr6,%eax
469 movl %eax,PCB_DR6(%ecx)
470 movl %dr7,%eax
471 movl %eax,PCB_DR7(%ecx)
472
473 mov %ds,PCB_DS(%ecx)
474 mov %es,PCB_ES(%ecx)
475 mov %fs,PCB_FS(%ecx)
476 mov %ss,PCB_SS(%ecx)
477
478 sgdt PCB_GDT(%ecx)
479 sidt PCB_IDT(%ecx)
480 sldt PCB_LDT(%ecx)
481 str PCB_TR(%ecx)
482
483 movl $1,%eax
484 ret
485END(suspendctx)
486
487/*
488 * resumectx(pcb in %esi)
489 * Resuming processor state from pcb.
490 */
491ENTRY(resumectx)
492 /* Fetch PCB. */
493 movl %esi,%ecx
494
495 /* Restore GDT. */
496 lgdt PCB_GDT(%ecx)
497
498 /* Restore segment registers */
499 movzwl PCB_DS(%ecx),%eax
500 mov %ax,%ds
501 movzwl PCB_ES(%ecx),%eax
502 mov %ax,%es
503 movzwl PCB_FS(%ecx),%eax
504 mov %ax,%fs
505 movzwl PCB_GS(%ecx),%eax
506 movw %ax,%gs
507 movzwl PCB_SS(%ecx),%eax
508 mov %ax,%ss
509
510 /* Restore CR2, CR4, CR3 and CR0 */
511 movl PCB_CR2(%ecx),%eax
512 movl %eax,%cr2
513 movl PCB_CR4(%ecx),%eax
514 movl %eax,%cr4
515 movl PCB_CR3(%ecx),%eax
516 movl %eax,%cr3
517 movl PCB_CR0(%ecx),%eax
518 movl %eax,%cr0
519 jmp 1f
5201:
521
522 /* Restore descriptor tables */
523 lidt PCB_IDT(%ecx)
524 lldt PCB_LDT(%ecx)
525
526#define SDT_SYS386TSS 9
527#define SDT_SYS386BSY 11
528 /* Clear "task busy" bit and reload TR */
529 movl PCPU(TSS_GDT),%eax
530 andb $(~SDT_SYS386BSY | SDT_SYS386TSS),5(%eax)
531 movzwl PCB_TR(%ecx),%eax
532 ltr %ax
533#undef SDT_SYS386TSS
534#undef SDT_SYS386BSY
535
536 /* Restore debug registers */
537 movl PCB_DR0(%ecx),%eax
538 movl %eax,%dr0
539 movl PCB_DR1(%ecx),%eax
540 movl %eax,%dr1
541 movl PCB_DR2(%ecx),%eax
542 movl %eax,%dr2
543 movl PCB_DR3(%ecx),%eax
544 movl %eax,%dr3
545 movl PCB_DR6(%ecx),%eax
546 movl %eax,%dr6
547 movl PCB_DR7(%ecx),%eax
548 movl %eax,%dr7
549
550#ifdef DEV_NPX
551 /* XXX FIX ME */
552#endif
553
554 /* Restore other registers */
555 movl PCB_EDI(%ecx),%edi
556 movl PCB_ESI(%ecx),%esi
557 movl PCB_EBP(%ecx),%ebp
558 movl PCB_ESP(%ecx),%esp
559 movl PCB_EBX(%ecx),%ebx
560
561 /* reload code selector by turning return into intersegmental return */
562 pushl PCB_EIP(%ecx)
563 movl $KCSEL,4(%esp)
564 xorl %eax,%eax
565 lret
566END(resumectx)