2009-05-20 21:37:39 +04:00
|
|
|
/*
|
|
|
|
* MicroBlaze virtual CPU header
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009 Edgar E. Iglesias
|
|
|
|
*
|
|
|
|
* 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 15:18:21 +03:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2009-05-20 21:37: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
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-07-17 00:47:01 +04:00
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2009-05-20 21:37:39 +04:00
|
|
|
*/
|
2016-06-29 12:05:55 +03:00
|
|
|
|
|
|
|
#ifndef MICROBLAZE_CPU_H
|
|
|
|
#define MICROBLAZE_CPU_H
|
2009-05-20 21:37:39 +04:00
|
|
|
|
2016-03-15 15:49:25 +03:00
|
|
|
#include "cpu-qom.h"
|
2019-03-22 21:51:19 +03:00
|
|
|
#include "exec/cpu-defs.h"
|
2022-03-23 18:57:39 +03:00
|
|
|
#include "qemu/cpu-float.h"
|
2009-05-20 21:37:39 +04:00
|
|
|
|
2022-02-07 15:35:58 +03:00
|
|
|
typedef struct CPUArchState CPUMBState;
|
2009-05-20 21:37:39 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
#include "mmu.h"
|
|
|
|
#endif
|
|
|
|
|
2015-04-29 08:34:29 +03:00
|
|
|
#define EXCP_MMU 1
|
|
|
|
#define EXCP_IRQ 2
|
2020-08-23 19:17:22 +03:00
|
|
|
#define EXCP_SYSCALL 3 /* user-only */
|
2015-04-29 08:34:29 +03:00
|
|
|
#define EXCP_HW_BREAK 4
|
|
|
|
#define EXCP_HW_EXCP 5
|
2009-05-20 21:37:39 +04:00
|
|
|
|
2011-05-05 00:34:31 +04:00
|
|
|
/* MicroBlaze-specific interrupt pending bits. */
|
|
|
|
#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_3
|
|
|
|
|
2014-01-13 07:35:26 +04:00
|
|
|
/* Meanings of the MBCPU object's two inbound GPIO lines */
|
|
|
|
#define MB_CPU_IRQ 0
|
|
|
|
#define MB_CPU_FIR 1
|
|
|
|
|
2009-05-20 21:37:39 +04:00
|
|
|
/* Register aliases. R0 - R15 */
|
|
|
|
#define R_SP 1
|
|
|
|
#define SR_PC 0
|
|
|
|
#define SR_MSR 1
|
|
|
|
#define SR_EAR 3
|
|
|
|
#define SR_ESR 5
|
|
|
|
#define SR_FSR 7
|
|
|
|
#define SR_BTR 0xb
|
|
|
|
#define SR_EDR 0xd
|
|
|
|
|
|
|
|
/* MSR flags. */
|
|
|
|
#define MSR_BE (1<<0) /* 0x001 */
|
|
|
|
#define MSR_IE (1<<1) /* 0x002 */
|
|
|
|
#define MSR_C (1<<2) /* 0x004 */
|
|
|
|
#define MSR_BIP (1<<3) /* 0x008 */
|
|
|
|
#define MSR_FSL (1<<4) /* 0x010 */
|
|
|
|
#define MSR_ICE (1<<5) /* 0x020 */
|
|
|
|
#define MSR_DZ (1<<6) /* 0x040 */
|
|
|
|
#define MSR_DCE (1<<7) /* 0x080 */
|
|
|
|
#define MSR_EE (1<<8) /* 0x100 */
|
|
|
|
#define MSR_EIP (1<<9) /* 0x200 */
|
2011-08-25 10:41:19 +04:00
|
|
|
#define MSR_PVR (1<<10) /* 0x400 */
|
2009-05-20 21:37:39 +04:00
|
|
|
#define MSR_CC (1<<31)
|
|
|
|
|
|
|
|
/* Machine State Register (MSR) Fields */
|
|
|
|
#define MSR_UM (1<<11) /* User Mode */
|
|
|
|
#define MSR_UMS (1<<12) /* User Mode Save */
|
|
|
|
#define MSR_VM (1<<13) /* Virtual Mode */
|
|
|
|
#define MSR_VMS (1<<14) /* Virtual Mode Save */
|
|
|
|
|
|
|
|
#define MSR_KERNEL MSR_EE|MSR_VM
|
|
|
|
//#define MSR_USER MSR_KERNEL|MSR_UM|MSR_IE
|
|
|
|
#define MSR_KERNEL_VMS MSR_EE|MSR_VMS
|
|
|
|
//#define MSR_USER_VMS MSR_KERNEL_VMS|MSR_UMS|MSR_IE
|
|
|
|
|
|
|
|
/* Exception State Register (ESR) Fields */
|
|
|
|
#define ESR_DIZ (1<<11) /* Zone Protection */
|
2020-08-21 06:29:01 +03:00
|
|
|
#define ESR_W (1<<11) /* Unaligned word access */
|
2009-05-20 21:37:39 +04:00
|
|
|
#define ESR_S (1<<10) /* Store instruction */
|
|
|
|
|
2011-04-12 02:42:28 +04:00
|
|
|
#define ESR_ESS_FSL_OFFSET 5
|
|
|
|
|
2020-08-21 06:29:01 +03:00
|
|
|
#define ESR_ESS_MASK (0x7f << 5)
|
|
|
|
|
2009-09-03 12:25:00 +04:00
|
|
|
#define ESR_EC_FSL 0
|
|
|
|
#define ESR_EC_UNALIGNED_DATA 1
|
|
|
|
#define ESR_EC_ILLEGAL_OP 2
|
|
|
|
#define ESR_EC_INSN_BUS 3
|
|
|
|
#define ESR_EC_DATA_BUS 4
|
|
|
|
#define ESR_EC_DIVZERO 5
|
|
|
|
#define ESR_EC_FPU 6
|
|
|
|
#define ESR_EC_PRIVINSN 7
|
2012-01-10 13:27:11 +04:00
|
|
|
#define ESR_EC_STACKPROT 7 /* Same as PRIVINSN. */
|
2009-09-03 12:25:00 +04:00
|
|
|
#define ESR_EC_DATA_STORAGE 8
|
|
|
|
#define ESR_EC_INSN_STORAGE 9
|
|
|
|
#define ESR_EC_DATA_TLB 10
|
|
|
|
#define ESR_EC_INSN_TLB 11
|
2011-04-12 01:55:42 +04:00
|
|
|
#define ESR_EC_MASK 31
|
2009-05-20 21:37:39 +04:00
|
|
|
|
2010-09-09 11:58:35 +04:00
|
|
|
/* Floating Point Status Register (FSR) Bits */
|
|
|
|
#define FSR_IO (1<<4) /* Invalid operation */
|
|
|
|
#define FSR_DZ (1<<3) /* Divide-by-zero */
|
|
|
|
#define FSR_OF (1<<2) /* Overflow */
|
|
|
|
#define FSR_UF (1<<1) /* Underflow */
|
|
|
|
#define FSR_DO (1<<0) /* Denormalized operand error */
|
|
|
|
|
2009-05-20 21:37:39 +04:00
|
|
|
/* Version reg. */
|
|
|
|
/* Basic PVR mask */
|
|
|
|
#define PVR0_PVR_FULL_MASK 0x80000000
|
|
|
|
#define PVR0_USE_BARREL_MASK 0x40000000
|
|
|
|
#define PVR0_USE_DIV_MASK 0x20000000
|
|
|
|
#define PVR0_USE_HW_MUL_MASK 0x10000000
|
|
|
|
#define PVR0_USE_FPU_MASK 0x08000000
|
|
|
|
#define PVR0_USE_EXC_MASK 0x04000000
|
|
|
|
#define PVR0_USE_ICACHE_MASK 0x02000000
|
|
|
|
#define PVR0_USE_DCACHE_MASK 0x01000000
|
2015-06-19 07:16:29 +03:00
|
|
|
#define PVR0_USE_MMU_MASK 0x00800000
|
2011-03-04 16:39:31 +03:00
|
|
|
#define PVR0_USE_BTC 0x00400000
|
2015-06-19 07:16:35 +03:00
|
|
|
#define PVR0_ENDI_MASK 0x00200000
|
2011-03-04 16:39:31 +03:00
|
|
|
#define PVR0_FAULT 0x00100000
|
2009-05-20 21:37:39 +04:00
|
|
|
#define PVR0_VERSION_MASK 0x0000FF00
|
|
|
|
#define PVR0_USER1_MASK 0x000000FF
|
2015-05-29 09:30:43 +03:00
|
|
|
#define PVR0_SPROT_MASK 0x00000001
|
2009-05-20 21:37:39 +04:00
|
|
|
|
2017-01-10 19:14:34 +03:00
|
|
|
#define PVR0_VERSION_SHIFT 8
|
|
|
|
|
2009-05-20 21:37:39 +04:00
|
|
|
/* User 2 PVR mask */
|
|
|
|
#define PVR1_USER2_MASK 0xFFFFFFFF
|
|
|
|
|
|
|
|
/* Configuration PVR masks */
|
|
|
|
#define PVR2_D_OPB_MASK 0x80000000
|
|
|
|
#define PVR2_D_LMB_MASK 0x40000000
|
|
|
|
#define PVR2_I_OPB_MASK 0x20000000
|
|
|
|
#define PVR2_I_LMB_MASK 0x10000000
|
|
|
|
#define PVR2_INTERRUPT_IS_EDGE_MASK 0x08000000
|
|
|
|
#define PVR2_EDGE_IS_POSITIVE_MASK 0x04000000
|
|
|
|
#define PVR2_D_PLB_MASK 0x02000000 /* new */
|
|
|
|
#define PVR2_I_PLB_MASK 0x01000000 /* new */
|
|
|
|
#define PVR2_INTERCONNECT 0x00800000 /* new */
|
|
|
|
#define PVR2_USE_EXTEND_FSL 0x00080000 /* new */
|
|
|
|
#define PVR2_USE_FSL_EXC 0x00040000 /* new */
|
|
|
|
#define PVR2_USE_MSR_INSTR 0x00020000
|
|
|
|
#define PVR2_USE_PCMP_INSTR 0x00010000
|
|
|
|
#define PVR2_AREA_OPTIMISED 0x00008000
|
|
|
|
#define PVR2_USE_BARREL_MASK 0x00004000
|
|
|
|
#define PVR2_USE_DIV_MASK 0x00002000
|
|
|
|
#define PVR2_USE_HW_MUL_MASK 0x00001000
|
|
|
|
#define PVR2_USE_FPU_MASK 0x00000800
|
|
|
|
#define PVR2_USE_MUL64_MASK 0x00000400
|
|
|
|
#define PVR2_USE_FPU2_MASK 0x00000200 /* new */
|
|
|
|
#define PVR2_USE_IPLBEXC 0x00000100
|
|
|
|
#define PVR2_USE_DPLBEXC 0x00000080
|
|
|
|
#define PVR2_OPCODE_0x0_ILL_MASK 0x00000040
|
|
|
|
#define PVR2_UNALIGNED_EXC_MASK 0x00000020
|
|
|
|
#define PVR2_ILL_OPCODE_EXC_MASK 0x00000010
|
|
|
|
#define PVR2_IOPB_BUS_EXC_MASK 0x00000008
|
|
|
|
#define PVR2_DOPB_BUS_EXC_MASK 0x00000004
|
|
|
|
#define PVR2_DIV_ZERO_EXC_MASK 0x00000002
|
|
|
|
#define PVR2_FPU_EXC_MASK 0x00000001
|
|
|
|
|
|
|
|
/* Debug and exception PVR masks */
|
|
|
|
#define PVR3_DEBUG_ENABLED_MASK 0x80000000
|
|
|
|
#define PVR3_NUMBER_OF_PC_BRK_MASK 0x1E000000
|
|
|
|
#define PVR3_NUMBER_OF_RD_ADDR_BRK_MASK 0x00380000
|
|
|
|
#define PVR3_NUMBER_OF_WR_ADDR_BRK_MASK 0x0000E000
|
|
|
|
#define PVR3_FSL_LINKS_MASK 0x00000380
|
|
|
|
|
|
|
|
/* ICache config PVR masks */
|
|
|
|
#define PVR4_USE_ICACHE_MASK 0x80000000
|
|
|
|
#define PVR4_ICACHE_ADDR_TAG_BITS_MASK 0x7C000000
|
|
|
|
#define PVR4_ICACHE_USE_FSL_MASK 0x02000000
|
|
|
|
#define PVR4_ICACHE_ALLOW_WR_MASK 0x01000000
|
|
|
|
#define PVR4_ICACHE_LINE_LEN_MASK 0x00E00000
|
|
|
|
#define PVR4_ICACHE_BYTE_SIZE_MASK 0x001F0000
|
|
|
|
|
|
|
|
/* DCache config PVR masks */
|
|
|
|
#define PVR5_USE_DCACHE_MASK 0x80000000
|
|
|
|
#define PVR5_DCACHE_ADDR_TAG_BITS_MASK 0x7C000000
|
|
|
|
#define PVR5_DCACHE_USE_FSL_MASK 0x02000000
|
|
|
|
#define PVR5_DCACHE_ALLOW_WR_MASK 0x01000000
|
|
|
|
#define PVR5_DCACHE_LINE_LEN_MASK 0x00E00000
|
|
|
|
#define PVR5_DCACHE_BYTE_SIZE_MASK 0x001F0000
|
2011-03-04 16:39:31 +03:00
|
|
|
#define PVR5_DCACHE_WRITEBACK_MASK 0x00004000
|
2009-05-20 21:37:39 +04:00
|
|
|
|
|
|
|
/* ICache base address PVR mask */
|
|
|
|
#define PVR6_ICACHE_BASEADDR_MASK 0xFFFFFFFF
|
|
|
|
|
|
|
|
/* ICache high address PVR mask */
|
|
|
|
#define PVR7_ICACHE_HIGHADDR_MASK 0xFFFFFFFF
|
|
|
|
|
|
|
|
/* DCache base address PVR mask */
|
|
|
|
#define PVR8_DCACHE_BASEADDR_MASK 0xFFFFFFFF
|
|
|
|
|
|
|
|
/* DCache high address PVR mask */
|
|
|
|
#define PVR9_DCACHE_HIGHADDR_MASK 0xFFFFFFFF
|
|
|
|
|
|
|
|
/* Target family PVR mask */
|
|
|
|
#define PVR10_TARGET_FAMILY_MASK 0xFF000000
|
2018-04-13 23:04:37 +03:00
|
|
|
#define PVR10_ASIZE_SHIFT 18
|
2009-05-20 21:37:39 +04:00
|
|
|
|
2023-07-14 14:23:51 +03:00
|
|
|
/* MMU description */
|
2009-05-20 21:37:39 +04:00
|
|
|
#define PVR11_USE_MMU 0xC0000000
|
|
|
|
#define PVR11_MMU_ITLB_SIZE 0x38000000
|
|
|
|
#define PVR11_MMU_DTLB_SIZE 0x07000000
|
|
|
|
#define PVR11_MMU_TLB_ACCESS 0x00C00000
|
2011-04-12 01:07:58 +04:00
|
|
|
#define PVR11_MMU_ZONES 0x003E0000
|
2009-05-20 21:37:39 +04:00
|
|
|
/* MSR Reset value PVR mask */
|
|
|
|
#define PVR11_MSR_RESET_VALUE_MASK 0x000007FF
|
|
|
|
|
2015-06-19 07:16:42 +03:00
|
|
|
#define C_PVR_NONE 0
|
|
|
|
#define C_PVR_BASIC 1
|
|
|
|
#define C_PVR_FULL 2
|
2009-05-20 21:37:39 +04:00
|
|
|
|
|
|
|
/* CPU flags. */
|
|
|
|
|
|
|
|
/* Condition codes. */
|
|
|
|
#define CC_GE 5
|
|
|
|
#define CC_GT 4
|
|
|
|
#define CC_LE 3
|
|
|
|
#define CC_LT 2
|
|
|
|
#define CC_NE 1
|
|
|
|
#define CC_EQ 0
|
|
|
|
|
2011-04-12 02:42:28 +04:00
|
|
|
#define STREAM_EXCEPTION (1 << 0)
|
|
|
|
#define STREAM_ATOMIC (1 << 1)
|
|
|
|
#define STREAM_TEST (1 << 2)
|
|
|
|
#define STREAM_CONTROL (1 << 3)
|
|
|
|
#define STREAM_NONBLOCK (1 << 4)
|
|
|
|
|
2020-08-20 18:44:20 +03:00
|
|
|
#define TARGET_INSN_START_EXTRA_WORDS 1
|
|
|
|
|
2021-01-22 03:18:53 +03:00
|
|
|
/* use-non-secure property masks */
|
|
|
|
#define USE_NON_SECURE_M_AXI_DP_MASK 0x1
|
|
|
|
#define USE_NON_SECURE_M_AXI_IP_MASK 0x2
|
|
|
|
#define USE_NON_SECURE_M_AXI_DC_MASK 0x4
|
|
|
|
#define USE_NON_SECURE_M_AXI_IC_MASK 0x8
|
|
|
|
|
2022-02-07 15:35:58 +03:00
|
|
|
struct CPUArchState {
|
2020-08-24 19:58:14 +03:00
|
|
|
uint32_t bvalue; /* TCG temporary, only valid during a TB */
|
|
|
|
uint32_t btarget; /* Full resolved branch destination */
|
2009-05-20 21:37:39 +04:00
|
|
|
|
|
|
|
uint32_t imm;
|
2018-04-13 22:55:21 +03:00
|
|
|
uint32_t regs[32];
|
2020-08-20 08:25:16 +03:00
|
|
|
uint32_t pc;
|
2020-08-18 21:58:23 +03:00
|
|
|
uint32_t msr; /* All bits of MSR except MSR[C] and MSR[CC] */
|
|
|
|
uint32_t msr_c; /* MSR[C], in low bit; other bits must be 0 */
|
2020-08-25 22:37:12 +03:00
|
|
|
target_ulong ear;
|
2020-08-20 08:37:40 +03:00
|
|
|
uint32_t esr;
|
2020-08-20 08:40:23 +03:00
|
|
|
uint32_t fsr;
|
2020-08-20 08:44:49 +03:00
|
|
|
uint32_t btr;
|
2020-08-20 08:48:18 +03:00
|
|
|
uint32_t edr;
|
2010-09-09 12:20:17 +04:00
|
|
|
float_status fp_status;
|
2012-01-10 13:27:11 +04:00
|
|
|
/* Stack protectors. Yes, it's a hw feature. */
|
|
|
|
uint32_t slr, shr;
|
2009-05-20 21:37:39 +04:00
|
|
|
|
2012-06-01 07:23:28 +04:00
|
|
|
/* lwx/swx reserved address */
|
|
|
|
#define RES_ADDR_NONE 0xffffffff /* Use 0xffffffff to indicate no reservation */
|
2018-04-13 21:20:25 +03:00
|
|
|
target_ulong res_addr;
|
2013-10-23 18:54:31 +04:00
|
|
|
uint32_t res_val;
|
2012-06-01 07:23:28 +04:00
|
|
|
|
2009-05-20 21:37:39 +04:00
|
|
|
/* Internal flags. */
|
2020-08-20 18:08:19 +03:00
|
|
|
#define IMM_FLAG (1 << 0)
|
|
|
|
#define BIMM_FLAG (1 << 1)
|
2020-08-21 06:29:01 +03:00
|
|
|
#define ESR_ESS_FLAG (1 << 2) /* indicates ESR_ESS_MASK is present */
|
|
|
|
/* MSR_EE (1 << 8) -- these 3 are not in iflags but tb_flags */
|
2020-08-20 02:12:12 +03:00
|
|
|
/* MSR_UM (1 << 11) */
|
|
|
|
/* MSR_VM (1 << 13) */
|
2020-08-21 06:29:01 +03:00
|
|
|
/* ESR_ESS_MASK [11:5] -- unwind into iflags for unaligned excp */
|
2020-09-03 08:46:49 +03:00
|
|
|
#define D_FLAG (1 << 12) /* Bit in ESR. */
|
2009-05-20 21:37:39 +04:00
|
|
|
#define DRTI_FLAG (1 << 16)
|
|
|
|
#define DRTE_FLAG (1 << 17)
|
|
|
|
#define DRTB_FLAG (1 << 18)
|
2020-08-20 18:01:52 +03:00
|
|
|
|
2012-03-14 04:38:22 +04:00
|
|
|
/* TB dependent CPUMBState. */
|
2020-09-04 22:08:24 +03:00
|
|
|
#define IFLAGS_TB_MASK (D_FLAG | BIMM_FLAG | IMM_FLAG | \
|
|
|
|
DRTI_FLAG | DRTE_FLAG | DRTB_FLAG)
|
2020-08-20 18:01:52 +03:00
|
|
|
#define MSR_TB_MASK (MSR_UM | MSR_VM | MSR_EE)
|
|
|
|
|
2009-05-20 21:37:39 +04:00
|
|
|
uint32_t iflags;
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
/* Unified MMU. */
|
2020-09-03 09:18:35 +03:00
|
|
|
MicroBlazeMMU mmu;
|
2009-05-20 21:37:39 +04:00
|
|
|
#endif
|
|
|
|
|
2016-11-14 17:19:17 +03:00
|
|
|
/* Fields up to this point are cleared by a CPU reset */
|
|
|
|
struct {} end_reset_fields;
|
|
|
|
|
2015-05-29 09:30:05 +03:00
|
|
|
/* These fields are preserved on reset. */
|
2012-03-15 04:19:42 +04:00
|
|
|
};
|
2009-05-20 21:37:39 +04:00
|
|
|
|
2020-09-04 20:49:22 +03:00
|
|
|
/*
|
|
|
|
* Microblaze Configuration Settings
|
2020-09-04 20:53:03 +03:00
|
|
|
*
|
|
|
|
* Note that the structure is sorted by type and size to minimize holes.
|
2020-09-04 20:49:22 +03:00
|
|
|
*/
|
|
|
|
typedef struct {
|
2020-09-04 20:53:03 +03:00
|
|
|
char *version;
|
|
|
|
|
2020-09-04 21:31:57 +03:00
|
|
|
uint64_t addr_mask;
|
|
|
|
|
2020-09-04 20:49:22 +03:00
|
|
|
uint32_t base_vectors;
|
2020-09-04 20:53:03 +03:00
|
|
|
uint32_t pvr_user2;
|
2020-09-04 21:11:28 +03:00
|
|
|
uint32_t pvr_regs[13];
|
2020-09-04 20:53:03 +03:00
|
|
|
|
2020-09-04 20:49:22 +03:00
|
|
|
uint8_t addr_size;
|
|
|
|
uint8_t use_fpu;
|
|
|
|
uint8_t use_hw_mul;
|
2020-09-04 20:53:03 +03:00
|
|
|
uint8_t pvr_user1;
|
|
|
|
uint8_t pvr;
|
2020-09-04 21:31:57 +03:00
|
|
|
uint8_t mmu;
|
|
|
|
uint8_t mmu_tlb_access;
|
|
|
|
uint8_t mmu_zones;
|
2020-09-04 20:53:03 +03:00
|
|
|
|
|
|
|
bool stackprot;
|
2020-09-04 20:49:22 +03:00
|
|
|
bool use_barrel;
|
|
|
|
bool use_div;
|
|
|
|
bool use_msr_instr;
|
|
|
|
bool use_pcmp_instr;
|
|
|
|
bool use_mmu;
|
2021-01-22 03:18:53 +03:00
|
|
|
uint8_t use_non_secure;
|
2020-09-04 20:49:22 +03:00
|
|
|
bool dcache_writeback;
|
|
|
|
bool endi;
|
|
|
|
bool dopb_bus_exception;
|
|
|
|
bool iopb_bus_exception;
|
|
|
|
bool illegal_opcode_exception;
|
|
|
|
bool opcode_0_illegal;
|
|
|
|
bool div_zero_exception;
|
|
|
|
bool unaligned_exceptions;
|
|
|
|
} MicroBlazeCPUConfig;
|
|
|
|
|
2016-03-15 15:49:25 +03:00
|
|
|
/**
|
|
|
|
* MicroBlazeCPU:
|
|
|
|
* @env: #CPUMBState
|
|
|
|
*
|
|
|
|
* A MicroBlaze CPU.
|
|
|
|
*/
|
2022-02-14 19:15:16 +03:00
|
|
|
struct ArchCPU {
|
2016-03-15 15:49:25 +03:00
|
|
|
CPUState parent_obj;
|
2023-09-13 03:47:56 +03:00
|
|
|
|
|
|
|
CPUMBState env;
|
|
|
|
|
2021-01-22 03:18:53 +03:00
|
|
|
bool ns_axi_dp;
|
|
|
|
bool ns_axi_ip;
|
|
|
|
bool ns_axi_dc;
|
|
|
|
bool ns_axi_ic;
|
2016-03-15 15:49:25 +03:00
|
|
|
|
2020-09-04 20:49:22 +03:00
|
|
|
MicroBlazeCPUConfig cfg;
|
2016-03-15 15:49:25 +03:00
|
|
|
};
|
|
|
|
|
2023-10-13 12:35:04 +03:00
|
|
|
/**
|
|
|
|
* MicroBlazeCPUClass:
|
|
|
|
* @parent_realize: The parent class' realize handler.
|
|
|
|
* @parent_phases: The parent class' reset phase handlers.
|
|
|
|
*
|
|
|
|
* A MicroBlaze CPU model.
|
|
|
|
*/
|
|
|
|
struct MicroBlazeCPUClass {
|
|
|
|
CPUClass parent_class;
|
|
|
|
|
|
|
|
DeviceRealize parent_realize;
|
|
|
|
ResettablePhases parent_phases;
|
|
|
|
};
|
2016-03-15 15:49:25 +03:00
|
|
|
|
2021-09-11 19:54:23 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2016-03-15 15:49:25 +03:00
|
|
|
void mb_cpu_do_interrupt(CPUState *cs);
|
|
|
|
bool mb_cpu_exec_interrupt(CPUState *cs, int int_req);
|
2022-12-06 18:20:51 +03:00
|
|
|
hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
|
|
|
|
MemTxAttrs *attrs);
|
2021-09-11 19:54:23 +03:00
|
|
|
#endif /* !CONFIG_USER_ONLY */
|
2022-04-20 16:26:02 +03:00
|
|
|
G_NORETURN void mb_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
|
|
|
|
MMUAccessType access_type,
|
|
|
|
int mmu_idx, uintptr_t retaddr);
|
2019-04-17 22:18:02 +03:00
|
|
|
void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
|
2020-03-16 20:21:41 +03:00
|
|
|
int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
|
2016-03-15 15:49:25 +03:00
|
|
|
int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
|
2024-02-27 17:43:16 +03:00
|
|
|
int mb_cpu_gdb_read_stack_protect(CPUState *cs, GByteArray *buf, int reg);
|
|
|
|
int mb_cpu_gdb_write_stack_protect(CPUState *cs, uint8_t *buf, int reg);
|
2012-04-12 04:17:53 +04:00
|
|
|
|
2020-08-18 21:58:23 +03:00
|
|
|
static inline uint32_t mb_cpu_read_msr(const CPUMBState *env)
|
|
|
|
{
|
|
|
|
/* Replicate MSR[C] to MSR[CC]. */
|
|
|
|
return env->msr | (env->msr_c * (MSR_C | MSR_CC));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void mb_cpu_write_msr(CPUMBState *env, uint32_t val)
|
|
|
|
{
|
|
|
|
env->msr_c = (val >> 2) & 1;
|
|
|
|
/*
|
|
|
|
* Clear both MSR[C] and MSR[CC] from the saved copy.
|
|
|
|
* MSR_PVR is not writable and is always clear.
|
|
|
|
*/
|
|
|
|
env->msr = val & ~(MSR_C | MSR_CC | MSR_PVR);
|
|
|
|
}
|
|
|
|
|
2013-01-20 04:10:52 +04:00
|
|
|
void mb_tcg_init(void);
|
2009-05-20 21:37:39 +04:00
|
|
|
|
2018-02-07 13:40:25 +03:00
|
|
|
#define CPU_RESOLVING_TYPE TYPE_MICROBLAZE_CPU
|
2012-05-05 14:14:03 +04:00
|
|
|
|
2009-05-20 21:37:39 +04:00
|
|
|
/* MMU modes definitions */
|
|
|
|
#define MMU_NOMMU_IDX 0
|
|
|
|
#define MMU_KERNEL_IDX 1
|
|
|
|
#define MMU_USER_IDX 2
|
2023-03-06 20:52:18 +03:00
|
|
|
/* See NB_MMU_MODES in cpu-defs.h. */
|
2009-05-20 21:37:39 +04:00
|
|
|
|
2012-12-17 21:19:49 +04:00
|
|
|
#include "exec/cpu-all.h"
|
2009-05-20 21:37:39 +04:00
|
|
|
|
2020-08-20 18:01:52 +03:00
|
|
|
/* Ensure there is no overlap between the two masks. */
|
|
|
|
QEMU_BUILD_BUG_ON(MSR_TB_MASK & IFLAGS_TB_MASK);
|
|
|
|
|
2023-06-21 16:56:24 +03:00
|
|
|
static inline void cpu_get_tb_cpu_state(CPUMBState *env, vaddr *pc,
|
|
|
|
uint64_t *cs_base, uint32_t *flags)
|
2009-05-20 21:37:39 +04:00
|
|
|
{
|
2020-08-20 07:33:32 +03:00
|
|
|
*pc = env->pc;
|
2020-08-20 18:01:52 +03:00
|
|
|
*flags = (env->iflags & IFLAGS_TB_MASK) | (env->msr & MSR_TB_MASK);
|
2020-08-18 07:52:15 +03:00
|
|
|
*cs_base = (*flags & IMM_FLAG ? env->imm : 0);
|
2009-05-20 21:37:39 +04:00
|
|
|
}
|
2009-09-03 15:25:09 +04:00
|
|
|
|
2010-03-01 07:11:28 +03:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2021-09-15 03:17:38 +03:00
|
|
|
bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
|
|
|
|
MMUAccessType access_type, int mmu_idx,
|
|
|
|
bool probe, uintptr_t retaddr);
|
|
|
|
|
2018-12-10 20:56:30 +03:00
|
|
|
void mb_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
|
|
|
|
unsigned size, MMUAccessType access_type,
|
|
|
|
int mmu_idx, MemTxAttrs attrs,
|
|
|
|
MemTxResult response, uintptr_t retaddr);
|
2009-05-20 21:37:39 +04:00
|
|
|
#endif
|
2011-05-21 11:10:23 +04:00
|
|
|
|
2020-09-03 07:41:00 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
extern const VMStateDescription vmstate_mb_cpu;
|
|
|
|
#endif
|
|
|
|
|
2010-03-01 07:11:28 +03:00
|
|
|
#endif
|