Add vectors for interrupt levels 2-6

This commit is contained in:
Gregory Nutt 2016-10-19 13:58:51 -06:00
parent 291c49afc3
commit d1562a18e6
6 changed files with 185 additions and 21 deletions

View File

@ -35,6 +35,14 @@ config XTENSA_NCOPROCESSORS
int "Number of co-processors"
default 1
config XTENSA_INT_NLEVELS
int "Number of interrupt levels"
default 5
config XTENSA_EXCM_LEVEL
int "Level masked by PS.EXCM"
default 3
config XTENSA_HAVE_LOOPS
bool "Zero overhead loops"
default n

View File

@ -31,7 +31,7 @@
*
****************************************************************************/
/* XTENSA CONTEXT SAVE AND RESTORE ROUTINES
/* XTENSA CONTEXT SAVE AND RESTORE ROUTINES
*
* Low-level Call0 functions for handling generic context save and restore of
* registers not specifically addressed by the interrupt vectors and handlers.
@ -160,7 +160,7 @@ _xtensa_context_save:
/* To spill the reg windows, temp. need pre-interrupt stack ptr and
* a4-15. Need to save a9,12,13 temporarily (in frame temps) and
* recover originals. Interrupts need to be disabled below
* XCHAL_EXCM_LEVEL and window overflow and underflow exceptions
* CONFIG_XTENSA_EXCM_LEVEL and window overflow and underflow exceptions
* disabled (assured by PS.EXCM == 1).
*/
@ -373,7 +373,7 @@ _xt_coproc_init:
movi a2, _xt_coproc_owner_sa /* a2 = base of owner array */
addi a3, a2, (XCHAL_CP_MAX*portNUM_PROCESSORS) << 2 /* a3 = top+1 of owner array */
movi a4, 0 /* a4 = 0 (unowned) */
1: s32i a4, a2, 0
1: s32i a4, a2, 0
addi a2, a2, 4
bltu a2, a3, 1b
@ -424,15 +424,15 @@ _xt_coproc_release:
addi a4, a3, XCHAL_CP_MAX << 2 /* a4 = top+1 of owner array */
movi a5, 0 /* a5 = 0 (unowned) */
rsil a6, XCHAL_EXCM_LEVEL /* lock interrupts */
rsil a6, CONFIG_XTENSA_EXCM_LEVEL /* Lock interrupts */
1: l32i a7, a3, 0 /* a7 = owner at a3 */
1: l32i a7, a3, 0 /* a7 = owner at a3 */
bne a2, a7, 2f /* if (coproc_sa_base == owner) */
s32i a5, a3, 0 /* owner = unowned */
2: addi a3, a3, 1<<2 /* a3 = next entry in owner array */
bltu a3, a4, 1b /* repeat until end of array */
2: addi a3, a3, 1 << 2 /* a3 = next entry in owner array */
bltu a3, a4, 1b /* Repeat until end of array */
3: wsr a6, PS /* restore interrupts */
3: wsr a6, PS /* Restore interrupts */
RET0
#endif

View File

