More context switching logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3016 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
6bb878ba15
commit
1cf064bc91
|
@ -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 <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue