Skip to content

Commit 55eee32

Browse files
committed
tests: relocate ctx_early_tricore under sdk_suite whitebox
- Keep the TriCore-only grey-box early-context check out of the SDK suite
1 parent 87d8788 commit 55eee32

3 files changed

Lines changed: 99 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
ARCH ?= tricore
2+
ROOT := ../../../..
3+
TARGET := ctx_early_tricore_test.elf
4+
5+
INTEG_KERNEL_EXTRA_CFLAGS := -DULMK_CSA_CTX_EARLY_TEST=1
6+
INTEG_KERNEL_EXTRA_SRCS := $(CURDIR)/ctx_early_tricore_kernel.c
7+
8+
TEST_SRCS := \
9+
$(ROOT)/tests/test_printk.c \
10+
ctx_early_tricore_test.c
11+
12+
SENTINELS := "ctx_early_tricore: PASS"
13+
14+
QEMU_TIMEOUT := 60
15+
16+
include $(ROOT)/tests/integ_common.mk
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* TriCore CSA early context test — kernel-side (runs before MPU enable).
4+
*/
5+
6+
#include <stdint.h>
7+
#include <ulmk/microkernel.h>
8+
#include <ulmk_arch.h>
9+
#include <kernel/include/ulmk_printk.h>
10+
11+
#define EXPECTED_ARG ((void *)0xC0FFEE42u)
12+
13+
static volatile uintptr_t g_ctx_early_result;
14+
15+
static ulmk_arch_ctx_t g_ctx_root;
16+
static ulmk_arch_ctx_t g_ctx_worker;
17+
static uint8_t g_worker_stack[2048] __attribute__((aligned(8)));
18+
19+
static void worker_fn(void *arg)
20+
{
21+
g_ctx_early_result = (uintptr_t)arg;
22+
ulmk_arch_ctx_switch(&g_ctx_worker, &g_ctx_root);
23+
for (;;)
24+
;
25+
}
26+
27+
void csa_ctx_run_early(void)
28+
{
29+
g_ctx_early_result = 0u;
30+
31+
ulmk_arch_ctx_init(&g_ctx_worker,
32+
worker_fn,
33+
EXPECTED_ARG,
34+
(uintptr_t)(g_worker_stack + sizeof(g_worker_stack)),
35+
ULMK_PRIV_KERNEL);
36+
37+
ulmk_arch_ctx_switch(&g_ctx_root, &g_ctx_worker);
38+
39+
if (g_ctx_early_result == (uintptr_t)EXPECTED_ARG)
40+
ulmk_printk("ctx_early_tricore: early arg pass — OK\n");
41+
else
42+
ulmk_printk("ctx_early_tricore: early arg pass — FAIL\n");
43+
44+
ulmk_arch_ctx_free(&g_ctx_worker);
45+
ulmk_arch_ctx_init(&g_ctx_worker,
46+
worker_fn,
47+
EXPECTED_ARG,
48+
(uintptr_t)(g_worker_stack + sizeof(g_worker_stack)),
49+
ULMK_PRIV_KERNEL);
50+
ulmk_arch_ctx_switch(&g_ctx_root, &g_ctx_worker);
51+
ulmk_arch_ctx_free(&g_ctx_worker);
52+
}
53+
54+
int csa_ctx_early_passed(void)
55+
{
56+
return g_ctx_early_result == (uintptr_t)EXPECTED_ARG;
57+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* TriCore CSA early context fabrication — userspace sentinel.
4+
* Core path runs in ctx_early_tricore_kernel.c before MPU enable.
5+
*/
6+
7+
#include <stdint.h>
8+
#include "../../../test_support.h"
9+
#include <ulmk/microkernel.h>
10+
11+
extern int csa_ctx_early_passed(void);
12+
13+
void ulmk_root_thread(const ulmk_boot_info_t *info)
14+
{
15+
(void)info;
16+
17+
ulmk_printk("ctx_early_tricore: start\n");
18+
19+
if (csa_ctx_early_passed()) {
20+
ulmk_printk("ctx_early_tricore: PASS\n");
21+
ulmk_sim_exit(0);
22+
}
23+
24+
ulmk_printk("ctx_early_tricore: FAIL\n");
25+
ulmk_sim_exit(1);
26+
}

0 commit comments

Comments
 (0)