summaryrefslogtreecommitdiff
path: root/nios2.h
diff options
context:
space:
mode:
Diffstat (limited to 'nios2.h')
-rw-r--r--nios2.h30
1 files changed, 28 insertions, 2 deletions
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_ */