qemu-e2k/target/e2k/cpu.h

105 lines
2.5 KiB
C

#ifndef E2K_CPU_H
#define E2K_CPU_H
#include "qemu/bswap.h"
#include "cpu-qom.h"
#include "exec/cpu-defs.h"
void e2k_tcg_initialize(void);
#define MMU_USER_IDX 1
#define CPU_RESOLVING_TYPE TYPE_E2K_CPU
#define WREGS_SIZE 192
// size of regular reg in bytes
#define REG_SIZE (sizeof(target_ulong))
typedef enum {
E2K_EXCP_UNIMPL = 0x01,
E2K_EXCP_SYSCALL = 0x02,
} Exception;
struct e2k_def_t {
const char *name;
uint32_t isa_version;
};
typedef struct CPUArchState {
/* register file */
target_ulong gregs[32]; // global regs
target_ulong wregs[WREGS_SIZE]; // window regs
target_ulong *win_ptr;
uint64_t pregs;
uint32_t wbs; // Real window regs offset, in bundle it comes divided by 2
uint32_t wsz; // Real window regs size, in bundle it comes divided by 2
uint32_t nfx; // TODO
uint32_t dbl; // TODO
uint32_t rbs; // Real based regs offset, in bundle it comes divided by 2
uint32_t rsz; // Real based regs size, in bundle it comes divided by 2 minus 2
uint32_t rcur; // Real based regs current index, in bundle it comes divided by 2
uint32_t psz; // pred regs window size
uint32_t syscall_wbs;
uint64_t usd_lo;
uint64_t usd_hi;
/* control registers */
target_ulong ctprs[3]; // Control Transfer Preparation Register (CTPR)
/* special registers */
target_ulong ip; /* instruction address, next instruction address */
uint32_t pfpfr; // Packed Floating Point Flag Register (PFPFR)
uint32_t fpcr; // Floating point control register (FPCR)
uint32_t fpsr; // Floating point state register (FPSR)
int interrupt_index;
/* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
uint32_t version;
struct e2k_def_t def;
} CPUE2KState;
/**
* E2KCPU:
* @env: #CPUE2KState
*
* An Elbrus CPU.
*/
struct ArchCPU {
/*< private >*/
CPUState parent_obj;
/*< public >*/
CPUNegativeOffsetState neg;
CPUE2KState env;
};
static inline void cpu_get_tb_cpu_state(CPUE2KState *env, target_ulong *pc,
target_ulong *cs_base, uint32_t *pflags)
{
*pc = env->ip;
*cs_base = 0;
*pflags = MMU_USER_IDX;
}
static inline int cpu_mmu_index(CPUE2KState *env, bool ifetch)
{
#ifdef CONFIG_USER_ONLY
return MMU_USER_IDX;
#else
#error softmmu is not supported on E2K
#endif
}
int e2k_cpu_signal_handler(int host_signum, void *pinfo, void *puc);
#define cpu_signal_handler e2k_cpu_signal_handler
#include "exec/cpu-all.h"
#endif