1 |
< |
/* |
2 |
< |
* UAE - The Un*x Amiga Emulator |
3 |
< |
* |
4 |
< |
* Memory management |
5 |
< |
* |
6 |
< |
* (c) 1995 Bernd Schmidt |
7 |
< |
*/ |
1 |
> |
/* |
2 |
> |
* UAE - The Un*x Amiga Emulator |
3 |
> |
* |
4 |
> |
* Memory management |
5 |
> |
* |
6 |
> |
* (c) 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 |
|
#include <stdio.h> |
24 |
|
#include <stdlib.h> |
26 |
|
#include "sysdeps.h" |
27 |
|
|
28 |
|
#include "cpu_emulation.h" |
29 |
+ |
#include "main.h" |
30 |
+ |
#include "video.h" |
31 |
+ |
|
32 |
|
#include "m68k.h" |
33 |
|
#include "memory.h" |
34 |
|
#include "readcpu.h" |
35 |
|
#include "newcpu.h" |
19 |
– |
#include "main.h" |
20 |
– |
#include "video.h" |
36 |
|
|
37 |
|
#if !REAL_ADDRESSING && !DIRECT_ADDRESSING |
38 |
|
|
51 |
|
#endif |
52 |
|
|
53 |
|
#ifdef NO_INLINE_MEMORY_ACCESS |
54 |
< |
__inline__ uae_u32 longget (uaecptr addr) |
54 |
> |
uae_u32 longget (uaecptr addr) |
55 |
|
{ |
56 |
|
return call_mem_get_func (get_mem_bank (addr).lget, addr); |
57 |
|
} |
58 |
< |
__inline__ uae_u32 wordget (uaecptr addr) |
58 |
> |
uae_u32 wordget (uaecptr addr) |
59 |
|
{ |
60 |
|
return call_mem_get_func (get_mem_bank (addr).wget, addr); |
61 |
|
} |
62 |
< |
__inline__ uae_u32 byteget (uaecptr addr) |
62 |
> |
uae_u32 byteget (uaecptr addr) |
63 |
|
{ |
64 |
|
return call_mem_get_func (get_mem_bank (addr).bget, addr); |
65 |
|
} |
66 |
< |
__inline__ void longput (uaecptr addr, uae_u32 l) |
66 |
> |
void longput (uaecptr addr, uae_u32 l) |
67 |
|
{ |
68 |
|
call_mem_put_func (get_mem_bank (addr).lput, addr, l); |
69 |
|
} |
70 |
< |
__inline__ void wordput (uaecptr addr, uae_u32 w) |
70 |
> |
void wordput (uaecptr addr, uae_u32 w) |
71 |
|
{ |
72 |
|
call_mem_put_func (get_mem_bank (addr).wput, addr, w); |
73 |
|
} |
74 |
< |
__inline__ void byteput (uaecptr addr, uae_u32 b) |
74 |
> |
void byteput (uaecptr addr, uae_u32 b) |
75 |
|
{ |
76 |
|
call_mem_put_func (get_mem_bank (addr).bput, addr, b); |
77 |
|
} |
85 |
|
static void REGPARAM2 dummy_lput (uaecptr, uae_u32) REGPARAM; |
86 |
|
static void REGPARAM2 dummy_wput (uaecptr, uae_u32) REGPARAM; |
87 |
|
static void REGPARAM2 dummy_bput (uaecptr, uae_u32) REGPARAM; |
73 |
– |
static int REGPARAM2 dummy_check (uaecptr addr, uae_u32 size) REGPARAM; |
88 |
|
|
89 |
|
uae_u32 REGPARAM2 dummy_lget (uaecptr addr) |
90 |
|
{ |
126 |
|
write_log ("Illegal bput at %08lx\n", addr); |
127 |
|
} |
128 |
|
|
115 |
– |
int REGPARAM2 dummy_check (uaecptr addr, uae_u32 size) |
116 |
– |
{ |
117 |
– |
if (illegal_mem) |
118 |
– |
write_log ("Illegal check at %08lx\n", addr); |
119 |
– |
|
120 |
– |
return 0; |
121 |
– |
} |
122 |
– |
|
129 |
|
/* Mac RAM (32 bit addressing) */ |
130 |
|
|
131 |
|
static uae_u32 REGPARAM2 ram_lget(uaecptr) REGPARAM; |
134 |
|
static void REGPARAM2 ram_lput(uaecptr, uae_u32) REGPARAM; |
135 |
|
static void REGPARAM2 ram_wput(uaecptr, uae_u32) REGPARAM; |
136 |
|
static void REGPARAM2 ram_bput(uaecptr, uae_u32) REGPARAM; |
131 |
– |
static int REGPARAM2 ram_check(uaecptr addr, uae_u32 size) REGPARAM; |
137 |
|
static uae_u8 *REGPARAM2 ram_xlate(uaecptr addr) REGPARAM; |
138 |
|
|
139 |
< |
static uae_u32 RAMBaseDiff; // RAMBaseHost - RAMBaseMac |
139 |
> |
static uintptr RAMBaseDiff; // RAMBaseHost - RAMBaseMac |
140 |
|
|
141 |
|
uae_u32 REGPARAM2 ram_lget(uaecptr addr) |
142 |
|
{ |
176 |
|
*(uae_u8 *)(RAMBaseDiff + addr) = b; |
177 |
|
} |
178 |
|
|
174 |
– |
int REGPARAM2 ram_check(uaecptr addr, uae_u32 size) |
175 |
– |
{ |
176 |
– |
return (addr - RAMBaseMac + size) < RAMSize; |
177 |
– |
} |
178 |
– |
|
179 |
|
uae_u8 *REGPARAM2 ram_xlate(uaecptr addr) |
180 |
|
{ |
181 |
|
return (uae_u8 *)(RAMBaseDiff + addr); |
189 |
|
static void REGPARAM2 ram24_lput(uaecptr, uae_u32) REGPARAM; |
190 |
|
static void REGPARAM2 ram24_wput(uaecptr, uae_u32) REGPARAM; |
191 |
|
static void REGPARAM2 ram24_bput(uaecptr, uae_u32) REGPARAM; |
192 |
– |
static int REGPARAM2 ram24_check(uaecptr addr, uae_u32 size) REGPARAM; |
192 |
|
static uae_u8 *REGPARAM2 ram24_xlate(uaecptr addr) REGPARAM; |
193 |
|
|
194 |
|
uae_u32 REGPARAM2 ram24_lget(uaecptr addr) |
229 |
|
*(uae_u8 *)(RAMBaseDiff + (addr & 0xffffff)) = b; |
230 |
|
} |
231 |
|
|
233 |
– |
int REGPARAM2 ram24_check(uaecptr addr, uae_u32 size) |
234 |
– |
{ |
235 |
– |
return ((addr & 0xffffff) - RAMBaseMac + size) < RAMSize; |
236 |
– |
} |
237 |
– |
|
232 |
|
uae_u8 *REGPARAM2 ram24_xlate(uaecptr addr) |
233 |
|
{ |
234 |
|
return (uae_u8 *)(RAMBaseDiff + (addr & 0xffffff)); |
242 |
|
static void REGPARAM2 rom_lput(uaecptr, uae_u32) REGPARAM; |
243 |
|
static void REGPARAM2 rom_wput(uaecptr, uae_u32) REGPARAM; |
244 |
|
static void REGPARAM2 rom_bput(uaecptr, uae_u32) REGPARAM; |
251 |
– |
static int REGPARAM2 rom_check(uaecptr addr, uae_u32 size) REGPARAM; |
245 |
|
static uae_u8 *REGPARAM2 rom_xlate(uaecptr addr) REGPARAM; |
246 |
|
|
247 |
< |
static uae_u32 ROMBaseDiff; // ROMBaseHost - ROMBaseMac |
247 |
> |
static uintptr ROMBaseDiff; // ROMBaseHost - ROMBaseMac |
248 |
|
|
249 |
|
uae_u32 REGPARAM2 rom_lget(uaecptr addr) |
250 |
|
{ |
283 |
|
write_log ("Illegal ROM bput at %08lx\n", addr); |
284 |
|
} |
285 |
|
|
293 |
– |
int REGPARAM2 rom_check(uaecptr addr, uae_u32 size) |
294 |
– |
{ |
295 |
– |
return (addr - ROMBaseMac + size) < ROMSize; |
296 |
– |
} |
297 |
– |
|
286 |
|
uae_u8 *REGPARAM2 rom_xlate(uaecptr addr) |
287 |
|
{ |
288 |
|
return (uae_u8 *)(ROMBaseDiff + addr); |
293 |
|
static uae_u32 REGPARAM2 rom24_lget(uaecptr) REGPARAM; |
294 |
|
static uae_u32 REGPARAM2 rom24_wget(uaecptr) REGPARAM; |
295 |
|
static uae_u32 REGPARAM2 rom24_bget(uaecptr) REGPARAM; |
308 |
– |
static int REGPARAM2 rom24_check(uaecptr addr, uae_u32 size) REGPARAM; |
296 |
|
static uae_u8 *REGPARAM2 rom24_xlate(uaecptr addr) REGPARAM; |
297 |
|
|
298 |
|
uae_u32 REGPARAM2 rom24_lget(uaecptr addr) |
314 |
|
return (uae_u32)*(uae_u8 *)(ROMBaseDiff + (addr & 0xffffff)); |
315 |
|
} |
316 |
|
|
330 |
– |
int REGPARAM2 rom24_check(uaecptr addr, uae_u32 size) |
331 |
– |
{ |
332 |
– |
return ((addr & 0xffffff) - ROMBaseMac + size) < ROMSize; |
333 |
– |
} |
334 |
– |
|
317 |
|
uae_u8 *REGPARAM2 rom24_xlate(uaecptr addr) |
318 |
|
{ |
319 |
|
return (uae_u8 *)(ROMBaseDiff + (addr & 0xffffff)); |
341 |
|
static uae_u32 REGPARAM2 frame_host_888_lget(uaecptr) REGPARAM; |
342 |
|
static void REGPARAM2 frame_host_888_lput(uaecptr, uae_u32) REGPARAM; |
343 |
|
|
362 |
– |
static int REGPARAM2 frame_check(uaecptr addr, uae_u32 size) REGPARAM; |
344 |
|
static uae_u8 *REGPARAM2 frame_xlate(uaecptr addr) REGPARAM; |
345 |
|
|
346 |
< |
static uae_u32 FrameBaseDiff; // MacFrameBaseHost - MacFrameBaseMac |
346 |
> |
static uintptr FrameBaseDiff; // MacFrameBaseHost - MacFrameBaseMac |
347 |
|
|
348 |
|
uae_u32 REGPARAM2 frame_direct_lget(uaecptr addr) |
349 |
|
{ |
458 |
|
*m = l; |
459 |
|
} |
460 |
|
|
480 |
– |
int REGPARAM2 frame_check(uaecptr addr, uae_u32 size) |
481 |
– |
{ |
482 |
– |
return (addr - MacFrameBaseMac + size) < MacFrameSize; |
483 |
– |
} |
484 |
– |
|
461 |
|
uae_u8 *REGPARAM2 frame_xlate(uaecptr addr) |
462 |
|
{ |
463 |
|
return (uae_u8 *)(FrameBaseDiff + addr); |
465 |
|
|
466 |
|
/* Default memory access functions */ |
467 |
|
|
492 |
– |
int REGPARAM2 default_check (uaecptr a, uae_u32 b) |
493 |
– |
{ |
494 |
– |
return 0; |
495 |
– |
} |
496 |
– |
|
468 |
|
uae_u8 *REGPARAM2 default_xlate (uaecptr a) |
469 |
|
{ |
470 |
|
write_log("Your Mac program just did something terribly stupid\n"); |
476 |
|
addrbank dummy_bank = { |
477 |
|
dummy_lget, dummy_wget, dummy_bget, |
478 |
|
dummy_lput, dummy_wput, dummy_bput, |
479 |
< |
default_xlate, dummy_check |
479 |
> |
default_xlate |
480 |
|
}; |
481 |
|
|
482 |
|
addrbank ram_bank = { |
483 |
|
ram_lget, ram_wget, ram_bget, |
484 |
|
ram_lput, ram_wput, ram_bput, |
485 |
< |
ram_xlate, ram_check |
485 |
> |
ram_xlate |
486 |
|
}; |
487 |
|
|
488 |
|
addrbank ram24_bank = { |
489 |
|
ram24_lget, ram24_wget, ram24_bget, |
490 |
|
ram24_lput, ram24_wput, ram24_bput, |
491 |
< |
ram24_xlate, ram24_check |
491 |
> |
ram24_xlate |
492 |
|
}; |
493 |
|
|
494 |
|
addrbank rom_bank = { |
495 |
|
rom_lget, rom_wget, rom_bget, |
496 |
|
rom_lput, rom_wput, rom_bput, |
497 |
< |
rom_xlate, rom_check |
497 |
> |
rom_xlate |
498 |
|
}; |
499 |
|
|
500 |
|
addrbank rom24_bank = { |
501 |
|
rom24_lget, rom24_wget, rom24_bget, |
502 |
|
rom_lput, rom_wput, rom_bput, |
503 |
< |
rom24_xlate, rom24_check |
503 |
> |
rom24_xlate |
504 |
|
}; |
505 |
|
|
506 |
|
addrbank frame_direct_bank = { |
507 |
|
frame_direct_lget, frame_direct_wget, frame_direct_bget, |
508 |
|
frame_direct_lput, frame_direct_wput, frame_direct_bput, |
509 |
< |
frame_xlate, frame_check |
509 |
> |
frame_xlate |
510 |
|
}; |
511 |
|
|
512 |
|
addrbank frame_host_555_bank = { |
513 |
|
frame_host_555_lget, frame_host_555_wget, frame_direct_bget, |
514 |
|
frame_host_555_lput, frame_host_555_wput, frame_direct_bput, |
515 |
< |
frame_xlate, frame_check |
515 |
> |
frame_xlate |
516 |
|
}; |
517 |
|
|
518 |
|
addrbank frame_host_565_bank = { |
519 |
|
frame_host_565_lget, frame_host_565_wget, frame_direct_bget, |
520 |
|
frame_host_565_lput, frame_host_565_wput, frame_direct_bput, |
521 |
< |
frame_xlate, frame_check |
521 |
> |
frame_xlate |
522 |
|
}; |
523 |
|
|
524 |
|
addrbank frame_host_888_bank = { |
525 |
|
frame_host_888_lget, frame_direct_wget, frame_direct_bget, |
526 |
|
frame_host_888_lput, frame_direct_wput, frame_direct_bput, |
527 |
< |
frame_xlate, frame_check |
527 |
> |
frame_xlate |
528 |
|
}; |
529 |
|
|
530 |
|
void memory_init(void) |
535 |
|
// Limit RAM size to not overlap ROM |
536 |
|
uint32 ram_size = RAMSize > ROMBaseMac ? ROMBaseMac : RAMSize; |
537 |
|
|
538 |
< |
RAMBaseDiff = (uae_u32)RAMBaseHost - (uae_u32)RAMBaseMac; |
539 |
< |
ROMBaseDiff = (uae_u32)ROMBaseHost - (uae_u32)ROMBaseMac; |
540 |
< |
FrameBaseDiff = (uae_u32)MacFrameBaseHost - (uae_u32)MacFrameBaseMac; |
538 |
> |
RAMBaseDiff = (uintptr)RAMBaseHost - (uintptr)RAMBaseMac; |
539 |
> |
ROMBaseDiff = (uintptr)ROMBaseHost - (uintptr)ROMBaseMac; |
540 |
> |
FrameBaseDiff = (uintptr)MacFrameBaseHost - (uintptr)MacFrameBaseMac; |
541 |
|
|
542 |
|
// Map RAM and ROM |
543 |
|
if (TwentyFourBitAddressing) { |