@ -0,0 +1,156 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_vectors.S
*
* Adapted from use in NuttX by:
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Derives from logic originally provided by Cadence Design Systems Inc.
*
* Copyright (c) 2006-2015 Cadence Design Systems Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
****************************************************************************/
.file "xtensa_vectors.S"
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "xtensa_specregs.h"
#include "xtensa_macros.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* C Prototype:
* void _xtensa_levelN_vector(void)
*
* Description:
* Xtensa interrupt vectors. Each vector goes at a predetermined location
* according to the Xtensa hardware configuration, which is ensured by its
* placement in a special section known to the NuttX linker script. The
* vector logic performs the minimum necessary operations before jumping
* to the handler.
*
****************************************************************************/
#if CONFIG_XTENSA_EXCM_LEVEL >= 2
.begin literal_prefix .xtensa_level2_vector
.section .xtensa_level2_vector.text, "ax"
.global _xtensa_level2_vector
.global _xtensa_level2_handler
.type _xtensa_level2_vector, @function
.align 4
_xtensa_level2_vector:
wsr a0, EXCSAVE_2 /* Preserve a0 */
call0 _xtensa_level2_handler /* Call level 2 interrupt handling */
/* Never returns here - call0 is used as a jump */
.end literal_prefix
.size _xtensa_level2_vector, . - _xtensa_level2_vector
#endif
#if CONFIG_XTENSA_EXCM_LEVEL >= 3
.begin literal_prefix .xtensa_level3_vector
.section .xtensa_level3_vector.text, "ax"
.global _xtensa_level3_vector
.global _xtensa_level3_handler
.type _xtensa_level3_vector, @function
.align 4
_xtensa_level3_vector:
wsr a0, EXCSAVE_3 /* Preserve a0 */
call0 _xtensa_level3_handler /* Call level 3 interrupt handling */
/* Never returns here - call0 is used as a jump */
.end literal_prefix
.size _xtensa_level3_vector, . - _xtensa_level3_vector
#endif
#if CONFIG_XTENSA_EXCM_LEVEL >= 4
.begin literal_prefix .xtensa_level4_vector
.section .xtensa_level4_vector.text, "ax"
.global _xtensa_level4_vector
.global _xtensa_level4_handler
.type _xtensa_level4_vector, @function
.align 4
_xtensa_level4_vector:
wsr a0, EXCSAVE_4 /* Preserve a0 */
call0 _xtensa_level4_handler /* Call level 5 interrupt handling */
/* Never returns here - call0 is used as a jump */
.end literal_prefix
.size _xtensa_level5_vector, . - _xtensa_level5_vector
#endif
#if CONFIG_XTENSA_EXCM_LEVEL >= 5
.begin literal_prefix .xtensa_level5_vector
.section .xtensa_level5_vector.text, "ax"
.global _xtensa_level5_vector
.global _xtensa_level5_handler
.type _xtensa_level5_vector, @function
.align 4
_xtensa_level5_vector:
wsr a0, EXCSAVE_5 /* Preserve a0 */
call0 _xtensa_level5_handler /* Call level 5 interrupt handling */
/* Never returns here - call0 is used as a jump */
.end literal_prefix
.size _xtensa_level5_vector, . - _xtensa_level5_vector
#endif
#if CONFIG_XTENSA_EXCM_LEVEL >= 6
.begin literal_prefix .xtensa_level6_vector
.section .xtensa_level6_vector.text, "ax"
.global _xtensa_level6_vector
.global _xtensa_level6_handler
.type _xtensa_level6_vector, @function
.align 4
_xtensa_level6_vector:
wsr a0, EXCSAVE_6 /* Preserve a0 */
call0 _xtensa_level6_handler /* Call level 6 interrupt handling */
/* Never returns here - call0 is used as a jump */
.end literal_prefix
.size _xtensa_level6_vector, . - _xtensa_level6_vector
#endif
.end

View File

@ -40,7 +40,7 @@ HEAD_CSRC = esp32_start.c
# Common XTENSA files (arch/xtensa/src/common)
CMN_ASRCS = xtensa_irq.S
CMN_ASRCS = xtensa_irq.S xtensa_vectors.S
CMN_CSRCS = xtensa_assert.c xtensa_copystate.c
CMN_CSRCS += xtensa_createstack.c xtensa_exit.c xtensa_idle.c
CMN_CSRCS += xtensa_initialize.c xtensa_initialstate.c

View File

@ -21,13 +21,13 @@ SECTIONS
. = 0x0;
KEEP(*(.WindowVectors.text));
. = 0x180;
KEEP(*(.Level2InterruptVector.text));
KEEP(*(.xtensa_level2_vector.text));
. = 0x1c0;
KEEP(*(.Level3InterruptVector.text));
KEEP(*(.xtensa_level3_vector.text));
. = 0x200;
KEEP(*(.Level4InterruptVector.text));
KEEP(*(.xtensa_level4_vector.text));
. = 0x240;
KEEP(*(.Level5InterruptVector.text));
KEEP(*(.xtensa_level5_vector.text));
. = 0x280;
KEEP(*(.DebugExceptionVector.text));
. = 0x2c0;

View File

@ -383,14 +383,14 @@ PROVIDE ( ld_sched_params = 0x3ffb96c0 );
PROVIDE ( ld_sync_train_channels = 0x3ff98a3c );
PROVIDE ( __ledf2 = 0x40063704 );
PROVIDE ( __lesf2 = 0x400633c0 );
PROVIDE ( _Level2FromVector = 0x40000954 );
PROVIDE ( _Level2Vector = 0x40000180 );
PROVIDE ( _Level3FromVector = 0x40000a28 );
PROVIDE ( _Level3Vector = 0x400001c0 );
PROVIDE ( _Level4FromVector = 0x40000af8 );
PROVIDE ( _Level4Vector = 0x40000200 );
PROVIDE ( _Level5FromVector = 0x40000c68 );
PROVIDE ( _Level5Vector = 0x40000240 );
PROVIDE ( _xtensa_level2_from = 0x40000954 );
PROVIDE ( _xtensa_level2_vector = 0x40000180 );
PROVIDE ( _xtensa_level3_from = 0x40000a28 );
PROVIDE ( _xtensa_level3_vector = 0x400001c0 );
PROVIDE ( _xtensa_level4_from = 0x40000af8 );
PROVIDE ( _xtensa_level4_vector = 0x40000200 );
PROVIDE ( _xtensa_level5_from = 0x40000c68 );
PROVIDE ( _xtensa_level5_vector = 0x40000240 );
PROVIDE ( _LevelOneInterrupt = 0x40000835 );
PROVIDE ( _link_r = 0x4000bc9c );
PROVIDE ( llc_default_handler = 0x3ff98b3c );