target/riscv: Add basic vmstate description of CPU
Add basic CPU state description to the newly created machine.c Signed-off-by: Yifei Jiang <jiangyifei@huawei.com> Signed-off-by: Yipeng Yin <yinyipeng1@huawei.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-id: 20201026115530.304-3-jiangyifei@huawei.com Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
284d697c74
commit
f7697f0e62
@ -22,6 +22,7 @@
|
|||||||
#include "qemu/ctype.h"
|
#include "qemu/ctype.h"
|
||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
|
#include "internals.h"
|
||||||
#include "exec/exec-all.h"
|
#include "exec/exec-all.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
@ -498,13 +499,6 @@ static void riscv_cpu_init(Object *obj)
|
|||||||
cpu_set_cpustate_pointers(cpu);
|
cpu_set_cpustate_pointers(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_USER_ONLY
|
|
||||||
static const VMStateDescription vmstate_riscv_cpu = {
|
|
||||||
.name = "cpu",
|
|
||||||
.unmigratable = 1,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static Property riscv_cpu_properties[] = {
|
static Property riscv_cpu_properties[] = {
|
||||||
DEFINE_PROP_BOOL("i", RISCVCPU, cfg.ext_i, true),
|
DEFINE_PROP_BOOL("i", RISCVCPU, cfg.ext_i, true),
|
||||||
DEFINE_PROP_BOOL("e", RISCVCPU, cfg.ext_e, false),
|
DEFINE_PROP_BOOL("e", RISCVCPU, cfg.ext_e, false),
|
||||||
|
@ -38,6 +38,10 @@ target_ulong fclass_d(uint64_t frs1);
|
|||||||
#define SEW32 2
|
#define SEW32 2
|
||||||
#define SEW64 3
|
#define SEW64 3
|
||||||
|
|
||||||
|
#ifndef CONFIG_USER_ONLY
|
||||||
|
extern const VMStateDescription vmstate_riscv_cpu;
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline uint64_t nanbox_s(float32 f)
|
static inline uint64_t nanbox_s(float32 f)
|
||||||
{
|
{
|
||||||
return f | MAKE_64BIT_MASK(32, 32);
|
return f | MAKE_64BIT_MASK(32, 32);
|
||||||
|
74
target/riscv/machine.c
Normal file
74
target/riscv/machine.c
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* RISC-V VMState Description
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 Huawei Technologies Co., Ltd
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms and conditions of the GNU General Public License,
|
||||||
|
* version 2 or later, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include "cpu.h"
|
||||||
|
#include "qemu/error-report.h"
|
||||||
|
#include "sysemu/kvm.h"
|
||||||
|
#include "migration/cpu.h"
|
||||||
|
|
||||||
|
const VMStateDescription vmstate_riscv_cpu = {
|
||||||
|
.name = "cpu",
|
||||||
|
.version_id = 1,
|
||||||
|
.minimum_version_id = 1,
|
||||||
|
.fields = (VMStateField[]) {
|
||||||
|
VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32),
|
||||||
|
VMSTATE_UINT64_ARRAY(env.fpr, RISCVCPU, 32),
|
||||||
|
VMSTATE_UINTTL(env.pc, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.load_res, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.load_val, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.frm, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.badaddr, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.guest_phys_fault_addr, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.priv_ver, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.vext_ver, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.misa, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.misa_mask, RISCVCPU),
|
||||||
|
VMSTATE_UINT32(env.features, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.priv, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.virt, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.resetvec, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.mhartid, RISCVCPU),
|
||||||
|
VMSTATE_UINT64(env.mstatus, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.mip, RISCVCPU),
|
||||||
|
VMSTATE_UINT32(env.miclaim, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.mie, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.mideleg, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.sptbr, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.satp, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.sbadaddr, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.mbadaddr, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.medeleg, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.stvec, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.sepc, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.scause, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.mtvec, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.mepc, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.mcause, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.mtval, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.scounteren, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.mcounteren, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.sscratch, RISCVCPU),
|
||||||
|
VMSTATE_UINTTL(env.mscratch, RISCVCPU),
|
||||||
|
VMSTATE_UINT64(env.mfromhost, RISCVCPU),
|
||||||
|
VMSTATE_UINT64(env.mtohost, RISCVCPU),
|
||||||
|
VMSTATE_UINT64(env.timecmp, RISCVCPU),
|
||||||
|
|
||||||
|
VMSTATE_END_OF_LIST()
|
||||||
|
}
|
||||||
|
};
|
@ -27,7 +27,8 @@ riscv_ss.add(files(
|
|||||||
riscv_softmmu_ss = ss.source_set()
|
riscv_softmmu_ss = ss.source_set()
|
||||||
riscv_softmmu_ss.add(files(
|
riscv_softmmu_ss.add(files(
|
||||||
'pmp.c',
|
'pmp.c',
|
||||||
'monitor.c'
|
'monitor.c',
|
||||||
|
'machine.c'
|
||||||
))
|
))
|
||||||
|
|
||||||
target_arch += {'riscv': riscv_ss}
|
target_arch += {'riscv': riscv_ss}
|
||||||
|
Loading…
Reference in New Issue
Block a user