summaryrefslogtreecommitdiff
path: root/libcpu/risc-v/common/cpu_spinwait.c
blob: 628046ccde010731b65544e7d6e123353afdf603 (plain)
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
/*
 * Copyright (c) 2006-2025, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2025-04-20     GuEe-GUI     The first version
 */

#include <rthw.h>

#include <cpu.h>

rt_uint8_t riscv_spinwait_table = 0;

static int spinwait_cpu_boot(rt_uint32_t cpuid, rt_uint64_t entry)
{
    rt_hw_barrier();

    HWREG8(&riscv_spinwait_table) = RT_UINT8_MAX;
    rt_hw_cpu_dcache_ops(RT_HW_CACHE_FLUSH, &riscv_spinwait_table, sizeof(riscv_spinwait_table));

    return 0;
}

struct cpu_ops_t cpu_spinwait_ops =
{
    .method = "spinwait",
    .cpu_boot = spinwait_cpu_boot,
};