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
4 changes: 4 additions & 0 deletions arch/tricore/include/csfr.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@
#define TRICORE_CPU_PSW 0xfe04 /* Program Status Word */
#define TRICORE_CPU_PC 0xfe08 /* Program Counter */
#define TRICORE_CPU_CORE_ID 0xfe1c /* Core Identification */
#define TRICORE_CPU_BIV 0xfe20 /* Base Interrupt Vector */
#define TRICORE_CPU_BTV 0xfe24 /* Base Trap Vector */
#define TRICORE_CPU_ISP 0xfe28 /* Interrupt Stack Pointer */
#define TRICORE_CPU_ICR 0xfe2c /* Interrupt Control Register */
#define TRICORE_CPU_FCX 0xfe38 /* Free CSA List Head Pointer */
#define TRICORE_CPU_LCX 0xfe3c /* Free CSA List Limit Pointer */

/* Core configuration (TC1.8 only) */

#define TRICORE_CPU_CORECON 0xfe14 /* Core Control */
#define TRICORE_CPU_VCON0 0xb000 /* Virtualization Control 0 */

/* Performance counters */

Expand Down
2 changes: 2 additions & 0 deletions arch/tricore/src/cmake/chip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ if(CONFIG_ARCH_CHIP_TC3XX)
add_compile_options(--default-near-size=0)
add_compile_options(--cpu=tc39xb)
add_link_options(-Ctc39xb)
add_link_options(--user-provided-initialization-code)
else()
list(APPEND PLATFORM_FLAGS -mcpu=tc39xx -mtc162)
endif()
Expand All @@ -35,6 +36,7 @@ elseif(CONFIG_ARCH_CHIP_TC4XX)
add_compile_options(--misrac-version=2004 --user-mode=hypervisor)
add_compile_options(--default-near-size=0)
add_link_options(-Ctc4dx)
add_link_options(--user-provided-initialization-code)
else()
list(APPEND PLATFORM_FLAGS -mcpu=tc4DAx -mtc18)
endif()
Expand Down
25 changes: 23 additions & 2 deletions arch/tricore/src/cmake/tasking.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ set(ASMEXT
asm
CACHE INTERNAL "")

# The .asm sources go through the C preprocessor first, as the .S sources of
# GCC, so that they can use the configuration and the headers. ctc -Ep leaves
# no line markers, which the assembler does not take.

if(CMAKE_NINJA_FORCE_RESPONSE_FILE)
# With the response files that the top-level CMakeLists.txt forces for Ninja,
# the defines and includes are only in the response file, which also has the
# control program options that ctc does not take, so ctc only gets the -D, -U
# and -I options of it.

set(CMAKE_ASM_COMPILE_OBJECT
"grep -o -E -e \"-[DUI][^ ]+\" ${CMAKE_BINARY_DIR}/$RSP_FILE > <OBJECT>.opt"
"${TOOLCHAIN_PREFIX}ctc -f <OBJECT>.opt -Ep <SOURCE> -o <OBJECT>.src"
"<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -c <OBJECT>.src -o <OBJECT>"
)
else()
set(CMAKE_ASM_COMPILE_OBJECT
"${TOOLCHAIN_PREFIX}ctc -Ep <DEFINES> <INCLUDES> <SOURCE> -o <OBJECT>.src"
"<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -c <OBJECT>.src -o <OBJECT>"
)
endif()

