From d47ef7561474aa768279a7523e3b415aaf46f1c3 Mon Sep 17 00:00:00 2001 From: Richard Yan Date: Wed, 29 Jan 2025 17:00:08 -0800 Subject: [PATCH] update idle kernel --- tests/regression/idle/common.h | 2 ++ tests/regression/idle/hello.c | 39 ++++++++++++++++++++++++++++++++ tests/regression/idle/kernel.cpp | 1 + 3 files changed, 42 insertions(+) create mode 100644 tests/regression/idle/hello.c diff --git a/tests/regression/idle/common.h b/tests/regression/idle/common.h index 5c84f3b7..c443474c 100644 --- a/tests/regression/idle/common.h +++ b/tests/regression/idle/common.h @@ -5,6 +5,8 @@ #define KERNEL_ARG_DEV_MEM_ADDR 0x9fff0000 #define DEV_SMEM_START_ADDR 0xff000000 +#define MARK_BEG() asm volatile ("slti x0, x1, -1047") +#define MARK_END() asm volatile ("slti x0, x1, -499") typedef struct { uint32_t dim_m; diff --git a/tests/regression/idle/hello.c b/tests/regression/idle/hello.c new file mode 100644 index 00000000..856f1acb --- /dev/null +++ b/tests/regression/idle/hello.c @@ -0,0 +1,39 @@ +#include +#include + +int main() { + int value32 = 4097; // Value for x32 + int value50 = -16778000; // Value for x50 + int value71 = 2147483647; // Value for x71 + int value125 = -2147483648; // Value for x125 + int sum; + + asm volatile ( + // Assign values to the registers + "mv x32, %1\n" + "mv x50, %2\n" + "mv x71, %3\n" + "mv x125, %4\n" + + // Sum the values in the registers + "add x32, x32, x50\n" // x32 = x32 + x50 + "add x32, x32, x71\n" // x32 = x32 + x71 + "add x32, x32, x125\n" // x32 = x32 + x125 + + // Move the result back to a C variable + "mv %0, x32\n" + : "=r" (sum) // Output + : "r" (value32), "r" (value50), "r" (value71), "r" (value125) // Inputs + : "x32", "x50", "x71", "x125" // Clobbered registers + ); + volatile bool test = *(&value125 + 4); + if (test) { + printf("hello world 1!"); + } else { + printf("hello world 2!"); + } + + // asm volatile (".insn r5 0, 0, 0, x101, x102, x103, x104, x105"); + + return sum; +} diff --git a/tests/regression/idle/kernel.cpp b/tests/regression/idle/kernel.cpp index 48c5a1a7..ce8f2f2b 100644 --- a/tests/regression/idle/kernel.cpp +++ b/tests/regression/idle/kernel.cpp @@ -53,6 +53,7 @@ void kernel_body(int task_id, kernel_arg_t *__UNIFORM__ arg) { asm volatile("li x29, 0xa0a0a0a0"); asm volatile("li x30, 0xa0a0a0a0"); asm volatile("li x31, 0xa0a0a0a0"); + MARK_BEG(); asm volatile("csrr a0, 0xcc1"); asm volatile("beqz a0, bar"); asm volatile("vx_tmc zero");