cpu_switch.S (570dbb53e0e7d5fa1a0dcc6b96757ca846f81574) | cpu_switch.S (48a09cf2760da35e089ae3e2d56578b730fc7047) |
---|---|
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 * $Id: swtch.s,v 1.5 1997/08/04 17:17:29 smp Exp smp $ | 36 * $Id: swtch.s,v 1.58 1997/08/04 17:31:43 fsmp Exp $ |
37 */ 38 39#include "npx.h" 40#include "opt_user_ldt.h" 41 42#include <sys/rtprio.h> 43 44#include <machine/asmacros.h> --- 207 unchanged lines hidden (view full) --- 252 jnz badsw3 253#endif /* SMP && DIAGNOSTIC */ 254 xorl %ebp,%ebp 255 movl $HIDENAME(tmpstk),%esp 256 movl _IdlePTD,%ecx 257 movl %ecx,%cr3 258 259 /* update common_tss.tss_esp0 pointer */ | 37 */ 38 39#include "npx.h" 40#include "opt_user_ldt.h" 41 42#include <sys/rtprio.h> 43 44#include <machine/asmacros.h> --- 207 unchanged lines hidden (view full) --- 252 jnz badsw3 253#endif /* SMP && DIAGNOSTIC */ 254 xorl %ebp,%ebp 255 movl $HIDENAME(tmpstk),%esp 256 movl _IdlePTD,%ecx 257 movl %ecx,%cr3 258 259 /* update common_tss.tss_esp0 pointer */ |
260#ifdef VM86 261 movl $GPROC0_SEL, %esi 262#endif /* VM86 */ |
|
260 movl $_common_tss, %eax 261 movl %esp, TSS_ESP0(%eax) 262 | 263 movl $_common_tss, %eax 264 movl %esp, TSS_ESP0(%eax) 265 |
263#ifdef TSS_IS_CACHED /* example only */ 264 /* Reload task register to force reload of selector */ 265 movl _tssptr, %ebx 266 andb $~0x02, 5(%ebx) /* Flip 386BSY -> 386TSS */ 267 movl _gsel_tss, %ebx 268 ltr %bx 269#endif | 266#ifdef VM86 267 btrl %esi, _private_tss 268 je 1f 269 movl $_common_tssd, %edi |
270 | 270 |
271 /* move correct tss descriptor into GDT slot, then reload tr */ 272 leal _gdt(,%esi,8), %ebx /* entry in GDT */ 273 movl 0(%edi), %eax 274 movl %eax, 0(%ebx) 275 movl 4(%edi), %eax 276 movl %eax, 4(%ebx) 277 shll $3, %esi /* GSEL(entry, SEL_KPL) */ 278 ltr %si 2791: 280#endif /* VM86 */ 281 |
|
271 sti 272 273 /* 274 * XXX callers of cpu_switch() do a bogus splclock(). Locking should 275 * be left to cpu_switch(). 276 */ 277 call _spl0 278 --- 188 unchanged lines hidden (view full) --- 467 * Dereferencing proc->vm_map->pmap->p_pdir[] is painful in asm. 468 */ 469 movl %eax, 4*MPPTDI(%esi) /* restore cpu's prv page */ 470 471 /* XXX: we have just changed the page tables.. reload.. */ 472 movl %ebx, %cr3 473#endif /* SMP */ 474 | 282 sti 283 284 /* 285 * XXX callers of cpu_switch() do a bogus splclock(). Locking should 286 * be left to cpu_switch(). 287 */ 288 call _spl0 289 --- 188 unchanged lines hidden (view full) --- 478 * Dereferencing proc->vm_map->pmap->p_pdir[] is painful in asm. 479 */ 480 movl %eax, 4*MPPTDI(%esi) /* restore cpu's prv page */ 481 482 /* XXX: we have just changed the page tables.. reload.. */ 483 movl %ebx, %cr3 484#endif /* SMP */ 485 |
475#ifdef HOW_TO_SWITCH_TSS /* example only */ 476 /* Fix up tss pointer to floating pcb/stack structure */ 477 /* XXX probably lots faster to store the 64 bits of tss entry 478 * in the pcb somewhere and copy them on activation. 479 */ 480 movl _tssptr, %ebx 481 movl %edx, %eax /* edx = pcb/tss */ 482 movw %ax, 2(%ebx) /* store bits 0->15 */ 483 roll $16, %eax /* swap upper and lower */ 484 movb %al, 4(%ebx) /* store bits 16->23 */ 485 movb %ah, 7(%ebx) /* store bits 24->31 */ 486 andb $~0x02, 5(%ebx) /* Flip 386BSY -> 386TSS */ | 486#ifdef VM86 487 movl $GPROC0_SEL, %esi 488 cmpl $0, PCB_EXT(%edx) /* has pcb extension? */ 489 je 1f 490 btsl %esi, _private_tss /* mark use of private tss */ 491 movl PCB_EXT(%edx), %edi /* new tss descriptor */ 492 jmp 2f 4931: |
487#endif 488 489 /* update common_tss.tss_esp0 pointer */ 490 movl $_common_tss, %eax 491 movl %edx, %ebx /* pcb */ | 494#endif 495 496 /* update common_tss.tss_esp0 pointer */ 497 movl $_common_tss, %eax 498 movl %edx, %ebx /* pcb */ |
499#ifdef VM86 500 addl $(UPAGES * PAGE_SIZE - 16), %ebx 501#else |
|
492 addl $(UPAGES * PAGE_SIZE), %ebx | 502 addl $(UPAGES * PAGE_SIZE), %ebx |
503#endif /* VM86 */ |
|
493 movl %ebx, TSS_ESP0(%eax) 494 | 504 movl %ebx, TSS_ESP0(%eax) 505 |
495#ifdef TSS_IS_CACHED /* example only */ 496 /* Reload task register to force reload of selector */ 497 movl _tssptr, %ebx 498 andb $~0x02, 5(%ebx) /* Flip 386BSY -> 386TSS */ 499 movl _gsel_tss, %ebx 500 ltr %bx 501#endif | 506#ifdef VM86 507 btrl %esi, _private_tss 508 je 3f 509 movl $_common_tssd, %edi 5102: 511 /* move correct tss descriptor into GDT slot, then reload tr */ 512 leal _gdt(,%esi,8), %ebx /* entry in GDT */ 513 movl 0(%edi), %eax 514 movl %eax, 0(%ebx) 515 movl 4(%edi), %eax 516 movl %eax, 4(%ebx) 517 shll $3, %esi /* GSEL(entry, SEL_KPL) */ 518 ltr %si 5193: 520#endif /* VM86 */ |
502 503 /* restore context */ 504 movl PCB_EBX(%edx),%ebx 505 movl PCB_ESP(%edx),%esp 506 movl PCB_EBP(%edx),%ebp 507 movl PCB_ESI(%edx),%esi 508 movl PCB_EDI(%edx),%edi 509 movl PCB_EIP(%edx),%eax --- 138 unchanged lines hidden --- | 521 522 /* restore context */ 523 movl PCB_EBX(%edx),%ebx 524 movl PCB_ESP(%edx),%esp 525 movl PCB_EBP(%edx),%ebp 526 movl PCB_ESI(%edx),%esi 527 movl PCB_EDI(%edx),%edi 528 movl PCB_EIP(%edx),%eax --- 138 unchanged lines hidden --- |