Skip to content

Commit 3c2b7df

Browse files
committed
Add LX8 support for > 32 interrupts
Also fix inconsistent SWPRI define in interrupt handler
1 parent 3726d79 commit 3c2b7df

10 files changed

Lines changed: 305 additions & 62 deletions

ports/xtensa/xcc/inc/xtensa_context.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,10 @@ XSTRUCT_END(XtExcFrame)
388388
#define XT_USE_INT_WRAPPER 0
389389
#endif
390390

391+
#if XCHAL_HAVE_XEA2 && (XCHAL_NUM_INTERRUPTS > 32) && (defined XT_USE_SWPRI)
392+
#error "Software prioritization of interrupts (XT_USE_SWPRI) not supported for XEA2 with > 32 interrupts."
393+
#endif
394+
391395
#if XCHAL_HAVE_XEA3
392396
#ifdef XT_USE_SWPRI
393397
//#warning "Software prioritization of interrupts (XT_USE_SWPRI) not supported for XEA3."

ports/xtensa/xcc/inc/xtensa_rtos.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ To enable interrupt/exception hooks, compile the RTOS with '-DXT_INTEXC_HOOKS'.
181181
#define XT_INTEXC_HOOK_NUM (1 + XCHAL_NUM_INTLEVELS + XCHAL_HAVE_NMI)
182182

183183
#ifndef __ASSEMBLER__
184+
#if XCHAL_HAVE_XEA2 && (XCHAL_NUM_INTERRUPTS > 32)
185+
typedef uint32_t (*XT_INTEXC_HOOK)(uint32_t cause, uint32_t block);
186+
#else
184187
typedef uint32_t (*XT_INTEXC_HOOK)(uint32_t cause);
188+
#endif
185189
extern volatile XT_INTEXC_HOOK _xt_intexc_hooks[XT_INTEXC_HOOK_NUM];
186190
#endif
187191

ports/xtensa/xcc/inc/xtensa_timer.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,19 @@ Otherwise select the first low or medium priority interrupt timer available.
108108
#define XT_TIMER_INTPRI XCHAL_INT_LEVEL(XT_TIMER_INTNUM)
109109

110110
#if XCHAL_HAVE_XEA2
111-
#define XT_TIMER_INTEN (1 << XT_TIMER_INTNUM)
111+
/*
112+
* Xtensa LX8 supports up to 128 interrupts whereas LX7 supports up to 32.
113+
*
114+
* Redefine the legacy XT_TIMER_INTEN (which limited the interrupt number to
115+
* be in the lower 32 or lower 64 bits depending on data type) as two defines
116+
* describing the INTEN bit within a 32-bit component and a 4-block component,
117+
* where each block contains a group of 32 interrupt bits.
118+
*
119+
* Name changes are intentional such that any dependencies are caught at
120+
* compile-time and are found regardless of timer configuration.
121+
*/
122+
#define XT_TIMER_INTEN_BIT (1 << (XT_TIMER_INTNUM & 31U))
123+
#define XT_TIMER_INTEN_BLK (XT_TIMER_INTNUM >> 5)
112124
#endif
113125

114126
#if XT_TIMER_INDEX == 0

ports/xtensa/xcc/readme_threadx.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ Application Defines (preprocessor macros definable with the -D option):
382382
higher bit numbers over those with lower bit
383383
numbers at the same level. This works only for
384384
low and medium priority interrupts that can be
385-
dispatched to C handlers.
385+
dispatched to C handlers on either NX cores or
386+
on LX cores with 32 or fewer interrupts.
386387

387388
TX_SYSTEM_STACK_SIZE=n Specify the size of the interrupt stack, which
388389
is the stack that all interrupt handlers switch

