X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Favr%2Fhw%2Fswitch_ctx_avr.S;h=db80e94355344349e346cebae01701aee65bc937;hb=f1fab319eb3fe91c157b3a9564841aef62a03554;hp=50280292ad7a2e90f73aabc4b8f557a380071bc2;hpb=71743c2a5a8bf9dbf66a945fd9656baed0d16329;p=bertos.git diff --git a/bertos/cpu/avr/hw/switch_ctx_avr.S b/bertos/cpu/avr/hw/switch_ctx_avr.S index 50280292..db80e943 100644 --- a/bertos/cpu/avr/hw/switch_ctx_avr.S +++ b/bertos/cpu/avr/hw/switch_ctx_avr.S @@ -30,7 +30,6 @@ * Copyright 1999, 2000, 2001 Bernie Innocenti * --> * - * \version $Id$ * \author Bernie Innocenti * \author Stefano Fedrigo * @@ -47,12 +46,9 @@ asm_switch_context: ; r0 is the TEMP REG and can be used freely. ; r1 is the ZERO REG and must always contain 0. ; -; Stack frame is 19 byte, remember to update +; Stack frame is 18 byte, remember to update ; CPU_SAVED_REGS_CNT if you change pushed regs. - in r0,SREG-__SFR_OFFSET - push r0 -; push r1 ;zero-reg push r2 push r3 push r4 @@ -69,20 +65,9 @@ asm_switch_context: push r15 push r16 push r17 -; push r18 ;caller-save -; push r19 ;caller-save -; push r20 ;caller-save -; push r21 ;caller-save -; push r22 ;caller-save -; push r23 ;caller-save -; push r24 ;caller-save -; push r25 ;caller-save -; push r26 ;caller-save -; push r27 ;caller-save + push r28 push r29 -; push r30 ;caller-save -; push r31 ;caller-save in r18,SPL-__SFR_OFFSET ; r18:r19 = SP in r19,SPH-__SFR_OFFSET @@ -93,6 +78,8 @@ asm_switch_context: ld r18,X+ ld r19,X +;FIXME: We probably need to safe the RAMP registers for some XMEGA devices / setups + ; Set new stack pointer. ; AVR is an 8 bit processor so ; care must be taken when updating @@ -100,25 +87,15 @@ asm_switch_context: ; Two instructions are required to update SP ; so an IRQ can sneak in between them. ; So IRQ *MUST* be disabled and then restored. + in r0, SREG-__SFR_OFFSET cli ; Disable interrupt out SPL-__SFR_OFFSET,r18 ; SP = *new_sp out SPH-__SFR_OFFSET,r19 out SREG-__SFR_OFFSET,r0 ; Restore previous IRQ state -; pop r31 ;caller-save -; pop r30 ;caller-save pop r29 pop r28 -; pop r27 ;caller-save -; pop r26 ;caller-save -; pop r25 ;caller-save -; pop r24 ;caller-save -; pop r23 ;caller-save -; pop r22 ;caller-save -; pop r21 ;caller-save -; pop r20 ;caller-save -; pop r19 ;caller-save -; pop r18 ;caller-save + pop r17 pop r16 pop r15 @@ -135,8 +112,5 @@ asm_switch_context: pop r4 pop r3 pop r2 -; pop r1 ;zero-reg - pop r0 - out SREG-__SFR_OFFSET,r0 ret