From 2118e12769269464a0a4b2c79aa7939289bebeb1 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 19 Nov 2010 11:04:15 +0100 Subject: Simulator updates --- nios2.h | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'nios2.h') diff --git a/nios2.h b/nios2.h index eb13b95..aacf1b9 100644 --- a/nios2.h +++ b/nios2.h @@ -13,6 +13,7 @@ #define _NIOS2_H_ #include "instruction.h" +#include "memory.h" #define NIOS2_GP_REG_COUNT 32 /* there are really 32, but 16-31 are reserved for future use */ @@ -34,6 +35,10 @@ struct nios2 { bool has_div; /* div, divu */ bool has_mmu; /* Memory Management Unit */ + + struct memory *mem; + /* Exception handler address */ + uint32_t exception_handler_addr; }; /* Aliases for general-purpose registers */ @@ -70,15 +75,36 @@ enum { mpuacc, }; +/* status register fields */ +#define NIOS2_STATUS_PIE 0 +#define NIOS2_STATUS_U 1 +#define NIOS2_STATUS_EH 2 + +/* exception causes */ +#define NIOS2_EX_RESET 0 +#define NIOS2_EX_PROC_ONLY_RESET 1 +#define NIOS2_EX_IRQ 2 +#define NIOS2_EX_UNIMPLEMENTED 4 +#define NIOS2_EX_DIV_ERR 8 +#define NIOS2_EX_SUPERVISOR_ONLY_I 9 +#define NIOS2_EX_SUPERVISOR_ONLY_D 11 +#define NIOS2_EX_FAST_TLB_MISS 12 + enum { NIOS2_SUPERVISOR_MODE, NIOS2_USER_MODE, }; extern void nios2_cpu_reset(struct nios2 *cpu); +extern void nios2_cpu_init(struct nios2 *cpu); +extern void nios2_simulate(struct nios2 *cpu); +extern void nios2_cpu_inc_pc(struct nios2 *cpu); extern bool nios2_in_user_mode(struct nios2 *cpu); extern bool nios2_in_supervisor_mode(struct nios2 *cpu); -extern uint32_t nios2_cpu_fetch_instr(struct nios2 *cpu, uint32_t *mem_base); -extern int nios2_cpu_execute_instr(struct nios2 *cpu, uint32_t instr); +extern void nios2_exception(struct nios2 *cpu, uint8_t cause); +extern uint32_t nios2_fetch_instr(struct nios2 *cpu); +extern int nios2_execute_instr(struct nios2 *cpu, uint32_t instr); + +extern void nios2_dump_registers(struct nios2 *cpu); #endif /* _NIOS2_H_ */ -- cgit v1.2.3-54-g00ecf