Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions arch/tricore/include/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@
__val; \
})

/* Return from a handler that the trap or interrupt vector entered with
* jli, to the vector code at A11.
*/

#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
# define tricore_jump_backto_link() __asm__ volatile ("ji a11" : : : "a11")
#else
# define tricore_jump_backto_link() __asm__ volatile ("ji %a11")
#endif

/****************************************************************************
* Public Types
****************************************************************************/
Expand Down
7 changes: 5 additions & 2 deletions arch/tricore/include/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,12 @@

#define TRICORE_SRCNUM_PER_GPSR 8
#define TRICORE_SRC2IRQ(src_addr) \
(((uintptr_t)(src_addr) - (uintptr_t)&MODULE_SRC) / 4)
(((uintptr_t)(src_addr) - TRICORE_SRC_BASE) / 4)
#define TRICORE_IRQ2SRC(irq) \
((volatile uint32_t *)(TRICORE_SRC_BASE + (irq) * 4))
#define TRICORE_GPSR_IRQNUM(src_cpu, dest_cpu) \
TRICORE_SRC2IRQ(&SRC_GPSR00 + src_cpu * 8 + dest_cpu)
TRICORE_SRC2IRQ(TRICORE_SRC_GPSR_BASE + \
((src_cpu) * TRICORE_SRCNUM_PER_GPSR + (dest_cpu)) * 4)

/* For use with EABI and floating point, the stack must be aligned to 8-byte
* addresses.
Expand Down
18 changes: 18 additions & 0 deletions arch/tricore/include/tc3xx/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@

#define TRICORE_UART_RX_IRQ 21

/* Interrupt router: the IRQ number is the index of the service request
* control (SRC) register from TRICORE_SRC_BASE.
*/

#define TRICORE_SRC_BASE 0xf0038000 /* SRC_CPU0SB, IRQ 0 */
#define TRICORE_SRC_GPSR_BASE 0xf0038990 /* SRC_GPSR0SR0 */
#define TRICORE_INT_SRB_BASE 0xf0037010 /* INT_SRB0 */

#define TRICORE_SRC_SRPN_MASK 0xff /* Service request priority */
#define TRICORE_SRC_SRE (1 << 10) /* Service request enable */
#define TRICORE_SRC_TOS_SHIFT 11 /* Type of service (core) */
#define TRICORE_SRC_TOS_MASK (0x7 << TRICORE_SRC_TOS_SHIFT)
#define TRICORE_SRC_CLRR (1 << 25) /* Clear request */

/* TOS of a core: 0 is CPU0, 1 is the DMA, 2 to 6 are CPU1 to CPU5 */

#define TRICORE_SRC_TOS_CPU(n) ((n) == 0 ? 0 : (n) + 1)

/****************************************************************************
* Public Types
****************************************************************************/
Expand Down
20 changes: 20 additions & 0 deletions arch/tricore/include/tc4xx/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@

#define TRICORE_UART_RX_IRQ 173

/* Interrupt router: the IRQ number is the index of the service request
* control (SRC) register from TRICORE_SRC_BASE.
*/

#define TRICORE_SRC_BASE 0xf4432000 /* SRC_CPU0SB, IRQ 0 */
#define TRICORE_SRC_GPSR_BASE 0xf4433460 /* SRC_GPSR0SR0 */
#define TRICORE_INT_SRB_BASE 0xf4430b00 /* INT_SRB0 */

#define TRICORE_SRC_SRPN_MASK 0xff /* Service request priority */
#define TRICORE_SRC_VM_MASK (0x7 << 8) /* Virtual machine */
#define TRICORE_SRC_CS (1 << 11) /* Set by the CSRM core */
#define TRICORE_SRC_TOS_SHIFT 12 /* Type of service (core) */
#define TRICORE_SRC_TOS_MASK (0xf << TRICORE_SRC_TOS_SHIFT)
#define TRICORE_SRC_SRE (1 << 23) /* Service request enable */
#define TRICORE_SRC_CLRR (1 << 25) /* Clear request */

/* TOS of a core: 0 to 5 are CPU0 to CPU5, 6 is the CSRM core */

#define TRICORE_SRC_TOS_CPU(n) (n)

/****************************************************************************
* Public Types
****************************************************************************/
Expand Down
19 changes: 19 additions & 0 deletions arch/tricore/src/common/gnu/tricore_vectors.S
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
* so is %sp when the trap switched to the interrupt stack. Without a pool
* the core stops in tricore_fcu_entry.
*
* The interrupt vector saves the lower context and enters
* tricore_doirq the same way. The startup code sets the priority bits
* of BIV, so every interrupt priority enters this one vector.
*
* tasking/tricore_vectors.asm is the same code in the TASKING syntax.
****************************************************************************/

Expand Down Expand Up @@ -79,6 +83,13 @@ tricore_trap_vectors_cpu\cpu:
TRAPTAB 4
TRAPTAB 5

.section .intvec, "ax", %progbits
.p2align 5
.global tricore_int_vector
tricore_int_vector:
svlcx
j tricore_int_entry

