ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/memory.h
Revision: 1.7
Committed: 2007-06-13T15:57:46Z (17 years ago) by gbeauche
Content type: text/plain
Branch: MAIN
Changes since 1.6: +0 -15 lines
Log Message:
Remove dead code, B2 doesn't use valid_address()

File Contents

# Content
1 /*
2 * UAE - The Un*x Amiga Emulator
3 *
4 * memory management
5 *
6 * Copyright 1995 Bernd Schmidt
7 */
8
9 #ifndef UAE_MEMORY_H
10 #define UAE_MEMORY_H
11
12 #if !DIRECT_ADDRESSING && !REAL_ADDRESSING
13
14 /* Enabling this adds one additional native memory reference per 68k memory
15 * access, but saves one shift (on the x86). Enabling this is probably
16 * better for the cache. My favourite benchmark (PP2) doesn't show a
17 * difference, so I leave this enabled. */
18
19 #if 1 || defined SAVE_MEMORY
20 #define SAVE_MEMORY_BANKS
21 #endif
22
23 typedef uae_u32 (REGPARAM2 *mem_get_func)(uaecptr) REGPARAM;
24 typedef void (REGPARAM2 *mem_put_func)(uaecptr, uae_u32) REGPARAM;
25 typedef uae_u8 *(REGPARAM2 *xlate_func)(uaecptr) REGPARAM;
26
27 #undef DIRECT_MEMFUNCS_SUCCESSFUL
28
29 #ifndef CAN_MAP_MEMORY
30 #undef USE_COMPILER
31 #endif
32
33 #if defined(USE_COMPILER) && !defined(USE_MAPPED_MEMORY)
34 #define USE_MAPPED_MEMORY
35 #endif
36
37 typedef struct {
38 /* These ones should be self-explanatory... */
39 mem_get_func lget, wget, bget;
40 mem_put_func lput, wput, bput;
41 /* Use xlateaddr to translate an Amiga address to a uae_u8 * that can
42 * be used to address memory without calling the wget/wput functions.
43 * This doesn't work for all memory banks, so this function may call
44 * abort(). */
45 xlate_func xlateaddr;
46 } addrbank;
47
48 extern uae_u8 filesysory[65536];
49
50 extern addrbank ram_bank; // Mac RAM
51 extern addrbank rom_bank; // Mac ROM
52 extern addrbank frame_bank; // Frame buffer
53
54 /* Default memory access functions */
55
56 extern uae_u8 *REGPARAM2 default_xlate(uaecptr addr) REGPARAM;
57
58 #define bankindex(addr) (((uaecptr)(addr)) >> 16)
59
60 #ifdef SAVE_MEMORY_BANKS
61 extern addrbank *mem_banks[65536];
62 #define get_mem_bank(addr) (*mem_banks[bankindex(addr)])
63 #define put_mem_bank(addr, b) (mem_banks[bankindex(addr)] = (b))
64 #else
65 extern addrbank mem_banks[65536];
66 #define get_mem_bank(addr) (mem_banks[bankindex(addr)])
67 #define put_mem_bank(addr, b) (mem_banks[bankindex(addr)] = *(b))
68 #endif
69
70 extern void memory_init(void);
71 extern void map_banks(addrbank *bank, int first, int count);
72
73 #ifndef NO_INLINE_MEMORY_ACCESS
74
75 #define longget(addr) (call_mem_get_func(get_mem_bank(addr).lget, addr))
76 #define wordget(addr) (call_mem_get_func(get_mem_bank(addr).wget, addr))
77 #define byteget(addr) (call_mem_get_func(get_mem_bank(addr).bget, addr))
78 #define longput(addr,l) (call_mem_put_func(get_mem_bank(addr).lput, addr, l))
79 #define wordput(addr,w) (call_mem_put_func(get_mem_bank(addr).wput, addr, w))
80 #define byteput(addr,b) (call_mem_put_func(get_mem_bank(addr).bput, addr, b))
81
82 #else
83
84 extern uae_u32 longget(uaecptr addr);
85 extern uae_u32 wordget(uaecptr addr);
86 extern uae_u32 byteget(uaecptr addr);
87 extern void longput(uaecptr addr, uae_u32 l);
88 extern void wordput(uaecptr addr, uae_u32 w);
89 extern void byteput(uaecptr addr, uae_u32 b);
90
91 #endif
92
93 #ifndef MD_HAVE_MEM_1_FUNCS
94
95 #define longget_1 longget
96 #define wordget_1 wordget
97 #define byteget_1 byteget
98 #define longput_1 longput
99 #define wordput_1 wordput
100 #define byteput_1 byteput
101
102 #endif
103
104 #endif /* !DIRECT_ADDRESSING && !REAL_ADDRESSING */
105
106 #if REAL_ADDRESSING
107 const uintptr MEMBaseDiff = 0;
108 #endif
109 #if DIRECT_ADDRESSING
110 extern uintptr MEMBaseDiff;
111 #endif
112
113 #if REAL_ADDRESSING || DIRECT_ADDRESSING
114 static __inline__ uae_u8 *do_get_real_address(uaecptr addr)
115 {
116 return (uae_u8 *)MEMBaseDiff + addr;
117 }
118 static __inline__ uae_u32 do_get_virtual_address(uae_u8 *addr)
119 {
120 return (uintptr)addr - MEMBaseDiff;
121 }
122 static __inline__ uae_u32 get_long(uaecptr addr)
123 {
124 uae_u32 * const m = (uae_u32 *)do_get_real_address(addr);
125 return do_get_mem_long(m);
126 }
127 static __inline__ uae_u32 get_word(uaecptr addr)
128 {
129 uae_u16 * const m = (uae_u16 *)do_get_real_address(addr);
130 return do_get_mem_word(m);
131 }
132 static __inline__ uae_u32 get_byte(uaecptr addr)
133 {
134 uae_u8 * const m = (uae_u8 *)do_get_real_address(addr);
135 return do_get_mem_byte(m);
136 }
137 static __inline__ void put_long(uaecptr addr, uae_u32 l)
138 {
139 uae_u32 * const m = (uae_u32 *)do_get_real_address(addr);
140 do_put_mem_long(m, l);
141 }
142 static __inline__ void put_word(uaecptr addr, uae_u32 w)
143 {
144 uae_u16 * const m = (uae_u16 *)do_get_real_address(addr);
145 do_put_mem_word(m, w);
146 }
147 static __inline__ void put_byte(uaecptr addr, uae_u32 b)
148 {
149 uae_u8 * const m = (uae_u8 *)do_get_real_address(addr);
150 do_put_mem_byte(m, b);
151 }
152 static __inline__ uae_u8 *get_real_address(uaecptr addr)
153 {
154 return do_get_real_address(addr);
155 }
156 static __inline__ uae_u32 get_virtual_address(uae_u8 *addr)
157 {
158 return do_get_virtual_address(addr);
159 }
160 #else
161 static __inline__ uae_u32 get_long(uaecptr addr)
162 {
163 return longget_1(addr);
164 }
165 static __inline__ uae_u32 get_word(uaecptr addr)
166 {
167 return wordget_1(addr);
168 }
169 static __inline__ uae_u32 get_byte(uaecptr addr)
170 {
171 return byteget_1(addr);
172 }
173 static __inline__ void put_long(uaecptr addr, uae_u32 l)
174 {
175 longput_1(addr, l);
176 }
177 static __inline__ void put_word(uaecptr addr, uae_u32 w)
178 {
179 wordput_1(addr, w);
180 }
181 static __inline__ void put_byte(uaecptr addr, uae_u32 b)
182 {
183 byteput_1(addr, b);
184 }
185 static __inline__ uae_u8 *get_real_address(uaecptr addr)
186 {
187 return get_mem_bank(addr).xlateaddr(addr);
188 }
189 /* gb-- deliberately not implemented since it shall not be used... */
190 extern uae_u32 get_virtual_address(uae_u8 *addr);
191 #endif /* DIRECT_ADDRESSING || REAL_ADDRESSING */
192
193 #endif /* MEMORY_H */
194