Skip to content

feat(tricore): Initial tricore support#242

Open
miguelafsilva5 wants to merge 16 commits intomainfrom
feat/tricore
Open

feat(tricore): Initial tricore support#242
miguelafsilva5 wants to merge 16 commits intomainfrom
feat/tricore

Conversation

@miguelafsilva5
Copy link
Member

@miguelafsilva5 miguelafsilva5 commented Aug 29, 2025

PR Description

This PR introduces the initial support for Infineon Tricore architectures.
This PR requires #218 to support boot from flash with a non-unified memory model.
The current state of this port supports baremetal and freeRTOS guests in single or multicore setups. At the moment, each guest is given an unique ID, and each core only executes one guest.

The following list shows what is missing:

  • DMA virtualization/isolation
  • History re-write and commit clean up
  • CI integration
  • bao-demos integration

@miguelafsilva5 miguelafsilva5 force-pushed the feat/tricore branch 2 times, most recently from f92535a to 57284c8 Compare September 1, 2025 14:05
@danielRep danielRep force-pushed the feat/non-unified-mem branch from 9ad59e5 to 474545c Compare September 1, 2025 15:56
@miguelafsilva5 miguelafsilva5 force-pushed the feat/tricore branch 2 times, most recently from b9e1caf to 7da4f29 Compare September 3, 2025 12:51
@danielRep danielRep force-pushed the feat/non-unified-mem branch 2 times, most recently from 829c219 to 61b37aa Compare September 3, 2025 13:06
@miguelafsilva5 miguelafsilva5 force-pushed the feat/tricore branch 4 times, most recently from 0e5ea75 to bf61453 Compare September 8, 2025 09:37
@danielRep danielRep force-pushed the feat/non-unified-mem branch 2 times, most recently from 674ffd5 to 3d1e91a Compare September 8, 2025 11:01
@danielRep danielRep force-pushed the feat/non-unified-mem branch from 3d1e91a to 53e6ea9 Compare September 9, 2025 13:40
@miguelafsilva5 miguelafsilva5 force-pushed the feat/tricore branch 2 times, most recently from 44a2cbb to 3d6619f Compare September 10, 2025 10:18
Base automatically changed from feat/non-unified-mem to main September 10, 2025 13:32
@miguelafsilva5 miguelafsilva5 force-pushed the feat/tricore branch 6 times, most recently from bffccac to 661df87 Compare September 15, 2025 13:43
@miguelafsilva5 miguelafsilva5 force-pushed the feat/tricore branch 2 times, most recently from ba20ef7 to f2194f5 Compare September 24, 2025 10:31
Copy link
Member

@DavidMCerdeira DavidMCerdeira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a quick review.
For now the my main comments are regarding stale code comments and magic numbers, I don't think my comments address them all, please check them more carefully than I did.
There's also some instances of using platformed defined values that need to be made more general to handle multiple platforms.

Comment on lines 19 to 20
#define IPI_CPU_MSG (0x1460 / 4) /* TODO this is the first GPSR in TC49 */
#define GSPR_SRC_BASE (0x1460 / 4) /* TODO this is the first GPSR in TC49 */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to a platform defined

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IPI_CPU_MSG needs to stay in this file due to other core files. The other is fixed in 62b4555

Copy link
Member

@DavidMCerdeira DavidMCerdeira Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the problem with including platform.h for the correct IPI_CPU_MSG?
Otherwise this assumes all TC4 platforms have IPI_CPU_MSG in the same place

Copy link
Member

@DavidMCerdeira DavidMCerdeira Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IR_MAX_INTERRUPTS and GSPR_SRC_BASE were moved to the wrong file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a distraction. Moved them to a wrong file. Should be fixed in 8620639

Copy link
Member

@DavidMCerdeira DavidMCerdeira Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GSPR_SRC_BASE should be in src/platform/tc4dx/inc/plat/platform.h

Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Optimizations were replacing calls with jump-links, which in turn were using
more stack instead of CSAs. Increasing the stack size solved this problem.
Furthermore, refactored the unlock function to include memory in the
clobber list.

Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Copy link
Member

@DavidMCerdeira DavidMCerdeira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've finished my second pass
In comments were I suggest to consider something, I believe it's worth doing but open to discuss why we shouldn't

Comment on lines +92 to +93
accessen->WRA |= ACCESSEN_CPU0_MASK << (cpuid * 2);
accessen->RDA |= ACCESSEN_CPU0_MASK << (cpuid * 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to create a macro that takes cpuid as an argument and outputs the correct mask.
Something like ACCESSEN_CPU_MASK(c)

{
unsigned long temp = PROT_ODEF_MASK | PROT_OWEN_MASK;
temp |= (vm << PROT_VM_POS);
temp |= (cpu * 2 << PROT_TAGID_POS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I suggest a macro that takes cpuid as an argument and outputs the correct bits

bitmap_clear_consecutive(cpu()->arch.mpu.data_locked, 0, MPU_DATA_MAX_NUM_ENTRIES);

for (mpid_t mpid = 0; mpid < MPU_CODE_MAX_NUM_ENTRIES; mpid++) {
cpu()->arch.mpu.code_entries[mpid].mpid = mpid;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If mpid indexes the entry, why do we need to store mpid?


void mpu_enable(void)
{
csfr_corecon_write(2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic number, should also it should only set the relevant bit

}

csfr_cpu_pc_write(coreid, load_addr);
csfr_cpu_bootcon_write(coreid, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic number

Comment on lines +69 to +70
const struct plat_device dev_array[] = {
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving to seperate c module for the sake of readability

#include <platform.h>

#ifdef GENERATING_DEFS
uint32_t plat_ints[] = { 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider moving to its own module for the sake of readability

.int_addr = 0xF4430000,
.src_addr = 0xF4432000,
.GPSR_offset = 0x700,
.GPSR_size = (0xB00 + (8*4)) - 0x700,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic numbers

Comment on lines +1858 to +1864
#ifdef MEM_NON_UNIFIED
{
.base = 0xA0000000,
.size = 0x400000,
.perms = MEM_RX,
},
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add one this region if memory is non-unified?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, you can change the .mk file to have bao be either unified or non-unified. I can remove that, if it seems better to you.

Comment on lines +1871 to +1878
#ifndef MEM_NON_UNIFIED
{
// DLMU1
.base = 0x90080000,
.size = 0x80000,
.perms = MEM_RWX,
},
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this region if memory is unified?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, you can change the .mk file to have bao be either unified or non-unified. I can remove that, if it seems better to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants