Skip to content

Commit e3e29b8

Browse files
committed
arch/tricore: early WDT hook, clear PSW.IS, board EndInit API
- Call board_wdt_disable_early before CSA init (standalone timeout) - Force PSW.IS=0 so bring-up never nests on a bad ISP - Declare ulmk_board_cpu_endinit_{clear,set} for EndInit CSFRs
1 parent 4d92c92 commit e3e29b8

4 files changed

Lines changed: 51 additions & 1 deletion

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Weak no-op — boards override with board_wdt_early.S (ji %a11 return).
4+
*/
5+
6+
.section .text.board_wdt_early, "ax"
7+
.weak ulmk_board_wdt_disable_early
8+
.type ulmk_board_wdt_disable_early, @function
9+
ulmk_board_wdt_disable_early:
10+
ji %a11
11+
.size ulmk_board_wdt_disable_early, . - ulmk_board_wdt_disable_early

arch/tricore/include/ulmk_arch.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,18 @@ void ulmk_kern_start(void);
203203
*/
204204
void ulmk_board_init(void);
205205

206+
/*
207+
* CPU EndInit unlock/relock for EndInit-protected CSFRs (BTV, BIV, ISP,
208+
* SYSCON.PROTEN, …). Board provides a strong implementation (WDT password
209+
* sequence). Weak no-ops in arch cover QEMU / boards without EndInit.
210+
*
211+
* OpenOCD's CBS_OCNTRL unlock makes these writes succeed without EndInit on
212+
* the flash path; button/PORST do not — without these hooks BTV/ISP stay at
213+
* reset defaults and the first SYSCALL class-4 traps (red ESR0).
214+
*/
215+
void ulmk_board_cpu_endinit_clear(void);
216+
void ulmk_board_cpu_endinit_set(void);
217+
206218
/*
207219
* ulmk_arch_init - one-time CPU and peripheral initialisation
208220
* Called by ulmk_kern_start() after ulmk_board_init() and after .data/.bss

arch/tricore/startup.S

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
.extern _small_data3_
2222
.extern _small_data4_
2323
.extern ulmk_kern_start
24+
.extern ulmk_board_wdt_disable_early
2425

2526
.section .text._start, "ax"
2627
.global _start
@@ -29,9 +30,34 @@ _start:
2930
/* 0. Interrupts off until the kernel unlocks them. */
3031
disable
3132

32-
/* 1. Supervisor stack */
33+
/*
34+
* Board hook: disable CPU0 + Safety WDT before CSA construction.
35+
* Default timeout can expire during the CSA loop on standalone reset
36+
* (OpenOCD reset-end pokes WDT only under OCDS). Weak stub is ji %a11.
37+
* No CALL (CSA not ready). ji needs a register operand; local .L labels
38+
* have no hi/lo reloc — use a global continue label.
39+
*/
40+
movh.a %a11, hi:_start_after_wdt
41+
lea %a11, [%a11] lo:_start_after_wdt
42+
movh.a %a2, hi:ulmk_board_wdt_disable_early
43+
lea %a2, [%a2] lo:ulmk_board_wdt_disable_early
44+
ji %a2
45+
.global _start_after_wdt
46+
_start_after_wdt:
47+
48+
/* 1. Supervisor stack + clear PSW.IS
49+
*
50+
* SSW / cold reset may leave PSW.IS=1. board_init runs before arch_init
51+
* programs ISP; an early class-4 with IS=1 then nests on a bad ISP and
52+
* cascades. Force IS=0 so A10 is the task/kernel stack throughout bring-up.
53+
*/
3354
movh.a %a10, hi:_ulmk_kernel_stack_top
3455
lea %a10, [%a10] lo:_ulmk_kernel_stack_top
56+
mfcr %d0, 0xFE04
57+
mov %d1, 0x200 /* PSW.IS */
58+
andn %d0, %d0, %d1
59+
mtcr 0xFE04, %d0
60+
isync
3561

3662
/* 2. CSA free list construction.
3763
*

cmake/arch_sources.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ if(ULMK_ARCH STREQUAL "tricore")
77
${ULMK_ARCH_DIR}/ctx_switch.S)
88
set(ULMK_ARCH_EXE_SOURCES
99
${ULMK_ARCH_DIR}/startup.S
10+
${ULMK_ARCH_DIR}/board_wdt_early_stub.S
1011
${ULMK_ARCH_DIR}/secondary.S
1112
${ULMK_ARCH_DIR}/vectors.S)
1213
elseif(ULMK_ARCH STREQUAL "riscv")

0 commit comments

Comments
 (0)