mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 07:12:54 +08:00
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:
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* arch/arm/src/cortexm3/up_switchcontext.S
|
* 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>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
.syntax unified
|
.syntax unified
|
||||||
.thumb
|
.thumb
|
||||||
.file "up_context.S"
|
.file "up_switchcontext.S"
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Macros
|
* Macros
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ HEAD_ASRC = up_nommuhead.S
|
|||||||
|
|
||||||
# Common AVR/AVR32 files
|
# 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 \
|
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_createstack.c up_mdelay.c up_udelay.c up_exit.c up_idle.c \
|
||||||
up_initialize.c up_initialstate.c up_interruptcontext.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?"
|
#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
|
/* 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
|
* the highest priority that has a pending interrupt of level n. This value
|
||||||
|
|||||||
@@ -44,11 +44,12 @@
|
|||||||
* External Symbols
|
* External Symbols
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
.global avr32_int0irqno /* Returns the IRQ number of an INT0 interrupt */
|
.global avr32_int0irqno /* Returns the IRQ number of an INT0 interrupt */
|
||||||
.global avr32_int1irqno /* Returns the IRQ number of an INT1 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_int2irqno /* Returns the IRQ number of an INT2 interrupt */
|
||||||
.global avr32_int3irqno /* Returns the IRQ number of an INT3 interrupt */
|
.global avr32_int3irqno /* Returns the IRQ number of an INT3 interrupt */
|
||||||
.global up_doirq /* Dispatch an IRQ */
|
.global up_doirq /* Dispatch an IRQ */
|
||||||
|
.global up_fullcontextrestore /* Restore new task contex */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Macros
|
* Macros
|
||||||
@@ -219,6 +220,16 @@ avr32_excptcommon:
|
|||||||
/* and call the IRQ dispatching logic. */
|
/* and call the IRQ dispatching logic. */
|
||||||
|
|
||||||
avr32_common:
|
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 */
|
/* Save the SP (as it was before the interrupt) in the conext save */
|
||||||
/* structure. */
|
/* structure. */
|
||||||
/* xx xx xx xx xx xx xx xx SP SR PC LR 12 11 10 09 08 */
|
/* 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
|
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||||
mov r7, sp
|
mov r7, sp
|
||||||
mov sp, up_intstackbase
|
lddpc sp, .Lup_instackbase
|
||||||
movh sp, (up_intstackbase >> 0)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Call up_doirq with r12=IRQ number and r11=register save area */
|
/* Call up_doirq with r12=IRQ number and r11=register save area */
|
||||||
@@ -282,12 +292,16 @@ avr32_common:
|
|||||||
sub sp, -4
|
sub sp, -4
|
||||||
rete
|
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:
|
1:
|
||||||
#warning "Missing Logic"
|
lddpc pc, .Lup_fullcontextrestore
|
||||||
|
|
||||||
.Lup_doirq:
|
.Lup_doirq:
|
||||||
.word up_doirq
|
.word up_doirq
|
||||||
|
.Lup_fullcontextrestore:
|
||||||
|
.word up_fullcontextrestore
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: up_interruptstack
|
* Name: up_interruptstack
|
||||||
@@ -302,6 +316,9 @@ up_interruptstack:
|
|||||||
.skip (CONFIG_ARCH_INTERRUPTSTACK & ~3)
|
.skip (CONFIG_ARCH_INTERRUPTSTACK & ~3)
|
||||||
up_intstackbase:
|
up_intstackbase:
|
||||||
.size up_interruptstack, .-up_interruptstack
|
.size up_interruptstack, .-up_interruptstack
|
||||||
|
.Lup_instackbase
|
||||||
|
.word up_intstackbase
|
||||||
|
.size .Lup_instackbase, .-.Lup_instackbase
|
||||||
#endif
|
#endif
|
||||||
.end
|
.end
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,8 @@
|
|||||||
* External Symbols
|
* External Symbols
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
.file "up_fullcontextrestore.S"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Macros
|
* Macros
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -54,6 +56,9 @@
|
|||||||
* C Prototype:
|
* C Prototype:
|
||||||
* void up_fullcontextrestore(uint32_t *regs);
|
* void up_fullcontextrestore(uint32_t *regs);
|
||||||
*
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* Interrupts are disabled.
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
.text
|
.text
|
||||||
@@ -96,7 +101,7 @@ up_fullcontextrestore:
|
|||||||
ldm r12++, r8-r11
|
ldm r12++, r8-r11
|
||||||
|
|
||||||
/* r12 now points +4 beyond the end of the register save area. Restore */
|
/* 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 */
|
/* 07 06 05 04 03 02 01 00 SP SR PC LR 12 11 10 09 08 */
|
||||||
/* ^r12-4*8 ^r12 */
|
/* ^r12-4*8 ^r12 */
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
* External Symbols
|
* External Symbols
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
.file "up_nommuhead.S"
|
||||||
.global _sbss /* Start of .bss. Defined by ld.script */
|
.global _sbss /* Start of .bss. Defined by ld.script */
|
||||||
.global _ebss /* End of .bss. Defined by ld.script */
|
.global _ebss /* End of .bss. Defined by ld.script */
|
||||||
#ifdef CONFIG_BOOT_RUNFROMFLASH
|
#ifdef CONFIG_BOOT_RUNFROMFLASH
|
||||||
|
|||||||
Reference in New Issue
Block a user