mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-31 23:15:44 +00:00
tcg: Split out target/arch/cpu-param.h
For all targets, into this new file move TARGET_LONG_BITS, TARGET_PAGE_BITS, TARGET_PHYS_ADDR_SPACE_BITS, TARGET_VIRT_ADDR_SPACE_BITS, and NB_MMU_MODES. Include this new file from exec/cpu-defs.h. This now removes the somewhat odd requirement that target/arch/cpu.h defines TARGET_LONG_BITS before including exec/cpu-defs.h, so push the bulk of the includes within target/arch/cpu.h to the top. Backports commit 74433bf083b0766aba81534f92de13194f23ff3e from qemu
This commit is contained in:
parent
93473b2e09
commit
df2a890bd7
|
@ -35,8 +35,28 @@
|
|||
#endif
|
||||
#include "exec/memattrs.h"
|
||||
|
||||
#include "cpu-param.h"
|
||||
|
||||
#ifndef TARGET_LONG_BITS
|
||||
#error TARGET_LONG_BITS must be defined before including this header
|
||||
# error TARGET_LONG_BITS must be defined in cpu-param.h
|
||||
#endif
|
||||
#ifndef NB_MMU_MODES
|
||||
# error NB_MMU_MODES must be defined in cpu-param.h
|
||||
#endif
|
||||
#ifndef TARGET_PHYS_ADDR_SPACE_BITS
|
||||
# error TARGET_PHYS_ADDR_SPACE_BITS must be defined in cpu-param.h
|
||||
#endif
|
||||
#ifndef TARGET_VIRT_ADDR_SPACE_BITS
|
||||
# error TARGET_VIRT_ADDR_SPACE_BITS must be defined in cpu-param.h
|
||||
#endif
|
||||
#ifndef TARGET_PAGE_BITS
|
||||
# ifdef TARGET_PAGE_BITS_VARY
|
||||
# ifndef TARGET_PAGE_BITS_MIN
|
||||
# error TARGET_PAGE_BITS_MIN must be defined in cpu-param.h
|
||||
# endif
|
||||
# else
|
||||
# error TARGET_PAGE_BITS must be defined in cpu-param.h
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
|
||||
|
|
36
qemu/target/arm/cpu-param.h
Normal file
36
qemu/target/arm/cpu-param.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* ARM cpu parameters for qemu.
|
||||
*
|
||||
* Copyright (c) 2003 Fabrice Bellard
|
||||
* SPDX-License-Identifier: LGPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef ARM_CPU_PARAM_H
|
||||
#define ARM_CPU_PARAM_H 1
|
||||
|
||||
#ifdef TARGET_AARCH64
|
||||
# define TARGET_LONG_BITS 64
|
||||
# define TARGET_PHYS_ADDR_SPACE_BITS 48
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 48
|
||||
#else
|
||||
# define TARGET_LONG_BITS 32
|
||||
# define TARGET_PHYS_ADDR_SPACE_BITS 40
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 32
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
#define TARGET_PAGE_BITS 12
|
||||
#else
|
||||
/*
|
||||
* ARMv7 and later CPUs have 4K pages minimum, but ARMv5 and v6
|
||||
* have to support 1K tiny pages.
|
||||
*/
|
||||
// Unicorn: Commented out until VTLB support is implemented.
|
||||
//# define TARGET_PAGE_BITS_VARY
|
||||
//# define TARGET_PAGE_BITS_MIN 10
|
||||
# define TARGET_PAGE_BITS 10
|
||||
#endif
|
||||
|
||||
#define NB_MMU_MODES 8
|
||||
|
||||
#endif
|
|
@ -24,23 +24,15 @@
|
|||
|
||||
#include "kvm-consts.h"
|
||||
#include "hw/registerfields.h"
|
||||
|
||||
#if defined(TARGET_AARCH64)
|
||||
/* AArch64 definitions */
|
||||
# define TARGET_LONG_BITS 64
|
||||
#else
|
||||
# define TARGET_LONG_BITS 32
|
||||
#endif
|
||||
#include "qemu-common.h"
|
||||
#include "cpu-qom.h"
|
||||
#include "exec/cpu-defs.h"
|
||||
|
||||
/* ARM processors have a weak memory model */
|
||||
#define TCG_GUEST_DEFAULT_MO (0)
|
||||
|
||||
#define CPUArchState struct CPUARMState
|
||||
|
||||
#include "qemu-common.h"
|
||||
#include "cpu-qom.h"
|
||||
#include "exec/cpu-defs.h"
|
||||
|
||||
#define EXCP_UDEF 1 /* undefined instruction */
|
||||
#define EXCP_SWI 2 /* software interrupt */
|
||||
#define EXCP_PREFETCH_ABORT 3
|
||||
|
@ -116,7 +108,6 @@ enum {
|
|||
#define ARM_CPU_VIRQ 2
|
||||
#define ARM_CPU_VFIQ 3
|
||||
|
||||
#define NB_MMU_MODES 8
|
||||
/* ARM-specific extra insn start words:
|
||||
* 1: Conditional execution bits
|
||||
* 2: Partial exception syndrome for data aborts
|
||||
|
@ -2590,23 +2581,6 @@ bool write_cpustate_to_list(ARMCPU *cpu);
|
|||
#define ARM_CPUID_TI915T 0x54029152
|
||||
#define ARM_CPUID_TI925T 0x54029252
|
||||
|
||||
#if defined(CONFIG_USER_ONLY)
|
||||
#define TARGET_PAGE_BITS 12
|
||||
#else
|
||||
/* The ARM MMU allows 1k pages. */
|
||||
/* ??? Linux doesn't actually use these, and they're deprecated in recent
|
||||
architecture revisions. Maybe a configure option to disable them. */
|
||||
#define TARGET_PAGE_BITS 10
|
||||
#endif
|
||||
|
||||
#if defined(TARGET_AARCH64)
|
||||
# define TARGET_PHYS_ADDR_SPACE_BITS 48
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 48
|
||||
#else
|
||||
# define TARGET_PHYS_ADDR_SPACE_BITS 40
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 32
|
||||
#endif
|
||||
|
||||
static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
|
||||
unsigned int target_el)
|
||||
{
|
||||
|
|
28
qemu/target/i386/cpu-param.h
Normal file
28
qemu/target/i386/cpu-param.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* i386 cpu parameters for qemu.
|
||||
*
|
||||
* Copyright (c) 2003 Fabrice Bellard
|
||||
* SPDX-License-Identifier: LGPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef I386_CPU_PARAM_H
|
||||
#define I386_CPU_PARAM_H 1
|
||||
|
||||
#ifdef TARGET_X86_64
|
||||
# define TARGET_LONG_BITS 64
|
||||
# define TARGET_PHYS_ADDR_SPACE_BITS 52
|
||||
/*
|
||||
* ??? This is really 48 bits, sign-extended, but the only thing
|
||||
* accessible to userland with bit 48 set is the VSYSCALL, and that
|
||||
* is handled via other mechanisms.
|
||||
*/
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 47
|
||||
#else
|
||||
# define TARGET_LONG_BITS 32
|
||||
# define TARGET_PHYS_ADDR_SPACE_BITS 36
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 32
|
||||
#endif
|
||||
#define TARGET_PAGE_BITS 12
|
||||
#define NB_MMU_MODES 3
|
||||
|
||||
#endif
|
|
@ -24,12 +24,6 @@
|
|||
#include "qemu-common.h"
|
||||
#include "cpu-qom.h"
|
||||
|
||||
#ifdef TARGET_X86_64
|
||||
#define TARGET_LONG_BITS 64
|
||||
#else
|
||||
#define TARGET_LONG_BITS 32
|
||||
#endif
|
||||
|
||||
/* The x86 has a strong memory model with some store-after-load re-ordering */
|
||||
#define TCG_GUEST_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD)
|
||||
|
||||
|
@ -915,7 +909,6 @@ typedef struct {
|
|||
#define MAX_FIXED_COUNTERS 3
|
||||
#define MAX_GP_COUNTERS (MSR_IA32_PERF_STATUS - MSR_P6_EVNTSEL0)
|
||||
|
||||
#define NB_MMU_MODES 3
|
||||
#define TARGET_INSN_START_EXTRA_WORDS 1
|
||||
|
||||
#define NB_OPMASK_REGS 8
|
||||
|
@ -1610,19 +1603,6 @@ void cpu_x86_update_dr7(CPUX86State *env, uint32_t new_dr7);
|
|||
void cpu_smm_update(CPUX86State *env);
|
||||
uint64_t cpu_get_tsc(CPUX86State *env);
|
||||
|
||||
#define TARGET_PAGE_BITS 12
|
||||
|
||||
#ifdef TARGET_X86_64
|
||||
#define TARGET_PHYS_ADDR_SPACE_BITS 52
|
||||
/* ??? This is really 48 bits, sign-extended, but the only thing
|
||||
accessible to userland with bit 48 set is the VSYSCALL, and that
|
||||
is handled via other mechanisms. */
|
||||
#define TARGET_VIRT_ADDR_SPACE_BITS 47
|
||||
#else
|
||||
#define TARGET_PHYS_ADDR_SPACE_BITS 36
|
||||
#define TARGET_VIRT_ADDR_SPACE_BITS 32
|
||||
#endif
|
||||
|
||||
/* XXX: This value should match the one returned by CPUID
|
||||
* and in exec.c */
|
||||
# if defined(TARGET_X86_64)
|
||||
|
|
22
qemu/target/m68k/cpu-param.h
Normal file
22
qemu/target/m68k/cpu-param.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* m68k cpu parameters for qemu.
|
||||
*
|
||||
* Copyright (c) 2005-2007 CodeSourcery
|
||||
* SPDX-License-Identifier: LGPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef M68K_CPU_PARAM_H
|
||||
#define M68K_CPU_PARAM_H 1
|
||||
|
||||
#define TARGET_LONG_BITS 32
|
||||
/*
|
||||
* Coldfire Linux uses 8k pages
|
||||
* and m68k linux uses 4k pages
|
||||
* use the smallest one
|
||||
*/
|
||||
#define TARGET_PAGE_BITS 12
|
||||
#define TARGET_PHYS_ADDR_SPACE_BITS 32
|
||||
#define TARGET_VIRT_ADDR_SPACE_BITS 32
|
||||
#define NB_MMU_MODES 2
|
||||
|
||||
#endif
|
|
@ -21,15 +21,13 @@
|
|||
#ifndef M68K_CPU_H
|
||||
#define M68K_CPU_H
|
||||
|
||||
#define TARGET_LONG_BITS 32
|
||||
|
||||
#define CPUArchState struct CPUM68KState
|
||||
|
||||
#include "config.h"
|
||||
#include "qemu-common.h"
|
||||
#include "cpu-qom.h"
|
||||
#include "exec/cpu-defs.h"
|
||||
|
||||
#define CPUArchState struct CPUM68KState
|
||||
|
||||
#define OS_BYTE 0
|
||||
#define OS_WORD 1
|
||||
#define OS_LONG 2
|
||||
|
@ -83,7 +81,6 @@
|
|||
#define M68K_MAX_TTR 2
|
||||
#define TTR(type, index) ttr[((type & ACCESS_CODE) == ACCESS_CODE) * 2 + index]
|
||||
|
||||
#define NB_MMU_MODES 2
|
||||
#define TARGET_INSN_START_EXTRA_WORDS 1
|
||||
|
||||
typedef CPU_LDoubleU FPReg;
|
||||
|
@ -497,12 +494,6 @@ void m68k_cpu_list(FILE *f, fprintf_function cpu_fprintf);
|
|||
|
||||
void register_m68k_insns (CPUM68KState *env);
|
||||
|
||||
/* Coldfire Linux uses 8k pages
|
||||
* and m68k linux uses 4k pages
|
||||
* use the smallest one
|
||||
*/
|
||||
#define TARGET_PAGE_BITS 12
|
||||
|
||||
enum {
|
||||
/* 1 bit to define user level / supervisor access */
|
||||
ACCESS_SUPER = 0x01,
|
||||
|
@ -517,9 +508,6 @@ enum {
|
|||
ACCESS_DATA = 0x20, /* Data load/store access */
|
||||
};
|
||||
|
||||
#define TARGET_PHYS_ADDR_SPACE_BITS 32
|
||||
#define TARGET_VIRT_ADDR_SPACE_BITS 32
|
||||
|
||||
#define M68K_CPU_TYPE_SUFFIX "-" TYPE_M68K_CPU
|
||||
#define M68K_CPU_TYPE_NAME(model) model M68K_CPU_TYPE_SUFFIX
|
||||
#define CPU_RESOLVING_TYPE TYPE_M68K_CPU
|
||||
|
|
29
qemu/target/mips/cpu-param.h
Normal file
29
qemu/target/mips/cpu-param.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* MIPS cpu parameters for qemu.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef MIPS_CPU_PARAM_H
|
||||
#define MIPS_CPU_PARAM_H 1
|
||||
|
||||
#ifdef TARGET_MIPS64
|
||||
# define TARGET_LONG_BITS 64
|
||||
#else
|
||||
# define TARGET_LONG_BITS 32
|
||||
#endif
|
||||
#ifdef TARGET_MIPS64
|
||||
#define TARGET_PHYS_ADDR_SPACE_BITS 48
|
||||
#define TARGET_VIRT_ADDR_SPACE_BITS 48
|
||||
#else
|
||||
#define TARGET_PHYS_ADDR_SPACE_BITS 40
|
||||
# ifdef CONFIG_USER_ONLY
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 31
|
||||
# else
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 32
|
||||
#endif
|
||||
#endif
|
||||
#define TARGET_PAGE_BITS 12
|
||||
#define NB_MMU_MODES 4
|
||||
|
||||
#endif
|
|
@ -8,9 +8,9 @@
|
|||
#include "config.h"
|
||||
#include "qemu-common.h"
|
||||
#include "cpu-qom.h"
|
||||
#include "mips-defs.h"
|
||||
#include "exec/cpu-defs.h"
|
||||
#include "fpu/softfloat.h"
|
||||
#include "mips-defs.h"
|
||||
|
||||
struct CPUMIPSState;
|
||||
|
||||
|
@ -102,7 +102,6 @@ struct CPUMIPSFPUContext {
|
|||
#define FP_UNIMPLEMENTED 32
|
||||
};
|
||||
|
||||
#define NB_MMU_MODES 4
|
||||
#define TARGET_INSN_START_EXTRA_WORDS 2
|
||||
|
||||
typedef struct CPUMIPSMVPContext CPUMIPSMVPContext;
|
||||
|
|
|
@ -5,19 +5,8 @@
|
|||
//#define USE_HOST_FLOAT_REGS
|
||||
|
||||
/* Real pages are variable size... */
|
||||
#define TARGET_PAGE_BITS 12
|
||||
#define MIPS_TLB_MAX 128
|
||||
|
||||
#if defined(TARGET_MIPS64)
|
||||
#define TARGET_LONG_BITS 64
|
||||
#define TARGET_PHYS_ADDR_SPACE_BITS 48
|
||||
#define TARGET_VIRT_ADDR_SPACE_BITS 48
|
||||
#else
|
||||
#define TARGET_LONG_BITS 32
|
||||
#define TARGET_PHYS_ADDR_SPACE_BITS 40
|
||||
#define TARGET_VIRT_ADDR_SPACE_BITS 32
|
||||
#endif
|
||||
|
||||
/*
|
||||
* bit definitions for insn_flags (ISAs/ASEs flags)
|
||||
* ------------------------------------------------
|
||||
|
|
23
qemu/target/riscv/cpu-param.h
Normal file
23
qemu/target/riscv/cpu-param.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* RISC-V cpu parameters for qemu.
|
||||
*
|
||||
* Copyright (c) 2017-2018 SiFive, Inc.
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef RISCV_CPU_PARAM_H
|
||||
#define RISCV_CPU_PARAM_H 1
|
||||
|
||||
#if defined(TARGET_RISCV64)
|
||||
# define TARGET_LONG_BITS 64
|
||||
# define TARGET_PHYS_ADDR_SPACE_BITS 56 /* 44-bit PPN */
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 48 /* sv48 */
|
||||
#elif defined(TARGET_RISCV32)
|
||||
# define TARGET_LONG_BITS 32
|
||||
# define TARGET_PHYS_ADDR_SPACE_BITS 34 /* 22-bit PPN */
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 32 /* sv32 */
|
||||
#endif
|
||||
#define TARGET_PAGE_BITS 12 /* 4 KiB Pages */
|
||||
#define NB_MMU_MODES 4
|
||||
|
||||
#endif
|
|
@ -20,22 +20,6 @@
|
|||
#ifndef RISCV_CPU_H
|
||||
#define RISCV_CPU_H
|
||||
|
||||
/* QEMU addressing/paging config */
|
||||
#define TARGET_PAGE_BITS 12 /* 4 KiB Pages */
|
||||
#if defined(TARGET_RISCV64)
|
||||
#define TARGET_LONG_BITS 64
|
||||
#define TARGET_PHYS_ADDR_SPACE_BITS 56 /* 44-bit PPN */
|
||||
#define TARGET_VIRT_ADDR_SPACE_BITS 48 /* sv48 */
|
||||
#elif defined(TARGET_RISCV32)
|
||||
#define TARGET_LONG_BITS 32
|
||||
#define TARGET_PHYS_ADDR_SPACE_BITS 34 /* 22-bit PPN */
|
||||
#define TARGET_VIRT_ADDR_SPACE_BITS 32 /* sv32 */
|
||||
#endif
|
||||
|
||||
#define TCG_GUEST_DEFAULT_MO 0
|
||||
|
||||
#define CPUArchState struct CPURISCVState
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "qemu-common.h"
|
||||
|
@ -43,6 +27,10 @@
|
|||
#include "exec/cpu-defs.h"
|
||||
#include "fpu/softfloat.h"
|
||||
|
||||
#define TCG_GUEST_DEFAULT_MO 0
|
||||
|
||||
#define CPUArchState struct CPURISCVState
|
||||
|
||||
#define TYPE_RISCV_CPU "riscv-cpu"
|
||||
|
||||
#define RISCV_CPU_TYPE_SUFFIX "-" TYPE_RISCV_CPU
|
||||
|
@ -100,7 +88,6 @@ enum {
|
|||
|
||||
#define TRANSLATE_FAIL 1
|
||||
#define TRANSLATE_SUCCESS 0
|
||||
#define NB_MMU_MODES 4
|
||||
#define MMU_USER_IDX 3
|
||||
|
||||
#define MAX_RISCV_PMPS (16)
|
||||
|
|
28
qemu/target/sparc/cpu-param.h
Normal file
28
qemu/target/sparc/cpu-param.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Sparc cpu parameters for qemu.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef SPARC_CPU_PARAM_H
|
||||
#define SPARC_CPU_PARAM_H 1
|
||||
|
||||
#ifdef TARGET_SPARC64
|
||||
# define TARGET_LONG_BITS 64
|
||||
# define TARGET_PAGE_BITS 13 /* 8k */
|
||||
# define TARGET_PHYS_ADDR_SPACE_BITS 41
|
||||
# ifdef TARGET_ABI32
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 32
|
||||
# else
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 44
|
||||
# endif
|
||||
# define NB_MMU_MODES 6
|
||||
#else
|
||||
# define TARGET_LONG_BITS 32
|
||||
# define TARGET_PAGE_BITS 12 /* 4k */
|
||||
# define TARGET_PHYS_ADDR_SPACE_BITS 36
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 32
|
||||
# define NB_MMU_MODES 3
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -4,32 +4,18 @@
|
|||
#include "config.h"
|
||||
#include "qemu-common.h"
|
||||
#include "cpu-qom.h"
|
||||
#include "qemu/bswap.h"
|
||||
#include "exec/cpu-defs.h"
|
||||
|
||||
#define ALIGNED_ONLY
|
||||
|
||||
#if !defined(TARGET_SPARC64)
|
||||
#define TARGET_LONG_BITS 32
|
||||
#define TARGET_DPREGS 16
|
||||
#define TARGET_PAGE_BITS 12 /* 4k */
|
||||
#define TARGET_PHYS_ADDR_SPACE_BITS 36
|
||||
#define TARGET_VIRT_ADDR_SPACE_BITS 32
|
||||
#else
|
||||
#define TARGET_LONG_BITS 64
|
||||
#define TARGET_DPREGS 32
|
||||
#define TARGET_PAGE_BITS 13 /* 8k */
|
||||
#define TARGET_PHYS_ADDR_SPACE_BITS 41
|
||||
# ifdef TARGET_ABI32
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 32
|
||||
# else
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 44
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define CPUArchState struct CPUSPARCState
|
||||
|
||||
#include "exec/cpu-defs.h"
|
||||
|
||||
/*#define EXCP_INTERRUPT 0x100*/
|
||||
|
||||
/* trap definitions */
|
||||
|
@ -221,10 +207,7 @@ enum {
|
|||
#define MIN_NWINDOWS 3
|
||||
#define MAX_NWINDOWS 32
|
||||
|
||||
#if !defined(TARGET_SPARC64)
|
||||
#define NB_MMU_MODES 3
|
||||
#else
|
||||
#define NB_MMU_MODES 6
|
||||
#ifdef TARGET_SPARC64
|
||||
typedef struct trap_state {
|
||||
uint64_t tpc;
|
||||
uint64_t tnpc;
|
||||
|
|
Loading…
Reference in a new issue