[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v13 02/26] target/loongarch: Add core definition
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH v13 02/26] target/loongarch: Add core definition |
Date: |
Sat, 4 Dec 2021 18:26:11 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 |
On 12/4/21 10:29, Song Gao wrote:
> This patch adds target state header, target definitions
> and initialization routines.
>
> Signed-off-by: Song Gao <gaosong@loongson.cn>
> Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> target/loongarch/cpu-param.h | 18 +++
> target/loongarch/cpu.c | 313
> +++++++++++++++++++++++++++++++++++++++++++
> target/loongarch/cpu.h | 252 ++++++++++++++++++++++++++++++++++
> target/loongarch/internals.h | 21 +++
> 4 files changed, 604 insertions(+)
> create mode 100644 target/loongarch/cpu-param.h
> create mode 100644 target/loongarch/cpu.c
> create mode 100644 target/loongarch/cpu.h
> create mode 100644 target/loongarch/internals.h
> diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
> new file mode 100644
> index 0000000..05ceb9c
> --- /dev/null
> +++ b/target/loongarch/cpu.c
> @@ -0,0 +1,313 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * QEMU LoongArch CPU
> + *
> + * Copyright (c) 2021 Loongson Technology Corporation Limited
> + */
> +
> +#include "qemu/osdep.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"
> +
> +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[EXCP_LAST + 1] = {
> + [EXCP_SYSCALL] = "Syscall",
> + [EXCP_BREAK] = "Break",
> + [EXCP_INE] = "Instruction Non-existent",
> + [EXCP_FPE] = "Floating Point Exception",
> +};
> +
> +const char *loongarch_exception_name(int32_t exception)
> +{
assert(excp_names[exception]);
?
> + return excp_names[exception];
> +}
> +static void loongarch_3a5000_initfn(Object *obj)
> +{
> + LoongArchCPU *cpu = LOONGARCH_CPU(obj);
> + CPULoongArchState *env = &cpu->env;
> + int i;
> + env->cpucfg[4] = 0x5f5e100; /* Crystal frequency */
100 * 1000 * 1000
> +}
> +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 = 0x1f1f031f;
Is this for all CPUs or only the 3A5000?
> + env->fcsr0 = 0x0;
> +
> + cs->exception_index = EXCP_NONE;
> +}
> diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
> new file mode 100644
> index 0000000..ab60322
> --- /dev/null
> +++ b/target/loongarch/cpu.h
> @@ -0,0 +1,252 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * QEMU LoongArch CPU
> + *
> + * Copyright (c) 2021 Loongson Technology Corporation Limited
> + */
> +
> +#ifndef LOONGARCH_CPU_H
> +#define LOONGARCH_CPU_H
> +
> +#include "exec/cpu-defs.h"
> +#include "fpu/softfloat-types.h"
> +#include "hw/registerfields.h"
> +
> +#define TCG_GUEST_DEFAULT_MO (0)
> +
> +#define FCSR0_M1 0x1f /* FCSR1 mask, Enables */
> +#define FCSR0_M2 0x1f1f0000 /* FCSR2 mask, Cause and Flags */
> +#define FCSR0_M3 0x300 /* FCSR3 mask, Round Mode */
> +#define FCSR0_RM 8 /* Round Mode bit num on fcsr0 */
> +extern const char * const regnames[];
> +extern const char * const fregnames[];
[32] to both.
- [PATCH v13 21/26] linux-user: Add LoongArch syscall support, (continued)
- [PATCH v13 21/26] linux-user: Add LoongArch syscall support, Song Gao, 2021/12/04
- [PATCH v13 12/26] target/loongarch: Add floating point conversion instruction translation, Song Gao, 2021/12/04
- [PATCH v13 10/26] target/loongarch: Add floating point arithmetic instruction translation, Song Gao, 2021/12/04
- [PATCH v13 13/26] target/loongarch: Add floating point move instruction translation, Song Gao, 2021/12/04
- [PATCH v13 06/26] target/loongarch: Add fixed point bit instruction translation, Song Gao, 2021/12/04
- [PATCH v13 18/26] linux-user: Add LoongArch specific structures, Song Gao, 2021/12/04
- [PATCH v13 20/26] linux-user: Add LoongArch elf support, Song Gao, 2021/12/04
- [PATCH v13 02/26] target/loongarch: Add core definition, Song Gao, 2021/12/04
- Re: [PATCH v13 02/26] target/loongarch: Add core definition,
Philippe Mathieu-Daudé <=
- [PATCH v13 22/26] linux-user: Add LoongArch cpu_loop support, Song Gao, 2021/12/04
- [PATCH v13 15/26] target/loongarch: Add branch instruction translation, Song Gao, 2021/12/04
- [PATCH v13 16/26] target/loongarch: Add disassembler, Song Gao, 2021/12/04
- Re: [PATCH v13 00/26] Add LoongArch linux-user emulation support, gaosong, 2021/12/15