-
Notifications
You must be signed in to change notification settings - Fork 0
/
memory.c
executable file
·1907 lines (1678 loc) · 44.7 KB
/
memory.c
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 "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"
#ifdef USE_MAPPED_MEMORY
#include <sys/mman.h>
#endif
#ifdef JIT
int canbang;
/* Set by each memory handler that does not simply access real memory. */
int special_mem;
#endif
int ersatzkickfile;
/*
#ifdef CD32
extern int cd32_enabled;
#endif
*/
#ifdef CDTV
extern int cdtv_enabled;
#endif
uae_u32 allocated_chipmem;
uae_u32 allocated_fastmem;
uae_u32 allocated_bogomem;
uae_u32 allocated_gfxmem;
uae_u32 allocated_z3fastmem;
uae_u32 allocated_a3000mem;
#ifdef SAVESTATE
static size_t chip_filepos;
static size_t bogo_filepos;
static size_t rom_filepos;
#endif
addrbank *mem_banks[MEMORY_BANKS];
#ifdef JIT
/* 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];
#endif
uae_u32 chipmem_mask, kickmem_mask, extendedkickmem_mask, bogomem_mask, a3000mem_mask;
static int illegal_count;
/* A dummy bank that only contains zeros */
static uae_u32 dummy_lget (uaecptr) REGPARAM;
static uae_u32 dummy_wget (uaecptr) REGPARAM;
static uae_u32 dummy_bget (uaecptr) REGPARAM;
static void dummy_lput (uaecptr, uae_u32) REGPARAM;
static void dummy_wput (uaecptr, uae_u32) REGPARAM;
static void dummy_bput (uaecptr, uae_u32) REGPARAM;
static int dummy_check (uaecptr addr, uae_u32 size) REGPARAM;
#define MAX_ILG 20
uae_u32 REGPARAM2 dummy_lget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
/*
if (currprefs.illegal_mem) {
if (illegal_count < MAX_ILG) {
illegal_count++;
write_log ("Illegal lget at %08lx\n", addr);
}
}
*/
if (currprefs.cpu_level >= 2)
return 0;
return (regs.irc << 16) | regs.irc;
}
uae_u32 REGPARAM2 dummy_wget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
if (currprefs.illegal_mem) {
if (illegal_count < MAX_ILG) {
illegal_count++;
write_log ("Illegal wget at %08lx\n", addr);
}
}
if (currprefs.cpu_level >= 2)
return 0;
return regs.irc;
}
uae_u32 REGPARAM2 dummy_bget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
/*
if (currprefs.illegal_mem) {
if (illegal_count < MAX_ILG) {
illegal_count++;
write_log ("Illegal bget at %08lx\n", addr);
}
}
*/
if (currprefs.cpu_level >= 2)
return 0;
return (addr & 1) ? regs.irc : regs.irc >> 8;
}
void REGPARAM2 dummy_lput (uaecptr addr, uae_u32 l)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
/*
if (currprefs.illegal_mem) {
if (illegal_count < MAX_ILG) {
illegal_count++;
write_log ("Illegal lput at %08lx\n", addr);
}
}
*/
}
void REGPARAM2 dummy_wput (uaecptr addr, uae_u32 w)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
/*
if (currprefs.illegal_mem) {
if (illegal_count < MAX_ILG) {
illegal_count++;
write_log ("Illegal wput at %08lx\n", addr);
}
}
*/
}
void REGPARAM2 dummy_bput (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
/*
if (currprefs.illegal_mem) {
if (illegal_count < MAX_ILG) {
illegal_count++;
write_log ("Illegal bput at %08lx\n", addr);
}
}
*/
}
int REGPARAM2 dummy_check (uaecptr addr, uae_u32 size)
{
#ifdef JIT
special_mem |= S_READ;
#endif
/*
if (currprefs.illegal_mem) {
if (illegal_count < MAX_ILG) {
illegal_count++;
write_log ("Illegal check at %08lx\n", addr);
}
}
*/
return 0;
}
#if defined AUTOCONFIG && defined A3000MBRES
/* A3000 "motherboard resources" bank. */
static uae_u32 mbres_lget (uaecptr) REGPARAM;
static uae_u32 mbres_wget (uaecptr) REGPARAM;
static uae_u32 mbres_bget (uaecptr) REGPARAM;
static void mbres_lput (uaecptr, uae_u32) REGPARAM;
static void mbres_wput (uaecptr, uae_u32) REGPARAM;
static void mbres_bput (uaecptr, uae_u32) REGPARAM;
static int mbres_check (uaecptr addr, uae_u32 size) REGPARAM;
static int mbres_val = 0;
uae_u32 REGPARAM2 mbres_lget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
// if (currprefs.illegal_mem)
// write_log ("Illegal lget at %08lx\n", addr);
return 0;
}
uae_u32 REGPARAM2 mbres_wget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
// if (currprefs.illegal_mem)
// write_log ("Illegal wget at %08lx\n", addr);
return 0;
}
uae_u32 REGPARAM2 mbres_bget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
// if (currprefs.illegal_mem)
// write_log ("Illegal bget at %08lx\n", addr);
return (addr & 0xFFFF) == 3 ? mbres_val : 0;
}
void REGPARAM2 mbres_lput (uaecptr addr, uae_u32 l)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
// if (currprefs.illegal_mem)
// write_log ("Illegal lput at %08lx\n", addr);
}
void REGPARAM2 mbres_wput (uaecptr addr, uae_u32 w)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
// if (currprefs.illegal_mem)
// write_log ("Illegal wput at %08lx\n", addr);
}
void REGPARAM2 mbres_bput (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
// if (currprefs.illegal_mem)
// write_log ("Illegal bput at %08lx\n", addr);
if ((addr & 0xFFFF) == 3)
mbres_val = b;
}
int REGPARAM2 mbres_check (uaecptr addr, uae_u32 size)
{
// if (currprefs.illegal_mem)
// write_log ("Illegal check at %08lx\n", addr);
return 0;
}
#endif
/* Chip memory */
uae_u8 *chipmemory;
static int chipmem_check (uaecptr addr, uae_u32 size) REGPARAM;
static uae_u8 *chipmem_xlate (uaecptr addr) REGPARAM;
#if defined AGA && defined CPUEMU_6
/* AGA ce-chipram access */
static void ce2_timeout (void)
{
wait_cpu_cycle_read (0, -1);
}
uae_u32 REGPARAM2 chipmem_lget_ce2 (uaecptr addr)
{
uae_u32 *m;
#ifdef JIT
special_mem |= S_READ;
#endif
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
m = (uae_u32 *)(chipmemory + addr);
ce2_timeout ();
return do_get_mem_long (m);
}
uae_u32 REGPARAM2 chipmem_wget_ce2 (uaecptr addr)
{
uae_u16 *m;
#ifdef JIT
special_mem |= S_READ;
#endif
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
m = (uae_u16 *)(chipmemory + addr);
ce2_timeout ();
return do_get_mem_word (m);
}
uae_u32 REGPARAM2 chipmem_bget_ce2 (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
ce2_timeout ();
return chipmemory[addr];
}
void REGPARAM2 chipmem_lput_ce2 (uaecptr addr, uae_u32 l)
{
uae_u32 *m;
#ifdef JIT
special_mem |= S_WRITE;
#endif
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
m = (uae_u32 *)(chipmemory + addr);
ce2_timeout ();
do_put_mem_long (m, l);
}
void REGPARAM2 chipmem_wput_ce2 (uaecptr addr, uae_u32 w)
{
uae_u16 *m;
#ifdef JIT
special_mem |= S_WRITE;
#endif
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
m = (uae_u16 *)(chipmemory + addr);
ce2_timeout ();
do_put_mem_word (m, w);
}
void REGPARAM2 chipmem_bput_ce2 (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
ce2_timeout ();
chipmemory[addr] = b;
}
#endif
uae_u32 REGPARAM2 chipmem_lget (uaecptr addr)
{
uae_u32 *m;
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
m = (uae_u32 *)(chipmemory + addr);
return do_get_mem_long (m);
}
uae_u32 REGPARAM2 chipmem_wget (uaecptr addr)
{
uae_u16 *m;
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
m = (uae_u16 *)(chipmemory + addr);
return do_get_mem_word (m);
}
uae_u32 REGPARAM2 chipmem_bget (uaecptr addr)
{
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
return chipmemory[addr];
}
void REGPARAM2 chipmem_lput (uaecptr addr, uae_u32 l)
{
uae_u32 *m;
addr -= chipmem_start & chipmem_mask;
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_start & chipmem_mask;
addr &= chipmem_mask;
m = (uae_u16 *)(chipmemory + addr);
do_put_mem_word (m, w);
}
void REGPARAM2 chipmem_bput (uaecptr addr, uae_u32 b)
{
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
chipmemory[addr] = b;
}
int REGPARAM2 chipmem_check (uaecptr addr, uae_u32 size)
{
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
return (addr + size) <= allocated_chipmem;
}
uae_u8 REGPARAM2 *chipmem_xlate (uaecptr addr)
{
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
return chipmemory + addr;
}
/* Slow memory */
static uae_u8 *bogomemory;
static uae_u32 bogomem_lget (uaecptr) REGPARAM;
static uae_u32 bogomem_wget (uaecptr) REGPARAM;
static uae_u32 bogomem_bget (uaecptr) REGPARAM;
static void bogomem_lput (uaecptr, uae_u32) REGPARAM;
static void bogomem_wput (uaecptr, uae_u32) REGPARAM;
static void bogomem_bput (uaecptr, uae_u32) REGPARAM;
static int bogomem_check (uaecptr addr, uae_u32 size) REGPARAM;
static uae_u8 *bogomem_xlate (uaecptr addr) REGPARAM;
uae_u32 REGPARAM2 bogomem_lget (uaecptr addr)
{
uae_u32 *m;
addr -= bogomem_start & bogomem_mask;
addr &= bogomem_mask;
m = (uae_u32 *)(bogomemory + addr);
return do_get_mem_long (m);
}
uae_u32 REGPARAM2 bogomem_wget (uaecptr addr)
{
uae_u16 *m;
addr -= bogomem_start & bogomem_mask;
addr &= bogomem_mask;
m = (uae_u16 *)(bogomemory + addr);
return do_get_mem_word (m);
}
uae_u32 REGPARAM2 bogomem_bget (uaecptr addr)
{
addr -= bogomem_start & bogomem_mask;
addr &= bogomem_mask;
return bogomemory[addr];
}
void REGPARAM2 bogomem_lput (uaecptr addr, uae_u32 l)
{
uae_u32 *m;
addr -= bogomem_start & bogomem_mask;
addr &= bogomem_mask;
m = (uae_u32 *)(bogomemory + addr);
do_put_mem_long (m, l);
}
void REGPARAM2 bogomem_wput (uaecptr addr, uae_u32 w)
{
uae_u16 *m;
addr -= bogomem_start & bogomem_mask;
addr &= bogomem_mask;
m = (uae_u16 *)(bogomemory + addr);
do_put_mem_word (m, w);
}
void REGPARAM2 bogomem_bput (uaecptr addr, uae_u32 b)
{
addr -= bogomem_start & bogomem_mask;
addr &= bogomem_mask;
bogomemory[addr] = b;
}
int REGPARAM2 bogomem_check (uaecptr addr, uae_u32 size)
{
addr -= bogomem_start & bogomem_mask;
addr &= bogomem_mask;
return (addr + size) <= allocated_bogomem;
}
uae_u8 REGPARAM2 *bogomem_xlate (uaecptr addr)
{
addr -= bogomem_start & bogomem_mask;
addr &= bogomem_mask;
return bogomemory + addr;
}
#ifdef AUTOCONFIG
/* A3000 motherboard fast memory */
static uae_u8 *a3000memory;
static uae_u32 a3000mem_lget (uaecptr) REGPARAM;
static uae_u32 a3000mem_wget (uaecptr) REGPARAM;
static uae_u32 a3000mem_bget (uaecptr) REGPARAM;
static void a3000mem_lput (uaecptr, uae_u32) REGPARAM;
static void a3000mem_wput (uaecptr, uae_u32) REGPARAM;
static void a3000mem_bput (uaecptr, uae_u32) REGPARAM;
static int a3000mem_check (uaecptr addr, uae_u32 size) REGPARAM;
static uae_u8 *a3000mem_xlate (uaecptr addr) REGPARAM;
uae_u32 REGPARAM2 a3000mem_lget (uaecptr addr)
{
uae_u32 *m;
addr -= a3000mem_start & a3000mem_mask;
addr &= a3000mem_mask;
m = (uae_u32 *)(a3000memory + addr);
return do_get_mem_long (m);
}
uae_u32 REGPARAM2 a3000mem_wget (uaecptr addr)
{
uae_u16 *m;
addr -= a3000mem_start & a3000mem_mask;
addr &= a3000mem_mask;
m = (uae_u16 *)(a3000memory + addr);
return do_get_mem_word (m);
}
uae_u32 REGPARAM2 a3000mem_bget (uaecptr addr)
{
addr -= a3000mem_start & a3000mem_mask;
addr &= a3000mem_mask;
return a3000memory[addr];
}
void REGPARAM2 a3000mem_lput (uaecptr addr, uae_u32 l)
{
uae_u32 *m;
addr -= a3000mem_start & a3000mem_mask;
addr &= a3000mem_mask;
m = (uae_u32 *)(a3000memory + addr);
do_put_mem_long (m, l);
}
void REGPARAM2 a3000mem_wput (uaecptr addr, uae_u32 w)
{
uae_u16 *m;
addr -= a3000mem_start & a3000mem_mask;
addr &= a3000mem_mask;
m = (uae_u16 *)(a3000memory + addr);
do_put_mem_word (m, w);
}
void REGPARAM2 a3000mem_bput (uaecptr addr, uae_u32 b)
{
addr -= a3000mem_start & a3000mem_mask;
addr &= a3000mem_mask;
a3000memory[addr] = b;
}
int REGPARAM2 a3000mem_check (uaecptr addr, uae_u32 size)
{
addr -= a3000mem_start & a3000mem_mask;
addr &= a3000mem_mask;
return (addr + size) <= allocated_a3000mem;
}
uae_u8 REGPARAM2 *a3000mem_xlate (uaecptr addr)
{
addr -= a3000mem_start & a3000mem_mask;
addr &= a3000mem_mask;
return a3000memory + addr;
}
#endif
/* Kick memory */
uae_u8 *kickmemory;
uae_u16 kickstart_version;
unsigned int kickmem_size = 0x80000;
/*
* 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 (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;
memset (kickmemory, 0, 262144);
memcpy (kickmemory, a1000_bootrom, 65536);
memcpy (kickmemory + 131072, a1000_bootrom, 65536);
kickstart_version = 0;
}
}
void a1000_reset (void)
{
if (a1000_bootrom)
a1000_handle_kickstart (1);
}
static uae_u32 kickmem_lget (uaecptr) REGPARAM;
static uae_u32 kickmem_wget (uaecptr) REGPARAM;
static uae_u32 kickmem_bget (uaecptr) REGPARAM;
static void kickmem_lput (uaecptr, uae_u32) REGPARAM;
static void kickmem_wput (uaecptr, uae_u32) REGPARAM;
static void kickmem_bput (uaecptr, uae_u32) REGPARAM;
static void kickmem2_lput (uaecptr addr, uae_u32) REGPARAM;
static void kickmem2_wput (uaecptr addr, uae_u32) REGPARAM;
static void kickmem2_bput (uaecptr addr, uae_u32) REGPARAM;
static int kickmem_check (uaecptr addr, uae_u32 size) REGPARAM;
static uae_u8 *kickmem_xlate (uaecptr addr) REGPARAM;
uae_u32 REGPARAM2 kickmem_lget (uaecptr addr)
{
uae_u32 *m;
addr -= kickmem_start & kickmem_mask;
addr &= kickmem_mask;
m = (uae_u32 *)(kickmemory + addr);
return do_get_mem_long (m);
}
uae_u32 REGPARAM2 kickmem_wget (uaecptr addr)
{
uae_u16 *m;
addr -= kickmem_start & kickmem_mask;
addr &= kickmem_mask;
m = (uae_u16 *)(kickmemory + addr);
return do_get_mem_word (m);
}
uae_u32 REGPARAM2 kickmem_bget (uaecptr addr)
{
addr -= kickmem_start & kickmem_mask;
addr &= kickmem_mask;
return kickmemory[addr];
}
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_start & kickmem_mask;
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 ("Illegal kickmem lput at %08lx\n", addr);
}
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_start & kickmem_mask;
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 ("Illegal kickmem wput at %08lx\n", addr);
}
void REGPARAM2 kickmem_bput (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
if (a1000_kickstart_mode) {
if (addr >= 0xfc0000) {
addr -= kickmem_start & kickmem_mask;
addr &= kickmem_mask;
kickmemory[addr] = b;
return;
} else
a1000_handle_kickstart (0);
} else if (currprefs.illegal_mem)
write_log ("Illegal kickmem lput at %08lx\n", addr);
}
void REGPARAM2 kickmem2_lput (uaecptr addr, uae_u32 l)
{
uae_u32 *m;
#ifdef JIT
special_mem |= S_WRITE;
#endif
addr -= kickmem_start & kickmem_mask;
addr &= kickmem_mask;
m = (uae_u32 *)(kickmemory + addr);
do_put_mem_long (m, l);
}
void REGPARAM2 kickmem2_wput (uaecptr addr, uae_u32 w)
{
uae_u16 *m;
#ifdef JIT
special_mem |= S_WRITE;
#endif
addr -= kickmem_start & kickmem_mask;
addr &= kickmem_mask;
m = (uae_u16 *)(kickmemory + addr);
do_put_mem_word (m, w);
}
void REGPARAM2 kickmem2_bput (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
addr -= kickmem_start & kickmem_mask;
addr &= kickmem_mask;
kickmemory[addr] = b;
}
int REGPARAM2 kickmem_check (uaecptr addr, uae_u32 size)
{
addr -= kickmem_start & kickmem_mask;
addr &= kickmem_mask;
return (addr + size) <= kickmem_size;
}
uae_u8 REGPARAM2 *kickmem_xlate (uaecptr addr)
{
addr -= kickmem_start & kickmem_mask;
addr &= kickmem_mask;
return kickmemory + addr;
}
/* CD32/CDTV extended kick memory */
uae_u8 *extendedkickmemory;
static unsigned int extendedkickmem_size;
static uae_u32 extendedkickmem_start;
#define EXTENDED_ROM_CD32 1
#define EXTENDED_ROM_CDTV 2
#if defined CDTV || defined CD32
static int extromtype (void)
{
switch (extendedkickmem_size) {
case 524288:
return EXTENDED_ROM_CD32;
case 262144:
return EXTENDED_ROM_CDTV;
}
return 0;
}
static uae_u32 extendedkickmem_lget (uaecptr) REGPARAM;
static uae_u32 extendedkickmem_wget (uaecptr) REGPARAM;
static uae_u32 extendedkickmem_bget (uaecptr) REGPARAM;
static void extendedkickmem_lput (uaecptr, uae_u32) REGPARAM;
static void extendedkickmem_wput (uaecptr, uae_u32) REGPARAM;
static void extendedkickmem_bput (uaecptr, uae_u32) REGPARAM;
static int extendedkickmem_check (uaecptr addr, uae_u32 size) REGPARAM;
static uae_u8 *extendedkickmem_xlate (uaecptr addr) REGPARAM;
uae_u32 REGPARAM2 extendedkickmem_lget (uaecptr addr)
{
uae_u32 *m;
addr -= extendedkickmem_start & extendedkickmem_mask;
addr &= extendedkickmem_mask;
m = (uae_u32 *)(extendedkickmemory + addr);
return do_get_mem_long (m);
}
uae_u32 REGPARAM2 extendedkickmem_wget (uaecptr addr)
{
uae_u16 *m;
addr -= extendedkickmem_start & extendedkickmem_mask;
addr &= extendedkickmem_mask;
m = (uae_u16 *)(extendedkickmemory + addr);
return do_get_mem_word (m);
}
uae_u32 REGPARAM2 extendedkickmem_bget (uaecptr addr)
{
addr -= extendedkickmem_start & extendedkickmem_mask;
addr &= extendedkickmem_mask;
return extendedkickmemory[addr];
}
void REGPARAM2 extendedkickmem_lput (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
if (currprefs.illegal_mem)
write_log ("Illegal extendedkickmem lput at %08lx\n", addr);
}
void REGPARAM2 extendedkickmem_wput (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
if (currprefs.illegal_mem)
write_log ("Illegal extendedkickmem wput at %08lx\n", addr);
}
void REGPARAM2 extendedkickmem_bput (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
if (currprefs.illegal_mem)
write_log ("Illegal extendedkickmem lput at %08lx\n", addr);
}
int REGPARAM2 extendedkickmem_check (uaecptr addr, uae_u32 size)
{
addr -= extendedkickmem_start & extendedkickmem_mask;
addr &= extendedkickmem_mask;
return (addr + size) <= extendedkickmem_size;
}
uae_u8 REGPARAM2 *extendedkickmem_xlate (uaecptr addr)
{
addr -= extendedkickmem_start & extendedkickmem_mask;
addr &= extendedkickmem_mask;
return extendedkickmemory + addr;
}
#endif
/* Default memory access functions */
int REGPARAM2 default_check (uaecptr a, uae_u32 b)
{
return 0;
}
static int be_cnt;
uae_u8 REGPARAM2 *default_xlate (uaecptr a)
{
if (quit_program == 0) {
/* do this only in 68010+ mode, there are some tricky A500 programs.. */
if (currprefs.cpu_level > 0 || !currprefs.cpu_compatible) {
if (be_cnt < 3) {
int i, j;
uaecptr a2 = a - 32;
uaecptr a3 = m68k_getpc (®s) - 32;
write_log ("Your Amiga program just did something terribly stupid %p PC=%p\n", a, m68k_getpc (®s));
m68k_dumpstate (0, 0);
for (i = 0; i < 10; i++) {
write_log ("%08.8X ", i >= 5 ? a3 : a2);
for (j = 0; j < 16; j += 2) {
write_log (" %04.4X", get_word (i >= 5 ? a3 : a2));
if (i >= 5) a3 +=2; else a2 += 2;
}
write_log ("\n");
}
}
be_cnt++;
if (be_cnt > 1000) {
uae_reset (0);
be_cnt = 0;
} else {
regs.panic = 1;
regs.panic_pc = m68k_getpc (®s);
regs.panic_addr = a;
set_special (®s, SPCFLAG_BRK);
}
}
}
return kickmem_xlate (0); /* So we don't crash. */
}
/* Address banks */
addrbank dummy_bank = {
dummy_lget, dummy_wget, dummy_bget,
dummy_lput, dummy_wput, dummy_bput,
default_xlate, dummy_check, NULL
};
#ifdef AUTOCONFIG
#ifdef A3000MBRES
addrbank mbres_bank = {
mbres_lget, mbres_wget, mbres_bget,
mbres_lput, mbres_wput, mbres_bput,
default_xlate, mbres_check, NULL
};
#endif
#endif
addrbank chipmem_bank = {
chipmem_lget, chipmem_wget, chipmem_bget,
chipmem_lput, chipmem_wput, chipmem_bput,
chipmem_xlate, chipmem_check, NULL
};
#if defined AGA && defined CPUEMU_6
addrbank chipmem_bank_ce2 = {
chipmem_lget_ce2, chipmem_wget_ce2, chipmem_bget_ce2,
chipmem_lput_ce2, chipmem_wput_ce2, chipmem_bput_ce2,
chipmem_xlate, chipmem_check, NULL
};
#endif
addrbank bogomem_bank = {
bogomem_lget, bogomem_wget, bogomem_bget,
bogomem_lput, bogomem_wput, bogomem_bput,
bogomem_xlate, bogomem_check, NULL
};
#ifdef AUTOCONFIG
addrbank a3000mem_bank = {
a3000mem_lget, a3000mem_wget, a3000mem_bget,
a3000mem_lput, a3000mem_wput, a3000mem_bput,
a3000mem_xlate, a3000mem_check, NULL
};
#endif
addrbank kickmem_bank = {
kickmem_lget, kickmem_wget, kickmem_bget,
kickmem_lput, kickmem_wput, kickmem_bput,
kickmem_xlate, kickmem_check, NULL
};
addrbank kickram_bank = {
kickmem_lget, kickmem_wget, kickmem_bget,
kickmem2_lput, kickmem2_wput, kickmem2_bput,
kickmem_xlate, kickmem_check, NULL
};
#if defined CDTV || defined CD32
addrbank extendedkickmem_bank = {
extendedkickmem_lget, extendedkickmem_wget, extendedkickmem_bget,
extendedkickmem_lput, extendedkickmem_wput, extendedkickmem_bput,
extendedkickmem_xlate, extendedkickmem_check, NULL
};
#endif
static int decode_cloanto_rom (uae_u8 *mem, int size, int real_size)
{
struct zfile *keyf;
uae_u8 *p;
long cnt, t;
int keysize;
if (strlen (currprefs.keyfile) == 0) {
#ifndef SINGLEFILE
gui_message ("No filename given for ROM key file and ROM image is an encrypted \"Amiga Forever\" ROM file.\n");
#endif
return 0;