forked from tonioni/WinUAE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemory.cpp
3002 lines (2720 loc) · 76.7 KB
/
memory.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* UAE - The Un*x Amiga Emulator
*
* Memory management
*
* (c) 1995 Bernd Schmidt
*/
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
#include "rommgr.h"
#include "ersatz.h"
#include "zfile.h"
#include "custom.h"
#include "events.h"
#include "newcpu.h"
#include "autoconf.h"
#include "savestate.h"
#include "ar.h"
#include "crc32.h"
#include "gui.h"
#include "cdtv.h"
#include "akiko.h"
#include "arcadia.h"
#include "enforcer.h"
#include "a2091.h"
#include "gayle.h"
#include "debug.h"
bool canbang;
int candirect = -1;
#ifdef JIT
/* Set by each memory handler that does not simply access real memory. */
int special_mem;
#endif
static bool isdirectjit (void)
{
return currprefs.cachesize && !currprefs.comptrustbyte;
}
static bool canjit (void)
{
if (currprefs.cpu_model < 68020 && currprefs.address_space_24)
return 0;
return 1;
}
static void nocanbang (void)
{
canbang = 0;
}
bool ersatzkickfile;
uae_u32 allocated_chipmem;
uae_u32 allocated_fastmem;
uae_u32 allocated_bogomem;
uae_u32 allocated_gfxmem;
uae_u32 allocated_z3fastmem, allocated_z3fastmem2, allocated_z3chipmem;
uae_u32 allocated_a3000lmem;
uae_u32 allocated_a3000hmem;
uae_u32 allocated_cardmem;
uae_u8 ce_banktype[65536];
uae_u8 ce_cachable[65536];
#if defined(CPU_64_BIT)
uae_u32 max_z3fastmem = 2048UL * 1024 * 1024;
#else
uae_u32 max_z3fastmem = 512 * 1024 * 1024;
#endif
static size_t bootrom_filepos, chip_filepos, bogo_filepos, rom_filepos, a3000lmem_filepos, a3000hmem_filepos;
/* Set if we notice during initialization that settings changed,
and we must clear all memory to prevent bogus contents from confusing
the Kickstart. */
static bool need_hardreset;
/* The address space setting used during the last reset. */
static bool last_address_space_24;
addrbank *mem_banks[MEMORY_BANKS];
/* This has two functions. It either holds a host address that, when added
to the 68k address, gives the host address corresponding to that 68k
address (in which case the value in this array is even), OR it holds the
same value as mem_banks, for those banks that have baseaddr==0. In that
case, bit 0 is set (the memory access routines will take care of it). */
uae_u8 *baseaddr[MEMORY_BANKS];
#ifdef NO_INLINE_MEMORY_ACCESS
__inline__ uae_u32 longget (uaecptr addr)
{
return call_mem_get_func (get_mem_bank (addr).lget, addr);
}
__inline__ uae_u32 wordget (uaecptr addr)
{
return call_mem_get_func (get_mem_bank (addr).wget, addr);
}
__inline__ uae_u32 byteget (uaecptr addr)
{
return call_mem_get_func (get_mem_bank (addr).bget, addr);
}
__inline__ void longput (uaecptr addr, uae_u32 l)
{
call_mem_put_func (get_mem_bank (addr).lput, addr, l);
}
__inline__ void wordput (uaecptr addr, uae_u32 w)
{
call_mem_put_func (get_mem_bank (addr).wput, addr, w);
}
__inline__ void byteput (uaecptr addr, uae_u32 b)
{
call_mem_put_func (get_mem_bank (addr).bput, addr, b);
}
#endif
int addr_valid (TCHAR *txt, uaecptr addr, uae_u32 len)
{
addrbank *ab = &get_mem_bank(addr);
if (ab == 0 || !(ab->flags & ABFLAG_RAM) || addr < 0x100 || len < 0 || len > 16777215 || !valid_address (addr, len)) {
write_log (L"corrupt %s pointer %x (%d) detected!\n", txt, addr, len);
return 0;
}
return 1;
}
uae_u32 chipmem_mask, chipmem_full_mask, chipmem_full_size;
uae_u32 kickmem_mask, extendedkickmem_mask, extendedkickmem2_mask, bogomem_mask;
uae_u32 a3000lmem_mask, a3000hmem_mask, cardmem_mask;
static int illegal_count;
/* A dummy bank that only contains zeros */
static uae_u32 REGPARAM3 dummy_lget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 dummy_wget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 dummy_bget (uaecptr) REGPARAM;
static void REGPARAM3 dummy_lput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 dummy_wput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 dummy_bput (uaecptr, uae_u32) REGPARAM;
static int REGPARAM3 dummy_check (uaecptr addr, uae_u32 size) REGPARAM;
#define MAX_ILG 200
#define NONEXISTINGDATA 0
//#define NONEXISTINGDATA 0xffffffff
static void dummylog (int rw, uaecptr addr, int size, uae_u32 val, int ins)
{
if (M68K_GETPC == 0xf81a16)
activate_debugger ();
if (illegal_count >= MAX_ILG)
return;
/* ignore Zorro3 expansion space */
if (addr >= 0xff000000 && addr <= 0xff000200)
return;
/* autoconfig and extended rom */
if (addr >= 0xe00000 && addr <= 0xf7ffff)
return;
/* motherboard ram */
if (addr >= 0x08000000 && addr <= 0x08000007)
return;
if (addr >= 0x07f00000 && addr <= 0x07f00007)
return;
if (addr >= 0x07f7fff0 && addr <= 0x07ffffff)
return;
if (MAX_ILG >= 0)
illegal_count++;
if (ins) {
write_log (L"WARNING: Illegal opcode %cget at %08lx PC=%x\n",
size == 2 ? 'w' : 'l', addr, M68K_GETPC);
} else if (rw) {
write_log (L"Illegal %cput at %08lx=%08lx PC=%x\n",
size == 1 ? 'b' : size == 2 ? 'w' : 'l', addr, val, M68K_GETPC);
} else {
write_log (L"Illegal %cget at %08lx PC=%x\n",
size == 1 ? 'b' : size == 2 ? 'w' : 'l', addr, M68K_GETPC);
}
}
static uae_u32 dummy_get (uaecptr addr, int size)
{
uae_u32 v;
if (currprefs.cpu_model >= 68020)
return NONEXISTINGDATA;
v = (regs.irc << 16) | regs.irc;
if (size == 4) {
;
} else if (size == 2) {
v &= 0xffff;
} else {
v = (addr & 1) ? (v & 0xff) : ((v >> 8) & 0xff);
}
#if 0
if (addr >= 0x10000000)
write_log (L"%08X %d = %08x\n", addr, size, v);
#endif
return v;
}
static uae_u32 REGPARAM2 dummy_lget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
if (currprefs.illegal_mem)
dummylog (0, addr, 4, 0, 0);
return dummy_get (addr, 4);
}
uae_u32 REGPARAM2 dummy_lgeti (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
if (currprefs.illegal_mem)
dummylog (0, addr, 4, 0, 1);
return dummy_get (addr, 4);
}
static uae_u32 REGPARAM2 dummy_wget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
if (currprefs.illegal_mem)
dummylog (0, addr, 2, 0, 0);
return dummy_get (addr, 2);
}
uae_u32 REGPARAM2 dummy_wgeti (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
if (currprefs.illegal_mem)
dummylog (0, addr, 2, 0, 1);
return dummy_get (addr, 2);
}
static uae_u32 REGPARAM2 dummy_bget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
if (currprefs.illegal_mem)
dummylog (0, addr, 1, 0, 0);
return dummy_get (addr, 1);
}
static void REGPARAM2 dummy_lput (uaecptr addr, uae_u32 l)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
if (currprefs.illegal_mem)
dummylog (1, addr, 4, l, 0);
}
static void REGPARAM2 dummy_wput (uaecptr addr, uae_u32 w)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
if (currprefs.illegal_mem)
dummylog (1, addr, 2, w, 0);
}
static void REGPARAM2 dummy_bput (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
if (currprefs.illegal_mem)
dummylog (1, addr, 1, b, 0);
}
static int REGPARAM2 dummy_check (uaecptr addr, uae_u32 size)
{
#ifdef JIT
special_mem |= S_READ;
#endif
return 0;
}
static void REGPARAM2 none_put (uaecptr addr, uae_u32 v)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
}
static uae_u32 REGPARAM2 ones_get (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
return 0xffffffff;
}
/* Chip memory */
uae_u8 *chipmemory;
static int REGPARAM3 chipmem_check (uaecptr addr, uae_u32 size) REGPARAM;
static uae_u8 *REGPARAM3 chipmem_xlate (uaecptr addr) REGPARAM;
#ifdef AGA
/* AGA ce-chipram access */
static void ce2_timeout (void)
{
wait_cpu_cycle_read (0, -1);
}
static uae_u32 REGPARAM2 chipmem_lget_ce2 (uaecptr addr)
{
uae_u32 *m;
#ifdef JIT
special_mem |= S_READ;
#endif
addr &= chipmem_mask;
m = (uae_u32 *)(chipmemory + addr);
ce2_timeout ();
return do_get_mem_long (m);
}
static uae_u32 REGPARAM2 chipmem_wget_ce2 (uaecptr addr)
{
uae_u16 *m, v;
#ifdef JIT
special_mem |= S_READ;
#endif
addr &= chipmem_mask;
m = (uae_u16 *)(chipmemory + addr);
ce2_timeout ();
v = do_get_mem_word (m);
//last_custom_value = v;
return v;
}
static uae_u32 REGPARAM2 chipmem_bget_ce2 (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
addr &= chipmem_mask;
ce2_timeout ();
return chipmemory[addr];
}
static void REGPARAM2 chipmem_lput_ce2 (uaecptr addr, uae_u32 l)
{
uae_u32 *m;
#ifdef JIT
special_mem |= S_WRITE;
#endif
addr &= chipmem_mask;
m = (uae_u32 *)(chipmemory + addr);
ce2_timeout ();
do_put_mem_long (m, l);
}
static void REGPARAM2 chipmem_wput_ce2 (uaecptr addr, uae_u32 w)
{
uae_u16 *m;
#ifdef JIT
special_mem |= S_WRITE;
#endif
addr &= chipmem_mask;
m = (uae_u16 *)(chipmemory + addr);
ce2_timeout ();
//last_custom_value = w;
do_put_mem_word (m, w);
}
static void REGPARAM2 chipmem_bput_ce2 (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
addr &= chipmem_mask;
ce2_timeout ();
chipmemory[addr] = b;
}
#endif
uae_u32 REGPARAM2 chipmem_lget (uaecptr addr)
{
uae_u32 *m;
addr &= chipmem_mask;
m = (uae_u32 *)(chipmemory + addr);
return do_get_mem_long (m);
}
static uae_u32 REGPARAM2 chipmem_wget (uaecptr addr)
{
uae_u16 *m, v;
addr &= chipmem_mask;
m = (uae_u16 *)(chipmemory + addr);
v = do_get_mem_word (m);
//last_custom_value = v;
return v;
}
static uae_u32 REGPARAM2 chipmem_bget (uaecptr addr)
{
uae_u8 v;
addr &= chipmem_mask;
v = chipmemory[addr];
//last_custom_value = (v << 8) | v;
return v;
}
void REGPARAM2 chipmem_lput (uaecptr addr, uae_u32 l)
{
uae_u32 *m;
addr &= chipmem_mask;
m = (uae_u32 *)(chipmemory + addr);
do_put_mem_long (m, l);
}
void REGPARAM2 chipmem_wput (uaecptr addr, uae_u32 w)
{
uae_u16 *m;
addr &= chipmem_mask;
m = (uae_u16 *)(chipmemory + addr);
//last_custom_value = w;
do_put_mem_word (m, w);
}
void REGPARAM2 chipmem_bput (uaecptr addr, uae_u32 b)
{
addr &= chipmem_mask;
//last_custom_value = (b << 8) | b;
chipmemory[addr] = b;
}
/* cpu chipmem access inside agnus addressable ram but no ram available */
static uae_u32 chipmem_dummy (void)
{
/* not really right but something random that has more ones than zeros.. */
return 0xffff & ~((1 << (rand () & 31)) | (1 << (rand () & 31)));
}
void REGPARAM2 chipmem_dummy_bput (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
}
void REGPARAM2 chipmem_dummy_wput (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
}
void REGPARAM2 chipmem_dummy_lput (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
}
static uae_u32 REGPARAM2 chipmem_dummy_bget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
return chipmem_dummy ();
}
static uae_u32 REGPARAM2 chipmem_dummy_wget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
return chipmem_dummy ();
}
static uae_u32 REGPARAM2 chipmem_dummy_lget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
return (chipmem_dummy () << 16) | chipmem_dummy ();
}
static uae_u32 REGPARAM2 chipmem_agnus_lget (uaecptr addr)
{
uae_u32 *m;
addr &= chipmem_full_mask;
m = (uae_u32 *)(chipmemory + addr);
return do_get_mem_long (m);
}
uae_u32 REGPARAM2 chipmem_agnus_wget (uaecptr addr)
{
uae_u16 *m;
addr &= chipmem_full_mask;
m = (uae_u16 *)(chipmemory + addr);
return do_get_mem_word (m);
}
static uae_u32 REGPARAM2 chipmem_agnus_bget (uaecptr addr)
{
addr &= chipmem_full_mask;
return chipmemory[addr];
}
static void REGPARAM2 chipmem_agnus_lput (uaecptr addr, uae_u32 l)
{
uae_u32 *m;
addr &= chipmem_full_mask;
if (addr >= chipmem_full_size)
return;
m = (uae_u32 *)(chipmemory + addr);
do_put_mem_long (m, l);
}
void REGPARAM2 chipmem_agnus_wput (uaecptr addr, uae_u32 w)
{
uae_u16 *m;
addr &= chipmem_full_mask;
if (addr >= chipmem_full_size)
return;
m = (uae_u16 *)(chipmemory + addr);
do_put_mem_word (m, w);
}
static void REGPARAM2 chipmem_agnus_bput (uaecptr addr, uae_u32 b)
{
addr &= chipmem_full_mask;
if (addr >= chipmem_full_size)
return;
chipmemory[addr] = b;
}
static int REGPARAM2 chipmem_check (uaecptr addr, uae_u32 size)
{
addr &= chipmem_mask;
return (addr + size) <= chipmem_full_size;
}
static uae_u8 *REGPARAM2 chipmem_xlate (uaecptr addr)
{
addr &= chipmem_mask;
return chipmemory + addr;
}
STATIC_INLINE void REGPARAM2 chipmem_lput_bigmem (uaecptr addr, uae_u32 v)
{
put_long (addr, v);
}
STATIC_INLINE void REGPARAM2 chipmem_wput_bigmem (uaecptr addr, uae_u32 v)
{
put_word (addr, v);
}
STATIC_INLINE void REGPARAM2 chipmem_bput_bigmem (uaecptr addr, uae_u32 v)
{
put_byte (addr, v);
}
STATIC_INLINE uae_u32 REGPARAM2 chipmem_lget_bigmem (uaecptr addr)
{
return get_long (addr);
}
STATIC_INLINE uae_u32 REGPARAM2 chipmem_wget_bigmem (uaecptr addr)
{
return get_word (addr);
}
STATIC_INLINE uae_u32 REGPARAM2 chipmem_bget_bigmem (uaecptr addr)
{
return get_byte (addr);
}
STATIC_INLINE int REGPARAM2 chipmem_check_bigmem (uaecptr addr, uae_u32 size)
{
return valid_address (addr, size);
}
STATIC_INLINE uae_u8* REGPARAM2 chipmem_xlate_bigmem (uaecptr addr)
{
return get_real_address (addr);
}
uae_u32 (REGPARAM2 *chipmem_lget_indirect)(uaecptr);
uae_u32 (REGPARAM2 *chipmem_wget_indirect)(uaecptr);
uae_u32 (REGPARAM2 *chipmem_bget_indirect)(uaecptr);
void (REGPARAM2 *chipmem_lput_indirect)(uaecptr, uae_u32);
void (REGPARAM2 *chipmem_wput_indirect)(uaecptr, uae_u32);
void (REGPARAM2 *chipmem_bput_indirect)(uaecptr, uae_u32);
int (REGPARAM2 *chipmem_check_indirect)(uaecptr, uae_u32);
uae_u8 *(REGPARAM2 *chipmem_xlate_indirect)(uaecptr);
static void chipmem_setindirect (void)
{
if (currprefs.z3chipmem_size) {
chipmem_lget_indirect = chipmem_lget_bigmem;
chipmem_wget_indirect = chipmem_wget_bigmem;
chipmem_bget_indirect = chipmem_bget_bigmem;
chipmem_lput_indirect = chipmem_lput_bigmem;
chipmem_wput_indirect = chipmem_wput_bigmem;
chipmem_bput_indirect = chipmem_bput_bigmem;
chipmem_check_indirect = chipmem_check_bigmem;
chipmem_xlate_indirect = chipmem_xlate_bigmem;
} else {
chipmem_lget_indirect = chipmem_lget;
chipmem_wget_indirect = chipmem_agnus_wget;
chipmem_bget_indirect = chipmem_agnus_bget;
chipmem_lput_indirect = chipmem_lput;
chipmem_wput_indirect = chipmem_agnus_wput;
chipmem_bput_indirect = chipmem_agnus_bput;
chipmem_check_indirect = chipmem_check;
chipmem_xlate_indirect = chipmem_xlate;
}
}
/* Slow memory */
static uae_u8 *bogomemory;
static int bogomemory_allocated;
static uae_u32 REGPARAM3 bogomem_lget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 bogomem_wget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 bogomem_bget (uaecptr) REGPARAM;
static void REGPARAM3 bogomem_lput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 bogomem_wput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 bogomem_bput (uaecptr, uae_u32) REGPARAM;
static int REGPARAM3 bogomem_check (uaecptr addr, uae_u32 size) REGPARAM;
static uae_u8 *REGPARAM3 bogomem_xlate (uaecptr addr) REGPARAM;
static uae_u32 REGPARAM2 bogomem_lget (uaecptr addr)
{
uae_u32 *m;
addr &= bogomem_mask;
m = (uae_u32 *)(bogomemory + addr);
return do_get_mem_long (m);
}
static uae_u32 REGPARAM2 bogomem_wget (uaecptr addr)
{
uae_u16 *m;
addr &= bogomem_mask;
m = (uae_u16 *)(bogomemory + addr);
return do_get_mem_word (m);
}
static uae_u32 REGPARAM2 bogomem_bget (uaecptr addr)
{
addr &= bogomem_mask;
return bogomemory[addr];
}
static void REGPARAM2 bogomem_lput (uaecptr addr, uae_u32 l)
{
uae_u32 *m;
addr &= bogomem_mask;
m = (uae_u32 *)(bogomemory + addr);
do_put_mem_long (m, l);
}
static void REGPARAM2 bogomem_wput (uaecptr addr, uae_u32 w)
{
uae_u16 *m;
addr &= bogomem_mask;
m = (uae_u16 *)(bogomemory + addr);
do_put_mem_word (m, w);
}
static void REGPARAM2 bogomem_bput (uaecptr addr, uae_u32 b)
{
addr &= bogomem_mask;
bogomemory[addr] = b;
}
static int REGPARAM2 bogomem_check (uaecptr addr, uae_u32 size)
{
addr &= bogomem_mask;
return (addr + size) <= allocated_bogomem;
}
static uae_u8 *REGPARAM2 bogomem_xlate (uaecptr addr)
{
addr &= bogomem_mask;
return bogomemory + addr;
}
/* CDTV expension memory card memory */
uae_u8 *cardmemory;
static uae_u32 REGPARAM3 cardmem_lget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 cardmem_wget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 cardmem_bget (uaecptr) REGPARAM;
static void REGPARAM3 cardmem_lput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 cardmem_wput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 cardmem_bput (uaecptr, uae_u32) REGPARAM;
static int REGPARAM3 cardmem_check (uaecptr addr, uae_u32 size) REGPARAM;
static uae_u8 *REGPARAM3 cardmem_xlate (uaecptr addr) REGPARAM;
static uae_u32 REGPARAM2 cardmem_lget (uaecptr addr)
{
uae_u32 *m;
addr &= cardmem_mask;
m = (uae_u32 *)(cardmemory + addr);
return do_get_mem_long (m);
}
static uae_u32 REGPARAM2 cardmem_wget (uaecptr addr)
{
uae_u16 *m;
addr &= cardmem_mask;
m = (uae_u16 *)(cardmemory + addr);
return do_get_mem_word (m);
}
static uae_u32 REGPARAM2 cardmem_bget (uaecptr addr)
{
addr &= cardmem_mask;
return cardmemory[addr];
}
static void REGPARAM2 cardmem_lput (uaecptr addr, uae_u32 l)
{
uae_u32 *m;
addr &= cardmem_mask;
m = (uae_u32 *)(cardmemory + addr);
do_put_mem_long (m, l);
}
static void REGPARAM2 cardmem_wput (uaecptr addr, uae_u32 w)
{
uae_u16 *m;
addr &= cardmem_mask;
m = (uae_u16 *)(cardmemory + addr);
do_put_mem_word (m, w);
}
static void REGPARAM2 cardmem_bput (uaecptr addr, uae_u32 b)
{
addr &= cardmem_mask;
cardmemory[addr] = b;
}
static int REGPARAM2 cardmem_check (uaecptr addr, uae_u32 size)
{
addr &= cardmem_mask;
return (addr + size) <= allocated_cardmem;
}
static uae_u8 *REGPARAM2 cardmem_xlate (uaecptr addr)
{
addr &= cardmem_mask;
return cardmemory + addr;
}
/* A3000 motherboard fast memory */
static uae_u8 *a3000lmemory, *a3000hmemory;
uae_u32 a3000lmem_start, a3000hmem_start;
static uae_u32 REGPARAM3 a3000lmem_lget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 a3000lmem_wget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 a3000lmem_bget (uaecptr) REGPARAM;
static void REGPARAM3 a3000lmem_lput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 a3000lmem_wput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 a3000lmem_bput (uaecptr, uae_u32) REGPARAM;
static int REGPARAM3 a3000lmem_check (uaecptr addr, uae_u32 size) REGPARAM;
static uae_u8 *REGPARAM3 a3000lmem_xlate (uaecptr addr) REGPARAM;
static uae_u32 REGPARAM2 a3000lmem_lget (uaecptr addr)
{
uae_u32 *m;
addr &= a3000lmem_mask;
m = (uae_u32 *)(a3000lmemory + addr);
return do_get_mem_long (m);
}
static uae_u32 REGPARAM2 a3000lmem_wget (uaecptr addr)
{
uae_u16 *m;
addr &= a3000lmem_mask;
m = (uae_u16 *)(a3000lmemory + addr);
return do_get_mem_word (m);
}
static uae_u32 REGPARAM2 a3000lmem_bget (uaecptr addr)
{
addr &= a3000lmem_mask;
return a3000lmemory[addr];
}
static void REGPARAM2 a3000lmem_lput (uaecptr addr, uae_u32 l)
{
uae_u32 *m;
addr &= a3000lmem_mask;
m = (uae_u32 *)(a3000lmemory + addr);
do_put_mem_long (m, l);
}
static void REGPARAM2 a3000lmem_wput (uaecptr addr, uae_u32 w)
{
uae_u16 *m;
addr &= a3000lmem_mask;
m = (uae_u16 *)(a3000lmemory + addr);
do_put_mem_word (m, w);
}
static void REGPARAM2 a3000lmem_bput (uaecptr addr, uae_u32 b)
{
addr &= a3000lmem_mask;
a3000lmemory[addr] = b;
}
static int REGPARAM2 a3000lmem_check (uaecptr addr, uae_u32 size)
{
addr &= a3000lmem_mask;
return (addr + size) <= allocated_a3000lmem;
}
static uae_u8 *REGPARAM2 a3000lmem_xlate (uaecptr addr)
{
addr &= a3000lmem_mask;
return a3000lmemory + addr;
}
static uae_u32 REGPARAM3 a3000hmem_lget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 a3000hmem_wget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 a3000hmem_bget (uaecptr) REGPARAM;
static void REGPARAM3 a3000hmem_lput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 a3000hmem_wput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 a3000hmem_bput (uaecptr, uae_u32) REGPARAM;
static int REGPARAM3 a3000hmem_check (uaecptr addr, uae_u32 size) REGPARAM;
static uae_u8 *REGPARAM3 a3000hmem_xlate (uaecptr addr) REGPARAM;
static uae_u32 REGPARAM2 a3000hmem_lget (uaecptr addr)
{
uae_u32 *m;
addr &= a3000hmem_mask;
m = (uae_u32 *)(a3000hmemory + addr);
return do_get_mem_long (m);
}
static uae_u32 REGPARAM2 a3000hmem_wget (uaecptr addr)
{
uae_u16 *m;
addr &= a3000hmem_mask;
m = (uae_u16 *)(a3000hmemory + addr);
return do_get_mem_word (m);
}
static uae_u32 REGPARAM2 a3000hmem_bget (uaecptr addr)
{
addr &= a3000hmem_mask;
return a3000hmemory[addr];
}
static void REGPARAM2 a3000hmem_lput (uaecptr addr, uae_u32 l)
{
uae_u32 *m;
addr &= a3000hmem_mask;
m = (uae_u32 *)(a3000hmemory + addr);
do_put_mem_long (m, l);
}
static void REGPARAM2 a3000hmem_wput (uaecptr addr, uae_u32 w)
{
uae_u16 *m;
addr &= a3000hmem_mask;
m = (uae_u16 *)(a3000hmemory + addr);
do_put_mem_word (m, w);
}
static void REGPARAM2 a3000hmem_bput (uaecptr addr, uae_u32 b)
{
addr &= a3000hmem_mask;
a3000hmemory[addr] = b;
}
static int REGPARAM2 a3000hmem_check (uaecptr addr, uae_u32 size)
{
addr &= a3000hmem_mask;
return (addr + size) <= allocated_a3000hmem;
}
static uae_u8 *REGPARAM2 a3000hmem_xlate (uaecptr addr)
{
addr &= a3000hmem_mask;
return a3000hmemory + addr;
}
/* Kick memory */
uae_u8 *kickmemory;
uae_u16 kickstart_version;
static int kickmem_size;
/*
* A1000 kickstart RAM handling
*
* RESET instruction unhides boot ROM and disables write protection
* write access to boot ROM hides boot ROM and enables write protection
*
*/
static int a1000_kickstart_mode;
static uae_u8 *a1000_bootrom;
static void a1000_handle_kickstart (int mode)
{
if (!a1000_bootrom)
return;
if (mode == 0) {
a1000_kickstart_mode = 0;
memcpy (kickmemory, kickmemory + 262144, 262144);
kickstart_version = (kickmemory[262144 + 12] << 8) | kickmemory[262144 + 13];
} else {
a1000_kickstart_mode = 1;
memcpy (kickmemory, a1000_bootrom, 262144);
kickstart_version = 0;
}
if (kickstart_version == 0xffff)
kickstart_version = 0;
}
void a1000_reset (void)
{
a1000_handle_kickstart (1);
}
static uae_u32 REGPARAM3 kickmem_lget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 kickmem_wget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 kickmem_bget (uaecptr) REGPARAM;
static void REGPARAM3 kickmem_lput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 kickmem_wput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 kickmem_bput (uaecptr, uae_u32) REGPARAM;
static int REGPARAM3 kickmem_check (uaecptr addr, uae_u32 size) REGPARAM;
static uae_u8 *REGPARAM3 kickmem_xlate (uaecptr addr) REGPARAM;
static uae_u32 REGPARAM2 kickmem_lget (uaecptr addr)
{
uae_u32 *m;
addr &= kickmem_mask;
m = (uae_u32 *)(kickmemory + addr);
return do_get_mem_long (m);
}
static uae_u32 REGPARAM2 kickmem_wget (uaecptr addr)
{
uae_u16 *m;
addr &= kickmem_mask;
m = (uae_u16 *)(kickmemory + addr);
return do_get_mem_word (m);
}
static uae_u32 REGPARAM2 kickmem_bget (uaecptr addr)
{
addr &= kickmem_mask;
return kickmemory[addr];
}
static void REGPARAM2 kickmem_lput (uaecptr addr, uae_u32 b)
{
uae_u32 *m;
#ifdef JIT
special_mem |= S_WRITE;
#endif
if (a1000_kickstart_mode) {
if (addr >= 0xfc0000) {
addr &= kickmem_mask;
m = (uae_u32 *)(kickmemory + addr);
do_put_mem_long (m, b);
return;
} else
a1000_handle_kickstart (0);
} else if (currprefs.illegal_mem)
write_log (L"Illegal kickmem lput at %08lx\n", addr);
}
static void REGPARAM2 kickmem_wput (uaecptr addr, uae_u32 b)
{
uae_u16 *m;
#ifdef JIT
special_mem |= S_WRITE;
#endif
if (a1000_kickstart_mode) {
if (addr >= 0xfc0000) {
addr &= kickmem_mask;
m = (uae_u16 *)(kickmemory + addr);
do_put_mem_word (m, b);
return;
} else
a1000_handle_kickstart (0);
} else if (currprefs.illegal_mem)
write_log (L"Illegal kickmem wput at %08lx\n", addr);