From: qwert Date: Tue, 17 Jun 2008 14:40:42 +0000 (+0000) Subject: Modified gen_mk_src script for asm file, moved asm .S file in relative cpu hw section X-Git-Tag: 2.0.0~460 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=0cbd71f97f523e15afe03bd400f44d1572e6bbf4;p=bertos.git Modified gen_mk_src script for asm file, moved asm .S file in relative cpu hw section git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1474 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cpu/arm/hw/switch_arm.S b/bertos/cpu/arm/hw/switch_arm.S new file mode 100644 index 00000000..531b18a5 --- /dev/null +++ b/bertos/cpu/arm/hw/switch_arm.S @@ -0,0 +1,67 @@ +/** + * \file + * + * + * \brief ARM context switch + * + * \version $Id: proc.c 18271 2007-10-11 14:51:31Z batt $ + * + * \author Stefano Fedrigo + * \author Francesco Sacchi + */ + + +/* + * NOTE: At each change of this function affecting proc.c + * (i.e. arguments, data stored in the stack) bump up version + * number in asm_switch_version(). + */ + +/* void asm_switch_context(void **new_sp, void **save_sp) */ +.globl asm_switch_context +asm_switch_context: + mrs r2, cpsr /* Save status. */ + stmfd sp!, {r2, r4-r11, lr} /* Save registers. */ + + str sp, [r1] /* Save old stack pointer. */ + ldr sp, [r0] /* Load new stack pointer */ + + ldmfd sp!, {r2, r4-r11, lr} /* Load new registers. */ + msr cpsr, r2 /* restore flags reg. */ + + mov pc, lr + + +/* int asm_switch_version(void) */ +.globl asm_switch_version +asm_switch_version: + mov r0, #1 + mov pc, lr diff --git a/bertos/cpu/avr/hw/switch_avr.S b/bertos/cpu/avr/hw/switch_avr.S new file mode 100644 index 00000000..93892919 --- /dev/null +++ b/bertos/cpu/avr/hw/switch_avr.S @@ -0,0 +1,135 @@ +/*! + * \file + * + * + * \brief AVR context switch + * + * \version $Id$ + * + * \author Bernardo Innocenti + * \author Stefano Fedrigo + */ + +#include + +/* + * NOTE: At each change of this function affecting proc.c + * (i.e. arguments, data stored in the stack) bump up version + * number in asm_switch_version(). + */ + +/* void asm_switch_context(void **new_sp, void **save_sp) */ +.globl asm_switch_context +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 +; 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 + push r5 + push r6 + push r7 + push r8 + push r9 + push r10 + push r11 + push r12 + push r13 + push r14 + 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 + +; First parameter (new_sp) is in r24:r25, second (save_sp) in r22:r23 + + in r18,SPL-__SFR_OFFSET ; r18:r19 = SP + in r19,SPH-__SFR_OFFSET + movw r26,r22 ; X = save_sp + st X+,r18 ; *save_sp = SP + st X,r19 + movw r26,r24 ; X = new_sp + ld r18,X+ + ld r19,X + +; Set new stack pointer. +; AVR is an 8 bit processor so +; care must be taken when updating +; SP that is a 16 bit reg. +; Two instructions are required to update SP +; so an IRQ can sneak in between them. +; So IRQ *MUST* be disabled and then restored. + 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 + pop r14 + pop r13 + pop r12 + pop r11 + pop r10 + pop r9 + pop r8 + pop r7 + pop r6 + pop r5 + pop r4 + pop r3 + pop r2 +; pop r1 ;zero-reg + pop r0 + out SREG-__SFR_OFFSET,r0 + + ret + + +/* int asm_switch_version(void) */ +.globl asm_switch_version +asm_switch_version: + ldi r24,lo8(1) + ldi r25,hi8(1) + ret + diff --git a/bertos/cpu/i196/hw/switch_i196.s32 b/bertos/cpu/i196/hw/switch_i196.s32 new file mode 100644 index 00000000..a2f3c70d --- /dev/null +++ b/bertos/cpu/i196/hw/switch_i196.s32 @@ -0,0 +1,92 @@ +;* Copyright 2004 Develer S.r.l. (http://www.develer.com/) +;* Copyright 1999,2000,2001 Bernardo Innocenti +;* This file is part of DevLib - See devlib/README for information. +;* +;* \version $Id$ +;* +;* \author Bernardo Innocenti +;* + +;* $Log$ +;* Revision 1.2 2004/06/06 16:14:12 bernie +;* Add DevLib license information. +;* +;* Revision 1.1 2004/05/23 17:27:00 bernie +;* Import kern/ subdirectory. +;* +;* + +!!!!!! THIS FILE HAS NOT BEEN REVISED FOR THE NEW SCHEDULER API !!!!!! + + + + NAME AsmSwitch + RSEG CODE + + EXTERN ?LR + EXTERN ?GR + PUBLIC AsmSwitchContext + PUBLIC AsmReplaceContext + + +;* Perform low-level process context switching +;* +;* void AsmSwitchContext(cpustack_t *new_sp, cpustack_t **save_sp) +;* GR+0 SP+2 +;* +;* Replace current context with new process +;* +;* void AsmReplaceContext(cpustack_t *new_sp, cpustack_t **dummy) +;* GR+0 SP+2 +;* + +AsmSwitchContext: + +; pop 2nd parameter from the stack + ld ?GR+2,2[SP] + +; save all registers + push ?LR+0 + push ?LR+2 + push ?LR+4 + push ?LR+6 + push ?LR+8 + push ?LR+10 + push ?LR+12 + push ?LR+14 + push ?LR+16 + push ?LR+18 + push ?LR+20 + push ?LR+22 + push ?LR+24 + push ?LR+26 + push ?LR+28 + push ?LR+30 + st SP,[?GR+2] ; save old stack pointer + ; fall-thru + +AsmReplaceContext: + ld SP,?GR+0 ; load new stack pointer + +; restore all registers + pop ?LR+30 + pop ?LR+28 + pop ?LR+26 + pop ?LR+24 + pop ?LR+22 + pop ?LR+20 + pop ?LR+18 + pop ?LR+16 + pop ?LR+14 + pop ?LR+12 + pop ?LR+10 + pop ?LR+8 + pop ?LR+6 + pop ?LR+4 + pop ?LR+2 + pop ?LR+0 + +; restore execution in new context + ret + + END diff --git a/bertos/kern/switch_arm.S b/bertos/kern/switch_arm.S deleted file mode 100644 index 531b18a5..00000000 --- a/bertos/kern/switch_arm.S +++ /dev/null @@ -1,67 +0,0 @@ -/** - * \file - * - * - * \brief ARM context switch - * - * \version $Id: proc.c 18271 2007-10-11 14:51:31Z batt $ - * - * \author Stefano Fedrigo - * \author Francesco Sacchi - */ - - -/* - * NOTE: At each change of this function affecting proc.c - * (i.e. arguments, data stored in the stack) bump up version - * number in asm_switch_version(). - */ - -/* void asm_switch_context(void **new_sp, void **save_sp) */ -.globl asm_switch_context -asm_switch_context: - mrs r2, cpsr /* Save status. */ - stmfd sp!, {r2, r4-r11, lr} /* Save registers. */ - - str sp, [r1] /* Save old stack pointer. */ - ldr sp, [r0] /* Load new stack pointer */ - - ldmfd sp!, {r2, r4-r11, lr} /* Load new registers. */ - msr cpsr, r2 /* restore flags reg. */ - - mov pc, lr - - -/* int asm_switch_version(void) */ -.globl asm_switch_version -asm_switch_version: - mov r0, #1 - mov pc, lr diff --git a/bertos/kern/switch_avr.S b/bertos/kern/switch_avr.S deleted file mode 100644 index 93892919..00000000 --- a/bertos/kern/switch_avr.S +++ /dev/null @@ -1,135 +0,0 @@ -/*! - * \file - * - * - * \brief AVR context switch - * - * \version $Id$ - * - * \author Bernardo Innocenti - * \author Stefano Fedrigo - */ - -#include - -/* - * NOTE: At each change of this function affecting proc.c - * (i.e. arguments, data stored in the stack) bump up version - * number in asm_switch_version(). - */ - -/* void asm_switch_context(void **new_sp, void **save_sp) */ -.globl asm_switch_context -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 -; 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 - push r5 - push r6 - push r7 - push r8 - push r9 - push r10 - push r11 - push r12 - push r13 - push r14 - 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 - -; First parameter (new_sp) is in r24:r25, second (save_sp) in r22:r23 - - in r18,SPL-__SFR_OFFSET ; r18:r19 = SP - in r19,SPH-__SFR_OFFSET - movw r26,r22 ; X = save_sp - st X+,r18 ; *save_sp = SP - st X,r19 - movw r26,r24 ; X = new_sp - ld r18,X+ - ld r19,X - -; Set new stack pointer. -; AVR is an 8 bit processor so -; care must be taken when updating -; SP that is a 16 bit reg. -; Two instructions are required to update SP -; so an IRQ can sneak in between them. -; So IRQ *MUST* be disabled and then restored. - 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 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - pop r9 - pop r8 - pop r7 - pop r6 - pop r5 - pop r4 - pop r3 - pop r2 -; pop r1 ;zero-reg - pop r0 - out SREG-__SFR_OFFSET,r0 - - ret - - -/* int asm_switch_version(void) */ -.globl asm_switch_version -asm_switch_version: - ldi r24,lo8(1) - ldi r25,hi8(1) - ret - diff --git a/bertos/kern/switch_i196.s32 b/bertos/kern/switch_i196.s32 deleted file mode 100644 index a2f3c70d..00000000 --- a/bertos/kern/switch_i196.s32 +++ /dev/null @@ -1,92 +0,0 @@ -;* Copyright 2004 Develer S.r.l. (http://www.develer.com/) -;* Copyright 1999,2000,2001 Bernardo Innocenti -;* This file is part of DevLib - See devlib/README for information. -;* -;* \version $Id$ -;* -;* \author Bernardo Innocenti -;* - -;* $Log$ -;* Revision 1.2 2004/06/06 16:14:12 bernie -;* Add DevLib license information. -;* -;* Revision 1.1 2004/05/23 17:27:00 bernie -;* Import kern/ subdirectory. -;* -;* - -!!!!!! THIS FILE HAS NOT BEEN REVISED FOR THE NEW SCHEDULER API !!!!!! - - - - NAME AsmSwitch - RSEG CODE - - EXTERN ?LR - EXTERN ?GR - PUBLIC AsmSwitchContext - PUBLIC AsmReplaceContext - - -;* Perform low-level process context switching -;* -;* void AsmSwitchContext(cpustack_t *new_sp, cpustack_t **save_sp) -;* GR+0 SP+2 -;* -;* Replace current context with new process -;* -;* void AsmReplaceContext(cpustack_t *new_sp, cpustack_t **dummy) -;* GR+0 SP+2 -;* - -AsmSwitchContext: - -; pop 2nd parameter from the stack - ld ?GR+2,2[SP] - -; save all registers - push ?LR+0 - push ?LR+2 - push ?LR+4 - push ?LR+6 - push ?LR+8 - push ?LR+10 - push ?LR+12 - push ?LR+14 - push ?LR+16 - push ?LR+18 - push ?LR+20 - push ?LR+22 - push ?LR+24 - push ?LR+26 - push ?LR+28 - push ?LR+30 - st SP,[?GR+2] ; save old stack pointer - ; fall-thru - -AsmReplaceContext: - ld SP,?GR+0 ; load new stack pointer - -; restore all registers - pop ?LR+30 - pop ?LR+28 - pop ?LR+26 - pop ?LR+24 - pop ?LR+22 - pop ?LR+20 - pop ?LR+18 - pop ?LR+16 - pop ?LR+14 - pop ?LR+12 - pop ?LR+10 - pop ?LR+8 - pop ?LR+6 - pop ?LR+4 - pop ?LR+2 - pop ?LR+0 - -; restore execution in new context - ret - - END diff --git a/test/gen_mk_src.sh b/test/gen_mk_src.sh index 37a5f2bc..c2733dc9 100755 --- a/test/gen_mk_src.sh +++ b/test/gen_mk_src.sh @@ -52,8 +52,8 @@ fi #Get list of source for selected cpu target CSRC=`${TEST_SCRIPT_DIR}/get_source_list.sh $1 c` -#ASRC=`${TEST_SCRIPT_DIR}/get_source_list.sh $1 s` -ASRC= +ASRC=`${TEST_SCRIPT_DIR}/get_source_list.sh $1 S` +#ASRC= #Source to skip: