diff --git a/arch/arm/src/cortexm3/up_switchcontext.S b/arch/arm/src/cortexm3/up_switchcontext.S index c85cf5d77e..2823d325a3 100755 --- a/arch/arm/src/cortexm3/up_switchcontext.S +++ b/arch/arm/src/cortexm3/up_switchcontext.S @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/cortexm3/up_switchcontext.S * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -51,7 +51,7 @@ .syntax unified .thumb - .file "up_context.S" + .file "up_switchcontext.S" /************************************************************************************ * Macros diff --git a/arch/avr/src/at91uc3/Make.defs b/arch/avr/src/at91uc3/Make.defs index a3369a606e..4318ccf386 100755 --- a/arch/avr/src/at91uc3/Make.defs +++ b/arch/avr/src/at91uc3/Make.defs @@ -39,7 +39,7 @@ HEAD_ASRC = up_nommuhead.S # Common AVR/AVR32 files -CMN_ASRCS = up_exceptions.S up_fullcontextrestore.S +CMN_ASRCS = up_exceptions.S up_fullcontextrestore.S up_switchcontext.S CMN_CSRCS = up_assert.c up_allocateheap.c up_blocktask.c up_copystate.c \ up_createstack.c up_mdelay.c up_udelay.c up_exit.c up_idle.c \ up_initialize.c up_initialstate.c up_interruptcontext.c \ diff --git a/arch/avr/src/at91uc3/at91uc3_irq.c b/arch/avr/src/at91uc3/at91uc3_irq.c index d354bbe47a..7f38f44744 100644 --- a/arch/avr/src/at91uc3/at91uc3_irq.c +++ b/arch/avr/src/at91uc3/at91uc3_irq.c @@ -292,7 +292,7 @@ int up_prioritize_irq(int irq, int priority) * ****************************************************************************/ #warning "Is this safe to call from assembly?" -unsigned int avr32_int0irqno(unsigned int level) +unsigned int avr32_intirqno(unsigned int level) { /* Get the group that caused the interrupt: "ICRn identifies the group with * the highest priority that has a pending interrupt of level n. This value diff --git a/arch/avr/src/avr32/up_exceptions.S b/arch/avr/src/avr32/up_exceptions.S index 5e5afd60d1..3dbb7d68ce 100755 --- a/arch/avr/src/avr32/up_exceptions.S +++ b/arch/avr/src/avr32/up_exceptions.S @@ -44,11 +44,12 @@ * External Symbols ****************************************************************************/ - .global avr32_int0irqno /* Returns the IRQ number of an INT0 interrupt */ - .global avr32_int1irqno /* Returns the IRQ number of an INT1 interrupt */ - .global avr32_int2irqno /* Returns the IRQ number of an INT2 interrupt */ - .global avr32_int3irqno /* Returns the IRQ number of an INT3 interrupt */ - .global up_doirq /* Dispatch an IRQ */ + .global avr32_int0irqno /* Returns the IRQ number of an INT0 interrupt */ + .global avr32_int1irqno /* Returns the IRQ number of an INT1 interrupt */ + .global avr32_int2irqno /* Returns the IRQ number of an INT2 interrupt */ + .global avr32_int3irqno /* Returns the IRQ number of an INT3 interrupt */ + .global up_doirq /* Dispatch an IRQ */ + .global up_fullcontextrestore /* Restore new task contex */ /**************************************************************************** * Macros @@ -219,6 +220,16 @@ avr32_excptcommon: /* and call the IRQ dispatching logic. */ avr32_common: + /* Disable interrupts in the current SR. This is necessary because the */ + /* AVR32 permits nested interrupts (if they are of higher priority). */ + /* We can support nested interrupts without some effort because: */ + /* - The global variable current_regs permits only one interrupt, */ + /* - If CONFIG_ARCH_INTERRUPTSTACK is defined, then there is a single */ + /* interrupt stack, and */ + /* - Probably other things. */ + + ssrf AVR32_SR_GM_SHIFT + /* Save the SP (as it was before the interrupt) in the conext save */ /* structure. */ /* xx xx xx xx xx xx xx xx SP SR PC LR 12 11 10 09 08 */ @@ -245,8 +256,7 @@ avr32_common: #if CONFIG_ARCH_INTERRUPTSTACK > 3 mov r7, sp - mov sp, up_intstackbase - movh sp, (up_intstackbase >> 0) + lddpc sp, .Lup_instackbase #endif /* Call up_doirq with r12=IRQ number and r11=register save area */ @@ -282,12 +292,16 @@ avr32_common: sub sp, -4 rete - /* Context switch... we need to do a little more work. */ + /* Context switch... jump to up_fullcontestrestor with r12=address of */ + /* the task context to restore. */ + 1: -#warning "Missing Logic" + lddpc pc, .Lup_fullcontextrestore .Lup_doirq: .word up_doirq +.Lup_fullcontextrestore: + .word up_fullcontextrestore /************************************************************************************ * Name: up_interruptstack @@ -302,6 +316,9 @@ up_interruptstack: .skip (CONFIG_ARCH_INTERRUPTSTACK & ~3) up_intstackbase: .size up_interruptstack, .-up_interruptstack +.Lup_instackbase + .word up_intstackbase + .size .Lup_instackbase, .-.Lup_instackbase #endif .end diff --git a/arch/avr/src/avr32/up_fullcontextrestore.S b/arch/avr/src/avr32/up_fullcontextrestore.S index 6969b0bed0..02c33adfd9 100755 --- a/arch/avr/src/avr32/up_fullcontextrestore.S +++ b/arch/avr/src/avr32/up_fullcontextrestore.S @@ -44,6 +44,8 @@ * External Symbols ****************************************************************************/ + .file "up_fullcontextrestore.S" + /**************************************************************************** * Macros ****************************************************************************/ @@ -54,6 +56,9 @@ * C Prototype: * void up_fullcontextrestore(uint32_t *regs); * + * Assumptions: + * Interrupts are disabled. + * ****************************************************************************/ .text @@ -96,7 +101,7 @@ up_fullcontextrestore: ldm r12++, r8-r11 /* r12 now points +4 beyond the end of the register save area. Restore */ - /* SR. */ + /* SR. NOTE: This may enable interrupts! */ /* 07 06 05 04 03 02 01 00 SP SR PC LR 12 11 10 09 08 */ /* ^r12-4*8 ^r12 */ diff --git a/arch/avr/src/avr32/up_nommuhead.S b/arch/avr/src/avr32/up_nommuhead.S index c80c98c29b..7a4f2ae496 100644 --- a/arch/avr/src/avr32/up_nommuhead.S +++ b/arch/avr/src/avr32/up_nommuhead.S @@ -47,6 +47,7 @@ * External Symbols ****************************************************************************/ + .file "up_nommuhead.S" .global _sbss /* Start of .bss. Defined by ld.script */ .global _ebss /* End of .bss. Defined by ld.script */ #ifdef CONFIG_BOOT_RUNFROMFLASH