Mercurial > repos > blastem
comparison m68k_core.h @ 2350:f8b5142c06aa
Allow 68K to return mid-instruction. Adjust how 68K interrupt ack works so int2 busy flag timing is more correct. Fix some other SCD timing issues
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 16 Oct 2023 23:30:04 -0700 |
parents | 0111c8344477 |
children | 8f3cfb77f1e3 |
comparison
equal
deleted
inserted
replaced
2349:f0fc6c09517d | 2350:f8b5142c06aa |
---|---|
25 #define M68K_STATUS_TRACE 0x80 | 25 #define M68K_STATUS_TRACE 0x80 |
26 | 26 |
27 typedef void (*start_fun)(uint8_t * addr, void * context); | 27 typedef void (*start_fun)(uint8_t * addr, void * context); |
28 typedef struct m68k_context m68k_context; | 28 typedef struct m68k_context m68k_context; |
29 typedef m68k_context *(*sync_fun)(m68k_context * context, uint32_t address); | 29 typedef m68k_context *(*sync_fun)(m68k_context * context, uint32_t address); |
30 typedef m68k_context *(*int_ack_fun)(m68k_context * context); | |
30 | 31 |
31 typedef struct { | 32 typedef struct { |
32 code_ptr impl; | 33 code_ptr impl; |
33 uint16_t reglist; | 34 uint16_t reglist; |
34 uint8_t reg_to_mem; | 35 uint8_t reg_to_mem; |
59 code_ptr native_addr_and_sync; | 60 code_ptr native_addr_and_sync; |
60 code_ptr get_sr; | 61 code_ptr get_sr; |
61 code_ptr set_sr; | 62 code_ptr set_sr; |
62 code_ptr set_ccr; | 63 code_ptr set_ccr; |
63 code_ptr bp_stub; | 64 code_ptr bp_stub; |
65 code_ptr save_context_scratch; | |
66 code_ptr load_context_scratch; | |
64 sync_fun sync_components; | 67 sync_fun sync_components; |
68 int_ack_fun int_ack; | |
65 code_info extra_code; | 69 code_info extra_code; |
66 movem_fun *big_movem; | 70 movem_fun *big_movem; |
67 uint32_t num_movem; | 71 uint32_t num_movem; |
68 uint32_t movem_storage; | 72 uint32_t movem_storage; |
69 code_word prologue_start; | 73 code_word prologue_start; |
77 } m68k_breakpoint; | 81 } m68k_breakpoint; |
78 | 82 |
79 struct m68k_context { | 83 struct m68k_context { |
80 uint8_t flags[5]; | 84 uint8_t flags[5]; |
81 uint8_t status; | 85 uint8_t status; |
82 uint16_t int_ack; | |
83 uint32_t dregs[8]; | 86 uint32_t dregs[8]; |
84 uint32_t aregs[9]; | 87 uint32_t aregs[9]; |
85 uint32_t target_cycle; //cycle at which the next synchronization or interrupt occurs | 88 uint32_t target_cycle; //cycle at which the next synchronization or interrupt occurs |
86 uint32_t current_cycle; | 89 uint32_t current_cycle; |
87 uint32_t sync_cycle; | 90 uint32_t sync_cycle; |
88 uint32_t int_cycle; | 91 uint32_t int_cycle; |
89 uint32_t int_num; | 92 uint32_t int_num; |
90 uint32_t last_prefetch_address; | 93 uint32_t last_prefetch_address; |
94 uint32_t scratch1; | |
95 uint32_t scratch2; | |
91 uint16_t *mem_pointers[NUM_MEM_AREAS]; | 96 uint16_t *mem_pointers[NUM_MEM_AREAS]; |
92 code_ptr resume_pc; | 97 code_ptr resume_pc; |
93 code_ptr reset_handler; | 98 code_ptr reset_handler; |
94 m68k_options *options; | 99 m68k_options *options; |
95 void *system; | 100 void *system; |
101 void *host_sp_entry; | |
102 void *stack_storage[10]; | |
96 m68k_breakpoint *breakpoints; | 103 m68k_breakpoint *breakpoints; |
97 uint32_t num_breakpoints; | 104 uint32_t num_breakpoints; |
98 uint32_t bp_storage; | 105 uint32_t bp_storage; |
99 uint8_t int_pending; | 106 uint8_t int_pending; |
100 uint8_t trace_pending; | 107 uint8_t trace_pending; |
101 uint8_t should_return; | 108 uint8_t should_return; |
109 uint8_t stack_storage_count; | |
102 uint8_t ram_code_flags[]; | 110 uint8_t ram_code_flags[]; |
103 }; | 111 }; |
104 | 112 |
105 typedef m68k_context *(*m68k_reset_handler)(m68k_context *context); | 113 typedef m68k_context *(*m68k_reset_handler)(m68k_context *context); |
106 | 114 |
107 | 115 |
108 void translate_m68k_stream(uint32_t address, m68k_context * context); | 116 void translate_m68k_stream(uint32_t address, m68k_context * context); |
109 void start_68k_context(m68k_context * context, uint32_t address); | 117 void start_68k_context(m68k_context * context, uint32_t address); |
110 void resume_68k(m68k_context *context); | 118 void resume_68k(m68k_context *context); |
111 void init_m68k_opts(m68k_options * opts, memmap_chunk * memmap, uint32_t num_chunks, uint32_t clock_divider, sync_fun sync_components); | 119 void init_m68k_opts(m68k_options * opts, memmap_chunk * memmap, uint32_t num_chunks, uint32_t clock_divider, sync_fun sync_components, int_ack_fun int_ack); |
112 m68k_context * init_68k_context(m68k_options * opts, m68k_reset_handler reset_handler); | 120 m68k_context * init_68k_context(m68k_options * opts, m68k_reset_handler reset_handler); |
113 void m68k_reset(m68k_context * context); | 121 void m68k_reset(m68k_context * context); |
114 void m68k_options_free(m68k_options *opts); | 122 void m68k_options_free(m68k_options *opts); |
115 void insert_breakpoint(m68k_context * context, uint32_t address, m68k_debug_handler bp_handler); | 123 void insert_breakpoint(m68k_context * context, uint32_t address, m68k_debug_handler bp_handler); |
116 void remove_breakpoint(m68k_context * context, uint32_t address); | 124 void remove_breakpoint(m68k_context * context, uint32_t address); |