1 |
< |
/* |
2 |
< |
* UAE - The Un*x Amiga Emulator |
3 |
< |
* |
4 |
< |
* memory management |
5 |
< |
* |
6 |
< |
* Copyright 1995 Bernd Schmidt |
7 |
< |
*/ |
1 |
> |
/* |
2 |
> |
* UAE - The Un*x Amiga Emulator |
3 |
> |
* |
4 |
> |
* memory management |
5 |
> |
* |
6 |
> |
* Copyright 1995 Bernd Schmidt |
7 |
> |
* |
8 |
> |
* This program is free software; you can redistribute it and/or modify |
9 |
> |
* it under the terms of the GNU General Public License as published by |
10 |
> |
* the Free Software Foundation; either version 2 of the License, or |
11 |
> |
* (at your option) any later version. |
12 |
> |
* |
13 |
> |
* This program is distributed in the hope that it will be useful, |
14 |
> |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
> |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
> |
* GNU General Public License for more details. |
17 |
> |
* |
18 |
> |
* You should have received a copy of the GNU General Public License |
19 |
> |
* along with this program; if not, write to the Free Software |
20 |
> |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
> |
*/ |
22 |
|
|
23 |
|
#ifndef UAE_MEMORY_H |
24 |
|
#define UAE_MEMORY_H |
25 |
|
|
26 |
+ |
#if !DIRECT_ADDRESSING && !REAL_ADDRESSING |
27 |
+ |
|
28 |
|
/* Enabling this adds one additional native memory reference per 68k memory |
29 |
|
* access, but saves one shift (on the x86). Enabling this is probably |
30 |
|
* better for the cache. My favourite benchmark (PP2) doesn't show a |
37 |
|
typedef uae_u32 (REGPARAM2 *mem_get_func)(uaecptr) REGPARAM; |
38 |
|
typedef void (REGPARAM2 *mem_put_func)(uaecptr, uae_u32) REGPARAM; |
39 |
|
typedef uae_u8 *(REGPARAM2 *xlate_func)(uaecptr) REGPARAM; |
24 |
– |
typedef int (REGPARAM2 *check_func)(uaecptr, uae_u32) REGPARAM; |
40 |
|
|
41 |
|
#undef DIRECT_MEMFUNCS_SUCCESSFUL |
42 |
|
|
57 |
|
* This doesn't work for all memory banks, so this function may call |
58 |
|
* abort(). */ |
59 |
|
xlate_func xlateaddr; |
45 |
– |
/* To prevent calls to abort(), use check before calling xlateaddr. |
46 |
– |
* It checks not only that the memory bank can do xlateaddr, but also |
47 |
– |
* that the pointer points to an area of at least the specified size. |
48 |
– |
* This is used for example to translate bitplane pointers in custom.c */ |
49 |
– |
check_func check; |
60 |
|
} addrbank; |
61 |
|
|
62 |
|
extern uae_u8 filesysory[65536]; |
67 |
|
|
68 |
|
/* Default memory access functions */ |
69 |
|
|
60 |
– |
extern int REGPARAM2 default_check(uaecptr addr, uae_u32 size) REGPARAM; |
70 |
|
extern uae_u8 *REGPARAM2 default_xlate(uaecptr addr) REGPARAM; |
71 |
|
|
72 |
|
#define bankindex(addr) (((uaecptr)(addr)) >> 16) |
95 |
|
|
96 |
|
#else |
97 |
|
|
89 |
– |
extern uae_u32 alongget(uaecptr addr); |
90 |
– |
extern uae_u32 awordget(uaecptr addr); |
98 |
|
extern uae_u32 longget(uaecptr addr); |
99 |
|
extern uae_u32 wordget(uaecptr addr); |
100 |
|
extern uae_u32 byteget(uaecptr addr); |
115 |
|
|
116 |
|
#endif |
117 |
|
|
118 |
+ |
#endif /* !DIRECT_ADDRESSING && !REAL_ADDRESSING */ |
119 |
+ |
|
120 |
|
#if REAL_ADDRESSING |
121 |
+ |
const uintptr MEMBaseDiff = 0; |
122 |
+ |
#elif DIRECT_ADDRESSING |
123 |
+ |
extern uintptr MEMBaseDiff; |
124 |
+ |
#endif |
125 |
+ |
|
126 |
+ |
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
127 |
+ |
static __inline__ uae_u8 *do_get_real_address(uaecptr addr) |
128 |
+ |
{ |
129 |
+ |
return (uae_u8 *)MEMBaseDiff + addr; |
130 |
+ |
} |
131 |
+ |
static __inline__ uae_u32 do_get_virtual_address(uae_u8 *addr) |
132 |
+ |
{ |
133 |
+ |
return (uintptr)addr - MEMBaseDiff; |
134 |
+ |
} |
135 |
|
static __inline__ uae_u32 get_long(uaecptr addr) |
136 |
|
{ |
137 |
< |
return ntohl(*(uae_u32 *)addr); |
137 |
> |
uae_u32 * const m = (uae_u32 *)do_get_real_address(addr); |
138 |
> |
return do_get_mem_long(m); |
139 |
|
} |
140 |
|
static __inline__ uae_u32 get_word(uaecptr addr) |
141 |
|
{ |
142 |
< |
return ntohs(*(uae_u16 *)addr); |
142 |
> |
uae_u16 * const m = (uae_u16 *)do_get_real_address(addr); |
143 |
> |
return do_get_mem_word(m); |
144 |
|
} |
145 |
|
static __inline__ uae_u32 get_byte(uaecptr addr) |
146 |
|
{ |
147 |
< |
return *(uae_u8 *)addr; |
147 |
> |
uae_u8 * const m = (uae_u8 *)do_get_real_address(addr); |
148 |
> |
return do_get_mem_byte(m); |
149 |
|
} |
150 |
|
static __inline__ void put_long(uaecptr addr, uae_u32 l) |
151 |
|
{ |
152 |
< |
*(uae_u32 *)addr = htonl(l); |
152 |
> |
uae_u32 * const m = (uae_u32 *)do_get_real_address(addr); |
153 |
> |
do_put_mem_long(m, l); |
154 |
|
} |
155 |
|
static __inline__ void put_word(uaecptr addr, uae_u32 w) |
156 |
|
{ |
157 |
< |
*(uae_u16 *)addr = htons(w); |
157 |
> |
uae_u16 * const m = (uae_u16 *)do_get_real_address(addr); |
158 |
> |
do_put_mem_word(m, w); |
159 |
|
} |
160 |
|
static __inline__ void put_byte(uaecptr addr, uae_u32 b) |
161 |
|
{ |
162 |
< |
*(uae_u8 *)addr = b; |
162 |
> |
uae_u8 * const m = (uae_u8 *)do_get_real_address(addr); |
163 |
> |
do_put_mem_byte(m, b); |
164 |
|
} |
165 |
|
static __inline__ uae_u8 *get_real_address(uaecptr addr) |
166 |
|
{ |
167 |
< |
return (uae_u8 *)addr; |
167 |
> |
return do_get_real_address(addr); |
168 |
|
} |
169 |
< |
static __inline__ int valid_address(uaecptr addr, uae_u32 size) |
169 |
> |
static __inline__ uae_u32 get_virtual_address(uae_u8 *addr) |
170 |
|
{ |
171 |
< |
return 1; |
171 |
> |
return do_get_virtual_address(addr); |
172 |
|
} |
173 |
|
#else |
174 |
|
static __inline__ uae_u32 get_long(uaecptr addr) |
195 |
|
{ |
196 |
|
byteput_1(addr, b); |
197 |
|
} |
169 |
– |
|
198 |
|
static __inline__ uae_u8 *get_real_address(uaecptr addr) |
199 |
|
{ |
200 |
|
return get_mem_bank(addr).xlateaddr(addr); |
201 |
|
} |
202 |
+ |
/* gb-- deliberately not implemented since it shall not be used... */ |
203 |
+ |
extern uae_u32 get_virtual_address(uae_u8 *addr); |
204 |
+ |
#endif /* DIRECT_ADDRESSING || REAL_ADDRESSING */ |
205 |
|
|
206 |
< |
static __inline__ int valid_address(uaecptr addr, uae_u32 size) |
176 |
< |
{ |
177 |
< |
return get_mem_bank(addr).check(addr, size); |
178 |
< |
} |
179 |
< |
#endif |
206 |
> |
#endif /* MEMORY_H */ |
207 |
|
|
181 |
– |
#endif |