if(CONFIG_OUTPUT_STRIP_PATHS)
# TASKING cctc has no -fmacro-prefix-map. Convert absolute source paths to
# relative paths by cd-ing to code root before compilation, so __FILE__ embeds
Expand Down Expand Up @@ -105,7 +127,6 @@ set(CMAKE_CXX_LINK_EXECUTABLE

# Architecture flags

add_compile_options(--lsl-core=vtc)
add_link_options(-v)
if(CONFIG_ARCH_CHIP_TC3XX)
add_compile_options($<$<COMPILE_LANGUAGE:C>:--iso=11>)
Expand Down Expand Up @@ -202,7 +223,7 @@ add_compile_options(--fp-model=2)
add_link_options(-lc_fpu)
add_link_options(-lfp_fpu)

add_link_options(--core=mpe:vtc)
add_link_options(--core=mpe:tc0)
add_link_options(--hex-format=s -mcrfiklsmnoduq)
add_link_options(-lrt)

Expand Down
19 changes: 3 additions & 16 deletions arch/tricore/src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ target_sources(nuttx PRIVATE tricore_doirq.c)

if(CONFIG_TRICORE_TOOLCHAIN_TASKING)
target_sources(nuttx PRIVATE tasking/tricore_vectors.${ASMEXT})
target_sources(nuttx PRIVATE tasking/tricore_head.${ASMEXT})
else()
target_sources(nuttx PRIVATE gnu/tricore_vectors.${ASMEXT})
target_sources(nuttx PRIVATE gnu/tricore_head.${ASMEXT})
endif()
target_compile_options(arch PRIVATE ${IFXFLAGS})
target_compile_options(nuttx PRIVATE ${IFXFLAGS})
Expand All @@ -98,23 +100,8 @@ target_include_directories(
# tricore_libc.c for details).

if(CONFIG_TRICORE_TOOLCHAIN_TASKING)
# iLLD calls _c_init, the TASKING copy table init, so take cinit.o from the
# toolchain C library. The rest of that library clashes with NuttX.

if(CONFIG_ARCH_TC1V8)
set(TASKING_LIBDIR tc18/dpfpu)
else()
set(TASKING_LIBDIR tc162)
endif()

get_filename_component(TASKING_BIN_DIR ${CMAKE_C_COMPILER} DIRECTORY)
execute_process(
COMMAND ${TASKING_BIN_DIR}/artc -x
${TASKING_BIN_DIR}/../lib/${TASKING_LIBDIR}/libc_fpu.a cinit.o
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
nuttx_add_kernel_library(c_fpu)
target_sources(c_fpu PRIVATE tricore_libc.c
${CMAKE_CURRENT_BINARY_DIR}/cinit.o)
target_sources(c_fpu PRIVATE tricore_libc.c)
target_link_options(nuttx PRIVATE
--library-directory=${CMAKE_CURRENT_BINARY_DIR})

Expand Down
18 changes: 3 additions & 15 deletions arch/tricore/src/common/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ else
endif

HEAD_ASRC += tricore_vectors$(ASMEXT)

HEAD_ASRC += tricore_head$(ASMEXT)
VPATH += common$(DELIM)$(TRICORE_SUBDIR)

ifeq ($(CONFIG_SCHED_BACKTRACE),y)
Expand Down Expand Up @@ -97,21 +99,7 @@ ifeq ($(CONFIG_TRICORE_TOOLCHAIN_TASKING),y)
tricore_libc$(OBJEXT): tricore_libc.c
$(call COMPILE, $<, $@)

# iLLD calls _c_init, the TASKING copy table init, so take cinit.o from
# the toolchain C library. The rest of that library clashes with NuttX.

ifeq ($(CONFIG_ARCH_TC1V8),y)
TASKING_LIBDIR = tc18$(DELIM)dpfpu
else
TASKING_LIBDIR = tc162
endif

TASKING_LIBC = $(C_COMPILER_DIR)..$(DELIM)lib$(DELIM)$(TASKING_LIBDIR)$(DELIM)libc_fpu$(LIBEXT)

cinit$(OBJEXT): $(TASKING_LIBC)
$(Q) artc -x $< cinit$(OBJEXT)

libc_fpu$(LIBEXT): tricore_libc$(OBJEXT) cinit$(OBJEXT)
libc_fpu$(LIBEXT): tricore_libc$(OBJEXT)
$(call ARCHIVE, $@, $^)

EXTRA_LIBS += libc_fpu$(LIBEXT)
Expand Down
18 changes: 13 additions & 5 deletions arch/tricore/src/common/ToolchainTasking.defs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,22 @@ OBJCOPY = echo
OBJDUMP = elfdump
ASMEXT = .asm

# The .asm sources are not run through the C preprocessor and include no
# headers, so they only depend on themselves.
# The .asm sources go through the C preprocessor first, as the .S sources
# of GCC, so that they can use the configuration and the headers. ctc -Ep
# leaves no line markers, which the assembler does not take.

define ASSEMBLE
$(ECHO_BEGIN)"AS: $1 "
$(Q) ctc -Ep $(filter -D% -U% -I%,$(subst -I ,-I,$(AFLAGS) $($(strip $1)_AFLAGS))) $1 -o $(basename $2).src
$(Q) $(CC) -c $(AFLAGS) $($(strip $1)_AFLAGS) $(basename $2).src -o $2
$(Q) $(call DELFILE, $(basename $2).src)
$(ECHO_END)
endef

%.dds: %.asm
$(Q) echo "$(OBJPATH)$(DELIM)$*$(OBJEXT): $<" > $@
$(Q) ctc -Em $(filter -D% -U% -I%,$(subst -I ,-I,$(CFLAGS))) $< -o $@
$(Q) sed -i "s|^$(notdir $*)\.o *:|$(OBJPATH)$(DELIM)$*$(OBJEXT):|" $@

ARCHOPTIMIZATION += --lsl-core=vtc
LDFLAGS += --lsl-core=vtc
ARCHOPTIMIZATION += --iso=99
ARCHOPTIMIZATION += --language=+gcc,+volatile,-strings,-kanji

Expand Down
Loading
Loading