2012-07-20 11:50:39 +04:00
|
|
|
/*
|
|
|
|
* OpenRISC virtual CPU header.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011-2012 Jia Liu <proljc@gmail.com>
|
|
|
|
*
|
|
|
|
* 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
|
2019-02-13 16:46:50 +03:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2012-07-20 11:50:39 +04: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
|
|
|
|
* Lesser 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 12:05:55 +03:00
|
|
|
#ifndef OPENRISC_CPU_H
|
|
|
|
#define OPENRISC_CPU_H
|
2012-07-20 11:50:39 +04:00
|
|
|
|
2019-03-22 21:51:19 +03:00
|
|
|
#include "exec/cpu-defs.h"
|
2022-03-23 18:57:39 +03:00
|
|
|
#include "fpu/softfloat-types.h"
|
2019-07-09 18:20:52 +03:00
|
|
|
#include "hw/core/cpu.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2012-07-20 11:50:39 +04:00
|
|
|
|
2022-06-15 02:43:56 +03:00
|
|
|
#define TCG_GUEST_DEFAULT_MO (0)
|
|
|
|
|
2017-02-09 02:06:54 +03:00
|
|
|
#define TYPE_OPENRISC_CPU "or1k-cpu"
|
2012-07-20 11:50:39 +04:00
|
|
|
|
2022-02-14 19:08:40 +03:00
|
|
|
OBJECT_DECLARE_CPU_TYPE(OpenRISCCPU, OpenRISCCPUClass, OPENRISC_CPU)
|
2012-07-20 11:50:39 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* OpenRISCCPUClass:
|
2013-01-05 17:11:07 +04:00
|
|
|
* @parent_realize: The parent class' realize handler.
|
2012-07-20 11:50:39 +04:00
|
|
|
* @parent_reset: The parent class' reset handler.
|
|
|
|
*
|
|
|
|
* A OpenRISC CPU model.
|
|
|
|
*/
|
2020-09-03 23:43:22 +03:00
|
|
|
struct OpenRISCCPUClass {
|
2012-07-20 11:50:39 +04:00
|
|
|
/*< private >*/
|
|
|
|
CPUClass parent_class;
|
|
|
|
/*< public >*/
|
|
|
|
|
2013-01-05 17:11:07 +04:00
|
|
|
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 13:05:11 +03:00
|
|
|
DeviceReset parent_reset;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2012-07-20 11:50:39 +04:00
|
|
|
|
2016-04-05 21:41:48 +03:00
|
|
|
#define TARGET_INSN_START_EXTRA_WORDS 1
|
2012-07-20 11:50:39 +04:00
|
|
|
|
2012-07-20 11:50:40 +04:00
|
|
|
enum {
|
|
|
|
MMU_NOMMU_IDX = 0,
|
|
|
|
MMU_SUPERVISOR_IDX = 1,
|
|
|
|
MMU_USER_IDX = 2,
|
|
|
|
};
|
|
|
|
|
2012-07-20 11:50:39 +04:00
|
|
|
#define SET_FP_CAUSE(reg, v) do {\
|
|
|
|
(reg) = ((reg) & ~(0x3f << 12)) | \
|
|
|
|
((v & 0x3f) << 12);\
|
|
|
|
} while (0)
|
|
|
|
#define GET_FP_ENABLE(reg) (((reg) >> 7) & 0x1f)
|
|
|
|
#define UPDATE_FP_FLAGS(reg, v) do {\
|
|
|
|
(reg) |= ((v & 0x1f) << 2);\
|
|
|
|
} while (0)
|
|
|
|
|
2012-07-20 11:50:41 +04:00
|
|
|
/* Interrupt */
|
|
|
|
#define NR_IRQS 32
|
|
|
|
|
2012-07-20 11:50:39 +04:00
|
|
|
/* Unit presece register */
|
|
|
|
enum {
|
|
|
|
UPR_UP = (1 << 0),
|
|
|
|
UPR_DCP = (1 << 1),
|
|
|
|
UPR_ICP = (1 << 2),
|
|
|
|
UPR_DMP = (1 << 3),
|
|
|
|
UPR_IMP = (1 << 4),
|
|
|
|
UPR_MP = (1 << 5),
|
|
|
|
UPR_DUP = (1 << 6),
|
|
|
|
UPR_PCUR = (1 << 7),
|
|
|
|
UPR_PMP = (1 << 8),
|
|
|
|
UPR_PICP = (1 << 9),
|
|
|
|
UPR_TTP = (1 << 10),
|
|
|
|
UPR_CUP = (255 << 24),
|
|
|
|
};
|
|
|
|
|
|
|
|
/* CPU configure register */
|
|
|
|
enum {
|
|
|
|
CPUCFGR_NSGF = (15 << 0),
|
|
|
|
CPUCFGR_CGF = (1 << 4),
|
|
|
|
CPUCFGR_OB32S = (1 << 5),
|
|
|
|
CPUCFGR_OB64S = (1 << 6),
|
|
|
|
CPUCFGR_OF32S = (1 << 7),
|
|
|
|
CPUCFGR_OF64S = (1 << 8),
|
|
|
|
CPUCFGR_OV64S = (1 << 9),
|
2019-08-26 01:23:42 +03:00
|
|
|
CPUCFGR_ND = (1 << 10),
|
|
|
|
CPUCFGR_AVRP = (1 << 11),
|
2017-04-18 09:15:50 +03:00
|
|
|
CPUCFGR_EVBARP = (1 << 12),
|
2019-08-26 01:23:42 +03:00
|
|
|
CPUCFGR_ISRP = (1 << 13),
|
|
|
|
CPUCFGR_AECSRP = (1 << 14),
|
|
|
|
CPUCFGR_OF64A32S = (1 << 15),
|
2012-07-20 11:50:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* DMMU configure register */
|
|
|
|
enum {
|
|
|
|
DMMUCFGR_NTW = (3 << 0),
|
|
|
|
DMMUCFGR_NTS = (7 << 2),
|
|
|
|
DMMUCFGR_NAE = (7 << 5),
|
|
|
|
DMMUCFGR_CRI = (1 << 8),
|
|
|
|
DMMUCFGR_PRI = (1 << 9),
|
|
|
|
DMMUCFGR_TEIRI = (1 << 10),
|
|
|
|
DMMUCFGR_HTR = (1 << 11),
|
|
|
|
};
|
|
|
|
|
|
|
|
/* IMMU configure register */
|
|
|
|
enum {
|
|
|
|
IMMUCFGR_NTW = (3 << 0),
|
|
|
|
IMMUCFGR_NTS = (7 << 2),
|
|
|
|
IMMUCFGR_NAE = (7 << 5),
|
|
|
|
IMMUCFGR_CRI = (1 << 8),
|
|
|
|
IMMUCFGR_PRI = (1 << 9),
|
|
|
|
IMMUCFGR_TEIRI = (1 << 10),
|
|
|
|
IMMUCFGR_HTR = (1 << 11),
|
|
|
|
};
|
|
|
|
|
2017-04-24 00:07:42 +03:00
|
|
|
/* Power management register */
|
|
|
|
enum {
|
|
|
|
PMR_SDF = (15 << 0),
|
|
|
|
PMR_DME = (1 << 4),
|
|
|
|
PMR_SME = (1 << 5),
|
|
|
|
PMR_DCGE = (1 << 6),
|
|
|
|
PMR_SUME = (1 << 7),
|
|
|
|
};
|
|
|
|
|
2012-07-20 11:50:39 +04:00
|
|
|
/* Float point control status register */
|
|
|
|
enum {
|
|
|
|
FPCSR_FPEE = 1,
|
|
|
|
FPCSR_RM = (3 << 1),
|
|
|
|
FPCSR_OVF = (1 << 3),
|
|
|
|
FPCSR_UNF = (1 << 4),
|
|
|
|
FPCSR_SNF = (1 << 5),
|
|
|
|
FPCSR_QNF = (1 << 6),
|
|
|
|
FPCSR_ZF = (1 << 7),
|
|
|
|
FPCSR_IXF = (1 << 8),
|
|
|
|
FPCSR_IVF = (1 << 9),
|
|
|
|
FPCSR_INF = (1 << 10),
|
|
|
|
FPCSR_DZF = (1 << 11),
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Exceptions indices */
|
|
|
|
enum {
|
|
|
|
EXCP_RESET = 0x1,
|
|
|
|
EXCP_BUSERR = 0x2,
|
|
|
|
EXCP_DPF = 0x3,
|
|
|
|
EXCP_IPF = 0x4,
|
|
|
|
EXCP_TICK = 0x5,
|
|
|
|
EXCP_ALIGN = 0x6,
|
|
|
|
EXCP_ILLEGAL = 0x7,
|
|
|
|
EXCP_INT = 0x8,
|
|
|
|
EXCP_DTLBMISS = 0x9,
|
|
|
|
EXCP_ITLBMISS = 0xa,
|
|
|
|
EXCP_RANGE = 0xb,
|
|
|
|
EXCP_SYSCALL = 0xc,
|
|
|
|
EXCP_FPE = 0xd,
|
|
|
|
EXCP_TRAP = 0xe,
|
|
|
|
EXCP_NR,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Supervisor register */
|
|
|
|
enum {
|
|
|
|
SR_SM = (1 << 0),
|
|
|
|
SR_TEE = (1 << 1),
|
|
|
|
SR_IEE = (1 << 2),
|
|
|
|
SR_DCE = (1 << 3),
|
|
|
|
SR_ICE = (1 << 4),
|
|
|
|
SR_DME = (1 << 5),
|
|
|
|
SR_IME = (1 << 6),
|
|
|
|
SR_LEE = (1 << 7),
|
|
|
|
SR_CE = (1 << 8),
|
|
|
|
SR_F = (1 << 9),
|
|
|
|
SR_CY = (1 << 10),
|
|
|
|
SR_OV = (1 << 11),
|
|
|
|
SR_OVE = (1 << 12),
|
|
|
|
SR_DSX = (1 << 13),
|
|
|
|
SR_EPH = (1 << 14),
|
|
|
|
SR_FO = (1 << 15),
|
|
|
|
SR_SUMRA = (1 << 16),
|
|
|
|
SR_SCE = (1 << 17),
|
|
|
|
};
|
|
|
|
|
2012-07-20 11:50:47 +04:00
|
|
|
/* Tick Timer Mode Register */
|
|
|
|
enum {
|
|
|
|
TTMR_TP = (0xfffffff),
|
|
|
|
TTMR_IP = (1 << 28),
|
|
|
|
TTMR_IE = (1 << 29),
|
|
|
|
TTMR_M = (3 << 30),
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Timer Mode */
|
|
|
|
enum {
|
|
|
|
TIMER_NONE = (0 << 30),
|
|
|
|
TIMER_INTR = (1 << 30),
|
|
|
|
TIMER_SHOT = (2 << 30),
|
|
|
|
TIMER_CONT = (3 << 30),
|
|
|
|
};
|
|
|
|
|
2012-07-20 11:50:40 +04:00
|
|
|
/* TLB size */
|
|
|
|
enum {
|
2018-05-23 08:04:46 +03:00
|
|
|
TLB_SIZE = 128,
|
2018-05-23 06:18:20 +03:00
|
|
|
TLB_MASK = TLB_SIZE - 1,
|
2012-07-20 11:50:40 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* TLB prot */
|
|
|
|
enum {
|
|
|
|
URE = (1 << 6),
|
|
|
|
UWE = (1 << 7),
|
|
|
|
SRE = (1 << 8),
|
|
|
|
SWE = (1 << 9),
|
|
|
|
|
|
|
|
SXE = (1 << 6),
|
|
|
|
UXE = (1 << 7),
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct OpenRISCTLBEntry {
|
|
|
|
uint32_t mr;
|
|
|
|
uint32_t tr;
|
|
|
|
} OpenRISCTLBEntry;
|
|
|
|
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
typedef struct CPUOpenRISCTLBContext {
|
2018-05-23 06:18:20 +03:00
|
|
|
OpenRISCTLBEntry itlb[TLB_SIZE];
|
|
|
|
OpenRISCTLBEntry dtlb[TLB_SIZE];
|
2012-07-20 11:50:40 +04:00
|
|
|
|
2022-02-07 15:17:56 +03:00
|
|
|
int (*cpu_openrisc_map_address_code)(OpenRISCCPU *cpu,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr *physical,
|
2012-07-20 11:50:40 +04:00
|
|
|
int *prot,
|
|
|
|
target_ulong address, int rw);
|
2022-02-07 15:17:56 +03:00
|
|
|
int (*cpu_openrisc_map_address_data)(OpenRISCCPU *cpu,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr *physical,
|
2012-07-20 11:50:40 +04:00
|
|
|
int *prot,
|
|
|
|
target_ulong address, int rw);
|
|
|
|
} CPUOpenRISCTLBContext;
|
|
|
|
#endif
|
|
|
|
|
2022-02-07 15:35:58 +03:00
|
|
|
typedef struct CPUArchState {
|
2017-04-06 00:44:56 +03:00
|
|
|
target_ulong shadow_gpr[16][32]; /* Shadow registers */
|
|
|
|
|
2012-07-20 11:50:39 +04:00
|
|
|
target_ulong pc; /* Program counter */
|
|
|
|
target_ulong ppc; /* Prev PC */
|
|
|
|
target_ulong jmp_pc; /* Jump PC */
|
|
|
|
|
2015-02-19 02:05:05 +03:00
|
|
|
uint64_t mac; /* Multiply registers MACHI:MACLO */
|
2012-07-20 11:50:39 +04:00
|
|
|
|
|
|
|
target_ulong epcr; /* Exception PC register */
|
|
|
|
target_ulong eear; /* Exception EA register */
|
|
|
|
|
2015-02-18 22:45:54 +03:00
|
|
|
target_ulong sr_f; /* the SR_F bit, values 0, 1. */
|
2015-02-19 00:26:26 +03:00
|
|
|
target_ulong sr_cy; /* the SR_CY bit, values 0, 1. */
|
|
|
|
target_long sr_ov; /* the SR_OV bit (in the sign bit only) */
|
|
|
|
uint32_t sr; /* Supervisor register, without SR_{F,CY,OV} */
|
2012-07-20 11:50:39 +04:00
|
|
|
uint32_t esr; /* Exception supervisor register */
|
2017-04-18 09:15:50 +03:00
|
|
|
uint32_t evbar; /* Exception vector base address register */
|
2017-04-24 00:07:42 +03:00
|
|
|
uint32_t pmr; /* Power Management Register */
|
2012-07-20 11:50:39 +04:00
|
|
|
uint32_t fpcsr; /* Float register */
|
|
|
|
float_status fp_status;
|
|
|
|
|
2015-02-19 09:19:18 +03:00
|
|
|
target_ulong lock_addr;
|
|
|
|
target_ulong lock_value;
|
|
|
|
|
2016-04-06 04:00:33 +03:00
|
|
|
uint32_t dflag; /* In delay slot (boolean) */
|
2012-07-20 11:50:39 +04:00
|
|
|
|
2018-05-23 02:28:33 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
CPUOpenRISCTLBContext tlb;
|
|
|
|
#endif
|
|
|
|
|
2016-11-14 17:19:17 +03:00
|
|
|
/* Fields up to this point are cleared by a CPU reset */
|
|
|
|
struct {} end_reset_fields;
|
|
|
|
|
2013-08-26 23:22:53 +04:00
|
|
|
/* Fields from here on are preserved across CPU reset. */
|
2019-08-26 01:02:54 +03:00
|
|
|
uint32_t vr; /* Version register */
|
2019-08-26 01:23:42 +03:00
|
|
|
uint32_t vr2; /* Version register 2 */
|
|
|
|
uint32_t avr; /* Architecture version register */
|
2019-08-26 01:02:54 +03:00
|
|
|
uint32_t upr; /* Unit presence register */
|
2017-04-21 18:28:55 +03:00
|
|
|
uint32_t cpucfgr; /* CPU configure register */
|
2019-08-26 01:02:54 +03:00
|
|
|
uint32_t dmmucfgr; /* DMMU configure register */
|
|
|
|
uint32_t immucfgr; /* IMMU configure register */
|
2017-04-21 18:28:55 +03:00
|
|
|
|
2012-07-20 11:50:39 +04:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2013-12-01 11:49:47 +04:00
|
|
|
QEMUTimer *timer;
|
2012-07-20 11:50:39 +04:00
|
|
|
uint32_t ttmr; /* Timer tick mode register */
|
2017-08-22 00:37:10 +03:00
|
|
|
int is_counting;
|
2012-07-20 11:50:39 +04:00
|
|
|
|
|
|
|
uint32_t picmr; /* Interrupt mask register */
|
|
|
|
uint32_t picsr; /* Interrupt contrl register*/
|
|
|
|
#endif
|
|
|
|
} CPUOpenRISCState;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* OpenRISCCPU:
|
|
|
|
* @env: #CPUOpenRISCState
|
|
|
|
*
|
|
|
|
* A OpenRISC CPU.
|
|
|
|
*/
|
2022-02-14 19:15:16 +03:00
|
|
|
struct ArchCPU {
|
2012-07-20 11:50:39 +04:00
|
|
|
/*< private >*/
|
|
|
|
CPUState parent_obj;
|
|
|
|
/*< public >*/
|
|
|
|
|
2019-03-23 03:16:06 +03:00
|
|
|
CPUNegativeOffsetState neg;
|
2012-07-20 11:50:39 +04:00
|
|
|
CPUOpenRISCState env;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2012-07-20 11:50:39 +04:00
|
|
|
|
2013-02-22 22:10:01 +04:00
|
|
|
|
2019-04-17 22:17:57 +03:00
|
|
|
void cpu_openrisc_list(void);
|
2019-04-17 22:18:02 +03:00
|
|
|
void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
|
2013-06-29 20:55:54 +04:00
|
|
|
hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
|
2020-03-16 20:21:41 +03:00
|
|
|
int openrisc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
|
2013-06-29 06:18:45 +04:00
|
|
|
int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
|
2012-07-20 11:50:39 +04:00
|
|
|
void openrisc_translate_init(void);
|
2018-05-23 18:14:46 +03:00
|
|
|
int print_insn_or1k(bfd_vma addr, disassemble_info *info);
|
2012-07-20 11:50:39 +04:00
|
|
|
|
|
|
|
#define cpu_list cpu_openrisc_list
|
|
|
|
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
2021-09-15 06:33:23 +03:00
|
|
|
bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
|
|
|
|
MMUAccessType access_type, int mmu_idx,
|
|
|
|
bool probe, uintptr_t retaddr);
|
|
|
|
|
2019-08-12 08:23:44 +03:00
|
|
|
extern const VMStateDescription vmstate_openrisc_cpu;
|
2013-02-02 16:59:05 +04:00
|
|
|
|
2021-09-11 19:54:26 +03:00
|
|
|
void openrisc_cpu_do_interrupt(CPUState *cpu);
|
|
|
|
bool openrisc_cpu_exec_interrupt(CPUState *cpu, int int_req);
|
|
|
|
|
2012-07-20 11:50:46 +04:00
|
|
|
/* hw/openrisc_pic.c */
|
|
|
|
void cpu_openrisc_pic_init(OpenRISCCPU *cpu);
|
|
|
|
|
2012-07-20 11:50:47 +04:00
|
|
|
/* hw/openrisc_timer.c */
|
|
|
|
void cpu_openrisc_clock_init(OpenRISCCPU *cpu);
|
2017-08-22 00:37:10 +03:00
|
|
|
uint32_t cpu_openrisc_count_get(OpenRISCCPU *cpu);
|
|
|
|
void cpu_openrisc_count_set(OpenRISCCPU *cpu, uint32_t val);
|
2012-07-20 11:50:47 +04:00
|
|
|
void cpu_openrisc_count_update(OpenRISCCPU *cpu);
|
2013-10-22 04:12:41 +04:00
|
|
|
void cpu_openrisc_timer_update(OpenRISCCPU *cpu);
|
2012-07-20 11:50:47 +04:00
|
|
|
void cpu_openrisc_count_start(OpenRISCCPU *cpu);
|
|
|
|
void cpu_openrisc_count_stop(OpenRISCCPU *cpu);
|
2012-07-20 11:50:39 +04:00
|
|
|
#endif
|
|
|
|
|
2017-10-05 16:50:51 +03:00
|
|
|
#define OPENRISC_CPU_TYPE_SUFFIX "-" TYPE_OPENRISC_CPU
|
|
|
|
#define OPENRISC_CPU_TYPE_NAME(model) model OPENRISC_CPU_TYPE_SUFFIX
|
2018-02-07 13:40:25 +03:00
|
|
|
#define CPU_RESOLVING_TYPE TYPE_OPENRISC_CPU
|
2017-10-05 16:50:51 +03:00
|
|
|
|
2012-12-17 21:19:49 +04:00
|
|
|
#include "exec/cpu-all.h"
|
2012-07-20 11:50:39 +04:00
|
|
|
|
2018-05-23 05:51:00 +03:00
|
|
|
#define TB_FLAGS_SM SR_SM
|
|
|
|
#define TB_FLAGS_DME SR_DME
|
|
|
|
#define TB_FLAGS_IME SR_IME
|
2016-04-06 04:00:33 +03:00
|
|
|
#define TB_FLAGS_OVE SR_OVE
|
2018-05-23 05:51:00 +03:00
|
|
|
#define TB_FLAGS_DFLAG 2 /* reuse SR_TEE */
|
|
|
|
#define TB_FLAGS_R0_0 4 /* reuse SR_IEE */
|
2016-04-06 04:00:33 +03:00
|
|
|
|
2017-04-06 00:44:56 +03:00
|
|
|
static inline uint32_t cpu_get_gpr(const CPUOpenRISCState *env, int i)
|
|
|
|
{
|
|
|
|
return env->shadow_gpr[0][i];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void cpu_set_gpr(CPUOpenRISCState *env, int i, uint32_t val)
|
|
|
|
{
|
|
|
|
env->shadow_gpr[0][i] = val;
|
|
|
|
}
|
|
|
|
|
2012-07-20 11:50:39 +04:00
|
|
|
static inline void cpu_get_tb_cpu_state(CPUOpenRISCState *env,
|
|
|
|
target_ulong *pc,
|
2016-04-07 20:19:22 +03:00
|
|
|
target_ulong *cs_base, uint32_t *flags)
|
2012-07-20 11:50:39 +04:00
|
|
|
{
|
|
|
|
*pc = env->pc;
|
|
|
|
*cs_base = 0;
|
2018-05-23 05:51:00 +03:00
|
|
|
*flags = (env->dflag ? TB_FLAGS_DFLAG : 0)
|
|
|
|
| (cpu_get_gpr(env, 0) ? 0 : TB_FLAGS_R0_0)
|
|
|
|
| (env->sr & (SR_SM | SR_DME | SR_IME | SR_OVE));
|
2012-07-20 11:50:39 +04:00
|
|
|
}
|
|
|
|
|
2015-08-17 10:34:10 +03:00
|
|
|
static inline int cpu_mmu_index(CPUOpenRISCState *env, bool ifetch)
|
2012-07-20 11:50:39 +04:00
|
|
|
{
|
2018-05-23 05:51:00 +03:00
|
|
|
int ret = MMU_NOMMU_IDX; /* mmu is disabled */
|
|
|
|
|
|
|
|
if (env->sr & (ifetch ? SR_IME : SR_DME)) {
|
|
|
|
/* The mmu is enabled; test supervisor state. */
|
|
|
|
ret = env->sr & SR_SM ? MMU_SUPERVISOR_IDX : MMU_USER_IDX;
|
2012-07-20 11:50:40 +04:00
|
|
|
}
|
2018-05-23 05:51:00 +03:00
|
|
|
|
|
|
|
return ret;
|
2012-07-20 11:50:39 +04:00
|
|
|
}
|
|
|
|
|
2015-02-18 22:45:54 +03:00
|
|
|
static inline uint32_t cpu_get_sr(const CPUOpenRISCState *env)
|
|
|
|
{
|
2015-02-19 00:26:26 +03:00
|
|
|
return (env->sr
|
|
|
|
+ env->sr_f * SR_F
|
|
|
|
+ env->sr_cy * SR_CY
|
|
|
|
+ (env->sr_ov < 0) * SR_OV);
|
2015-02-18 22:45:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void cpu_set_sr(CPUOpenRISCState *env, uint32_t val)
|
|
|
|
{
|
|
|
|
env->sr_f = (val & SR_F) != 0;
|
2015-02-19 00:26:26 +03:00
|
|
|
env->sr_cy = (val & SR_CY) != 0;
|
|
|
|
env->sr_ov = (val & SR_OV ? -1 : 0);
|
|
|
|
env->sr = (val & ~(SR_F | SR_CY | SR_OV)) | SR_FO;
|
2015-02-18 22:45:54 +03:00
|
|
|
}
|
|
|
|
|
2019-08-27 01:10:10 +03:00
|
|
|
void cpu_set_fpcsr(CPUOpenRISCState *env, uint32_t val);
|
|
|
|
|
2012-07-20 11:50:41 +04:00
|
|
|
#define CPU_INTERRUPT_TIMER CPU_INTERRUPT_TGT_INT_0
|
2012-07-20 11:50:39 +04:00
|
|
|
|
2016-06-29 12:05:55 +03:00
|
|
|
#endif /* OPENRISC_CPU_H */
|