blob: 907adfc488b3e7f92fd116613d6eb2685f34f9ff (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*
* 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 <cpuport.h>
#include <isa_ext.h>
#define RISCV_ISA_WORD_BITS (sizeof(rt_ubase_t) * 8)
#define RISCV_ISA_WORDS ((RISCV_ISA_EXT_MAX + RISCV_ISA_WORD_BITS - 1) / \
RISCV_ISA_WORD_BITS)
static rt_ubase_t isa_map[RISCV_ISA_WORDS];
void riscv_isa_ext_set_raw(rt_uint32_t isa)
{
if (isa < RISCV_ISA_EXT_MAX)
{
isa_map[isa / RISCV_ISA_WORD_BITS] |=
(rt_ubase_t)1 << (isa % RISCV_ISA_WORD_BITS);
rt_hw_wmb();
}
}
void riscv_isa_ext_clear_raw(rt_uint32_t isa)
{
if (isa < RISCV_ISA_EXT_MAX)
{
isa_map[isa / RISCV_ISA_WORD_BITS] &=
~((rt_ubase_t)1 << (isa % RISCV_ISA_WORD_BITS));
rt_hw_wmb();
}
}
rt_bool_t riscv_isa_ext_test_raw(rt_uint32_t isa)
{
rt_hw_rmb();
return isa < RISCV_ISA_EXT_MAX &&
!!(isa_map[isa / RISCV_ISA_WORD_BITS] &
((rt_ubase_t)1 << (isa % RISCV_ISA_WORD_BITS)));
}
|