2022-06-06 14:42:52 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/*
|
|
|
|
* QEMU LoongArch CPU
|
|
|
|
*
|
|
|
|
* Copyright (c) 2021 Loongson Technology Corporation Limited
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
|
|
#include "qemu/log.h"
|
|
|
|
#include "qemu/qemu-print.h"
|
|
|
|
#include "qapi/error.h"
|
|
|
|
#include "qemu/module.h"
|
|
|
|
#include "sysemu/qtest.h"
|
|
|
|
#include "exec/exec-all.h"
|
|
|
|
#include "qapi/qapi-commands-machine-target.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "internals.h"
|
|
|
|
#include "fpu/softfloat-helpers.h"
|
2022-06-06 14:43:09 +02:00
|
|
|
#include "cpu-csr.h"
|
2022-06-06 14:42:52 +02:00
|
|
|
|
|
|
|
const char * const regnames[32] = {
|
|
|
|
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
|
|
|
|
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
|
|
|
|
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
|
|
|
|
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
|
|
|
|
};
|
|
|
|
|
|
|
|
const char * const fregnames[32] = {
|
|
|
|
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
|
|
|
|
"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
|
|
|
|
"f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
|
|
|
|
"f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const excp_names[] = {
|
|
|
|
[EXCCODE_INT] = "Interrupt",
|
|
|
|
[EXCCODE_PIL] = "Page invalid exception for load",
|
|
|
|
[EXCCODE_PIS] = "Page invalid exception for store",
|
|
|
|
[EXCCODE_PIF] = "Page invalid exception for fetch",
|
|
|
|
[EXCCODE_PME] = "Page modified exception",
|
|
|
|
[EXCCODE_PNR] = "Page Not Readable exception",
|
|
|
|
[EXCCODE_PNX] = "Page Not Executable exception",
|
|
|
|
[EXCCODE_PPI] = "Page Privilege error",
|
|
|
|
[EXCCODE_ADEF] = "Address error for instruction fetch",
|
|
|
|
[EXCCODE_ADEM] = "Address error for Memory access",
|
|
|
|
[EXCCODE_SYS] = "Syscall",
|
|
|
|
[EXCCODE_BRK] = "Break",
|
|
|
|
[EXCCODE_INE] = "Instruction Non-Existent",
|
|
|
|
[EXCCODE_IPE] = "Instruction privilege error",
|
|
|
|
[EXCCODE_FPE] = "Floating Point Exception",
|
|
|
|
[EXCCODE_DBP] = "Debug breakpoint",
|
|
|
|
};
|
|
|
|
|
|
|
|
const char *loongarch_exception_name(int32_t exception)
|
|
|
|
{
|
|
|
|
assert(excp_names[exception]);
|
|
|
|
return excp_names[exception];
|
|
|
|
}
|
|
|
|
|
|
|
|
void G_NORETURN do_raise_exception(CPULoongArchState *env,
|
|
|
|
uint32_t exception,
|
|
|
|
uintptr_t pc)
|
|
|
|
{
|
|
|
|
CPUState *cs = env_cpu(env);
|
|
|
|
|
|
|
|
qemu_log_mask(CPU_LOG_INT, "%s: %d (%s)\n",
|
|
|
|
__func__,
|
|
|
|
exception,
|
|
|
|
loongarch_exception_name(exception));
|
|
|
|
cs->exception_index = exception;
|
|
|
|
|
|
|
|
cpu_loop_exit_restore(cs, pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void loongarch_cpu_set_pc(CPUState *cs, vaddr value)
|
|
|
|
{
|
|
|
|
LoongArchCPU *cpu = LOONGARCH_CPU(cs);
|
|
|
|
CPULoongArchState *env = &cpu->env;
|
|
|
|
|
|
|
|
env->pc = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_TCG
|
|
|
|
static void loongarch_cpu_synchronize_from_tb(CPUState *cs,
|
|
|
|
const TranslationBlock *tb)
|
|
|
|
{
|
|
|
|
LoongArchCPU *cpu = LOONGARCH_CPU(cs);
|
|
|
|
CPULoongArchState *env = &cpu->env;
|
|
|
|
|
|
|
|
env->pc = tb->pc;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_TCG */
|
|
|
|
|
|
|
|
static void loongarch_la464_initfn(Object *obj)
|
|
|
|
{
|
|
|
|
LoongArchCPU *cpu = LOONGARCH_CPU(obj);
|
|
|
|
CPULoongArchState *env = &cpu->env;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 21; i++) {
|
|
|
|
env->cpucfg[i] = 0x0;
|
|
|
|
}
|
|
|
|
|
|
|
|
env->cpucfg[0] = 0x14c010; /* PRID */
|
|
|
|
|
|
|
|
uint32_t data = 0;
|
|
|
|
data = FIELD_DP32(data, CPUCFG1, ARCH, 2);
|
|
|
|
data = FIELD_DP32(data, CPUCFG1, PGMMU, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG1, IOCSR, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG1, PALEN, 0x2f);
|
|
|
|
data = FIELD_DP32(data, CPUCFG1, VALEN, 0x2f);
|
|
|
|
data = FIELD_DP32(data, CPUCFG1, UAL, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG1, RI, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG1, EP, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG1, RPLV, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG1, HP, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG1, IOCSR_BRD, 1);
|
|
|
|
env->cpucfg[1] = data;
|
|
|
|
|
|
|
|
data = 0;
|
|
|
|
data = FIELD_DP32(data, CPUCFG2, FP, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG2, FP_SP, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG2, FP_DP, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG2, FP_VER, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG2, LLFTP, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG2, LLFTP_VER, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG2, LAM, 1);
|
|
|
|
env->cpucfg[2] = data;
|
|
|
|
|
|
|
|
env->cpucfg[4] = 100 * 1000 * 1000; /* Crystal frequency */
|
|
|
|
|
|
|
|
data = 0;
|
|
|
|
data = FIELD_DP32(data, CPUCFG5, CC_MUL, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG5, CC_DIV, 1);
|
|
|
|
env->cpucfg[5] = data;
|
|
|
|
|
|
|
|
data = 0;
|
|
|
|
data = FIELD_DP32(data, CPUCFG16, L1_IUPRE, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG16, L1_DPRE, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG16, L2_IUPRE, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG16, L2_IUUNIFY, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG16, L2_IUPRIV, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG16, L3_IUPRE, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG16, L3_IUUNIFY, 1);
|
|
|
|
data = FIELD_DP32(data, CPUCFG16, L3_IUINCL, 1);
|
|
|
|
env->cpucfg[16] = data;
|
|
|
|
|
|
|
|
data = 0;
|
|
|
|
data = FIELD_DP32(data, CPUCFG17, L1IU_WAYS, 3);
|
|
|
|
data = FIELD_DP32(data, CPUCFG17, L1IU_SETS, 8);
|
|
|
|
data = FIELD_DP32(data, CPUCFG17, L1IU_SIZE, 6);
|
|
|
|
env->cpucfg[17] = data;
|
|
|
|
|
|
|
|
data = 0;
|
|
|
|
data = FIELD_DP32(data, CPUCFG18, L1D_WAYS, 3);
|
|
|
|
data = FIELD_DP32(data, CPUCFG18, L1D_SETS, 8);
|
|
|
|
data = FIELD_DP32(data, CPUCFG18, L1D_SIZE, 6);
|
|
|
|
env->cpucfg[18] = data;
|
|
|
|
|
|
|
|
data = 0;
|
|
|
|
data = FIELD_DP32(data, CPUCFG19, L2IU_WAYS, 15);
|
|
|
|
data = FIELD_DP32(data, CPUCFG19, L2IU_SETS, 8);
|
|
|
|
data = FIELD_DP32(data, CPUCFG19, L2IU_SIZE, 6);
|
|
|
|
env->cpucfg[19] = data;
|
|
|
|
|
|
|
|
data = 0;
|
|
|
|
data = FIELD_DP32(data, CPUCFG20, L3IU_WAYS, 15);
|
|
|
|
data = FIELD_DP32(data, CPUCFG20, L3IU_SETS, 14);
|
|
|
|
data = FIELD_DP32(data, CPUCFG20, L3IU_SETS, 6);
|
|
|
|
env->cpucfg[20] = data;
|
2022-06-06 14:43:09 +02:00
|
|
|
|
|
|
|
env->CSR_ASID = FIELD_DP64(0, CSR_ASID, ASIDBITS, 0xa);
|
2022-06-06 14:42:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void loongarch_cpu_list_entry(gpointer data, gpointer user_data)
|
|
|
|
{
|
|
|
|
const char *typename = object_class_get_name(OBJECT_CLASS(data));
|
|
|
|
|
|
|
|
qemu_printf("%s\n", typename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void loongarch_cpu_list(void)
|
|
|
|
{
|
|
|
|
GSList *list;
|
|
|
|
list = object_class_get_list_sorted(TYPE_LOONGARCH_CPU, false);
|
|
|
|
g_slist_foreach(list, loongarch_cpu_list_entry, NULL);
|
|
|
|
g_slist_free(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void loongarch_cpu_reset(DeviceState *dev)
|
|
|
|
{
|
|
|
|
CPUState *cs = CPU(dev);
|
|
|
|
LoongArchCPU *cpu = LOONGARCH_CPU(cs);
|
|
|
|
LoongArchCPUClass *lacc = LOONGARCH_CPU_GET_CLASS(cpu);
|
|
|
|
CPULoongArchState *env = &cpu->env;
|
|
|
|
|
|
|
|
lacc->parent_reset(dev);
|
|
|
|
|
|
|
|
env->fcsr0_mask = FCSR0_M1 | FCSR0_M2 | FCSR0_M3;
|
|
|
|
env->fcsr0 = 0x0;
|
|
|
|
|
2022-06-06 14:43:09 +02:00
|
|
|
int n;
|
|
|
|
/* Set csr registers value after reset */
|
|
|
|
env->CSR_CRMD = FIELD_DP64(env->CSR_CRMD, CSR_CRMD, PLV, 0);
|
|
|
|
env->CSR_CRMD = FIELD_DP64(env->CSR_CRMD, CSR_CRMD, IE, 0);
|
|
|
|
env->CSR_CRMD = FIELD_DP64(env->CSR_CRMD, CSR_CRMD, DA, 1);
|
|
|
|
env->CSR_CRMD = FIELD_DP64(env->CSR_CRMD, CSR_CRMD, PG, 0);
|
|
|
|
env->CSR_CRMD = FIELD_DP64(env->CSR_CRMD, CSR_CRMD, DATF, 1);
|
|
|
|
env->CSR_CRMD = FIELD_DP64(env->CSR_CRMD, CSR_CRMD, DATM, 1);
|
|
|
|
|
|
|
|
env->CSR_EUEN = FIELD_DP64(env->CSR_EUEN, CSR_EUEN, FPE, 0);
|
|
|
|
env->CSR_EUEN = FIELD_DP64(env->CSR_EUEN, CSR_EUEN, SXE, 0);
|
|
|
|
env->CSR_EUEN = FIELD_DP64(env->CSR_EUEN, CSR_EUEN, ASXE, 0);
|
|
|
|
env->CSR_EUEN = FIELD_DP64(env->CSR_EUEN, CSR_EUEN, BTE, 0);
|
|
|
|
|
|
|
|
env->CSR_MISC = 0;
|
|
|
|
|
|
|
|
env->CSR_ECFG = FIELD_DP64(env->CSR_ECFG, CSR_ECFG, VS, 0);
|
|
|
|
env->CSR_ECFG = FIELD_DP64(env->CSR_ECFG, CSR_ECFG, LIE, 0);
|
|
|
|
|
|
|
|
env->CSR_ESTAT = env->CSR_ESTAT & (~MAKE_64BIT_MASK(0, 2));
|
|
|
|
env->CSR_RVACFG = FIELD_DP64(env->CSR_RVACFG, CSR_RVACFG, RBITS, 0);
|
|
|
|
env->CSR_TCFG = FIELD_DP64(env->CSR_TCFG, CSR_TCFG, EN, 0);
|
|
|
|
env->CSR_LLBCTL = FIELD_DP64(env->CSR_LLBCTL, CSR_LLBCTL, KLO, 0);
|
|
|
|
env->CSR_TLBRERA = FIELD_DP64(env->CSR_TLBRERA, CSR_TLBRERA, ISTLBR, 0);
|
|
|
|
env->CSR_MERRCTL = FIELD_DP64(env->CSR_MERRCTL, CSR_MERRCTL, ISMERR, 0);
|
|
|
|
|
|
|
|
env->CSR_PRCFG3 = FIELD_DP64(env->CSR_PRCFG3, CSR_PRCFG3, TLB_TYPE, 2);
|
|
|
|
env->CSR_PRCFG3 = FIELD_DP64(env->CSR_PRCFG3, CSR_PRCFG3, MTLB_ENTRY, 63);
|
|
|
|
env->CSR_PRCFG3 = FIELD_DP64(env->CSR_PRCFG3, CSR_PRCFG3, STLB_WAYS, 7);
|
|
|
|
env->CSR_PRCFG3 = FIELD_DP64(env->CSR_PRCFG3, CSR_PRCFG3, STLB_SETS, 8);
|
|
|
|
|
|
|
|
for (n = 0; n < 4; n++) {
|
|
|
|
env->CSR_DMW[n] = FIELD_DP64(env->CSR_DMW[n], CSR_DMW, PLV0, 0);
|
|
|
|
env->CSR_DMW[n] = FIELD_DP64(env->CSR_DMW[n], CSR_DMW, PLV1, 0);
|
|
|
|
env->CSR_DMW[n] = FIELD_DP64(env->CSR_DMW[n], CSR_DMW, PLV2, 0);
|
|
|
|
env->CSR_DMW[n] = FIELD_DP64(env->CSR_DMW[n], CSR_DMW, PLV3, 0);
|
|
|
|
}
|
|
|
|
|
2022-06-06 14:43:00 +02:00
|
|
|
restore_fp_status(env);
|
2022-06-06 14:42:52 +02:00
|
|
|
cs->exception_index = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void loongarch_cpu_disas_set_info(CPUState *s, disassemble_info *info)
|
|
|
|
{
|
|
|
|
info->print_insn = print_insn_loongarch;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void loongarch_cpu_realizefn(DeviceState *dev, Error **errp)
|
|
|
|
{
|
|
|
|
CPUState *cs = CPU(dev);
|
|
|
|
LoongArchCPUClass *lacc = LOONGARCH_CPU_GET_CLASS(dev);
|
|
|
|
Error *local_err = NULL;
|
|
|
|
|
|
|
|
cpu_exec_realizefn(cs, &local_err);
|
|
|
|
if (local_err != NULL) {
|
|
|
|
error_propagate(errp, local_err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cpu_reset(cs);
|
|
|
|
qemu_init_vcpu(cs);
|
|
|
|
|
|
|
|
lacc->parent_realize(dev, errp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void loongarch_cpu_init(Object *obj)
|
|
|
|
{
|
|
|
|
LoongArchCPU *cpu = LOONGARCH_CPU(obj);
|
|
|
|
|
|
|
|
cpu_set_cpustate_pointers(cpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ObjectClass *loongarch_cpu_class_by_name(const char *cpu_model)
|
|
|
|
{
|
|
|
|
ObjectClass *oc;
|
|
|
|
char *typename;
|
|
|
|
|
|
|
|
typename = g_strdup_printf(LOONGARCH_CPU_TYPE_NAME("%s"), cpu_model);
|
|
|
|
oc = object_class_by_name(typename);
|
|
|
|
g_free(typename);
|
|
|
|
return oc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void loongarch_cpu_dump_state(CPUState *cs, FILE *f, int flags)
|
|
|
|
{
|
|
|
|
LoongArchCPU *cpu = LOONGARCH_CPU(cs);
|
|
|
|
CPULoongArchState *env = &cpu->env;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc);
|
|
|
|
qemu_fprintf(f, " FCSR0 0x%08x fp_status 0x%02x\n", env->fcsr0,
|
|
|
|
get_float_exception_flags(&env->fp_status));
|
|
|
|
|
|
|
|
/* gpr */
|
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
if ((i & 3) == 0) {
|
|
|
|
qemu_fprintf(f, " GPR%02d:", i);
|
|
|
|
}
|
|
|
|
qemu_fprintf(f, " %s %016" PRIx64, regnames[i], env->gpr[i]);
|
|
|
|
if ((i & 3) == 3) {
|
|
|
|
qemu_fprintf(f, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-06 14:43:12 +02:00
|
|
|
qemu_fprintf(f, "CRMD=%016" PRIx64 "\n", env->CSR_CRMD);
|
|
|
|
qemu_fprintf(f, "PRMD=%016" PRIx64 "\n", env->CSR_PRMD);
|
|
|
|
qemu_fprintf(f, "EUEN=%016" PRIx64 "\n", env->CSR_EUEN);
|
|
|
|
qemu_fprintf(f, "ESTAT=%016" PRIx64 "\n", env->CSR_ESTAT);
|
|
|
|
qemu_fprintf(f, "ERA=%016" PRIx64 "\n", env->CSR_ERA);
|
|
|
|
qemu_fprintf(f, "BADV=%016" PRIx64 "\n", env->CSR_BADV);
|
|
|
|
qemu_fprintf(f, "BADI=%016" PRIx64 "\n", env->CSR_BADI);
|
|
|
|
qemu_fprintf(f, "EENTRY=%016" PRIx64 "\n", env->CSR_EENTRY);
|
|
|
|
qemu_fprintf(f, "PRCFG1=%016" PRIx64 ", PRCFG2=%016" PRIx64 ","
|
|
|
|
" PRCFG3=%016" PRIx64 "\n",
|
|
|
|
env->CSR_PRCFG1, env->CSR_PRCFG3, env->CSR_PRCFG3);
|
|
|
|
qemu_fprintf(f, "TLBRENTRY=%016" PRIx64 "\n", env->CSR_TLBRENTRY);
|
|
|
|
qemu_fprintf(f, "TLBRBADV=%016" PRIx64 "\n", env->CSR_TLBRBADV);
|
|
|
|
qemu_fprintf(f, "TLBRERA=%016" PRIx64 "\n", env->CSR_TLBRERA);
|
|
|
|
|
2022-06-06 14:42:52 +02:00
|
|
|
/* fpr */
|
|
|
|
if (flags & CPU_DUMP_FPU) {
|
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
qemu_fprintf(f, " %s %016" PRIx64, fregnames[i], env->fpr[i]);
|
|
|
|
if ((i & 3) == 3) {
|
|
|
|
qemu_fprintf(f, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_TCG
|
|
|
|
#include "hw/core/tcg-cpu-ops.h"
|
|
|
|
|
|
|
|
static struct TCGCPUOps loongarch_tcg_ops = {
|
|
|
|
.initialize = loongarch_translate_init,
|
|
|
|
.synchronize_from_tb = loongarch_cpu_synchronize_from_tb,
|
2022-06-06 14:43:12 +02:00
|
|
|
|
|
|
|
.tlb_fill = loongarch_cpu_tlb_fill,
|
2022-06-06 14:42:52 +02:00
|
|
|
};
|
|
|
|
#endif /* CONFIG_TCG */
|
|
|
|
|
2022-06-06 14:43:12 +02:00
|
|
|
#include "hw/core/sysemu-cpu-ops.h"
|
|
|
|
|
|
|
|
static const struct SysemuCPUOps loongarch_sysemu_ops = {
|
|
|
|
.get_phys_page_debug = loongarch_cpu_get_phys_page_debug,
|
|
|
|
};
|
|
|
|
|
2022-06-06 14:42:52 +02:00
|
|
|
static void loongarch_cpu_class_init(ObjectClass *c, void *data)
|
|
|
|
{
|
|
|
|
LoongArchCPUClass *lacc = LOONGARCH_CPU_CLASS(c);
|
|
|
|
CPUClass *cc = CPU_CLASS(c);
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(c);
|
|
|
|
|
|
|
|
device_class_set_parent_realize(dc, loongarch_cpu_realizefn,
|
|
|
|
&lacc->parent_realize);
|
|
|
|
device_class_set_parent_reset(dc, loongarch_cpu_reset, &lacc->parent_reset);
|
|
|
|
|
|
|
|
cc->class_by_name = loongarch_cpu_class_by_name;
|
|
|
|
cc->dump_state = loongarch_cpu_dump_state;
|
|
|
|
cc->set_pc = loongarch_cpu_set_pc;
|
2022-06-06 14:43:10 +02:00
|
|
|
dc->vmsd = &vmstate_loongarch_cpu;
|
2022-06-06 14:43:12 +02:00
|
|
|
cc->sysemu_ops = &loongarch_sysemu_ops;
|
2022-06-06 14:42:52 +02:00
|
|
|
cc->disas_set_info = loongarch_cpu_disas_set_info;
|
|
|
|
#ifdef CONFIG_TCG
|
|
|
|
cc->tcg_ops = &loongarch_tcg_ops;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFINE_LOONGARCH_CPU_TYPE(model, initfn) \
|
|
|
|
{ \
|
|
|
|
.parent = TYPE_LOONGARCH_CPU, \
|
|
|
|
.instance_init = initfn, \
|
|
|
|
.name = LOONGARCH_CPU_TYPE_NAME(model), \
|
|
|
|
}
|
|
|
|
|
|
|
|
static const TypeInfo loongarch_cpu_type_infos[] = {
|
|
|
|
{
|
|
|
|
.name = TYPE_LOONGARCH_CPU,
|
|
|
|
.parent = TYPE_CPU,
|
|
|
|
.instance_size = sizeof(LoongArchCPU),
|
|
|
|
.instance_init = loongarch_cpu_init,
|
|
|
|
|
|
|
|
.abstract = true,
|
|
|
|
.class_size = sizeof(LoongArchCPUClass),
|
|
|
|
.class_init = loongarch_cpu_class_init,
|
|
|
|
},
|
|
|
|
DEFINE_LOONGARCH_CPU_TYPE("la464", loongarch_la464_initfn),
|
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_TYPES(loongarch_cpu_type_infos)
|
2022-06-06 14:43:11 +02:00
|
|
|
|
|
|
|
static void loongarch_cpu_add_definition(gpointer data, gpointer user_data)
|
|
|
|
{
|
|
|
|
ObjectClass *oc = data;
|
|
|
|
CpuDefinitionInfoList **cpu_list = user_data;
|
|
|
|
CpuDefinitionInfo *info = g_new0(CpuDefinitionInfo, 1);
|
|
|
|
const char *typename = object_class_get_name(oc);
|
|
|
|
|
|
|
|
info->name = g_strndup(typename,
|
|
|
|
strlen(typename) - strlen("-" TYPE_LOONGARCH_CPU));
|
|
|
|
info->q_typename = g_strdup(typename);
|
|
|
|
|
|
|
|
QAPI_LIST_PREPEND(*cpu_list, info);
|
|
|
|
}
|
|
|
|
|
|
|
|
CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
|
|
|
{
|
|
|
|
CpuDefinitionInfoList *cpu_list = NULL;
|
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
list = object_class_get_list(TYPE_LOONGARCH_CPU, false);
|
|
|
|
g_slist_foreach(list, loongarch_cpu_add_definition, &cpu_list);
|
|
|
|
g_slist_free(list);
|
|
|
|
|
|
|
|
return cpu_list;
|
|
|
|
}
|