xref: /qemu/target/loongarch/csr.h (revision 513823e7521a09ed7ad1e32e6454bac3b2cbf52d)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (c) 2025 Loongson Technology Corporation Limited
4  */
5 
6 #ifndef TARGET_LOONGARCH_CSR_H
7 #define TARGET_LOONGARCH_CSR_H
8 
9 #include "cpu-csr.h"
10 
11 typedef void (*GenCSRFunc)(void);
12 enum {
13     CSRFL_READONLY = (1 << 0),
14     CSRFL_EXITTB   = (1 << 1),
15     CSRFL_IO       = (1 << 2),
16     CSRFL_UNUSED   = (1 << 3),
17 };
18 
19 typedef struct {
20     const char *name;
21     int offset;
22     int flags;
23     GenCSRFunc readfn;
24     GenCSRFunc writefn;
25 } CSRInfo;
26 
27 CSRInfo *get_csr(unsigned int csr_num);
28 bool set_csr_flag(unsigned int csr_num, int flag);
29 #endif /* TARGET_LOONGARCH_CSR_H */
30