#ifndef _SYS_SIMULATE_H
#define _SYS_SIMULATE_H
#ifdef __cplusplus
extern "C" {
#endif
#define SIMU_SUCCESS 1
#define SIMU_ILLEGAL 2
#define SIMU_FAULT 3
#define SIMU_DZERO 4
#define SIMU_UNALIGN 5
#define SIMU_RETRY 6
#define OP_V8_BRANCH 0
#define OP_V8_CALL 1
#define OP_V8_ARITH 2
#define OP_V8_LDSTR 3
#define IOP_V8_LD 0x00
#define IOP_V8_LDA 0x10
#define IOP_V8_LDUBA 0x11
#define IOP_V8_LDUHA 0x12
#define IOP_V8_LDDA 0x13
#define IOP_V8_STA 0x14
#define IOP_V8_STBA 0x15
#define IOP_V8_STHA 0x16
#define IOP_V8_STDA 0x17
#define IOP_V8_LDSBA 0x19
#define IOP_V8_LDSHA 0x1a
#define IOP_V8_LDSTUBA 0x1d
#define IOP_V8_SWAPA 0x1f
#define IOP_V8_LDFSR 0x21
#define IOP_V8_LDQF 0x22
#define IOP_V8_STFSR 0x25
#define IOP_V8_STQF 0x26
#define IOP_V8_LDQFA 0x32
#define IOP_V8_LDDFA 0x33
#define IOP_V8_STQFA 0x36
#define IOP_V8_STDFA 0x37
#define IOP_V8_ADD 0x00
#define IOP_V8_AND 0x01
#define IOP_V8_OR 0x02
#define IOP_V8_XOR 0x03
#define IOP_V8_SUB 0x04
#define IOP_V8_ANDN 0x05
#define IOP_V8_ORN 0x06
#define IOP_V8_XNOR 0x07
#define IOP_V8_ADDC 0x08
#define IOP_V8_UMUL 0x0a
#define IOP_V8_SMUL 0x0b
#define IOP_V8_SUBC 0x0c
#define IOP_V8_UDIV 0x0e
#define IOP_V8_SDIV 0x0f
#define IOP_V8_ADDcc 0x10
#define IOP_V8_ANDcc 0x11
#define IOP_V8_ORcc 0x12
#define IOP_V8_XORcc 0x13
#define IOP_V8_SUBcc 0x14
#define IOP_V8_ANDNcc 0x15
#define IOP_V8_ORNcc 0x16
#define IOP_V8_XNORcc 0x17
#define IOP_V8_ADDCcc 0x18
#define IOP_V8_UMULcc 0x1a
#define IOP_V8_SMULcc 0x1b
#define IOP_V8_SUBCcc 0x1c
#define IOP_V8_UDIVcc 0x1e
#define IOP_V8_SDIVcc 0x1f
#define IOP_V8_TADDcc 0x20
#define IOP_V8_TSUBcc 0x21
#define IOP_V8_TADDccTV 0x22
#define IOP_V8_TSUBccTV 0x23
#define IOP_V8_MULScc 0x24
#define IOP_V8_SLL 0x25
#define IOP_V8_SRL 0x26
#define IOP_V8_SRA 0x27
#define IOP_V8_RDASR 0x28
#define IOP_V8_POPC 0x2e
#define IOP_V8_WRASR 0x30
#define IOP_V8_FCMP 0x35
#define IOP_V8_JMPL 0x38
#define IOP_V8_RETT 0x39
#define IOP_V8_TCC 0x3a
#define IOP_V8_FLUSH 0x3b
#define IOP_V8_SAVE 0x3c
#define IOP_V8_RESTORE 0x3d
#define IS_LDST_ALT(x) \
(((x) == IOP_V8_LDA || (x) == IOP_V8_LDDA || \
(x) == IOP_V8_LDSBA || (x) == IOP_V8_LDSHA || \
(x) == IOP_V8_LDSTUBA || (x) == IOP_V8_LDUBA || \
(x) == IOP_V8_LDUHA || (x) == IOP_V8_STA || \
(x) == IOP_V8_STBA || (x) == IOP_V8_STDA || \
(x) == IOP_V8_STHA || (x) == IOP_V8_SWAPA) ? 1 : 0)
#ifndef _ASM
#include <vm/seg_enum.h>
extern int32_t fetch_user_instr(caddr_t);
extern int simulate_unimp(struct regs *, caddr_t *);
extern int simulate_lddstd(struct regs *, caddr_t *);
extern int simulate_rdtick(struct regs *);
extern int do_unaligned(struct regs *, caddr_t *);
extern int calc_memaddr(struct regs *, caddr_t *);
extern int is_atomic(struct regs *);
extern int instr_size(struct regs *, caddr_t *, enum seg_rw);
extern int getreg(struct regs *, uint_t, uint64_t *, caddr_t *);
extern int putreg(uint64_t *, struct regs *, uint_t, caddr_t *);
extern int extended_asi_size(int asi);
#endif
#ifdef __cplusplus
}
#endif
#endif