Files
QEMU-S5L8950X/target/loongarch/csr.h
T
Yaya48 cf256aa081 Import QEMU upstream snapshot d2e570c
Upstream: https://gitlab.com/qemu-project/qemu.git

Upstream-Commit: d2e570cc0f97b936902a5b1b86b73c0f5998b475
2026-08-31 02:15:30 +02:00

40 lines
1.1 KiB
C

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (c) 2025 Loongson Technology Corporation Limited
*/
#ifndef TARGET_LOONGARCH_CSR_H
#define TARGET_LOONGARCH_CSR_H
#include "cpu-csr.h"
#define CSR_OFFSET(id) offsetof(CPUSysState, id)
#define CPU_CSR_OFFSET(id, vm_level) \
(offsetof(CPULoongArchState, sys_states[vm_level]) \
+ CSR_OFFSET(id))
typedef void (*GenCSRFunc)(void);
enum {
CSRFL_READONLY = (1 << 0),
CSRFL_EXITTB = (1 << 1),
CSRFL_IO = (1 << 2),
CSRFL_UNUSED = (1 << 3),
CSRFL_BASIC = (1 << 4),
};
typedef struct {
const char *name;
int offset;
int flags;
GenCSRFunc readfn;
GenCSRFunc writefn;
} CSRInfo;
CSRInfo *get_csr(unsigned int csr_num);
bool set_csr_flag(unsigned int csr_num, int flag);
static inline unsigned int get_csr_offset(const CSRInfo *csr, int vm_level)
{
return csr->offset + offsetof(CPULoongArchState, sys_states[vm_level]);
}
#endif /* TARGET_LOONGARCH_CSR_H */