comparison z80_to_x86.h @ 803:236a184bf6f0

Merge
author Michael Pavone <pavone@retrodev.com>
date Sun, 26 Jul 2015 16:51:03 -0700
parents 539d12fa6a4d
children ab017fb09e77
comparison
equal deleted inserted replaced
802:6811f601008f 803:236a184bf6f0
7 #define Z80_TO_X86_H_ 7 #define Z80_TO_X86_H_
8 #include "z80inst.h" 8 #include "z80inst.h"
9 #include "backend.h" 9 #include "backend.h"
10 10
11 #define ZNUM_MEM_AREAS 4 11 #define ZNUM_MEM_AREAS 4
12 #ifdef Z80_LOG_ADDRESS
13 #define ZMAX_NATIVE_SIZE 255
14 #else
12 #define ZMAX_NATIVE_SIZE 128 15 #define ZMAX_NATIVE_SIZE 128
16 #endif
13 17
14 enum { 18 enum {
15 ZF_C = 0, 19 ZF_C = 0,
16 ZF_N, 20 ZF_N,
17 ZF_PV, 21 ZF_PV,
19 ZF_Z, 23 ZF_Z,
20 ZF_S, 24 ZF_S,
21 ZF_NUM 25 ZF_NUM
22 }; 26 };
23 27
28 typedef void (*z80_run_fun)(void * context);
29
24 typedef struct { 30 typedef struct {
25 uint8_t * cur_code; 31 cpu_options gen;
26 uint8_t * code_end; 32 code_ptr save_context_scratch;
27 uint8_t *ram_inst_sizes; 33 code_ptr load_context_scratch;
28 deferred_addr * deferred; 34 code_ptr native_addr;
35 code_ptr retrans_stub;
36 code_ptr do_sync;
37 code_ptr read_8;
38 code_ptr write_8;
39 code_ptr read_8_noinc;
40 code_ptr write_8_noinc;
41 code_ptr read_16;
42 code_ptr write_16_highfirst;
43 code_ptr write_16_lowfirst;
44 code_ptr read_io;
45 code_ptr write_io;
46
29 uint32_t flags; 47 uint32_t flags;
30 int8_t regs[Z80_UNUSED]; 48 int8_t regs[Z80_UNUSED];
31 } x86_z80_options; 49 z80_run_fun run;
50 } z80_options;
32 51
33 typedef struct { 52 typedef struct {
34 void * native_pc; 53 void * native_pc;
35 uint16_t sp; 54 uint16_t sp;
36 uint8_t flags[ZF_NUM]; 55 uint8_t flags[ZF_NUM];
49 void * extra_pc; 68 void * extra_pc;
50 uint32_t sync_cycle; 69 uint32_t sync_cycle;
51 uint32_t int_cycle; 70 uint32_t int_cycle;
52 native_map_slot * static_code_map; 71 native_map_slot * static_code_map;
53 native_map_slot * banked_code_map; 72 native_map_slot * banked_code_map;
54 void * options; 73 z80_options * options;
55 void * system; 74 void * system;
56 uint8_t ram_code_flags[(8 * 1024)/128/8]; 75 uint8_t ram_code_flags[(8 * 1024)/128/8];
57 uint32_t int_enable_cycle; 76 uint32_t int_enable_cycle;
58 uint16_t pc; 77 uint16_t pc;
78 uint32_t int_pulse_start;
79 uint32_t int_pulse_end;
80 uint8_t breakpoint_flags[(16 * 1024)/sizeof(uint8_t)];
81 uint8_t * bp_handler;
82 uint8_t * bp_stub;
83 uint8_t * interp_code[256];
84 uint8_t reset;
85 uint8_t busreq;
86 uint8_t busack;
59 } z80_context; 87 } z80_context;
60 88
61 void translate_z80_stream(z80_context * context, uint32_t address); 89 void translate_z80_stream(z80_context * context, uint32_t address);
62 void init_x86_z80_opts(x86_z80_options * options); 90 void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks, uint32_t clock_divider);
63 void init_z80_context(z80_context * context, x86_z80_options * options); 91 void init_z80_context(z80_context * context, z80_options * options);
64 uint8_t * z80_get_native_address(z80_context * context, uint32_t address); 92 code_ptr z80_get_native_address(z80_context * context, uint32_t address);
65 uint8_t * z80_get_native_address_trans(z80_context * context, uint32_t address); 93 code_ptr z80_get_native_address_trans(z80_context * context, uint32_t address);
66 z80_context * z80_handle_code_write(uint32_t address, z80_context * context); 94 z80_context * z80_handle_code_write(uint32_t address, z80_context * context);
67 void z80_run(z80_context * context);
68 void z80_reset(z80_context * context); 95 void z80_reset(z80_context * context);
69 void zinsert_breakpoint(z80_context * context, uint16_t address, uint8_t * bp_handler); 96 void zinsert_breakpoint(z80_context * context, uint16_t address, uint8_t * bp_handler);
70 void zremove_breakpoint(z80_context * context, uint16_t address); 97 void zremove_breakpoint(z80_context * context, uint16_t address);
98 void z80_run(z80_context * context, uint32_t target_cycle);
99 void z80_assert_reset(z80_context * context, uint32_t cycle);
100 void z80_clear_reset(z80_context * context, uint32_t cycle);
101 void z80_assert_busreq(z80_context * context, uint32_t cycle);
102 void z80_clear_busreq(z80_context * context, uint32_t cycle);
103 uint8_t z80_get_busack(z80_context * context, uint32_t cycle);
104 void z80_adjust_cycles(z80_context * context, uint32_t deduction);
105 //to be provided by system code
106 void z80_next_int_pulse(z80_context * z_context);
71 107
72 #endif //Z80_TO_X86_H_ 108 #endif //Z80_TO_X86_H_
73 109