comparison backend.h @ 1507:2455662378ed mame_interp

Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
author Michael Pavone <pavone@retrodev.com>
date Sat, 30 Dec 2017 18:27:06 -0800
parents ded16f3d7eb4
children b7ecd0d6a77b
comparison
equal deleted inserted replaced
1506:ded16f3d7eb4 1507:2455662378ed
6 #ifndef BACKEND_H_ 6 #ifndef BACKEND_H_
7 #define BACKEND_H_ 7 #define BACKEND_H_
8 8
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
11 #ifdef USE_NATIVE
11 #include "gen.h" 12 #include "gen.h"
13 #else
14 typedef uint8_t * code_ptr;
15 typedef struct {
16 code_ptr cur;
17 code_ptr last;
18 uint32_t stack_off;
19 } code_info;
20 #endif
12 21
13 #define INVALID_OFFSET 0xFFFFFFFF 22 #define INVALID_OFFSET 0xFFFFFFFF
14 #define EXTENSION_WORD 0xFFFFFFFE 23 #define EXTENSION_WORD 0xFFFFFFFE
15 #define CYCLE_NEVER 0xFFFFFFFF 24 #define CYCLE_NEVER 0xFFFFFFFF
16 25
78 87
79 #include "system.h" 88 #include "system.h"
80 89
81 typedef struct { 90 typedef struct {
82 uint32_t flags; 91 uint32_t flags;
92 #ifdef USE_NATIVE
83 native_map_slot *native_code_map; 93 native_map_slot *native_code_map;
84 deferred_addr *deferred; 94 deferred_addr *deferred;
85 code_info code; 95 code_info code;
86 uint8_t **ram_inst_sizes; 96 uint8_t **ram_inst_sizes;
97 #endif
87 memmap_chunk const *memmap; 98 memmap_chunk const *memmap;
99 #ifdef USE_NATIVE
88 code_ptr save_context; 100 code_ptr save_context;
89 code_ptr load_context; 101 code_ptr load_context;
90 code_ptr handle_cycle_limit; 102 code_ptr handle_cycle_limit;
91 code_ptr handle_cycle_limit_int; 103 code_ptr handle_cycle_limit_int;
92 code_ptr handle_code_write; 104 code_ptr handle_code_write;
93 code_ptr handle_align_error_write; 105 code_ptr handle_align_error_write;
94 code_ptr handle_align_error_read; 106 code_ptr handle_align_error_read;
107 #endif
95 system_str_fun_r8 debug_cmd_handler; 108 system_str_fun_r8 debug_cmd_handler;
96 uint32_t memmap_chunks; 109 uint32_t memmap_chunks;
97 uint32_t address_mask; 110 uint32_t address_mask;
98 uint32_t max_address; 111 uint32_t max_address;
99 uint32_t bus_cycles; 112 uint32_t bus_cycles;
100 uint32_t clock_divider; 113 uint32_t clock_divider;
114 #ifdef USE_NATIVE
101 uint32_t move_pc_off; 115 uint32_t move_pc_off;
102 uint32_t move_pc_size; 116 uint32_t move_pc_size;
103 int32_t mem_ptr_off; 117 int32_t mem_ptr_off;
104 int32_t ram_flags_off; 118 int32_t ram_flags_off;
105 uint8_t ram_flags_shift; 119 uint8_t ram_flags_shift;
120 #endif
106 uint8_t address_size; 121 uint8_t address_size;
107 uint8_t byte_swap; 122 uint8_t byte_swap;
123 #ifdef USE_NATIVE
108 int8_t context_reg; 124 int8_t context_reg;
109 int8_t cycles; 125 int8_t cycles;
110 int8_t limit; 126 int8_t limit;
111 int8_t scratch1; 127 int8_t scratch1;
112 int8_t scratch2; 128 int8_t scratch2;
113 uint8_t align_error_mask; 129 uint8_t align_error_mask;
130 #endif
114 } cpu_options; 131 } cpu_options;
115 132
133 #ifdef USE_NATIVE
116 typedef uint8_t * (*native_addr_func)(void * context, uint32_t address); 134 typedef uint8_t * (*native_addr_func)(void * context, uint32_t address);
117 135
118 deferred_addr * defer_address(deferred_addr * old_head, uint32_t address, uint8_t *dest); 136 deferred_addr * defer_address(deferred_addr * old_head, uint32_t address, uint8_t *dest);
119 void remove_deferred_until(deferred_addr **head_ptr, deferred_addr * remove_to); 137 void remove_deferred_until(deferred_addr **head_ptr, deferred_addr * remove_to);
120 void process_deferred(deferred_addr ** head_ptr, void * context, native_addr_func get_native); 138 void process_deferred(deferred_addr ** head_ptr, void * context, native_addr_func get_native);
127 145
128 void retranslate_calc(cpu_options *opts); 146 void retranslate_calc(cpu_options *opts);
129 void patch_for_retranslate(cpu_options *opts, code_ptr native_address, code_ptr handler); 147 void patch_for_retranslate(cpu_options *opts, code_ptr native_address, code_ptr handler);
130 148
131 code_ptr gen_mem_fun(cpu_options * opts, memmap_chunk const * memmap, uint32_t num_chunks, ftype fun_type, code_ptr *after_inc); 149 code_ptr gen_mem_fun(cpu_options * opts, memmap_chunk const * memmap, uint32_t num_chunks, ftype fun_type, code_ptr *after_inc);
150 #endif
132 void * get_native_pointer(uint32_t address, void ** mem_pointers, cpu_options * opts); 151 void * get_native_pointer(uint32_t address, void ** mem_pointers, cpu_options * opts);
133 uint16_t read_word(uint32_t address, void **mem_pointers, cpu_options *opts, void *context); 152 uint16_t read_word(uint32_t address, void **mem_pointers, cpu_options *opts, void *context);
134 void write_word(uint32_t address, uint16_t value, void **mem_pointers, cpu_options *opts, void *context); 153 void write_word(uint32_t address, uint16_t value, void **mem_pointers, cpu_options *opts, void *context);
135 uint8_t read_byte(uint32_t address, void **mem_pointers, cpu_options *opts, void *context); 154 uint8_t read_byte(uint32_t address, void **mem_pointers, cpu_options *opts, void *context);
136 void write_byte(uint32_t address, uint8_t value, void **mem_pointers, cpu_options *opts, void *context); 155 void write_byte(uint32_t address, uint8_t value, void **mem_pointers, cpu_options *opts, void *context);