mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 03:45:50 +08:00
This finishes ALL AVR assembly language
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3685 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -1,125 +1,176 @@
|
|||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* arch/avr/src/at90usb/at90usb_exceptions.S
|
* arch/avr/src/at90usb/at90usb_exceptions.S
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011 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
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* notice, this list of conditions and the following disclaimer in
|
||||||
* the documentation and/or other materials provided with the
|
* the documentation and/or other materials provided with the
|
||||||
* distribution.
|
* distribution.
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
* used to endorse or promote products derived from this software
|
* used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <arch/irq.h>
|
||||||
|
|
||||||
#include "excptmacros.h"
|
#include "excptmacros.h"
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* External Symbols
|
* External Symbols
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
.file "at90usb_exceptions.S"
|
.file "at90usb_exceptions.S"
|
||||||
.global up_doirq
|
.global up_doirq
|
||||||
|
.global up_fullcontextrestore
|
||||||
/********************************************************************************************
|
|
||||||
* Macros
|
/********************************************************************************************
|
||||||
********************************************************************************************/
|
* Macros
|
||||||
|
********************************************************************************************/
|
||||||
/********************************************************************************************
|
|
||||||
* Exception Vector Handlers
|
/********************************************************************************************
|
||||||
********************************************************************************************/
|
* Exception Vector Handlers
|
||||||
|
********************************************************************************************/
|
||||||
.section .handlers, "ax", @progbits
|
|
||||||
|
.section .handlers, "ax", @progbits
|
||||||
HANDLER at90usb_int0, AT90USB_IRQ_INT0, excpt_common /* External interrupt request 0 */
|
|
||||||
HANDLER at90usb_int1, AT90USB_IRQ_INT1, excpt_common /* External interrupt request 1 */
|
HANDLER at90usb_int0, AT90USB_IRQ_INT0, excpt_common /* External interrupt request 0 */
|
||||||
HANDLER at90usb_int2, AT90USB_IRQ_INT2, excpt_common /* External interrupt request 2 */
|
HANDLER at90usb_int1, AT90USB_IRQ_INT1, excpt_common /* External interrupt request 1 */
|
||||||
HANDLER at90usb_int3, AT90USB_IRQ_INT3, excpt_common /* External interrupt request 3 */
|
HANDLER at90usb_int2, AT90USB_IRQ_INT2, excpt_common /* External interrupt request 2 */
|
||||||
HANDLER at90usb_int4, AT90USB_IRQ_INT4, excpt_common /* External interrupt request 4 */
|
HANDLER at90usb_int3, AT90USB_IRQ_INT3, excpt_common /* External interrupt request 3 */
|
||||||
HANDLER at90usb_int5, AT90USB_IRQ_INT5, excpt_common /* External interrupt request 5 */
|
HANDLER at90usb_int4, AT90USB_IRQ_INT4, excpt_common /* External interrupt request 4 */
|
||||||
HANDLER at90usb_int6, AT90USB_IRQ_INT6, excpt_common /* External interrupt request 6 */
|
HANDLER at90usb_int5, AT90USB_IRQ_INT5, excpt_common /* External interrupt request 5 */
|
||||||
HANDLER at90usb_int7, AT90USB_IRQ_INT7, excpt_common /* External interrupt request 7 */
|
HANDLER at90usb_int6, AT90USB_IRQ_INT6, excpt_common /* External interrupt request 6 */
|
||||||
HANDLER at90usb_pcint0, AT90USB_IRQ_PCINT0, excpt_common /* Pin Change Interrupt Request 0 */
|
HANDLER at90usb_int7, AT90USB_IRQ_INT7, excpt_common /* External interrupt request 7 */
|
||||||
HANDLER at90usb_usbgen, AT90USB_IRQ_USBGEN, excpt_common /* USB General USB General Interrupt request */
|
HANDLER at90usb_pcint0, AT90USB_IRQ_PCINT0, excpt_common /* Pin Change Interrupt Request 0 */
|
||||||
HANDLER at90usb_usbep, AT90USB_IRQ_USBEP, excpt_common /* USB Endpoint/Pipe USB ENdpoint/Pipe Interrupt request */
|
HANDLER at90usb_usbgen, AT90USB_IRQ_USBGEN, excpt_common /* USB General USB General Interrupt request */
|
||||||
HANDLER at90usb_wdt, AT90USB_IRQ_WDT, excpt_common /* Watchdog Time-out Interrupt */
|
HANDLER at90usb_usbep, AT90USB_IRQ_USBEP, excpt_common /* USB Endpoint/Pipe USB ENdpoint/Pipe Interrupt request */
|
||||||
HANDLER at90usb_t2compa, AT90USB_IRQ_T2COMPA, excpt_common /* TIMER2 COMPA Timer/Counter2 Compare Match A */
|
HANDLER at90usb_wdt, AT90USB_IRQ_WDT, excpt_common /* Watchdog Time-out Interrupt */
|
||||||
HANDLER at90usb_t2compb, AT90USB_IRQ_T2COMPB, excpt_common /* TIMER2 COMPA Timer/Counter2 Compare Match B */
|
HANDLER at90usb_t2compa, AT90USB_IRQ_T2COMPA, excpt_common /* TIMER2 COMPA Timer/Counter2 Compare Match A */
|
||||||
HANDLER at90usb_t2ovf, AT90USB_IRQ_T2OVF, excpt_common /* TIMER2 OVF timer/counter2 overflow */
|
HANDLER at90usb_t2compb, AT90USB_IRQ_T2COMPB, excpt_common /* TIMER2 COMPA Timer/Counter2 Compare Match B */
|
||||||
HANDLER at90usb_t1capt, AT90USB_IRQ_T1CAPT, excpt_common /* TIMER1 CAPT timer/counter1 capture event */
|
HANDLER at90usb_t2ovf, AT90USB_IRQ_T2OVF, excpt_common /* TIMER2 OVF timer/counter2 overflow */
|
||||||
HANDLER at90usb_t1compa, AT90USB_IRQ_T1COMPA, excpt_common /* TIMER1 COMPA timer/counter1 compare match A */
|
HANDLER at90usb_t1capt, AT90USB_IRQ_T1CAPT, excpt_common /* TIMER1 CAPT timer/counter1 capture event */
|
||||||
HANDLER at90usb_t1compb, AT90USB_IRQ_T1COMPB, excpt_common /* TIMER1 COMPB timer/counter1 compare match B */
|
HANDLER at90usb_t1compa, AT90USB_IRQ_T1COMPA, excpt_common /* TIMER1 COMPA timer/counter1 compare match A */
|
||||||
HANDLER at90usb_t1compc, AT90USB_IRQ_T1COMPC, excpt_common /* TIMER1 COMPC timer/counter1 compare match C */
|
HANDLER at90usb_t1compb, AT90USB_IRQ_T1COMPB, excpt_common /* TIMER1 COMPB timer/counter1 compare match B */
|
||||||
HANDLER at90usb_t1ovf, AT90USB_IRQ_T1OVF, excpt_common /* TIMER1 OVF timer/counter1 overflow */
|
HANDLER at90usb_t1compc, AT90USB_IRQ_T1COMPC, excpt_common /* TIMER1 COMPC timer/counter1 compare match C */
|
||||||
HANDLER at90usb_t0compa, AT90USB_IRQ_T0COMPA, excpt_common /* TIMER0 COMPA Timer/Counter0 Compare Match A */
|
HANDLER at90usb_t1ovf, AT90USB_IRQ_T1OVF, excpt_common /* TIMER1 OVF timer/counter1 overflow */
|
||||||
HANDLER at90usb_t0compb, AT90USB_IRQ_T0COMPB, excpt_common /* TIMER0 COMPB Timer/Counter0 Compare Match B */
|
HANDLER at90usb_t0compa, AT90USB_IRQ_T0COMPA, excpt_common /* TIMER0 COMPA Timer/Counter0 Compare Match A */
|
||||||
HANDLER at90usb_t0ovf, AT90USB_IRQ_T0OVF, excpt_common /* TIMER0 OVF timer/counter0 overflow */
|
HANDLER at90usb_t0compb, AT90USB_IRQ_T0COMPB, excpt_common /* TIMER0 COMPB Timer/Counter0 Compare Match B */
|
||||||
HANDLER at90usb_spi, AT90USB_IRQ_SPI, excpt_common /* STC SPI serial transfer complete */
|
HANDLER at90usb_t0ovf, AT90USB_IRQ_T0OVF, excpt_common /* TIMER0 OVF timer/counter0 overflow */
|
||||||
HANDLER at90usb_u1rx, AT90USB_IRQ_U1RX, excpt_common /* USART1 RX complete */
|
HANDLER at90usb_spi, AT90USB_IRQ_SPI, excpt_common /* STC SPI serial transfer complete */
|
||||||
HANDLER at90usb_u1dre, AT90USB_IRQ_U1DRE, excpt_common /* USART1 data register empty */
|
HANDLER at90usb_u1rx, AT90USB_IRQ_U1RX, excpt_common /* USART1 RX complete */
|
||||||
HANDLER at90usb_u1tx, AT90USB_IRQ_U1TX, excpt_common /* USART1 TX complete */
|
HANDLER at90usb_u1dre, AT90USB_IRQ_U1DRE, excpt_common /* USART1 data register empty */
|
||||||
HANDLER at90usb_anacomp, AT90USB_IRQ_ANACOMP, excpt_common /* ANALOG COMP analog comparator */
|
HANDLER at90usb_u1tx, AT90USB_IRQ_U1TX, excpt_common /* USART1 TX complete */
|
||||||
HANDLER at90usb_adc, AT90USB_IRQ_ADC, excpt_common /* ADC conversion complete */
|
HANDLER at90usb_anacomp, AT90USB_IRQ_ANACOMP, excpt_common /* ANALOG COMP analog comparator */
|
||||||
HANDLER at90usb_ee, AT90USB_IRQ_EE, excpt_common /* EEPROM ready */
|
HANDLER at90usb_adc, AT90USB_IRQ_ADC, excpt_common /* ADC conversion complete */
|
||||||
HANDLER at90usb_t3capt, AT90USB_IRQ_T3CAPT, excpt_common /* TIMER3 CAPT timer/counter3 capture event */
|
HANDLER at90usb_ee, AT90USB_IRQ_EE, excpt_common /* EEPROM ready */
|
||||||
HANDLER at90usb_t3compa, AT90USB_IRQ_T3COMPA, excpt_common /* TIMER3 COMPA timer/counter3 compare match a */
|
HANDLER at90usb_t3capt, AT90USB_IRQ_T3CAPT, excpt_common /* TIMER3 CAPT timer/counter3 capture event */
|
||||||
HANDLER at90usb_t3compb, AT90USB_IRQ_T3COMPB, excpt_common /* TIMER3 COMPB timer/counter3 compare match b */
|
HANDLER at90usb_t3compa, AT90USB_IRQ_T3COMPA, excpt_common /* TIMER3 COMPA timer/counter3 compare match a */
|
||||||
HANDLER at90usb_t3compc, AT90USB_IRQ_T3COMPC, excpt_common /* TIMER3 COMPC timer/counter3 compare match c */
|
HANDLER at90usb_t3compb, AT90USB_IRQ_T3COMPB, excpt_common /* TIMER3 COMPB timer/counter3 compare match b */
|
||||||
HANDLER at90usb_t3ovf, AT90USB_IRQ_T3OVF, excpt_common /* TIMER3 OVF timer/counter3 overflow */
|
HANDLER at90usb_t3compc, AT90USB_IRQ_T3COMPC, excpt_common /* TIMER3 COMPC timer/counter3 compare match c */
|
||||||
HANDLER at90usb_twi, AT90USB_IRQ_TWI, excpt_common /* TWI two-wire serial interface */
|
HANDLER at90usb_t3ovf, AT90USB_IRQ_T3OVF, excpt_common /* TIMER3 OVF timer/counter3 overflow */
|
||||||
HANDLER at90usb_spmrdy, AT90USB_IRQ_SPMRDY, excpt_common /* Store program memory ready */
|
HANDLER at90usb_twi, AT90USB_IRQ_TWI, excpt_common /* TWI two-wire serial interface */
|
||||||
|
HANDLER at90usb_spmrdy, AT90USB_IRQ_SPMRDY, excpt_common /* Store program memory ready */
|
||||||
/* Common exception handling logic. */
|
|
||||||
|
/********************************************************************************************
|
||||||
excpt_common:
|
* Name: excpt_common
|
||||||
#warning "Missing Logic"
|
*
|
||||||
|
* Description:
|
||||||
/****************************************************************************************************
|
* Exception Vector Handlers
|
||||||
* Name: up_interruptstack
|
*
|
||||||
****************************************************************************************************/
|
* On Entry:
|
||||||
|
* The return PC and the saved r24 is on the stack, r24 now contains the IRQ number
|
||||||
#if CONFIG_ARCH_INTERRUPTSTACK > 0
|
*
|
||||||
.bss
|
* PCL
|
||||||
.align 4
|
* PCH
|
||||||
.globl up_interruptstack
|
* R0
|
||||||
.type up_interruptstack, object
|
* --- <- SP
|
||||||
up_interruptstack:
|
*
|
||||||
.skip CONFIG_ARCH_INTERRUPTSTACK
|
********************************************************************************************/
|
||||||
.Lintstackbase:
|
|
||||||
.size up_interruptstack, .-up_interruptstack
|
excpt_common:
|
||||||
#endif
|
/* Save the remaining registers on the stack, preserving the IRQ number in r14 */
|
||||||
.end
|
|
||||||
|
EXCPT_PROLOGUE
|
||||||
|
|
||||||
|
/* Call up_doirq with r24 = IRQ number, r22-23 = Pointer to the save structure. The stack
|
||||||
|
* pointer currently points to the save structure (or maybe the save struture -1 since
|
||||||
|
* the push operation post-decrements -- need to REVISIT this).
|
||||||
|
*/
|
||||||
|
|
||||||
|
in r16, __SP_L__ /* Get the save structure pointer in a Call-saved register pair */
|
||||||
|
in r17, __SP_H__ /* (Careful, push post-decrements) */
|
||||||
|
movw r22, r16 /* Pass register save structure as the parameter 2 */
|
||||||
|
USE_INTSTACK rx, ry, rz /* Switch to the interrupt stack */
|
||||||
|
call up_doirq /* Dispatch the interrupt */
|
||||||
|
RESTORE_STACK rx, ry /* - Undo the operations of USE_INTSTACK */
|
||||||
|
|
||||||
|
/* up_doiq returns with r24-r25 equal to the new save structure. If no context
|
||||||
|
* switch occurred, this will be the same as the value passed to it in r22-23.
|
||||||
|
* But if a context switch occurs, then the returned value will point not at a
|
||||||
|
* stack frame, but at a register save area inside of the new task's TCB.
|
||||||
|
*/
|
||||||
|
|
||||||
|
cp r16, r24
|
||||||
|
cpc r17, r25
|
||||||
|
breq .Lnoswitch
|
||||||
|
|
||||||
|
/* A context switch has occurred, jump to up_fullcontextrestore with r24, r25
|
||||||
|
* equal to the address of the new register save ared.
|
||||||
|
*/
|
||||||
|
|
||||||
|
jmp up_fullcontextrestore
|
||||||
|
|
||||||
|
/* No context switch occurred.. just return off the stack */
|
||||||
|
|
||||||
|
.Lnoswitch:
|
||||||
|
EXCPT_EPILOGUE
|
||||||
|
reti
|
||||||
|
|
||||||
|
/****************************************************************************************************
|
||||||
|
* Name: up_interruptstack
|
||||||
|
****************************************************************************************************/
|
||||||
|
|
||||||
|
#if CONFIG_ARCH_INTERRUPTSTACK > 0
|
||||||
|
.bss
|
||||||
|
.align 4
|
||||||
|
.globl up_interruptstack
|
||||||
|
.type up_interruptstack, object
|
||||||
|
up_interruptstack:
|
||||||
|
.skip CONFIG_ARCH_INTERRUPTSTACK
|
||||||
|
.Lintstackbase:
|
||||||
|
.size up_interruptstack, .-up_interruptstack
|
||||||
|
#endif
|
||||||
|
.end
|
||||||
|
|
||||||
|
|||||||
+277
-277
File diff suppressed because it is too large
Load Diff
@@ -1,118 +1,169 @@
|
|||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* arch/avr/src/atmega/atmega_exceptions.S
|
* arch/avr/src/atmega/atmega_exceptions.S
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011 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
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* notice, this list of conditions and the following disclaimer in
|
||||||
* the documentation and/or other materials provided with the
|
* the documentation and/or other materials provided with the
|
||||||
* distribution.
|
* distribution.
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
* used to endorse or promote products derived from this software
|
* used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <arch/irq.h>
|
||||||
|
|
||||||
#include "excptmacros.h"
|
#include "excptmacros.h"
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* External Symbols
|
* External Symbols
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
.file "atmega_exceptions.S"
|
.file "atmega_exceptions.S"
|
||||||
.global up_doirq
|
.global up_doirq
|
||||||
|
.gloal up_fullcontextrestore
|
||||||
/********************************************************************************************
|
|
||||||
* Macros
|
/********************************************************************************************
|
||||||
********************************************************************************************/
|
* Macros
|
||||||
|
********************************************************************************************/
|
||||||
/********************************************************************************************
|
|
||||||
* Exception Vector Handlers
|
/********************************************************************************************
|
||||||
********************************************************************************************/
|
* Exception Vector Handlers
|
||||||
|
********************************************************************************************/
|
||||||
.section .handlers, "ax", @progbits
|
|
||||||
|
.section .handlers, "ax", @progbits
|
||||||
HANDLER atmega_int0, ATMEGA_IRQ_INT0, excpt_common /* External interrupt request 0 */
|
|
||||||
HANDLER atmega_int1, ATMEGA_IRQ_INT1, excpt_common /* External interrupt request 1 */
|
HANDLER atmega_int0, ATMEGA_IRQ_INT0, excpt_common /* External interrupt request 0 */
|
||||||
HANDLER atmega_int2, ATMEGA_IRQ_INT2, excpt_common /* External interrupt request 2 */
|
HANDLER atmega_int1, ATMEGA_IRQ_INT1, excpt_common /* External interrupt request 1 */
|
||||||
HANDLER atmega_int3, ATMEGA_IRQ_INT3, excpt_common /* External interrupt request 3 */
|
HANDLER atmega_int2, ATMEGA_IRQ_INT2, excpt_common /* External interrupt request 2 */
|
||||||
HANDLER atmega_int4, ATMEGA_IRQ_INT4, excpt_common /* External interrupt request 4 */
|
HANDLER atmega_int3, ATMEGA_IRQ_INT3, excpt_common /* External interrupt request 3 */
|
||||||
HANDLER atmega_int5, ATMEGA_IRQ_INT5, excpt_common /* External interrupt request 5 */
|
HANDLER atmega_int4, ATMEGA_IRQ_INT4, excpt_common /* External interrupt request 4 */
|
||||||
HANDLER atmega_int6, ATMEGA_IRQ_INT6, excpt_common /* External interrupt request 6 */
|
HANDLER atmega_int5, ATMEGA_IRQ_INT5, excpt_common /* External interrupt request 5 */
|
||||||
HANDLER atmega_int7, ATMEGA_IRQ_INT7, excpt_common /* External interrupt request 7 */
|
HANDLER atmega_int6, ATMEGA_IRQ_INT6, excpt_common /* External interrupt request 6 */
|
||||||
HANDLER atmega_t2comp, ATMEGA_IRQ_T2COMP, excpt_common /* TIMER2 COMP timer/counter2 compare match */
|
HANDLER atmega_int7, ATMEGA_IRQ_INT7, excpt_common /* External interrupt request 7 */
|
||||||
HANDLER atmega_t2ovf, ATMEGA_IRQ_T2OVF, excpt_common /* TIMER2 OVF timer/counter2 overflow */
|
HANDLER atmega_t2comp, ATMEGA_IRQ_T2COMP, excpt_common /* TIMER2 COMP timer/counter2 compare match */
|
||||||
HANDLER atmega_t1capt, ATMEGA_IRQ_T1CAPT, excpt_common /* TIMER1 CAPT timer/counter1 capture event */
|
HANDLER atmega_t2ovf, ATMEGA_IRQ_T2OVF, excpt_common /* TIMER2 OVF timer/counter2 overflow */
|
||||||
HANDLER atmega_t1compa, ATMEGA_IRQ_T1COMPA, excpt_common /* TIMER1 COMPA timer/counter1 compare match a */
|
HANDLER atmega_t1capt, ATMEGA_IRQ_T1CAPT, excpt_common /* TIMER1 CAPT timer/counter1 capture event */
|
||||||
HANDLER atmega_t1compb, ATMEGA_IRQ_T1COMPB, excpt_common /* TIMER1 COMPB timer/counter1 compare match b */
|
HANDLER atmega_t1compa, ATMEGA_IRQ_T1COMPA, excpt_common /* TIMER1 COMPA timer/counter1 compare match a */
|
||||||
HANDLER atmega_t1ovf, ATMEGA_IRQ_T1OVF, excpt_common /* TIMER1 OVF timer/counter1 overflow */
|
HANDLER atmega_t1compb, ATMEGA_IRQ_T1COMPB, excpt_common /* TIMER1 COMPB timer/counter1 compare match b */
|
||||||
HANDLER atmega_t0comp, ATMEGA_IRQ_T0COMP, excpt_common /* TIMER0 COMP timer/counter0 compare match */
|
HANDLER atmega_t1ovf, ATMEGA_IRQ_T1OVF, excpt_common /* TIMER1 OVF timer/counter1 overflow */
|
||||||
HANDLER atmega_t0ovf, ATMEGA_IRQ_T0OVF, excpt_common /* TIMER0 OVF timer/counter0 overflow */
|
HANDLER atmega_t0comp, ATMEGA_IRQ_T0COMP, excpt_common /* TIMER0 COMP timer/counter0 compare match */
|
||||||
HANDLER atmega_spi, ATMEGA_IRQ_SPI, excpt_common /* STC SPI serial transfer complete */
|
HANDLER atmega_t0ovf, ATMEGA_IRQ_T0OVF, excpt_common /* TIMER0 OVF timer/counter0 overflow */
|
||||||
HANDLER atmega_u0rx, ATMEGA_IRQ_U0RX, excpt_common /* USART0 RX complete */
|
HANDLER atmega_spi, ATMEGA_IRQ_SPI, excpt_common /* STC SPI serial transfer complete */
|
||||||
HANDLER atmega_u0dre, ATMEGA_IRQ_U0DRE, excpt_common /* USART0 data register empty */
|
HANDLER atmega_u0rx, ATMEGA_IRQ_U0RX, excpt_common /* USART0 RX complete */
|
||||||
HANDLER atmega_u0tx, ATMEGA_IRQ_U0TX, excpt_common /* USART0 TX complete */
|
HANDLER atmega_u0dre, ATMEGA_IRQ_U0DRE, excpt_common /* USART0 data register empty */
|
||||||
HANDLER atmega_adc, ATMEGA_IRQ_ADC, excpt_common /* ADC conversion complete */
|
HANDLER atmega_u0tx, ATMEGA_IRQ_U0TX, excpt_common /* USART0 TX complete */
|
||||||
HANDLER atmega_ee, ATMEGA_IRQ_EE, excpt_common /* EEPROM ready */
|
HANDLER atmega_adc, ATMEGA_IRQ_ADC, excpt_common /* ADC conversion complete */
|
||||||
HANDLER atmega_anacomp, ATMEGA_IRQ_ANACOMP, excpt_common /* ANALOG COMP analog comparator */
|
HANDLER atmega_ee, ATMEGA_IRQ_EE, excpt_common /* EEPROM ready */
|
||||||
HANDLER atmega_t1compc, ATMEGA_IRQ_T1COMPC, excpt_common /* TIMER1 COMPC timer/countre1 compare match c */
|
HANDLER atmega_anacomp, ATMEGA_IRQ_ANACOMP, excpt_common /* ANALOG COMP analog comparator */
|
||||||
HANDLER atmega_t3capt, ATMEGA_IRQ_T3CAPT, excpt_common /* TIMER3 CAPT timer/counter3 capture event */
|
HANDLER atmega_t1compc, ATMEGA_IRQ_T1COMPC, excpt_common /* TIMER1 COMPC timer/countre1 compare match c */
|
||||||
HANDLER atmega_t3compa, ATMEGA_IRQ_T3COMPA, excpt_common /* TIMER3 COMPA timer/counter3 compare match a */
|
HANDLER atmega_t3capt, ATMEGA_IRQ_T3CAPT, excpt_common /* TIMER3 CAPT timer/counter3 capture event */
|
||||||
HANDLER atmega_t3compb, ATMEGA_IRQ_T3COMPB, excpt_common /* TIMER3 COMPB timer/counter3 compare match b */
|
HANDLER atmega_t3compa, ATMEGA_IRQ_T3COMPA, excpt_common /* TIMER3 COMPA timer/counter3 compare match a */
|
||||||
HANDLER atmega_t3compc, ATMEGA_IRQ_T3COMPC, excpt_common /* TIMER3 COMPC timer/counter3 compare match c */
|
HANDLER atmega_t3compb, ATMEGA_IRQ_T3COMPB, excpt_common /* TIMER3 COMPB timer/counter3 compare match b */
|
||||||
HANDLER atmega_t3ovf, ATMEGA_IRQ_T3OVF, excpt_common /* TIMER3 OVF timer/counter3 overflow */
|
HANDLER atmega_t3compc, ATMEGA_IRQ_T3COMPC, excpt_common /* TIMER3 COMPC timer/counter3 compare match c */
|
||||||
HANDLER atmega_u1rx, ATMEGA_IRQ_U1RX, excpt_common /* USART1 RX complete */
|
HANDLER atmega_t3ovf, ATMEGA_IRQ_T3OVF, excpt_common /* TIMER3 OVF timer/counter3 overflow */
|
||||||
HANDLER atmega_u1dre, ATMEGA_IRQ_U1DRE, excpt_common /* USART1 data register empty */
|
HANDLER atmega_u1rx, ATMEGA_IRQ_U1RX, excpt_common /* USART1 RX complete */
|
||||||
HANDLER atmega_u1tx, ATMEGA_IRQ_U1TX, excpt_common /* USART1 TX complete */
|
HANDLER atmega_u1dre, ATMEGA_IRQ_U1DRE, excpt_common /* USART1 data register empty */
|
||||||
HANDLER atmega_twi, ATMEGA_IRQ_TWI, excpt_common /* TWI two-wire serial interface */
|
HANDLER atmega_u1tx, ATMEGA_IRQ_U1TX, excpt_common /* USART1 TX complete */
|
||||||
HANDLER atmega_spmrdy, ATMEGA_IRQ_SPMRDY, excpt_common /* Store program memory ready */
|
HANDLER atmega_twi, ATMEGA_IRQ_TWI, excpt_common /* TWI two-wire serial interface */
|
||||||
|
HANDLER atmega_spmrdy, ATMEGA_IRQ_SPMRDY, excpt_common /* Store program memory ready */
|
||||||
/* Common exception handling logic. */
|
|
||||||
|
/********************************************************************************************
|
||||||
excpt_common:
|
* Name: excpt_common
|
||||||
#warning "Missing Logic"
|
*
|
||||||
|
* Description:
|
||||||
/****************************************************************************************************
|
* Exception Vector Handlers
|
||||||
* Name: up_interruptstack
|
*
|
||||||
****************************************************************************************************/
|
* On Entry:
|
||||||
|
* The return PC and the saved r24 is on the stack, r24 now contains the IRQ number
|
||||||
#if CONFIG_ARCH_INTERRUPTSTACK > 0
|
*
|
||||||
.bss
|
* PCL
|
||||||
.align 4
|
* PCH
|
||||||
.globl up_interruptstack
|
* R0
|
||||||
.type up_interruptstack, object
|
* --- <- SP
|
||||||
up_interruptstack:
|
*
|
||||||
.skip CONFIG_ARCH_INTERRUPTSTACK
|
********************************************************************************************/
|
||||||
.Lintstackbase:
|
|
||||||
.size up_interruptstack, .-up_interruptstack
|
excpt_common:
|
||||||
#endif
|
/* Save the remaining registers on the stack, preserving the IRQ number in r14 */
|
||||||
.end
|
|
||||||
|
EXCPT_PROLOGUE
|
||||||
|
|
||||||
|
/* Call up_doirq with r24 = IRQ number, r22-23 = Pointer to the save structure. The stack
|
||||||
|
* pointer currently points to the save structure (or maybe the save struture -1 since
|
||||||
|
* the push operation post-decrements -- need to REVISIT this).
|
||||||
|
*/
|
||||||
|
|
||||||
|
in r16, __SP_L__ /* Get the save structure pointer in a Call-saved register pair */
|
||||||
|
in r17, __SP_H__ /* (Careful, push post-decrements) */
|
||||||
|
movw r22, r16 /* Pass register save structure as the parameter 2 */
|
||||||
|
USE_INTSTACK rx, ry, rz /* Switch to the interrupt stack */
|
||||||
|
call up_doirq /* Dispatch the interrupt */
|
||||||
|
RESTORE_STACK rx, ry /* - Undo the operations of USE_INTSTACK */
|
||||||
|
|
||||||
|
/* up_doiq returns with r24-r25 equal to the new save structure. If no context
|
||||||
|
* switch occurred, this will be the same as the value passed to it in r22-23.
|
||||||
|
* But if a context switch occurs, then the returned value will point not at a
|
||||||
|
* stack frame, but at a register save area inside of the new task's TCB.
|
||||||
|
*/
|
||||||
|
|
||||||
|
cp r16, r24
|
||||||
|
cpc r17, r25
|
||||||
|
breq .Lnoswitch
|
||||||
|
|
||||||
|
/* A context switch has occurred, jump to up_fullcontextrestore with r24, r25
|
||||||
|
* equal to the address of the new register save ared.
|
||||||
|
*/
|
||||||
|
|
||||||
|
jmp up_fullcontextrestore
|
||||||
|
|
||||||
|
/* No context switch occurred.. just return off the stack */
|
||||||
|
|
||||||
|
.Lnoswitch:
|
||||||
|
EXCPT_EPILOGUE
|
||||||
|
reti
|
||||||
|
|
||||||
|
/****************************************************************************************************
|
||||||
|
* Name: up_interruptstack
|
||||||
|
****************************************************************************************************/
|
||||||
|
|
||||||
|
#if CONFIG_ARCH_INTERRUPTSTACK > 0
|
||||||
|
.bss
|
||||||
|
.align 4
|
||||||
|
.globl up_interruptstack
|
||||||
|
.type up_interruptstack, object
|
||||||
|
up_interruptstack:
|
||||||
|
.skip CONFIG_ARCH_INTERRUPTSTACK
|
||||||
|
.Lintstackbase:
|
||||||
|
.size up_interruptstack, .-up_interruptstack
|
||||||
|
#endif
|
||||||
|
.end
|
||||||
|
|
||||||
|
|||||||
+271
-271
File diff suppressed because it is too large
Load Diff
+566
-567
File diff suppressed because it is too large
Load Diff
+373
-373
File diff suppressed because it is too large
Load Diff
@@ -1,158 +1,158 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/avr32/src/avr32/up_fullcontextrestore.S
|
* arch/avr32/src/avr32/up_fullcontextrestore.S
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
|
* Copyright (C) 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
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* notice, this list of conditions and the following disclaimer in
|
||||||
* the documentation and/or other materials provided with the
|
* the documentation and/or other materials provided with the
|
||||||
* distribution.
|
* distribution.
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
* used to endorse or promote products derived from this software
|
* used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <arch/avr32/avr32.h>
|
#include <arch/avr32/avr32.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* External Symbols
|
* External Symbols
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
.file "up_fullcontextrestore.S"
|
.file "up_fullcontextrestore.S"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Macros
|
* Macros
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_fullcontextrestore
|
* Name: up_fullcontextrestore
|
||||||
*
|
*
|
||||||
* Descripion:
|
* Descripion:
|
||||||
* Restore the full-running contex of a thread.
|
* Restore the full-running contex of a thread.
|
||||||
*
|
*
|
||||||
* NOTE: Thus function must handle one very strange case. That is when
|
* NOTE: Thus function must handle one very strange case. That is when
|
||||||
* this function is called with up_sigdeliver(). That case is strange in
|
* this function is called with up_sigdeliver(). That case is strange in
|
||||||
* two ways:
|
* two ways:
|
||||||
*
|
*
|
||||||
* 1. It is not a context switch between threads. Rather, up_fullcontextrestore
|
* 1. It is not a context switch between threads. Rather, up_fullcontextrestore
|
||||||
* must behave more it more like a longjmp within the same task, using the
|
* must behave more it more like a longjmp within the same task, using the
|
||||||
* same stack.
|
* same stack.
|
||||||
* 2. In this case, this function is called with r12 pointing to a register
|
* 2. In this case, this function is called with r12 pointing to a register
|
||||||
* save area on the stack to be destroyed. This is dangerous for two
|
* save area on the stack to be destroyed. This is dangerous for two
|
||||||
* reasons: (a) there is a period of time where the stack contents still
|
* reasons: (a) there is a period of time where the stack contents still
|
||||||
* contain valid data, but are outside of range protected by the stack
|
* contain valid data, but are outside of range protected by the stack
|
||||||
* pointer (hence, interrupts must be disabled), and (b) there is the
|
* pointer (hence, interrupts must be disabled), and (b) there is the
|
||||||
* very real possibility that the new stack pointer might overlap with
|
* very real possibility that the new stack pointer might overlap with
|
||||||
* the register save area and stack usage in this function might corrupt
|
* the register save area and stack usage in this function might corrupt
|
||||||
* the register save data before the state is restored. It turns that
|
* the register save data before the state is restored. It turns that
|
||||||
* an extra 3 words in the register save structure size will protect its
|
* an extra 3 words in the register save structure size will protect its
|
||||||
* contents (because that is the number of temporaries pushed onto the
|
* contents (because that is the number of temporaries pushed onto the
|
||||||
* stack).
|
* stack).
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* r12 = A pointer to the register save area of the thread to be restored.
|
* r12 = A pointer to the register save area of the thread to be restored.
|
||||||
*
|
*
|
||||||
* C Prototype:
|
* C Prototype:
|
||||||
* void up_fullcontextrestore(uint32_t *regs);
|
* void up_fullcontextrestore(uint32_t *regs);
|
||||||
*
|
*
|
||||||
* Assumptions:
|
* Assumptions:
|
||||||
* Interrupts are disabled.
|
* Interrupts are disabled.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
.text
|
.text
|
||||||
.global up_fullcontextrestore
|
.global up_fullcontextrestore
|
||||||
.type up_fullcontextrestore, @function
|
.type up_fullcontextrestore, @function
|
||||||
up_fullcontextrestore:
|
up_fullcontextrestore:
|
||||||
|
|
||||||
/* Initially, r12 points to the r7 save area. Restore r0-r7. */
|
/* Initially, r12 points to the r7 save area. Restore r0-r7. */
|
||||||
/* regs: 07 06 05 04 03 02 01 00 xx xx xx xx xx xx xx xx xx */
|
/* regs: 07 06 05 04 03 02 01 00 xx xx xx xx xx xx xx xx xx */
|
||||||
/* ^r12 */
|
/* ^r12 */
|
||||||
|
|
||||||
ldm r12++, r0-r7
|
ldm r12++, r0-r7
|
||||||
|
|
||||||
/* Now, r12 points to the SP (r13) save area. Recover the value of */
|
/* Now, r12 points to the SP (r13) save area. Recover the value of */
|
||||||
/* the stack pointer (r13). We will need to save some temporaries on */
|
/* the stack pointer (r13). We will need to save some temporaries on */
|
||||||
/* the final stack. */
|
/* the final stack. */
|
||||||
/* regs: 07 06 05 04 03 02 01 00 SP xx xx xx xx xx xx xx xx */
|
/* regs: 07 06 05 04 03 02 01 00 SP xx xx xx xx xx xx xx xx */
|
||||||
/* ^r12 */
|
/* ^r12 */
|
||||||
|
|
||||||
ld.w sp, r12++
|
ld.w sp, r12++
|
||||||
|
|
||||||
/* Now r12 points to the SR save area. Skip over the SR for now. */
|
/* Now r12 points to the SR save area. Skip over the SR for now. */
|
||||||
/* regs: 07 06 05 04 03 02 01 00 SP xx xx xx xx xx xx xx xx */
|
/* regs: 07 06 05 04 03 02 01 00 SP xx xx xx xx xx xx xx xx */
|
||||||
/* ^r12 */
|
/* ^r12 */
|
||||||
|
|
||||||
sub r12, -1*4
|
sub r12, -1*4
|
||||||
|
|
||||||
/* Get the pc, lr, and r12 (in r10, r9, and r8) and move them to the */
|
/* Get the pc, lr, and r12 (in r10, r9, and r8) and move them to the */
|
||||||
/* stack. We can now use r12 and lr as scratch registers. */
|
/* stack. We can now use r12 and lr as scratch registers. */
|
||||||
/* regs: 07 06 05 04 03 02 01 00 SP xx PC LR 12 xx xx xx xx */
|
/* regs: 07 06 05 04 03 02 01 00 SP xx PC LR 12 xx xx xx xx */
|
||||||
/* ^r12 */
|
/* ^r12 */
|
||||||
/* stack: lr, r12, pc */
|
/* stack: lr, r12, pc */
|
||||||
/* ^sp */
|
/* ^sp */
|
||||||
|
|
||||||
ldm r12++, r8-r10 /* Get r10=pc, r9=lr, r8=r12 */
|
ldm r12++, r8-r10 /* Get r10=pc, r9=lr, r8=r12 */
|
||||||
|
|
||||||
#if 0 /* See comments below */
|
#if 0 /* See comments below */
|
||||||
stm --sp, r8-r10 /* Save r12, lr, and pc from the stack */
|
stm --sp, r8-r10 /* Save r12, lr, and pc from the stack */
|
||||||
#else
|
#else
|
||||||
st.w --sp, r10 /* Save R10=PC on the stack */
|
st.w --sp, r10 /* Save R10=PC on the stack */
|
||||||
st.w --sp, r8 /* Save R8=r12 on the stack */
|
st.w --sp, r8 /* Save R8=r12 on the stack */
|
||||||
st.w --sp, r9 /* Save R9=lr on the stack */
|
st.w --sp, r9 /* Save R9=lr on the stack */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Now r12 now points to the r11 save area. Restore r8-r11. */
|
/* Now r12 now points to the r11 save area. Restore r8-r11. */
|
||||||
/* regs: 07 06 05 04 03 02 01 00 SP xx PC LR 12 11 10 09 08 */
|
/* regs: 07 06 05 04 03 02 01 00 SP xx PC LR 12 11 10 09 08 */
|
||||||
/* ^r12 */
|
/* ^r12 */
|
||||||
|
|
||||||
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. NOTE: This may enable interrupts! */
|
/* SR. NOTE: This may enable interrupts! */
|
||||||
/* regs: 07 06 05 04 03 02 01 00 SP SR PC LR 12 11 10 09 08 */
|
/* regs: 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 */
|
||||||
|
|
||||||
ld.w lr, r12[-4*8]
|
ld.w lr, r12[-4*8]
|
||||||
mtsr AVR32_SR, lr
|
mtsr AVR32_SR, lr
|
||||||
|
|
||||||
/* Restore PC, LR and r12. Hmmm.. I need to study the behaviour of ldm */
|
/* Restore PC, LR and r12. Hmmm.. I need to study the behaviour of ldm */
|
||||||
/* when r12,lr, and pc on in ldm reglist16. I'm not sure that I want */
|
/* when r12,lr, and pc on in ldm reglist16. I'm not sure that I want */
|
||||||
/* that behavior. */
|
/* that behavior. */
|
||||||
/* stack: lr, r12, pc */
|
/* stack: lr, r12, pc */
|
||||||
/* ^sp */
|
/* ^sp */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
ldm sp++, r12, lr, pc /* Restore r12, lr, and pc from the stack */
|
ldm sp++, r12, lr, pc /* Restore r12, lr, and pc from the stack */
|
||||||
#else
|
#else
|
||||||
ld.w lr, sp++ /* Recover lr from the stack */
|
ld.w lr, sp++ /* Recover lr from the stack */
|
||||||
ld.w r12, sp++ /* Recover r12 from the stack */
|
ld.w r12, sp++ /* Recover r12 from the stack */
|
||||||
ld.w pc, sp++ /* Jump to the address on the stack */
|
ld.w pc, sp++ /* Jump to the address on the stack */
|
||||||
#endif
|
#endif
|
||||||
.end
|
.end
|
||||||
|
|||||||
@@ -1,84 +1,84 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/avr/src/avr32/up_syscall6.S
|
* arch/avr/src/avr32/up_syscall6.S
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Based on Bran's kernel development tutorials. Rewritten for JamesM's
|
* Based on Bran's kernel development tutorials. Rewritten for JamesM's
|
||||||
* kernel development tutorials.
|
* kernel development tutorials.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* notice, this list of conditions and the following disclaimer in
|
||||||
* the documentation and/or other materials provided with the
|
* the documentation and/or other materials provided with the
|
||||||
* distribution.
|
* distribution.
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
* used to endorse or promote products derived from this software
|
* used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
.file "up_syscall6.S"
|
.file "up_syscall6.S"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Globals
|
* Globals
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* .text
|
* .text
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
.text
|
.text
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: sys_call6
|
* Name: sys_call6
|
||||||
*
|
*
|
||||||
* C Prototype:
|
* C Prototype:
|
||||||
* uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1,
|
* uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1,
|
||||||
* uintptr_t parm2, uintptr_t parm3,
|
* uintptr_t parm2, uintptr_t parm3,
|
||||||
* uintptr_t parm4, uintptr_t parm5,
|
* uintptr_t parm4, uintptr_t parm5,
|
||||||
* uintptr_t parm6);
|
* uintptr_t parm6);
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
.global sys_call6
|
.global sys_call6
|
||||||
.type sys_call6, @function
|
.type sys_call6, @function
|
||||||
.align 2
|
.align 2
|
||||||
|
|
||||||
sys_call6:
|
sys_call6:
|
||||||
stm --sp, r3, r5, r6, lr
|
stm --sp, r3, r5, r6, lr
|
||||||
sub lr, sp, -16
|
sub lr, sp, -16
|
||||||
mov r8, r12
|
mov r8, r12
|
||||||
ldm lr, r3, r5, r9-r12
|
ldm lr, r3, r5, r9-r12
|
||||||
scall
|
scall
|
||||||
ldm sp++, r3, r5, r6, pc
|
ldm sp++, r3, r5, r6, pc
|
||||||
|
|
||||||
.size sys_call6, . - sys_call6
|
.size sys_call6, . - sys_call6
|
||||||
|
|||||||
@@ -262,6 +262,7 @@ CONFIG_HAVE_LIBM=n
|
|||||||
CONFIG_DEBUG=n
|
CONFIG_DEBUG=n
|
||||||
CONFIG_DEBUG_VERBOSE=n
|
CONFIG_DEBUG_VERBOSE=n
|
||||||
CONFIG_DEBUG_SYMBOLS=n
|
CONFIG_DEBUG_SYMBOLS=n
|
||||||
|
CONFIG_DEBUG_SCHED=n
|
||||||
CONFIG_MM_REGIONS=1
|
CONFIG_MM_REGIONS=1
|
||||||
CONFIG_ARCH_LOWPUTC=y
|
CONFIG_ARCH_LOWPUTC=y
|
||||||
CONFIG_RR_INTERVAL=200
|
CONFIG_RR_INTERVAL=200
|
||||||
|
|||||||
Reference in New Issue
Block a user