forked from tonioni/WinUAE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpansion.cpp
1669 lines (1448 loc) · 42.4 KB
/
expansion.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
*
* AutoConfig (tm) Expansions (ZorroII/III)
*
* Copyright 1996,1997 Stefan Reinauer <[email protected]>
* Copyright 1997 Brian King <[email protected]>
* - added gfxcard code
*
*/
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
#include "rommgr.h"
#include "autoconf.h"
#include "custom.h"
#include "newcpu.h"
#include "savestate.h"
#include "zfile.h"
#include "catweasel.h"
#include "cdtv.h"
#include "a2091.h"
#include "a2065.h"
#include "cd32_fmv.h"
#include "ncr_scsi.h"
#include "debug.h"
#include "gayle.h"
#define MAX_EXPANSION_BOARDS 8
/* ********************************************************** */
/* 00 / 02 */
/* er_Type */
#define Z2_MEM_8MB 0x00 /* Size of Memory Block */
#define Z2_MEM_4MB 0x07
#define Z2_MEM_2MB 0x06
#define Z2_MEM_1MB 0x05
#define Z2_MEM_512KB 0x04
#define Z2_MEM_256KB 0x03
#define Z2_MEM_128KB 0x02
#define Z2_MEM_64KB 0x01
/* extended definitions */
#define Z2_MEM_16MB 0x00
#define Z2_MEM_32MB 0x01
#define Z2_MEM_64MB 0x02
#define Z2_MEM_128MB 0x03
#define Z2_MEM_256MB 0x04
#define Z2_MEM_512MB 0x05
#define Z2_MEM_1GB 0x06
#define chainedconfig 0x08 /* Next config is part of the same card */
#define rom_card 0x10 /* ROM vector is valid */
#define add_memory 0x20 /* Link RAM into free memory list */
#define zorroII 0xc0 /* Type of Expansion Card */
#define zorroIII 0x80
/* ********************************************************** */
/* 04 - 06 & 10-16 */
/* Manufacturer */
#define commodore_g 513 /* Commodore Braunschweig (Germany) */
#define commodore 514 /* Commodore West Chester */
#define gvp 2017 /* GVP */
#define ass 2102 /* Advanced Systems & Software */
#define hackers_id 2011 /* Special ID for test cards */
/* Card Type */
#define commodore_a2091 3 /* A2091 / A590 Card from C= */
#define commodore_a2091_ram 10 /* A2091 / A590 Ram on HD-Card */
#define commodore_a2232 70 /* A2232 Multiport Expansion */
#define ass_nexus_scsi 1 /* Nexus SCSI Controller */
#define gvp_series_2_scsi 11
#define gvp_iv_24_gfx 32
/* ********************************************************** */
/* 08 - 0A */
/* er_Flags */
#define Z3_MEM_64KB 0x02
#define Z3_MEM_128KB 0x03
#define Z3_MEM_256KB 0x04
#define Z3_MEM_512KB 0x05
#define Z3_MEM_1MB 0x06 /* Zorro III card subsize */
#define Z3_MEM_2MB 0x07
#define Z3_MEM_4MB 0x08
#define Z3_MEM_6MB 0x09
#define Z3_MEM_8MB 0x0a
#define Z3_MEM_10MB 0x0b
#define Z3_MEM_12MB 0x0c
#define Z3_MEM_14MB 0x0d
#define Z3_MEM_16MB 0x00
#define Z3_MEM_AUTO 0x01
#define Z3_MEM_defunct1 0x0e
#define Z3_MEM_defunct2 0x0f
#define force_z3 0x10 /* *MUST* be set if card is Z3 */
#define ext_size 0x20 /* Use extended size table for bits 0-2 of er_Type */
#define no_shutup 0x40 /* Card cannot receive Shut_up_forever */
#define care_addr 0x80 /* Z2=Adress HAS to be $200000-$9fffff Z3=1->mem,0=io */
/* ********************************************************** */
/* 40-42 */
/* ec_interrupt (unused) */
#define enable_irq 0x01 /* enable Interrupt */
#define reset_card 0x04 /* Reset of Expansion Card - must be 0 */
#define card_int2 0x10 /* READ ONLY: IRQ 2 active */
#define card_irq6 0x20 /* READ ONLY: IRQ 6 active */
#define card_irq7 0x40 /* READ ONLY: IRQ 7 active */
#define does_irq 0x80 /* READ ONLY: Card currently throws IRQ */
/* ********************************************************** */
/* ROM defines (DiagVec) */
#define rom_4bit (0x00<<14) /* ROM width */
#define rom_8bit (0x01<<14)
#define rom_16bit (0x02<<14)
#define rom_never (0x00<<12) /* Never run Boot Code */
#define rom_install (0x01<<12) /* run code at install time */
#define rom_binddrv (0x02<<12) /* run code with binddrivers */
uaecptr ROM_filesys_resname, ROM_filesys_resid;
uaecptr ROM_filesys_diagentry;
uaecptr ROM_hardfile_resname, ROM_hardfile_resid;
uaecptr ROM_hardfile_init;
bool uae_boot_rom;
int uae_boot_rom_size; /* size = code size only */
/* ********************************************************** */
static void (*card_init[MAX_EXPANSION_BOARDS]) (void);
static void (*card_map[MAX_EXPANSION_BOARDS]) (void);
static int ecard, cardno, z3num;
static uae_u16 uae_id;
/* ********************************************************** */
/* Please note: ZorroIII implementation seems to work different
* than described in the HRM. This claims that ZorroIII config
* address is 0xff000000 while the ZorroII config space starts
* at 0x00e80000. In reality, both, Z2 and Z3 cards are
* configured in the ZorroII config space. Kickstart 3.1 doesn't
* even do a single read or write access to the ZorroIII space.
* The original Amiga include files tell the same as the HRM.
* ZorroIII: If you set ext_size in er_Flags and give a Z2-size
* in er_Type you can very likely add some ZorroII address space
* to a ZorroIII card on a real Amiga. This is not implemented
* yet.
* -- Stefan
*
* Surprising that 0xFF000000 isn't used. Maybe it depends on the
* ROM. Anyway, the HRM says that Z3 cards may appear in Z2 config
* space, so what we are doing here is correct.
* -- Bernd
*/
/* Autoconfig address space at 0xE80000 */
static uae_u8 expamem[65536];
static uae_u8 expamem_lo;
static uae_u16 expamem_hi;
static uae_u32 REGPARAM3 expamem_lget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 expamem_wget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 expamem_bget (uaecptr) REGPARAM;
static void REGPARAM3 expamem_lput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 expamem_wput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 expamem_bput (uaecptr, uae_u32) REGPARAM;
addrbank expamem_bank = {
expamem_lget, expamem_wget, expamem_bget,
expamem_lput, expamem_wput, expamem_bput,
default_xlate, default_check, NULL, L"Autoconfig",
dummy_lgeti, dummy_wgeti, ABFLAG_IO | ABFLAG_SAFE
};
static void expamem_map_clear (void)
{
write_log (L"expamem_map_clear() got called. Shouldn't happen.\n");
}
static void expamem_init_clear (void)
{
memset (expamem, 0xff, sizeof expamem);
}
/* autoconfig area is "non-existing" after last device */
static void expamem_init_clear_zero (void)
{
map_banks (&dummy_bank, 0xe8, 1, 0);
}
static void expamem_init_clear2 (void)
{
expamem_init_clear_zero ();
ecard = cardno;
}
static void expamem_init_last (void)
{
expamem_init_clear2 ();
write_log (L"Memory map after autoconfig:\n");
memory_map_dump();
}
static uae_u32 REGPARAM2 expamem_lget (uaecptr addr)
{
write_log (L"warning: READ.L from address $%lx PC=%x\n", addr, M68K_GETPC);
return (expamem_wget (addr) << 16) | expamem_wget (addr + 2);
}
static uae_u32 REGPARAM2 expamem_wget (uaecptr addr)
{
uae_u32 v = (expamem_bget (addr) << 8) | expamem_bget (addr + 1);
write_log (L"warning: READ.W from address $%lx=%04x PC=%x\n", addr, v & 0xffff, M68K_GETPC);
return v;
}
static uae_u32 REGPARAM2 expamem_bget (uaecptr addr)
{
uae_u8 b;
#ifdef JIT
special_mem |= S_READ;
#endif
addr &= 0xFFFF;
b = expamem[addr];
//write_log (L"%08x=%02X\n", addr, b);
return b;
}
static void REGPARAM2 expamem_write (uaecptr addr, uae_u32 value)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
addr &= 0xffff;
if (addr == 00 || addr == 02 || addr == 0x40 || addr == 0x42) {
expamem[addr] = (value & 0xf0);
expamem[addr + 2] = (value & 0x0f) << 4;
} else {
expamem[addr] = ~(value & 0xf0);
expamem[addr + 2] = ~((value & 0x0f) << 4);
}
}
static int REGPARAM2 expamem_type (void)
{
return ((expamem[0] | expamem[2] >> 4) & 0xc0);
}
static void REGPARAM2 expamem_lput (uaecptr addr, uae_u32 value)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
write_log (L"warning: WRITE.L to address $%lx : value $%lx\n", addr, value);
}
static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
value &= 0xffff;
if (ecard >= cardno)
return;
if (expamem_type() != zorroIII)
write_log (L"warning: WRITE.W to address $%lx : value $%x\n", addr, value);
else {
switch (addr & 0xff) {
case 0x44:
if (expamem_type() == zorroIII) {
uae_u32 p1, p2;
// +Bernd Roesch & Toni Wilen
p1 = get_word (regs.regs[11] + 0x20);
if (expamem[0] & add_memory) {
// Z3 RAM expansion
p2 = 0;
while (!p2 && z3num < 2) {
if (z3num == 0 && currprefs.z3fastmem_size)
p2 = z3fastmem_start >> 16;
else if (z3num == 1 && currprefs.z3fastmem2_size)
p2 = z3fastmem2_start >> 16;
if (!p2)
z3num++;
}
z3num++;
} else {
// Z3 P96 RAM
p2 = p96ram_start >> 16;
}
put_word (regs.regs[11] + 0x20, p2);
put_word (regs.regs[11] + 0x28, p2);
// -Bernd Roesch
expamem_hi = p2;
(*card_map[ecard]) ();
ecard++;
if (p1 != p2)
write_log (L" Card %d remapped %04x0000 -> %04x0000\n", ecard, p1, p2);
write_log (L" Card %d (Zorro%s) done.\n", ecard, expamem_type () == 0xc0 ? L"II" : L"III");
if (ecard < cardno)
(*card_init[ecard]) ();
else
expamem_init_clear2 ();
}
break;
}
}
}
static void REGPARAM2 expamem_bput (uaecptr addr, uae_u32 value)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
if (ecard >= cardno)
return;
value &= 0xff;
switch (addr & 0xff) {
case 0x30:
case 0x32:
expamem_hi = 0;
expamem_lo = 0;
expamem_write (0x48, 0x00);
break;
case 0x48:
if (expamem_type () == zorroII) {
expamem_hi = value;
(*card_map[ecard]) ();
write_log (L" Card %d (Zorro%s) done.\n", ecard + 1, expamem_type () == 0xc0 ? L"II" : L"III");
++ecard;
if (ecard < cardno)
(*card_init[ecard]) ();
else
expamem_init_clear2 ();
} else if (expamem_type() == zorroIII)
expamem_lo = value;
break;
case 0x4a:
if (expamem_type () == zorroII)
expamem_lo = value;
break;
case 0x4c:
write_log (L" Card %d (Zorro%s) had no success.\n", ecard + 1, expamem_type () == 0xc0 ? L"II" : L"III");
++ecard;
if (ecard < cardno)
(*card_init[ecard]) ();
else
expamem_init_clear2 ();
break;
}
}
#ifdef CD32
static void expamem_map_cd32fmv (void)
{
uaecptr start = ((expamem_hi | (expamem_lo >> 4)) << 16);
cd32_fmv_init (start);
}
static void expamem_init_cd32fmv (void)
{
int ids[] = { 23, -1 };
struct romlist *rl = getromlistbyids (ids);
struct romdata *rd;
struct zfile *z;
expamem_init_clear ();
if (!rl)
return;
write_log (L"CD32 FMV ROM '%s' %d.%d\n", rl->path, rl->rd->ver, rl->rd->rev);
rd = rl->rd;
z = read_rom (&rd);
if (z) {
zfile_fread (expamem, 128, 1, z);
zfile_fclose (z);
}
}
#endif
/* ********************************************************** */
/*
* Fast Memory
*/
static uae_u32 fastmem_mask;
static uae_u32 REGPARAM3 fastmem_lget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 fastmem_wget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 fastmem_bget (uaecptr) REGPARAM;
static void REGPARAM3 fastmem_lput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 fastmem_wput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 fastmem_bput (uaecptr, uae_u32) REGPARAM;
static int REGPARAM3 fastmem_check (uaecptr addr, uae_u32 size) REGPARAM;
static uae_u8 *REGPARAM3 fastmem_xlate (uaecptr addr) REGPARAM;
uaecptr fastmem_start; /* Determined by the OS */
static uae_u8 *fastmemory;
static uae_u32 REGPARAM2 fastmem_lget (uaecptr addr)
{
uae_u8 *m;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
m = fastmemory + addr;
return do_get_mem_long ((uae_u32 *)m);
}
static uae_u32 REGPARAM2 fastmem_wget (uaecptr addr)
{
uae_u8 *m;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
m = fastmemory + addr;
return do_get_mem_word ((uae_u16 *)m);
}
static uae_u32 REGPARAM2 fastmem_bget (uaecptr addr)
{
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
return fastmemory[addr];
}
static void REGPARAM2 fastmem_lput (uaecptr addr, uae_u32 l)
{
uae_u8 *m;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
m = fastmemory + addr;
do_put_mem_long ((uae_u32 *)m, l);
}
static void REGPARAM2 fastmem_wput (uaecptr addr, uae_u32 w)
{
uae_u8 *m;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
m = fastmemory + addr;
do_put_mem_word ((uae_u16 *)m, w);
}
static void REGPARAM2 fastmem_bput (uaecptr addr, uae_u32 b)
{
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
fastmemory[addr] = b;
}
static int REGPARAM2 fastmem_check (uaecptr addr, uae_u32 size)
{
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
return (addr + size) <= allocated_fastmem;
}
static uae_u8 *REGPARAM2 fastmem_xlate (uaecptr addr)
{
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
return fastmemory + addr;
}
addrbank fastmem_bank = {
fastmem_lget, fastmem_wget, fastmem_bget,
fastmem_lput, fastmem_wput, fastmem_bput,
fastmem_xlate, fastmem_check, NULL, L"Fast memory",
fastmem_lget, fastmem_wget, ABFLAG_RAM
};
#ifdef CATWEASEL
/*
* Catweasel ZorroII
*/
static uae_u32 REGPARAM3 catweasel_lget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 catweasel_wget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 catweasel_bget (uaecptr) REGPARAM;
static void REGPARAM3 catweasel_lput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 catweasel_wput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 catweasel_bput (uaecptr, uae_u32) REGPARAM;
static int REGPARAM3 catweasel_check (uaecptr addr, uae_u32 size) REGPARAM;
static uae_u8 *REGPARAM3 catweasel_xlate (uaecptr addr) REGPARAM;
static uae_u32 catweasel_mask;
static uae_u32 catweasel_start;
static uae_u32 REGPARAM2 catweasel_lget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
write_log (L"catweasel_lget @%08X!\n",addr);
return 0;
}
static uae_u32 REGPARAM2 catweasel_wget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
write_log (L"catweasel_wget @%08X!\n",addr);
return 0;
}
static uae_u32 REGPARAM2 catweasel_bget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
addr -= catweasel_start & catweasel_mask;
addr &= catweasel_mask;
return catweasel_do_bget (addr);
}
static void REGPARAM2 catweasel_lput (uaecptr addr, uae_u32 l)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
write_log (L"catweasel_lput @%08X=%08X!\n",addr,l);
}
static void REGPARAM2 catweasel_wput (uaecptr addr, uae_u32 w)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
write_log (L"catweasel_wput @%08X=%04X!\n",addr,w);
}
static void REGPARAM2 catweasel_bput (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
addr -= catweasel_start & catweasel_mask;
addr &= catweasel_mask;
catweasel_do_bput (addr, b);
}
static int REGPARAM2 catweasel_check (uaecptr addr, uae_u32 size)
{
return 0;
}
static uae_u8 *REGPARAM2 catweasel_xlate (uaecptr addr)
{
write_log (L"catweasel_xlate @%08X size %08X\n", addr);
return 0;
}
static addrbank catweasel_bank = {
catweasel_lget, catweasel_wget, catweasel_bget,
catweasel_lput, catweasel_wput, catweasel_bput,
catweasel_xlate, catweasel_check, NULL, L"Catweasel",
dummy_lgeti, dummy_wgeti, ABFLAG_IO
};
static void expamem_map_catweasel (void)
{
catweasel_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
map_banks (&catweasel_bank, catweasel_start >> 16, 1, 0);
write_log (L"Catweasel MK%d: mapped @$%lx\n", cwc.type, catweasel_start);
}
static void expamem_init_catweasel (void)
{
uae_u8 productid = cwc.type >= CATWEASEL_TYPE_MK3 ? 66 : 200;
uae_u16 vendorid = cwc.type >= CATWEASEL_TYPE_MK3 ? 4626 : 5001;
catweasel_mask = (cwc.type >= CATWEASEL_TYPE_MK3) ? 0xffff : 0x1ffff;
expamem_init_clear ();
expamem_write (0x00, (cwc.type >= CATWEASEL_TYPE_MK3 ? Z2_MEM_64KB : Z2_MEM_128KB) | zorroII);
expamem_write (0x04, productid);
expamem_write (0x08, no_shutup);
expamem_write (0x10, vendorid >> 8);
expamem_write (0x14, vendorid & 0xff);
expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
expamem_write (0x24, 0x00); /* ser.no. Byte 3 */
expamem_write (0x28, 0x00); /* Rom-Offset hi */
expamem_write (0x2c, 0x00); /* ROM-Offset lo */
expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
}
#endif
#ifdef FILESYS
/*
* Filesystem device ROM
* This is very simple, the Amiga shouldn't be doing things with it.
*/
static uae_u32 REGPARAM3 filesys_lget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 filesys_wget (uaecptr) REGPARAM;
static uae_u32 REGPARAM3 filesys_bget (uaecptr) REGPARAM;
static void REGPARAM3 filesys_lput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 filesys_wput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 filesys_bput (uaecptr, uae_u32) REGPARAM;
static uae_u32 filesys_start; /* Determined by the OS */
uae_u8 *filesysory;
static uae_u32 REGPARAM2 filesys_lget (uaecptr addr)
{
uae_u8 *m;
#ifdef JIT
special_mem |= S_READ;
#endif
addr -= filesys_start & 65535;
addr &= 65535;
m = filesysory + addr;
return do_get_mem_long ((uae_u32 *)m);
}
static uae_u32 REGPARAM2 filesys_wget (uaecptr addr)
{
uae_u8 *m;
#ifdef JIT
special_mem |= S_READ;
#endif
addr -= filesys_start & 65535;
addr &= 65535;
m = filesysory + addr;
return do_get_mem_word ((uae_u16 *)m);
}
static uae_u32 REGPARAM2 filesys_bget (uaecptr addr)
{
#ifdef JIT
special_mem |= S_READ;
#endif
addr -= filesys_start & 65535;
addr &= 65535;
return filesysory[addr];
}
static void REGPARAM2 filesys_lput (uaecptr addr, uae_u32 l)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
write_log (L"filesys_lput called PC=%p\n", M68K_GETPC);
}
static void REGPARAM2 filesys_wput (uaecptr addr, uae_u32 w)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
write_log (L"filesys_wput called PC=%p\n", M68K_GETPC);
}
static void REGPARAM2 filesys_bput (uaecptr addr, uae_u32 b)
{
#ifdef JIT
special_mem |= S_WRITE;
#endif
}
static addrbank filesys_bank = {
filesys_lget, filesys_wget, filesys_bget,
filesys_lput, filesys_wput, filesys_bput,
default_xlate, default_check, NULL, L"Filesystem Autoconfig Area",
dummy_lgeti, dummy_wgeti, ABFLAG_IO | ABFLAG_SAFE
};
#endif /* FILESYS */
/*
* Z3fastmem Memory
*/
static uae_u32 z3fastmem_mask, z3fastmem2_mask, z3chipmem_mask;
uaecptr z3fastmem_start, z3fastmem2_start, z3chipmem_start;
static uae_u8 *z3fastmem, *z3fastmem2, *z3chipmem;
static uae_u32 REGPARAM2 z3fastmem_lget (uaecptr addr)
{
uae_u8 *m;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
m = z3fastmem + addr;
return do_get_mem_long ((uae_u32 *)m);
}
static uae_u32 REGPARAM2 z3fastmem_wget (uaecptr addr)
{
uae_u8 *m;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
m = z3fastmem + addr;
return do_get_mem_word ((uae_u16 *)m);
}
static uae_u32 REGPARAM2 z3fastmem_bget (uaecptr addr)
{
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
return z3fastmem[addr];
}
static void REGPARAM2 z3fastmem_lput (uaecptr addr, uae_u32 l)
{
uae_u8 *m;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
m = z3fastmem + addr;
do_put_mem_long ((uae_u32 *)m, l);
}
static void REGPARAM2 z3fastmem_wput (uaecptr addr, uae_u32 w)
{
uae_u8 *m;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
m = z3fastmem + addr;
do_put_mem_word ((uae_u16 *)m, w);
}
static void REGPARAM2 z3fastmem_bput (uaecptr addr, uae_u32 b)
{
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
z3fastmem[addr] = b;
}
static int REGPARAM2 z3fastmem_check (uaecptr addr, uae_u32 size)
{
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
return (addr + size) <= allocated_z3fastmem;
}
static uae_u8 *REGPARAM2 z3fastmem_xlate (uaecptr addr)
{
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
return z3fastmem + addr;
}
static uae_u32 REGPARAM2 z3fastmem2_lget (uaecptr addr)
{
uae_u8 *m;
addr -= z3fastmem2_start & z3fastmem2_mask;
addr &= z3fastmem2_mask;
m = z3fastmem2 + addr;
return do_get_mem_long ((uae_u32 *)m);
}
static uae_u32 REGPARAM2 z3fastmem2_wget (uaecptr addr)
{
uae_u8 *m;
addr -= z3fastmem2_start & z3fastmem2_mask;
addr &= z3fastmem2_mask;
m = z3fastmem2 + addr;
return do_get_mem_word ((uae_u16 *)m);
}
static uae_u32 REGPARAM2 z3fastmem2_bget (uaecptr addr)
{
addr -= z3fastmem2_start & z3fastmem2_mask;
addr &= z3fastmem2_mask;
return z3fastmem2[addr];
}
static void REGPARAM2 z3fastmem2_lput (uaecptr addr, uae_u32 l)
{
uae_u8 *m;
addr -= z3fastmem2_start & z3fastmem2_mask;
addr &= z3fastmem2_mask;
m = z3fastmem2 + addr;
do_put_mem_long ((uae_u32 *)m, l);
}
static void REGPARAM2 z3fastmem2_wput (uaecptr addr, uae_u32 w)
{
uae_u8 *m;
addr -= z3fastmem2_start & z3fastmem2_mask;
addr &= z3fastmem2_mask;
m = z3fastmem2 + addr;
do_put_mem_word ((uae_u16 *)m, w);
}
static void REGPARAM2 z3fastmem2_bput (uaecptr addr, uae_u32 b)
{
addr -= z3fastmem2_start & z3fastmem2_mask;
addr &= z3fastmem2_mask;
z3fastmem2[addr] = b;
}
static int REGPARAM2 z3fastmem2_check (uaecptr addr, uae_u32 size)
{
addr -= z3fastmem2_start & z3fastmem2_mask;
addr &= z3fastmem2_mask;
return (addr + size) <= allocated_z3fastmem2;
}
static uae_u8 *REGPARAM2 z3fastmem2_xlate (uaecptr addr)
{
addr -= z3fastmem2_start & z3fastmem2_mask;
addr &= z3fastmem2_mask;
return z3fastmem2 + addr;
}
static uae_u32 REGPARAM2 z3chipmem_lget (uaecptr addr)
{
uae_u8 *m;
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
m = z3chipmem + addr;
return do_get_mem_long ((uae_u32 *)m);
}
static uae_u32 REGPARAM2 z3chipmem_wget (uaecptr addr)
{
uae_u8 *m;
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
m = z3chipmem + addr;
return do_get_mem_word ((uae_u16 *)m);
}
static uae_u32 REGPARAM2 z3chipmem_bget (uaecptr addr)
{
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
return z3chipmem[addr];
}
static void REGPARAM2 z3chipmem_lput (uaecptr addr, uae_u32 l)
{
uae_u8 *m;
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
m = z3chipmem + addr;
do_put_mem_long ((uae_u32 *)m, l);
}
static void REGPARAM2 z3chipmem_wput (uaecptr addr, uae_u32 w)
{
uae_u8 *m;
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
m = z3chipmem + addr;
do_put_mem_word ((uae_u16 *)m, w);
}
static void REGPARAM2 z3chipmem_bput (uaecptr addr, uae_u32 b)
{
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
z3chipmem[addr] = b;
}
static int REGPARAM2 z3chipmem_check (uaecptr addr, uae_u32 size)
{
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
return (addr + size) <= allocated_z3chipmem;
}
static uae_u8 *REGPARAM2 z3chipmem_xlate (uaecptr addr)
{
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
return z3chipmem + addr;
}
addrbank z3fastmem_bank = {
z3fastmem_lget, z3fastmem_wget, z3fastmem_bget,
z3fastmem_lput, z3fastmem_wput, z3fastmem_bput,
z3fastmem_xlate, z3fastmem_check, NULL, L"ZorroIII Fast RAM",
z3fastmem_lget, z3fastmem_wget, ABFLAG_RAM
};
addrbank z3fastmem2_bank = {
z3fastmem2_lget, z3fastmem2_wget, z3fastmem2_bget,
z3fastmem2_lput, z3fastmem2_wput, z3fastmem2_bput,
z3fastmem2_xlate, z3fastmem2_check, NULL, L"ZorroIII Fast RAM #2",
z3fastmem2_lget, z3fastmem2_wget, ABFLAG_RAM
};
addrbank z3chipmem_bank = {
z3chipmem_lget, z3chipmem_wget, z3chipmem_bget,
z3chipmem_lput, z3chipmem_wput, z3chipmem_bput,
z3chipmem_xlate, z3chipmem_check, NULL, L"MegaChipRAM",
z3chipmem_lget, z3chipmem_wget, ABFLAG_RAM
};
/* Z3-based UAEGFX-card */
uae_u32 gfxmem_mask; /* for memory.c */
uae_u8 *gfxmemory;
uae_u32 gfxmem_start;
/* ********************************************************** */
/*
* Expansion Card (ZORRO II) for 1/2/4/8 MB of Fast Memory
*/
static void expamem_map_fastcard (void)
{
fastmem_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
map_banks (&fastmem_bank, fastmem_start >> 16, allocated_fastmem >> 16, 0);
write_log (L"Fastcard: mapped @$%lx: %dMB fast memory\n", fastmem_start, allocated_fastmem >> 20);
}
static void expamem_init_fastcard (void)
{
uae_u16 mid = (currprefs.cs_a2091 || currprefs.uae_hide) ? commodore : uae_id;
uae_u8 pid = (currprefs.cs_a2091 || currprefs.uae_hide) ? commodore_a2091_ram : 1;
expamem_init_clear ();
if (allocated_fastmem == 0x100000)
expamem_write (0x00, Z2_MEM_1MB + add_memory + zorroII);
else if (allocated_fastmem == 0x200000)
expamem_write (0x00, Z2_MEM_2MB + add_memory + zorroII);
else if (allocated_fastmem == 0x400000)
expamem_write (0x00, Z2_MEM_4MB + add_memory + zorroII);
else if (allocated_fastmem == 0x800000)
expamem_write (0x00, Z2_MEM_8MB + add_memory + zorroII);
expamem_write (0x08, care_addr);
expamem_write (0x04, pid);
expamem_write (0x10, mid >> 8);
expamem_write (0x14, mid & 0xff);
expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
expamem_write (0x28, 0x00); /* Rom-Offset hi */
expamem_write (0x2c, 0x00); /* ROM-Offset lo */
expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
}
/* ********************************************************** */
#ifdef FILESYS
/*
* Filesystem device
*/
static void expamem_map_filesys (void)
{
uaecptr a;
filesys_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
map_banks (&filesys_bank, filesys_start >> 16, 1, 0);
write_log (L"Filesystem: mapped memory @$%lx.\n", filesys_start);
/* 68k code needs to know this. */
a = here ();
org (rtarea_base + 0xFFFC);
dl (filesys_start + 0x2000);
org (a);
}
static void expamem_init_filesys (void)
{
/* struct DiagArea - the size has to be large enough to store several device ROMTags */
uae_u8 diagarea[] = { 0x90, 0x00, /* da_Config, da_Flags */
0x02, 0x00, /* da_Size */
0x01, 0x00, /* da_DiagPoint */
0x01, 0x06 /* da_BootPoint */
};
expamem_init_clear ();
expamem_write (0x00, Z2_MEM_64KB | rom_card | zorroII);
expamem_write (0x08, no_shutup);
expamem_write (0x04, 2);
expamem_write (0x10, uae_id >> 8);
expamem_write (0x14, uae_id & 0xff);
expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
/* er_InitDiagVec */
expamem_write (0x28, 0x10); /* Rom-Offset hi */
expamem_write (0x2c, 0x00); /* ROM-Offset lo */
expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/