swtch32.S (214739) | swtch32.S (223485) |
---|---|
1/* $FreeBSD: head/sys/powerpc/aim/swtch32.S 214739 2010-11-03 15:15:48Z nwhitehorn $ */ | 1/* $FreeBSD: head/sys/powerpc/aim/swtch32.S 223485 2011-06-23 22:21:28Z nwhitehorn $ */ |
2/* $NetBSD: locore.S,v 1.24 2000/05/31 05:09:17 thorpej Exp $ */ 3 4/*- 5 * Copyright (C) 2001 Benno Rice 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 54 unchanged lines hidden (view full) --- 64#include <machine/trap.h> 65#include <machine/param.h> 66#include <machine/asm.h> 67 68/* 69 * void cpu_throw(struct thread *old, struct thread *new) 70 */ 71ENTRY(cpu_throw) | 2/* $NetBSD: locore.S,v 1.24 2000/05/31 05:09:17 thorpej Exp $ */ 3 4/*- 5 * Copyright (C) 2001 Benno Rice 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 54 unchanged lines hidden (view full) --- 64#include <machine/trap.h> 65#include <machine/param.h> 66#include <machine/asm.h> 67 68/* 69 * void cpu_throw(struct thread *old, struct thread *new) 70 */ 71ENTRY(cpu_throw) |
72 mr %r15, %r4 | 72 mr %r2, %r4 |
73 b cpu_switchin 74 75/* 76 * void cpu_switch(struct thread *old, 77 * struct thread *new, 78 * struct mutex *mtx); 79 * 80 * Switch to a new thread saving the current state in the old thread. 81 */ 82ENTRY(cpu_switch) 83 lwz %r6,TD_PCB(%r3) /* Get the old thread's PCB ptr */ 84 stmw %r12,PCB_CONTEXT(%r6) /* Save the non-volatile GP regs. 85 These can now be used for scratch */ 86 87 mfcr %r16 /* Save the condition register */ 88 stw %r16,PCB_CR(%r6) 89 mflr %r16 /* Save the link register */ 90 stw %r16,PCB_LR(%r6) 91 stw %r1,PCB_SP(%r6) /* Save the stack pointer */ | 73 b cpu_switchin 74 75/* 76 * void cpu_switch(struct thread *old, 77 * struct thread *new, 78 * struct mutex *mtx); 79 * 80 * Switch to a new thread saving the current state in the old thread. 81 */ 82ENTRY(cpu_switch) 83 lwz %r6,TD_PCB(%r3) /* Get the old thread's PCB ptr */ 84 stmw %r12,PCB_CONTEXT(%r6) /* Save the non-volatile GP regs. 85 These can now be used for scratch */ 86 87 mfcr %r16 /* Save the condition register */ 88 stw %r16,PCB_CR(%r6) 89 mflr %r16 /* Save the link register */ 90 stw %r16,PCB_LR(%r6) 91 stw %r1,PCB_SP(%r6) /* Save the stack pointer */ |
92 stw %r2,PCB_TOC(%r6) /* Save the TOC pointer */ | |
93 94 mr %r14,%r3 /* Copy the old thread ptr... */ | 92 93 mr %r14,%r3 /* Copy the old thread ptr... */ |
95 mr %r15,%r4 /* and the new thread ptr in scratch */ | 94 mr %r2,%r4 /* and the new thread ptr in curthread */ |
96 mr %r16,%r5 /* and the new lock */ 97 mr %r17,%r6 /* and the PCB */ 98 99 lwz %r7,PCB_FLAGS(%r17) 100 /* Save FPU context if needed */ 101 andi. %r7, %r7, PCB_FPU 102 beq .L1 103 bl save_fpu --- 13 unchanged lines hidden (view full) --- 117 stw %r16,TD_LOCK(%r14) /* ULE: update old thread's lock */ 118 119cpu_switchin: 120#if defined(SMP) && defined(SCHED_ULE) 121 /* Wait for the new thread to become unblocked */ 122 lis %r6,blocked_lock@ha 123 addi %r6,%r6,blocked_lock@l 124blocked_loop: | 95 mr %r16,%r5 /* and the new lock */ 96 mr %r17,%r6 /* and the PCB */ 97 98 lwz %r7,PCB_FLAGS(%r17) 99 /* Save FPU context if needed */ 100 andi. %r7, %r7, PCB_FPU 101 beq .L1 102 bl save_fpu --- 13 unchanged lines hidden (view full) --- 116 stw %r16,TD_LOCK(%r14) /* ULE: update old thread's lock */ 117 118cpu_switchin: 119#if defined(SMP) && defined(SCHED_ULE) 120 /* Wait for the new thread to become unblocked */ 121 lis %r6,blocked_lock@ha 122 addi %r6,%r6,blocked_lock@l 123blocked_loop: |
125 lwz %r7,TD_LOCK(%r15) | 124 lwz %r7,TD_LOCK(%r2) |
126 cmpw %r6,%r7 127 beq blocked_loop 128#endif 129 130 mfsprg %r7,0 /* Get the pcpu pointer */ | 125 cmpw %r6,%r7 126 beq blocked_loop 127#endif 128 129 mfsprg %r7,0 /* Get the pcpu pointer */ |
131 stw %r15,PC_CURTHREAD(%r7) /* Store new current thread */ 132 lwz %r17,TD_PCB(%r15) /* Store new current PCB */ | 130 stw %r2,PC_CURTHREAD(%r7) /* Store new current thread */ 131 lwz %r17,TD_PCB(%r2) /* Store new current PCB */ |
133 stw %r17,PC_CURPCB(%r7) 134 | 132 stw %r17,PC_CURPCB(%r7) 133 |
135 mr %r3,%r15 /* Get new thread ptr */ | 134 mr %r3,%r2 /* Get new thread ptr */ |
136 bl pmap_activate /* Activate the new address space */ 137 138 lwz %r6, PCB_FLAGS(%r17) 139 /* Restore FPU context if needed */ 140 andi. %r6, %r6, PCB_FPU 141 beq .L3 | 135 bl pmap_activate /* Activate the new address space */ 136 137 lwz %r6, PCB_FLAGS(%r17) 138 /* Restore FPU context if needed */ 139 andi. %r6, %r6, PCB_FPU 140 beq .L3 |
142 mr %r3,%r15 /* Pass curthread to enable_fpu */ | 141 mr %r3,%r2 /* Pass curthread to enable_fpu */ |
143 bl enable_fpu 144 145.L3: 146 lwz %r6, PCB_FLAGS(%r17) 147 /* Restore Altivec context if needed */ 148 andi. %r6, %r6, PCB_VEC 149 beq .L4 | 142 bl enable_fpu 143 144.L3: 145 lwz %r6, PCB_FLAGS(%r17) 146 /* Restore Altivec context if needed */ 147 andi. %r6, %r6, PCB_VEC 148 beq .L4 |
150 mr %r3,%r15 /* Pass curthread to enable_vec */ | 149 mr %r3,%r2 /* Pass curthread to enable_vec */ |
151 bl enable_vec 152 153 /* thread to restore is in r3 */ 154.L4: 155 mr %r3,%r17 /* Recover PCB ptr */ 156 lmw %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs */ 157 lwz %r5,PCB_CR(%r3) /* Load the condition register */ 158 mtcr %r5 159 lwz %r5,PCB_LR(%r3) /* Load the link register */ 160 mtlr %r5 161 lwz %r5,PCB_AIM_USR_VSID(%r3) /* Load the USER_SR segment reg */ 162 isync 163 mtsr USER_SR,%r5 164 isync 165 lwz %r1,PCB_SP(%r3) /* Load the stack pointer */ | 150 bl enable_vec 151 152 /* thread to restore is in r3 */ 153.L4: 154 mr %r3,%r17 /* Recover PCB ptr */ 155 lmw %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs */ 156 lwz %r5,PCB_CR(%r3) /* Load the condition register */ 157 mtcr %r5 158 lwz %r5,PCB_LR(%r3) /* Load the link register */ 159 mtlr %r5 160 lwz %r5,PCB_AIM_USR_VSID(%r3) /* Load the USER_SR segment reg */ 161 isync 162 mtsr USER_SR,%r5 163 isync 164 lwz %r1,PCB_SP(%r3) /* Load the stack pointer */ |
166 lwz %r2,PCB_TOC(%r3) /* Load the TOC pointer */ | |
167 /* 168 * Perform a dummy stwcx. to clear any reservations we may have 169 * inherited from the previous thread. It doesn't matter if the 170 * stwcx succeeds or not. pcb_context[0] can be clobbered. 171 */ 172 stwcx. %r1, 0, %r3 173 blr 174 --- 24 unchanged lines hidden --- | 165 /* 166 * Perform a dummy stwcx. to clear any reservations we may have 167 * inherited from the previous thread. It doesn't matter if the 168 * stwcx succeeds or not. pcb_context[0] can be clobbered. 169 */ 170 stwcx. %r1, 0, %r3 171 blr 172 --- 24 unchanged lines hidden --- |