2015-08-20 23:41:01 +02:00
|
|
|
/*
|
|
|
|
* TILE-Gx virtual CPU header
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015 Chen Gang
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2020-10-23 14:44:24 +02:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2015-08-20 23:41:01 +02:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that 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 Lesser General Public
|
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2016-06-29 11:05:55 +02:00
|
|
|
|
|
|
|
#ifndef TILEGX_CPU_H
|
|
|
|
#define TILEGX_CPU_H
|
2015-08-20 23:41:01 +02:00
|
|
|
|
|
|
|
#include "exec/cpu-defs.h"
|
2020-09-03 22:43:22 +02:00
|
|
|
#include "qom/object.h"
|
2015-08-20 23:41:01 +02:00
|
|
|
|
|
|
|
/* TILE-Gx common register alias */
|
|
|
|
#define TILEGX_R_RE 0 /* 0 register, for function/syscall return value */
|
|
|
|
#define TILEGX_R_ERR 1 /* 1 register, for syscall errno flag */
|
|
|
|
#define TILEGX_R_NR 10 /* 10 register, for syscall number */
|
|
|
|
#define TILEGX_R_BP 52 /* 52 register, optional frame pointer */
|
|
|
|
#define TILEGX_R_TP 53 /* TP register, thread local storage data */
|
|
|
|
#define TILEGX_R_SP 54 /* SP register, stack pointer */
|
|
|
|
#define TILEGX_R_LR 55 /* LR register, may save pc, but it is not pc */
|
|
|
|
#define TILEGX_R_COUNT 56 /* Only 56 registers are really useful */
|
|
|
|
#define TILEGX_R_SN 56 /* SN register, obsoleted, it likes zero register */
|
|
|
|
#define TILEGX_R_IDN0 57 /* IDN0 register, cause IDN_ACCESS exception */
|
|
|
|
#define TILEGX_R_IDN1 58 /* IDN1 register, cause IDN_ACCESS exception */
|
|
|
|
#define TILEGX_R_UDN0 59 /* UDN0 register, cause UDN_ACCESS exception */
|
|
|
|
#define TILEGX_R_UDN1 60 /* UDN1 register, cause UDN_ACCESS exception */
|
|
|
|
#define TILEGX_R_UDN2 61 /* UDN2 register, cause UDN_ACCESS exception */
|
|
|
|
#define TILEGX_R_UDN3 62 /* UDN3 register, cause UDN_ACCESS exception */
|
|
|
|
#define TILEGX_R_ZERO 63 /* Zero register, always zero */
|
|
|
|
#define TILEGX_R_NOREG 255 /* Invalid register value */
|
|
|
|
|
|
|
|
/* TILE-Gx special registers used by outside */
|
|
|
|
enum {
|
|
|
|
TILEGX_SPR_CMPEXCH = 0,
|
|
|
|
TILEGX_SPR_CRITICAL_SEC = 1,
|
|
|
|
TILEGX_SPR_SIM_CONTROL = 2,
|
2015-10-04 11:41:14 +02:00
|
|
|
TILEGX_SPR_EX_CONTEXT_0_0 = 3,
|
|
|
|
TILEGX_SPR_EX_CONTEXT_0_1 = 4,
|
2015-08-20 23:41:01 +02:00
|
|
|
TILEGX_SPR_COUNT
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Exception numbers */
|
|
|
|
typedef enum {
|
|
|
|
TILEGX_EXCP_NONE = 0,
|
|
|
|
TILEGX_EXCP_SYSCALL = 1,
|
2015-09-27 23:26:04 +02:00
|
|
|
TILEGX_EXCP_SIGNAL = 2,
|
2015-08-20 23:41:01 +02:00
|
|
|
TILEGX_EXCP_OPCODE_UNKNOWN = 0x101,
|
|
|
|
TILEGX_EXCP_OPCODE_UNIMPLEMENTED = 0x102,
|
|
|
|
TILEGX_EXCP_OPCODE_CMPEXCH = 0x103,
|
|
|
|
TILEGX_EXCP_OPCODE_CMPEXCH4 = 0x104,
|
|
|
|
TILEGX_EXCP_OPCODE_EXCH = 0x105,
|
|
|
|
TILEGX_EXCP_OPCODE_EXCH4 = 0x106,
|
|
|
|
TILEGX_EXCP_OPCODE_FETCHADD = 0x107,
|
|
|
|
TILEGX_EXCP_OPCODE_FETCHADD4 = 0x108,
|
|
|
|
TILEGX_EXCP_OPCODE_FETCHADDGEZ = 0x109,
|
|
|
|
TILEGX_EXCP_OPCODE_FETCHADDGEZ4 = 0x10a,
|
|
|
|
TILEGX_EXCP_OPCODE_FETCHAND = 0x10b,
|
|
|
|
TILEGX_EXCP_OPCODE_FETCHAND4 = 0x10c,
|
|
|
|
TILEGX_EXCP_OPCODE_FETCHOR = 0x10d,
|
|
|
|
TILEGX_EXCP_OPCODE_FETCHOR4 = 0x10e,
|
|
|
|
TILEGX_EXCP_REG_IDN_ACCESS = 0x181,
|
|
|
|
TILEGX_EXCP_REG_UDN_ACCESS = 0x182,
|
|
|
|
TILEGX_EXCP_UNALIGNMENT = 0x201,
|
|
|
|
TILEGX_EXCP_DBUG_BREAK = 0x301
|
|
|
|
} TileExcp;
|
|
|
|
|
|
|
|
typedef struct CPUTLGState {
|
|
|
|
uint64_t regs[TILEGX_R_COUNT]; /* Common used registers by outside */
|
|
|
|
uint64_t spregs[TILEGX_SPR_COUNT]; /* Special used registers by outside */
|
|
|
|
uint64_t pc; /* Current pc */
|
|
|
|
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2015-09-26 07:00:35 +02:00
|
|
|
uint64_t excaddr; /* exception address */
|
2015-08-24 16:55:47 +02:00
|
|
|
uint64_t atomic_srca; /* Arguments to atomic "exceptions" */
|
|
|
|
uint64_t atomic_srcb;
|
|
|
|
uint32_t atomic_dstr;
|
2015-09-26 07:00:35 +02:00
|
|
|
uint32_t signo; /* Signal number */
|
|
|
|
uint32_t sigcode; /* Signal code */
|
2015-08-20 23:41:01 +02:00
|
|
|
#endif
|
|
|
|
|
2016-11-14 15:19:17 +01:00
|
|
|
/* Fields up to this point are cleared by a CPU reset */
|
|
|
|
struct {} end_reset_fields;
|
2015-08-20 23:41:01 +02:00
|
|
|
} CPUTLGState;
|
|
|
|
|
2019-07-09 17:20:52 +02:00
|
|
|
#include "hw/core/cpu.h"
|
2015-08-20 23:41:01 +02:00
|
|
|
|
|
|
|
#define TYPE_TILEGX_CPU "tilegx-cpu"
|
|
|
|
|
2020-08-31 23:07:37 +02:00
|
|
|
OBJECT_DECLARE_TYPE(TileGXCPU, TileGXCPUClass,
|
qom: Remove module_obj_name parameter from OBJECT_DECLARE* macros
One of the goals of having less boilerplate on QOM declarations
is to avoid human error. Requiring an extra argument that is
never used is an opportunity for mistakes.
Remove the unused argument from OBJECT_DECLARE_TYPE and
OBJECT_DECLARE_SIMPLE_TYPE.
Coccinelle patch used to convert all users of the macros:
@@
declarer name OBJECT_DECLARE_TYPE;
identifier InstanceType, ClassType, lowercase, UPPERCASE;
@@
OBJECT_DECLARE_TYPE(InstanceType, ClassType,
- lowercase,
UPPERCASE);
@@
declarer name OBJECT_DECLARE_SIMPLE_TYPE;
identifier InstanceType, lowercase, UPPERCASE;
@@
OBJECT_DECLARE_SIMPLE_TYPE(InstanceType,
- lowercase,
UPPERCASE);
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Acked-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Paul Durrant <paul@xen.org>
Acked-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20200916182519.415636-4-ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2020-09-16 20:25:17 +02:00
|
|
|
TILEGX_CPU)
|
2015-08-20 23:41:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TileGXCPUClass:
|
|
|
|
* @parent_realize: The parent class' realize handler.
|
|
|
|
* @parent_reset: The parent class' reset handler.
|
|
|
|
*
|
|
|
|
* A Tile-Gx CPU model.
|
|
|
|
*/
|
2020-09-03 22:43:22 +02:00
|
|
|
struct TileGXCPUClass {
|
2015-08-20 23:41:01 +02:00
|
|
|
/*< private >*/
|
|
|
|
CPUClass parent_class;
|
|
|
|
/*< public >*/
|
|
|
|
|
|
|
|
DeviceRealize parent_realize;
|
cpu: Use DeviceClass reset instead of a special CPUClass reset
The CPUClass has a 'reset' method. This is a legacy from when
TYPE_CPU used not to inherit from TYPE_DEVICE. We don't need it any
more, as we can simply use the TYPE_DEVICE reset. The 'cpu_reset()'
function is kept as the API which most places use to reset a CPU; it
is now a wrapper which calls device_cold_reset() and then the
tracepoint function.
This change should not cause CPU objects to be reset more often
than they are at the moment, because:
* nobody is directly calling device_cold_reset() or
qdev_reset_all() on CPU objects
* no CPU object is on a qbus, so they will not be reset either
by somebody calling qbus_reset_all()/bus_cold_reset(), or
by the main "reset sysbus and everything in the qbus tree"
reset that most devices are reset by
Note that this does not change the need for each machine or whatever
to use qemu_register_reset() to arrange to call cpu_reset() -- that
is necessary because CPU objects are not on any qbus, so they don't
get reset when the qbus tree rooted at the sysbus bus is reset, and
this isn't being changed here.
All the changes to the files under target/ were made using the
included Coccinelle script, except:
(1) the deletion of the now-inaccurate and not terribly useful
"CPUClass::reset" comments was done with a perl one-liner afterwards:
perl -n -i -e '/ CPUClass::reset/ or print' target/*/*.c
(2) this bit of the s390 change was done by hand, because the
Coccinelle script is not sophisticated enough to handle the
parent_reset call being inside another function:
| @@ -96,8 +96,9 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
| S390CPU *cpu = S390_CPU(s);
| S390CPUClass *scc = S390_CPU_GET_CLASS(cpu);
| CPUS390XState *env = &cpu->env;
|+ DeviceState *dev = DEVICE(s);
|
|- scc->parent_reset(s);
|+ scc->parent_reset(dev);
| cpu->env.sigp_order = 0;
| s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu);
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20200303100511.5498-1-peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2020-03-03 11:05:11 +01:00
|
|
|
DeviceReset parent_reset;
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
2015-08-20 23:41:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TileGXCPU:
|
|
|
|
* @env: #CPUTLGState
|
|
|
|
*
|
|
|
|
* A Tile-GX CPU.
|
|
|
|
*/
|
2020-09-03 22:43:22 +02:00
|
|
|
struct TileGXCPU {
|
2015-08-20 23:41:01 +02:00
|
|
|
/*< private >*/
|
|
|
|
CPUState parent_obj;
|
|
|
|
/*< public >*/
|
|
|
|
|
2019-03-23 01:16:06 +01:00
|
|
|
CPUNegativeOffsetState neg;
|
2015-08-20 23:41:01 +02:00
|
|
|
CPUTLGState env;
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
2015-08-20 23:41:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* TILE-Gx memory attributes */
|
|
|
|
#define MMU_USER_IDX 0 /* Current memory operation is in user mode */
|
|
|
|
|
2019-03-22 23:32:23 +01:00
|
|
|
typedef CPUTLGState CPUArchState;
|
2019-03-22 23:56:19 +01:00
|
|
|
typedef TileGXCPU ArchCPU;
|
2019-03-22 23:32:23 +01:00
|
|
|
|
2015-08-20 23:41:01 +02:00
|
|
|
#include "exec/cpu-all.h"
|
|
|
|
|
|
|
|
void tilegx_tcg_init(void);
|
|
|
|
int cpu_tilegx_signal_handler(int host_signum, void *pinfo, void *puc);
|
|
|
|
|
2018-02-07 11:40:25 +01:00
|
|
|
#define CPU_RESOLVING_TYPE TYPE_TILEGX_CPU
|
2015-08-20 23:41:01 +02:00
|
|
|
|
|
|
|
#define cpu_signal_handler cpu_tilegx_signal_handler
|
|
|
|
|
|
|
|
static inline void cpu_get_tb_cpu_state(CPUTLGState *env, target_ulong *pc,
|
2016-04-07 19:19:22 +02:00
|
|
|
target_ulong *cs_base, uint32_t *flags)
|
2015-08-20 23:41:01 +02:00
|
|
|
{
|
|
|
|
*pc = env->pc;
|
|
|
|
*cs_base = 0;
|
|
|
|
*flags = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|