ports/xtensa/xcc/src/tx_clib_lock.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ TX_MUTEX clib_lock_mutex;
6666
void
6767
__malloc_lock (struct _reent * ptr)
6868
{
69+
(void) ptr;
70+
6971
if (_tx_thread_system_state != TX_INITIALIZE_IS_FINISHED) {
7072
return;
7173
}
@@ -80,6 +82,8 @@ __malloc_lock (struct _reent * ptr)
8082
void
8183
__malloc_unlock (struct _reent * ptr)
8284
{
85+
(void) ptr;
86+
8387
if (_tx_thread_system_state != TX_INITIALIZE_IS_FINISHED) {
8488
return;
8589
}
@@ -99,6 +103,8 @@ __malloc_unlock (struct _reent * ptr)
99103
void
100104
__env_lock (struct _reent * ptr)
101105
{
106+
(void) ptr;
107+
102108
if (_tx_thread_system_state != TX_INITIALIZE_IS_FINISHED) {
103109
return;
104110
}
@@ -113,6 +119,8 @@ __env_lock (struct _reent * ptr)
113119
void
114120
__env_unlock (struct _reent * ptr)
115121
{
122+
(void) ptr;
123+
116124
if (_tx_thread_system_state != TX_INITIALIZE_IS_FINISHED) {
117125
return;
118126
}

ports/xtensa/xcc/src/tx_initialize_low_level.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ VOID _tx_initialize_low_level(VOID)
8080

8181
/* Disable interrupts - don't want any that interact with ThreadX yet. */
8282
TX_DISABLE
83+
/* Suppress compiler warning about set but not used variable. */
84+
(void) interrupt_save;
8385

8486
/*
8587
Disable stack limit checking if present. Whatever was set up earlier

ports/xtensa/xcc/src/xtensa_context.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ _xt_context_save:
131131
s32i a3, sp, XT_STK_ATOMCTL
132132
#endif
133133

134-
#if XT_USE_SWPRI
134+
#ifdef XT_USE_SWPRI
135135
/* Save virtual priority mask */
136136
movi a3, _xt_vpri_mask
137137
l32i a3, a3, 0
@@ -318,7 +318,7 @@ _xt_context_restore:
318318

319319
ret
320320

321-
#endif /* XCHAL_HAVE_XEA3 */
321+
#endif /* XCHAL_HAVE_XEA2 */
322322

323323

324324
/*******************************************************************************

ports/xtensa/xcc/src/xtensa_intr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
Copyright (c) 2006-2019 Cadence Design Systems Inc.
2+
Copyright (c) 2006-2023 Cadence Design Systems Inc.
33
44
Permission is hereby granted, free of charge, to any person obtaining
55
a copy of this software and associated documentation files (the
@@ -80,7 +80,7 @@ xt_exc_handler xt_set_exception_handler(uint32_t n, xt_exc_handler f)
8080

8181
#if XCHAL_HAVE_INTERRUPTS
8282

83-
#if XCHAL_HAVE_XEA2
83+
#if XCHAL_HAVE_XEA2 && (XCHAL_NUM_INTERRUPTS <= 32)
8484
/* Defined in xtensa_intr_asm.S */
8585
extern uint32_t _xt_intenable;
8686
extern uint32_t _xt_vpri_mask;
@@ -157,7 +157,7 @@ xt_handler xt_set_interrupt_handler(uint32_t n, xt_handler f, void * arg)
157157
*/
158158
void xt_interrupt_enable(uint32_t intnum)
159159
{
160-
#if XCHAL_HAVE_XEA2
160+
#if XCHAL_HAVE_XEA2 && (XCHAL_NUM_INTERRUPTS <= 32)
161161
uint32_t ps = XT_RSIL(15);
162162

163163
// New INTENABLE = (_xt_intenable | mask) & _xt_vpri_mask.
@@ -177,7 +177,7 @@ void xt_interrupt_enable(uint32_t intnum)
177177
*/
178178
void xt_interrupt_disable(uint32_t intnum)
179179
{
180-
#if XCHAL_HAVE_XEA2
180+
#if XCHAL_HAVE_XEA2 && (XCHAL_NUM_INTERRUPTS <= 32)
181181
uint32_t ps = XT_RSIL(15);
182182

183183
// New INTENABLE = (_xt_intenable & ~mask) & _xt_vpri_mask.

ports/xtensa/xcc/src/xtensa_intr_asm.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
-------------------------------------------------------------------------------
4646
*/
4747

48-
#if XCHAL_HAVE_XEA2
48+
#if XCHAL_HAVE_XEA2 && (XCHAL_NUM_INTERRUPTS <= 32)
4949

5050
.data
5151
.global _xt_intdata

0 commit comments

Comments
 (0)