Mercurial > repos > blastem
comparison backend.h @ 803:236a184bf6f0
Merge
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 26 Jul 2015 16:51:03 -0700 |
parents | 7f96bd1cb1be |
children | 1f09994e92c5 |
comparison
equal
deleted
inserted
replaced
802:6811f601008f | 803:236a184bf6f0 |
---|---|
10 #include <stdio.h> | 10 #include <stdio.h> |
11 #include "gen.h" | 11 #include "gen.h" |
12 | 12 |
13 #define INVALID_OFFSET 0xFFFFFFFF | 13 #define INVALID_OFFSET 0xFFFFFFFF |
14 #define EXTENSION_WORD 0xFFFFFFFE | 14 #define EXTENSION_WORD 0xFFFFFFFE |
15 #define CYCLE_NEVER 0xFFFFFFFF | |
15 | 16 |
16 #if defined(X86_32) || defined(X86_64) | 17 #if defined(X86_32) || defined(X86_64) |
17 typedef struct { | 18 typedef struct { |
18 int32_t disp; | 19 int32_t disp; |
19 uint8_t mode; | 20 uint8_t mode; |
44 READ_8, | 45 READ_8, |
45 WRITE_16, | 46 WRITE_16, |
46 WRITE_8 | 47 WRITE_8 |
47 } ftype; | 48 } ftype; |
48 | 49 |
49 typedef struct { | |
50 uint32_t flags; | |
51 native_map_slot *native_code_map; | |
52 deferred_addr *deferred; | |
53 code_info code; | |
54 uint8_t **ram_inst_sizes; | |
55 code_ptr save_context; | |
56 code_ptr load_context; | |
57 code_ptr handle_cycle_limit; | |
58 code_ptr handle_cycle_limit_int; | |
59 code_ptr handle_code_write; | |
60 uint32_t address_mask; | |
61 uint32_t max_address; | |
62 uint32_t bus_cycles; | |
63 int32_t mem_ptr_off; | |
64 int32_t ram_flags_off; | |
65 uint8_t address_size; | |
66 uint8_t byte_swap; | |
67 uint8_t context_reg; | |
68 uint8_t cycles; | |
69 uint8_t limit; | |
70 uint8_t scratch1; | |
71 uint8_t scratch2; | |
72 } cpu_options; | |
73 | |
74 | |
75 #define MMAP_READ 0x01 | 50 #define MMAP_READ 0x01 |
76 #define MMAP_WRITE 0x02 | 51 #define MMAP_WRITE 0x02 |
77 #define MMAP_CODE 0x04 | 52 #define MMAP_CODE 0x04 |
78 #define MMAP_PTR_IDX 0x08 | 53 #define MMAP_PTR_IDX 0x08 |
79 #define MMAP_ONLY_ODD 0x10 | 54 #define MMAP_ONLY_ODD 0x10 |
80 #define MMAP_ONLY_EVEN 0x20 | 55 #define MMAP_ONLY_EVEN 0x20 |
81 #define MMAP_FUNC_NULL 0x40 | 56 #define MMAP_FUNC_NULL 0x40 |
57 #define MMAP_BYTESWAP 0x80 | |
82 | 58 |
83 typedef uint16_t (*read_16_fun)(uint32_t address, void * context); | 59 typedef uint16_t (*read_16_fun)(uint32_t address, void * context); |
84 typedef uint8_t (*read_8_fun)(uint32_t address, void * context); | 60 typedef uint8_t (*read_8_fun)(uint32_t address, void * context); |
85 typedef void * (*write_16_fun)(uint32_t address, void * context, uint16_t value); | 61 typedef void * (*write_16_fun)(uint32_t address, void * context, uint16_t value); |
86 typedef void * (*write_8_fun)(uint32_t address, void * context, uint8_t value); | 62 typedef void * (*write_8_fun)(uint32_t address, void * context, uint8_t value); |
96 write_16_fun write_16; | 72 write_16_fun write_16; |
97 read_8_fun read_8; | 73 read_8_fun read_8; |
98 write_8_fun write_8; | 74 write_8_fun write_8; |
99 } memmap_chunk; | 75 } memmap_chunk; |
100 | 76 |
77 typedef struct { | |
78 uint32_t flags; | |
79 native_map_slot *native_code_map; | |
80 deferred_addr *deferred; | |
81 code_info code; | |
82 uint8_t **ram_inst_sizes; | |
83 memmap_chunk const *memmap; | |
84 code_ptr save_context; | |
85 code_ptr load_context; | |
86 code_ptr handle_cycle_limit; | |
87 code_ptr handle_cycle_limit_int; | |
88 code_ptr handle_code_write; | |
89 uint32_t memmap_chunks; | |
90 uint32_t address_mask; | |
91 uint32_t max_address; | |
92 uint32_t bus_cycles; | |
93 uint32_t clock_divider; | |
94 int32_t mem_ptr_off; | |
95 int32_t ram_flags_off; | |
96 uint8_t ram_flags_shift; | |
97 uint8_t address_size; | |
98 uint8_t byte_swap; | |
99 uint8_t context_reg; | |
100 uint8_t cycles; | |
101 uint8_t limit; | |
102 uint8_t scratch1; | |
103 uint8_t scratch2; | |
104 } cpu_options; | |
105 | |
101 typedef uint8_t * (*native_addr_func)(void * context, uint32_t address); | 106 typedef uint8_t * (*native_addr_func)(void * context, uint32_t address); |
102 | 107 |
103 deferred_addr * defer_address(deferred_addr * old_head, uint32_t address, uint8_t *dest); | 108 deferred_addr * defer_address(deferred_addr * old_head, uint32_t address, uint8_t *dest); |
104 void remove_deferred_until(deferred_addr **head_ptr, deferred_addr * remove_to); | 109 void remove_deferred_until(deferred_addr **head_ptr, deferred_addr * remove_to); |
105 void process_deferred(deferred_addr ** head_ptr, void * context, native_addr_func get_native); | 110 void process_deferred(deferred_addr ** head_ptr, void * context, native_addr_func get_native); |
106 | 111 |
107 void cycles(cpu_options *opts, uint32_t num); | 112 void cycles(cpu_options *opts, uint32_t num); |
108 void check_cycles_int(cpu_options *opts, uint32_t address); | 113 void check_cycles_int(cpu_options *opts, uint32_t address); |
109 void check_cycles(cpu_options * opts); | 114 void check_cycles(cpu_options * opts); |
115 void check_code_prologue(code_info *code); | |
116 void log_address(cpu_options *opts, uint32_t address, char * format); | |
110 | 117 |
111 code_ptr gen_mem_fun(cpu_options * opts, memmap_chunk * memmap, uint32_t num_chunks, ftype fun_type); | 118 code_ptr gen_mem_fun(cpu_options * opts, memmap_chunk const * memmap, uint32_t num_chunks, ftype fun_type, code_ptr *after_inc); |
119 void * get_native_pointer(uint32_t address, void ** mem_pointers, cpu_options * opts); | |
120 uint32_t chunk_size(cpu_options *opts, memmap_chunk const *chunk); | |
121 uint32_t ram_size(cpu_options *opts); | |
112 | 122 |
113 #endif //BACKEND_H_ | 123 #endif //BACKEND_H_ |
114 | 124 |