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> |
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; |
74 |
– |
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 |
|
|
116 |
– |
int REGPARAM2 dummy_check (uaecptr addr, uae_u32 size) |
117 |
– |
{ |
118 |
– |
if (illegal_mem) |
119 |
– |
write_log ("Illegal check at %08lx\n", addr); |
120 |
– |
|
121 |
– |
return 0; |
122 |
– |
} |
123 |
– |
|
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; |
132 |
– |
static int REGPARAM2 ram_check(uaecptr addr, uae_u32 size) REGPARAM; |
137 |
|
static uae_u8 *REGPARAM2 ram_xlate(uaecptr addr) REGPARAM; |
138 |
|
|
139 |
|
static uintptr RAMBaseDiff; // RAMBaseHost - RAMBaseMac |
176 |
|
*(uae_u8 *)(RAMBaseDiff + addr) = b; |
177 |
|
} |
178 |
|
|
175 |
– |
int REGPARAM2 ram_check(uaecptr addr, uae_u32 size) |
176 |
– |
{ |
177 |
– |
return (addr - RAMBaseMac + size) < RAMSize; |
178 |
– |
} |
179 |
– |
|
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; |
193 |
– |
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 |
|
|
234 |
– |
int REGPARAM2 ram24_check(uaecptr addr, uae_u32 size) |
235 |
– |
{ |
236 |
– |
return ((addr & 0xffffff) - RAMBaseMac + size) < RAMSize; |
237 |
– |
} |
238 |
– |
|
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; |
252 |
– |
static int REGPARAM2 rom_check(uaecptr addr, uae_u32 size) REGPARAM; |
245 |
|
static uae_u8 *REGPARAM2 rom_xlate(uaecptr addr) REGPARAM; |
246 |
|
|
247 |
|
static uintptr ROMBaseDiff; // ROMBaseHost - ROMBaseMac |
283 |
|
write_log ("Illegal ROM bput at %08lx\n", addr); |
284 |
|
} |
285 |
|
|
294 |
– |
int REGPARAM2 rom_check(uaecptr addr, uae_u32 size) |
295 |
– |
{ |
296 |
– |
return (addr - ROMBaseMac + size) < ROMSize; |
297 |
– |
} |
298 |
– |
|
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; |
309 |
– |
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 |
|
|
331 |
– |
int REGPARAM2 rom24_check(uaecptr addr, uae_u32 size) |
332 |
– |
{ |
333 |
– |
return ((addr & 0xffffff) - ROMBaseMac + size) < ROMSize; |
334 |
– |
} |
335 |
– |
|
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 |
|
|
363 |
– |
static int REGPARAM2 frame_check(uaecptr addr, uae_u32 size) REGPARAM; |
344 |
|
static uae_u8 *REGPARAM2 frame_xlate(uaecptr addr) REGPARAM; |
345 |
|
|
346 |
|
static uintptr FrameBaseDiff; // MacFrameBaseHost - MacFrameBaseMac |
458 |
|
*m = l; |
459 |
|
} |
460 |
|
|
481 |
– |
int REGPARAM2 frame_check(uaecptr addr, uae_u32 size) |
482 |
– |
{ |
483 |
– |
return (addr - MacFrameBaseMac + size) < MacFrameSize; |
484 |
– |
} |
485 |
– |
|
461 |
|
uae_u8 *REGPARAM2 frame_xlate(uaecptr addr) |
462 |
|
{ |
463 |
|
return (uae_u8 *)(FrameBaseDiff + addr); |
465 |
|
|
466 |
|
/* Default memory access functions */ |
467 |
|
|
493 |
– |
int REGPARAM2 default_check (uaecptr a, uae_u32 b) |
494 |
– |
{ |
495 |
– |
return 0; |
496 |
– |
} |
497 |
– |
|
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) |