Skip to content
Draft
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,13 @@ endif
ifeq ($(plat_mem),non_unified)
build_macros+=-DMEM_NON_UNIFIED
endif
ifeq ($(phys_irqs_only),y)
build_macros+=-DPHYS_IRQS_ONLY

ifeq ($(mmio_slave_side_prot),y)
build_macros+=-DMMIO_SLAVE_SIDE_PROT

ifneq ($(arch_mem_prot),mpu)
$(error mmio_slave_side_prot=y requires arch_mem_prot=mpu)
endif
endif

ifeq ($(CC_IS_GCC),y)
Expand Down Expand Up @@ -240,7 +245,8 @@ ifeq ($(CC_IS_GCC),y)
-Wmissing-prototypes -Wmissing-declarations \
-Wswitch-default -Wshadow -Wshadow=global \
-Wcast-qual -Wunused-macros \
-Wstrict-prototypes -Wunused-but-set-variable
-Wstrict-prototypes -Wunused-but-set-variable \
-Wno-multistatement-macros

override CFLAGS+=-Wno-unused-command-line-argument \
-pedantic -pedantic-errors
Expand Down
36 changes: 36 additions & 0 deletions scripts/arch/tricore/platform_defs_gen.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) Bao Project and Contributors. All rights reserved
*/

#include <stdio.h>
#include <platform.h>

extern uint32_t plat_ints[];
extern uint32_t plat_int_size;

void arch_platform_defs() {
unsigned int bitmap[64] = {0};
unsigned int count = plat_int_size;

for(int i = 0; i < count; i++){
unsigned int irq = plat_ints[i];
unsigned int index = irq / 32;
unsigned int bit = irq % 32;

if(index < 64 && bit < 32)
bitmap[index] |= 1UL << bit;
}

printf ("#define INTERRUPTS_COUNT %d\n", count);
printf("#define INTERRUPTS_BITMAP {\t");
for(int i = 0; i < 64; i++)
{
if(i && i % 4 == 0)
printf(" \\\n\t\t\t\t\t\t");
if(i != 63)
printf("0x%x, ", bitmap[i]);
else printf("0x%x }\n", bitmap[i]);
}

}
16 changes: 16 additions & 0 deletions src/arch/tricore/arch.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## SPDX-License-Identifier: Apache-2.0
## Copyright (c) Bao Project and Contributors. All rights reserved.

CROSS_COMPILE ?= tricore-elf-

clang_arch_target:=tricore-unknown-unknown-elf

arch-cppflags+=
#arch-cflags=-march=tc18
#arch-asflags=-march=tc18
arch-ldflags=

arch_mem_prot:=mpu
plat_mem:=non_unified
PAGE_SIZE:=64
mmio_slave_side_prot:=y
38 changes: 38 additions & 0 deletions src/arch/tricore/asm_defs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) Bao Project and Contributors. All rights reserved.
*/

#include <bao.h>
#include <cpu.h>
#include <vm.h>
#include <platform.h>

__attribute__((used)) static void cpu_defines(void)
{
DEFINE_SIZE(CPU_SIZE, struct cpu);

DEFINE_OFFSET(CPU_STACK_OFF, struct cpu, stack);
DEFINE_SIZE(CPU_STACK_SIZE, ((struct cpu*)NULL)->stack);

DEFINE_OFFSET(CPU_VCPU_OFF, struct cpu, vcpu);
}

__attribute__((used)) static void vcpu_defines(void)
{
DEFINE_SIZE(VCPU_ARCH_SIZE, struct vcpu_arch);
DEFINE_OFFSET(VCPU_REGS_OFF, struct vcpu, regs);
DEFINE_OFFSET(VCPU_VM_OFF, struct vcpu, vm);
DEFINE_OFFSET(VCPU_REGS_LOWER_CTX_OFF, struct vcpu, regs.lower_ctx);
DEFINE_OFFSET(REGS_A0_OFF, struct arch_regs, a0);
DEFINE_OFFSET(REGS_A1_OFF, struct arch_regs, a1);
DEFINE_OFFSET(REGS_A8_OFF, struct arch_regs, a8);
DEFINE_OFFSET(REGS_A9_OFF, struct arch_regs, a9);
DEFINE_SIZE(VCPU_REGS_SIZE, struct arch_regs);
}

__attribute__((used)) static void platform_defines(void)
{
DEFINE_OFFSET(PLAT_CPUNUM_OFF, struct platform, cpu_num);
DEFINE_OFFSET(PLAT_ARCH_OFF, struct platform, arch);
}
Loading
Loading