/* struct tricore_trap_s: taddr at 0, tid at 4, tclass at 5, tcpu at 6 */

.macro TRAPENTRY name, handler
Expand Down Expand Up @@ -107,6 +118,14 @@ tricore_trap_vectors_cpu\cpu:
TRAPENTRY tricore_trap_entry, tricore_trapcall
TRAPENTRY tricore_syscall_entry, tricore_svcall

.type tricore_int_entry, %function
tricore_int_entry:
movh.a %a2, hi:tricore_doirq
lea %a2, [%a2]lo:tricore_doirq
jli %a2
rslcx
rfe

.type tricore_ctx_entry, %function
tricore_ctx_entry:
jeq %d15, 4, tricore_fcu_entry
Expand Down
16 changes: 16 additions & 0 deletions arch/tricore/src/common/tasking/tricore_vectors.asm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

.extern tricore_trapcall
.extern tricore_svcall
.extern tricore_doirq
.extern tricore_fcu_recover
.extern g_tricore_fcu_pool

Expand Down Expand Up @@ -67,6 +68,14 @@ label:
TRAPTAB 4, tricore_trap_vectors_cpu4
TRAPTAB 5, tricore_trap_vectors_cpu5

.sdecl ".text.intvec",code,protect
.sect ".text.intvec"
.align 32
.global tricore_int_vector
tricore_int_vector:
svlcx
j tricore_int_entry

; struct tricore_trap_s: taddr at 0, tid at 4, tclass at 5, tcpu at 6

TRAPENTRY .macro name, handler
Expand Down Expand Up @@ -94,6 +103,13 @@ name:
TRAPENTRY tricore_trap_entry, tricore_trapcall
TRAPENTRY tricore_syscall_entry, tricore_svcall

tricore_int_entry:
movh.a a2, #@HIS(tricore_doirq)
lea a2, [a2]@LOS(tricore_doirq)
jli a2
rslcx
rfe

tricore_ctx_entry:
jeq d15, #4, tricore_fcu_entry
Comment thread
xiaoxiang781216 marked this conversation as resolved.
Resolved
svlcx
Expand Down
34 changes: 18 additions & 16 deletions arch/tricore/src/common/tricore_doirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,30 @@

#include "tricore_internal.h"

/* The interrupt entry still uses the iLLD until it is native */

#include <IfxCpu_reg.h>
#include <Ifx_Ssw_Compilers.h>
#include <Compilers/Compilers.h>
#include <IfxCpu_Intrinsics.h>

/****************************************************************************
* Public Functions
****************************************************************************/

IFX_INTERRUPT_INTERNAL(tricore_doirq, 0, 255)
/****************************************************************************
* Name: tricore_doirq
*
* Description:
* Common interrupt handler, entered from the interrupt vector in
* tricore_vectors.S/.asm with the lower context saved.
*
****************************************************************************/

void tricore_doirq(void)
{
struct tcb_s **running_task = &g_running_tasks[this_cpu()];
struct tcb_s *tcb = this_task();

#ifdef CONFIG_SUPPRESS_INTERRUPTS
PANIC();
#else
Ifx_CPU_ICR icr;
uintptr_t *regs;

icr.U = tricore_mfcr(CPU_ICR);
regs = tricore_csa2addr(tricore_mfcr(CPU_PCXI));
int irq = NDX_TO_IRQ(tricore_mfcr(TRICORE_CPU_ICR) &
TRICORE_ICR_CCPN_MASK);
uintptr_t *regs = tricore_csa2addr(tricore_mfcr(TRICORE_CPU_PCXI));

if (*running_task != NULL)
{
Expand All @@ -83,9 +83,9 @@ IFX_INTERRUPT_INTERNAL(tricore_doirq, 0, 255)

/* Deliver the IRQ */

tricore_ack_irq(NDX_TO_IRQ(icr.B.CCPN));
tricore_ack_irq(irq);

irq_dispatch(NDX_TO_IRQ(icr.B.CCPN), regs);
irq_dispatch(irq, regs);

/* Check for a context switch. */

Expand Down Expand Up @@ -113,7 +113,7 @@ IFX_INTERRUPT_INTERNAL(tricore_doirq, 0, 255)

*running_task = tcb;

tricore_mtcr(CPU_PCXI, tricore_addr2csa(tcb->xcp.regs));
tricore_mtcr(TRICORE_CPU_PCXI, tricore_addr2csa(tcb->xcp.regs));
UP_ISB();
}

Expand All @@ -128,4 +128,6 @@ IFX_INTERRUPT_INTERNAL(tricore_doirq, 0, 255)
(*running_task)->xcp.regs = NULL;
board_autoled_off(LED_INIRQ);
#endif

tricore_jump_backto_link();
}
1 change: 1 addition & 0 deletions arch/tricore/src/common/tricore_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ extern uintptr_t _eheap[]; /* End+1 of .heap */
/* Interrupt ****************************************************************/

void tricore_ack_irq(int irq);
void tricore_doirq(void);

/* Signal handling **********************************************************/

Expand Down
Loading
Loading