swtch-v6.S (254454) | swtch-v6.S (254461) |
---|---|
1/* $NetBSD: cpuswitch.S,v 1.41 2003/11/15 08:44:18 scw Exp $ */ 2 3/*- 4 * Copyright 2003 Wasabi Systems, Inc. 5 * All rights reserved. 6 * 7 * Written by Steve C. Woodford for Wasabi Systems, Inc. 8 * --- 70 unchanged lines hidden (view full) --- 79 */ 80 81#include "assym.s" 82#include "opt_sched.h" 83 84#include <machine/asm.h> 85#include <machine/asmacros.h> 86#include <machine/armreg.h> | 1/* $NetBSD: cpuswitch.S,v 1.41 2003/11/15 08:44:18 scw Exp $ */ 2 3/*- 4 * Copyright 2003 Wasabi Systems, Inc. 5 * All rights reserved. 6 * 7 * Written by Steve C. Woodford for Wasabi Systems, Inc. 8 * --- 70 unchanged lines hidden (view full) --- 79 */ 80 81#include "assym.s" 82#include "opt_sched.h" 83 84#include <machine/asm.h> 85#include <machine/asmacros.h> 86#include <machine/armreg.h> |
87__FBSDID("$FreeBSD: head/sys/arm/arm/swtch.S 254454 2013-08-17 15:09:14Z andrew $"); | 87__FBSDID("$FreeBSD: head/sys/arm/arm/swtch.S 254461 2013-08-17 18:51:38Z andrew $"); |
88 89#define DOMAIN_CLIENT 0x01 90 91#ifdef _ARM_ARCH_6 92#define GET_PCPU(tmp) \ 93 mrc p15, 0, tmp, c13, c0, 4; 94#else 95.Lcurpcpu: --- 13 unchanged lines hidden (view full) --- 109 110 /* 111 * r0 = oldtd 112 * r5 = newtd 113 */ 114 115 GET_PCPU(r7) 116 | 88 89#define DOMAIN_CLIENT 0x01 90 91#ifdef _ARM_ARCH_6 92#define GET_PCPU(tmp) \ 93 mrc p15, 0, tmp, c13, c0, 4; 94#else 95.Lcurpcpu: --- 13 unchanged lines hidden (view full) --- 109 110 /* 111 * r0 = oldtd 112 * r5 = newtd 113 */ 114 115 GET_PCPU(r7) 116 |
117#ifdef ARM_VFP_SUPPORT | 117#ifdef VFP |
118 /* 119 * vfp_discard will clear pcpu->pc_vfpcthread, and modify 120 * and modify the control as needed. 121 */ 122 ldr r4, [r7, #(PC_VFPCTHREAD)] /* this thread using vfp? */ 123 cmp r0, r4 124 bne 3f 125 bl _C_LABEL(vfp_discard) /* yes, shut down vfp */ 1263: | 118 /* 119 * vfp_discard will clear pcpu->pc_vfpcthread, and modify 120 * and modify the control as needed. 121 */ 122 ldr r4, [r7, #(PC_VFPCTHREAD)] /* this thread using vfp? */ 123 cmp r0, r4 124 bne 3f 125 bl _C_LABEL(vfp_discard) /* yes, shut down vfp */ 1263: |
127#endif /* ARM_VFP_SUPPORT */ | 127#endif /* VFP */ |
128 129 ldr r7, [r5, #(TD_PCB)] /* r7 = new thread's PCB */ 130 131 /* Switch to lwp0 context */ 132 133 ldr r9, .Lcpufuncs 134#if !defined(CPU_ARM11) && !defined(CPU_CORTEXA) && !defined(CPU_MV_PJ4B) 135 mov lr, pc --- 162 unchanged lines hidden (view full) --- 298 299 str sp, [r2, #(PCB_UND_SP)] 300 301 msr cpsr_c, r3 /* Restore the old mode */ 302 /* rem: r2 = old PCB */ 303 /* rem: r9 = new PCB */ 304 /* rem: interrupts are enabled */ 305 | 128 129 ldr r7, [r5, #(TD_PCB)] /* r7 = new thread's PCB */ 130 131 /* Switch to lwp0 context */ 132 133 ldr r9, .Lcpufuncs 134#if !defined(CPU_ARM11) && !defined(CPU_CORTEXA) && !defined(CPU_MV_PJ4B) 135 mov lr, pc --- 162 unchanged lines hidden (view full) --- 298 299 str sp, [r2, #(PCB_UND_SP)] 300 301 msr cpsr_c, r3 /* Restore the old mode */ 302 /* rem: r2 = old PCB */ 303 /* rem: r9 = new PCB */ 304 /* rem: interrupts are enabled */ 305 |
306#ifdef ARM_VFP_SUPPORT | 306#ifdef VFP |
307 /* 308 * vfp_store will clear pcpu->pc_vfpcthread, save 309 * registers and state, and modify the control as needed. 310 * a future exception will bounce the backup settings in the fp unit. 311 * XXX vfp_store can't change r4 312 */ 313 GET_PCPU(r7) 314 ldr r8, [r7, #(PC_VFPCTHREAD)] --- 5 unchanged lines hidden (view full) --- 320 ldr r8, [r7, #(PC_CPU)] /* last used on this cpu? */ 321 ldr r3, [r2, #(PCB_VFPCPU)] 322 cmp r8, r3 /* last cpu to use these registers? */ 323 bne 1f /* no. these values are stale */ 324#endif 325 add r0, r2, #(PCB_VFPSTATE) 326 bl _C_LABEL(vfp_store) 3271: | 307 /* 308 * vfp_store will clear pcpu->pc_vfpcthread, save 309 * registers and state, and modify the control as needed. 310 * a future exception will bounce the backup settings in the fp unit. 311 * XXX vfp_store can't change r4 312 */ 313 GET_PCPU(r7) 314 ldr r8, [r7, #(PC_VFPCTHREAD)] --- 5 unchanged lines hidden (view full) --- 320 ldr r8, [r7, #(PC_CPU)] /* last used on this cpu? */ 321 ldr r3, [r2, #(PCB_VFPCPU)] 322 cmp r8, r3 /* last cpu to use these registers? */ 323 bne 1f /* no. these values are stale */ 324#endif 325 add r0, r2, #(PCB_VFPSTATE) 326 bl _C_LABEL(vfp_store) 3271: |
328#endif /* ARM_VFP_SUPPORT */ | 328#endif /* VFP */ |
329 330 /* r1 now free! */ 331 332 /* Third phase : restore saved context */ 333 334 /* rem: r2 = old PCB */ 335 /* rem: r9 = new PCB */ 336 /* rem: interrupts are enabled */ --- 163 unchanged lines hidden (view full) --- 500 stmfd sp!, {r4-r7, lr} 501 sub sp, sp, #4 502 /* 503 * r0 = pcb 504 */ 505 /* Store all the registers in the process's pcb */ 506 add r2, r0, #(PCB_R8) 507 stmia r2, {r8-r13} | 329 330 /* r1 now free! */ 331 332 /* Third phase : restore saved context */ 333 334 /* rem: r2 = old PCB */ 335 /* rem: r9 = new PCB */ 336 /* rem: interrupts are enabled */ --- 163 unchanged lines hidden (view full) --- 500 stmfd sp!, {r4-r7, lr} 501 sub sp, sp, #4 502 /* 503 * r0 = pcb 504 */ 505 /* Store all the registers in the process's pcb */ 506 add r2, r0, #(PCB_R8) 507 stmia r2, {r8-r13} |
508#ifdef ARM_VFP_SUPPORT | 508#ifdef VFP |
509 /* 510 * vfp_store will clear pcpu->pc_vfpcthread, save 511 * registers and state, and modify the control as needed. 512 * a future exception will bounce the backup settings in the fp unit. 513 */ 514 GET_PCPU(r7) 515 ldr r4, [r7, #(PC_VFPCTHREAD)] /* vfp thread */ 516 ldr r2, [r7, #(PC_CURTHREAD)] /* current thread */ 517 cmp r4, r2 518 bne 1f 519#ifdef SMP 520 ldr r2, [r7, #(PC_CPU)] /* last used on this cpu? */ 521 ldr r3, [r0, #(PCB_VFPCPU)] 522 cmp r2, r3 523 bne 1f /* no. these values are stale */ 524#endif 525 add r0, r0, #(PCB_VFPSTATE) 526 bl _C_LABEL(vfp_store) 5271: | 509 /* 510 * vfp_store will clear pcpu->pc_vfpcthread, save 511 * registers and state, and modify the control as needed. 512 * a future exception will bounce the backup settings in the fp unit. 513 */ 514 GET_PCPU(r7) 515 ldr r4, [r7, #(PC_VFPCTHREAD)] /* vfp thread */ 516 ldr r2, [r7, #(PC_CURTHREAD)] /* current thread */ 517 cmp r4, r2 518 bne 1f 519#ifdef SMP 520 ldr r2, [r7, #(PC_CPU)] /* last used on this cpu? */ 521 ldr r3, [r0, #(PCB_VFPCPU)] 522 cmp r2, r3 523 bne 1f /* no. these values are stale */ 524#endif 525 add r0, r0, #(PCB_VFPSTATE) 526 bl _C_LABEL(vfp_store) 5271: |
528#endif /* ARM_VFP_SUPPORT */ | 528#endif /* VFP */ |
529 add sp, sp, #4; 530 ldmfd sp!, {r4-r7, pc} 531END(savectx) 532 533ENTRY(fork_trampoline) 534 STOP_UNWINDING /* Can't unwind beyond the thread enty point */ 535 mov r1, r5 536 mov r2, sp --- 15 unchanged lines hidden --- | 529 add sp, sp, #4; 530 ldmfd sp!, {r4-r7, pc} 531END(savectx) 532 533ENTRY(fork_trampoline) 534 STOP_UNWINDING /* Can't unwind beyond the thread enty point */ 535 mov r1, r5 536 mov r2, sp --- 15 unchanged lines hidden --- |