-
Notifications
You must be signed in to change notification settings - Fork 0
/
emulator.h
57 lines (47 loc) · 1.26 KB
/
emulator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#define FAKEFLASH_START 0x9a000000
#define FAKEFLASH_END 0x9f200000
#define FLASH_START 0x9fc00000
#define FLASH_END 0x9fe00000
#define FLASH_SIZE 0x00200000
#define RAM_START 0x80000000
#define RAM_END 0x82000000
#define RAM_SIZE 0x02000000
#define REG_START 0xfffe0000
#define REG_END 0xffffffff
struct cpu_state;
struct callback
{
struct callback* next;
uint32_t address;
void(*callback)(struct cpu_state *);
};
struct cpu_state
{
int32_t reg[32];
int32_t HI;
int32_t LO;
int32_t pc;
int32_t prev_pc[3];
int32_t delayed_jump;
int32_t jump_pc;
int32_t eret;
bool in_irq;
struct callback *callbacks;
int8_t *ram;
int8_t *flash;
int32_t cop0[32][10];
};
extern struct cpu_state cpu;
extern bool debug;
extern bool run;
extern bool do_step;
void initialize_emulator(struct cpu_state *cpu, char *firmware_file);
void initialize_cpu(struct cpu_state *cpu, int32_t start_address);
void register_callbacks(void);
void register_callback(struct cpu_state *cpu, uint32_t address, void(*callback)(struct cpu_state *));
void bp(struct cpu_state *cpu);
void instlog(struct cpu_state *cpu);
void execute(struct cpu_state *cpu);
void print_string(struct cpu_state *cpu);
void printf_string(struct cpu_state *cpu);
void print_char(struct cpu_state *cpu);