-
Notifications
You must be signed in to change notification settings - Fork 350
Expand file tree
/
Copy pathcache.c
More file actions
53 lines (39 loc) · 1.11 KB
/
cache.c
File metadata and controls
53 lines (39 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-License-Identifier: BSD-3-Clause
/*
* Copyright(c) 2025 Intel Corporation.
*/
#include <sof/boot_test.h>
#include <zephyr/kernel.h>
#include <rtos/cache.h>
#include <zephyr/ztest.h>
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(sof_boot_test, LOG_LEVEL_DBG);
#define USER_STACKSIZE 2048
static struct k_thread user_thread;
static K_THREAD_STACK_DEFINE(user_stack, USER_STACKSIZE);
static void user_function(void *p1, void *p2, void *p3)
{
char stack_buf[64];
__ASSERT(k_is_user_context(), "isn't user");
LOG_INF("SOF thread %s (%s)",
k_is_user_context() ? "UserSpace!" : "privileged mode.",
CONFIG_BOARD_TARGET);
/*
* Use rtos/cache.h calls as these are also used by
* src/audio code.
*/
dcache_writeback_region(stack_buf, sizeof(stack_buf));
dcache_invalidate_region(stack_buf, sizeof(stack_buf));
}
static void test_user_thread_cache(void)
{
k_thread_create(&user_thread, user_stack, USER_STACKSIZE,
user_function, NULL, NULL, NULL,
-1, K_USER, K_MSEC(0));
k_thread_join(&user_thread, K_FOREVER);
}
ZTEST(sof_boot, user_space_cache)
{
test_user_thread_cache();
ztest_test_pass();
}