|
|
1.1.1.11 root 1: /*
1.1 root 2: * UAE - The Un*x Amiga Emulator
3: *
1.1.1.3 root 4: * AutoConfig (tm) Expansions (ZorroII/III)
5: *
6: * Copyright 1996,1997 Stefan Reinauer <[email protected]>
7: * Copyright 1997 Brian King <[email protected]>
8: * - added gfxcard code
9: *
1.1 root 10: */
11:
12: #include "sysconfig.h"
13: #include "sysdeps.h"
14:
15: #include "options.h"
1.1.1.3 root 16: #include "uae.h"
1.1 root 17: #include "memory.h"
18: #include "autoconf.h"
1.1.1.3 root 19: #include "picasso96.h"
1.1.1.8 root 20: #include "savestate.h"
1.1 root 21:
1.1.1.3 root 22: #define MAX_EXPANSION_BOARDS 8
1.1 root 23:
1.1.1.3 root 24: /* ********************************************************** */
1.1 root 25: /* 00 / 02 */
1.1.1.3 root 26: /* er_Type */
27:
28: #define Z2_MEM_8MB 0x00 /* Size of Memory Block */
29: #define Z2_MEM_4MB 0x07
30: #define Z2_MEM_2MB 0x06
31: #define Z2_MEM_1MB 0x05
32: #define Z2_MEM_512KB 0x04
33: #define Z2_MEM_256KB 0x03
34: #define Z2_MEM_128KB 0x02
35: #define Z2_MEM_64KB 0x01
36: /* extended definitions */
37: #define Z2_MEM_16MB 0x00
38: #define Z2_MEM_32MB 0x01
39: #define Z2_MEM_64MB 0x02
40: #define Z2_MEM_128MB 0x03
41: #define Z2_MEM_256MB 0x04
42: #define Z2_MEM_512MB 0x05
43: #define Z2_MEM_1GB 0x06
44:
45: #define chainedconfig 0x08 /* Next config is part of the same card */
46: #define rom_card 0x10 /* ROM vector is valid */
47: #define add_memory 0x20 /* Link RAM into free memory list */
1.1 root 48:
1.1.1.3 root 49: #define zorroII 0xc0 /* Type of Expansion Card */
50: #define zorroIII 0x80
1.1 root 51:
52: /* ********************************************************** */
1.1.1.3 root 53: /* 04 - 06 & 10-16 */
1.1 root 54:
1.1.1.3 root 55: /* Manufacturer */
56: #define commodore_g 513 /* Commodore Braunschweig (Germany) */
57: #define commodore 514 /* Commodore West Chester */
58: #define gvp 2017 /* GVP */
59: #define ass 2102 /* Advanced Systems & Software */
60: #define hackers_id 2011 /* Special ID for test cards */
61:
62: /* Card Type */
63: #define commodore_a2091 3 /* A2091 / A590 Card from C= */
64: #define commodore_a2091_ram 10 /* A2091 / A590 Ram on HD-Card */
65: #define commodore_a2232 70 /* A2232 Multiport Expansion */
66: #define ass_nexus_scsi 1 /* Nexus SCSI Controller */
1.1 root 67:
1.1.1.3 root 68: #define gvp_series_2_scsi 11
69: #define gvp_iv_24_gfx 32
1.1 root 70:
1.1.1.3 root 71: /* ********************************************************** */
72: /* 08 - 0A */
73: /* er_Flags */
74: #define Z3_MEM_64KB 0x02
75: #define Z3_MEM_128KB 0x03
76: #define Z3_MEM_256KB 0x04
77: #define Z3_MEM_512KB 0x05
78: #define Z3_MEM_1MB 0x06 /* Zorro III card subsize */
79: #define Z3_MEM_2MB 0x07
80: #define Z3_MEM_4MB 0x08
81: #define Z3_MEM_6MB 0x09
82: #define Z3_MEM_8MB 0x0a
83: #define Z3_MEM_10MB 0x0b
84: #define Z3_MEM_12MB 0x0c
85: #define Z3_MEM_14MB 0x0d
86: #define Z3_MEM_16MB 0x00
87: #define Z3_MEM_AUTO 0x01
88: #define Z3_MEM_defunct1 0x0e
89: #define Z3_MEM_defunct2 0x0f
90:
91: #define force_z3 0x10 /* *MUST* be set if card is Z3 */
92: #define ext_size 0x20 /* Use extended size table for bits 0-2 of er_Type */
93: #define no_shutup 0x40 /* Card cannot receive Shut_up_forever */
94: #define care_addr 0x80 /* Adress HAS to be $200000-$9fffff */
1.1 root 95:
96: /* ********************************************************** */
1.1.1.3 root 97: /* 40-42 */
98: /* ec_interrupt (unused) */
1.1 root 99:
1.1.1.3 root 100: #define enable_irq 0x01 /* enable Interrupt */
101: #define reset_card 0x04 /* Reset of Expansion Card - must be 0 */
102: #define card_int2 0x10 /* READ ONLY: IRQ 2 active */
103: #define card_irq6 0x20 /* READ ONLY: IRQ 6 active */
104: #define card_irq7 0x40 /* READ ONLY: IRQ 7 active */
105: #define does_irq 0x80 /* READ ONLY: Card currently throws IRQ */
1.1 root 106:
107: /* ********************************************************** */
108:
1.1.1.3 root 109: /* ROM defines (DiagVec) */
110:
111: #define rom_4bit (0x00<<14) /* ROM width */
112: #define rom_8bit (0x01<<14)
113: #define rom_16bit (0x02<<14)
114:
115: #define rom_never (0x00<<12) /* Never run Boot Code */
116: #define rom_install (0x01<<12) /* run code at install time */
117: #define rom_binddrv (0x02<<12) /* run code with binddrivers */
118:
119: uaecptr ROM_filesys_resname = 0, ROM_filesys_resid = 0;
120: uaecptr ROM_filesys_diagentry = 0;
121: uaecptr ROM_hardfile_resname = 0, ROM_hardfile_resid = 0;
122: uaecptr ROM_hardfile_init = 0;
1.1.1.13! root 123: int uae_boot_rom, uae_boot_rom_size; /* size = code size only */
1.1 root 124:
125: /* ********************************************************** */
126:
1.1.1.3 root 127: static void (*card_init[MAX_EXPANSION_BOARDS]) (void);
128: static void (*card_map[MAX_EXPANSION_BOARDS]) (void);
1.1 root 129:
1.1.1.3 root 130: static int ecard = 0;
1.1 root 131:
132: /* ********************************************************** */
133:
1.1.1.3 root 134: /* Please note: ZorroIII implementation seems to work different
135: * than described in the HRM. This claims that ZorroIII config
136: * address is 0xff000000 while the ZorroII config space starts
1.1.1.11 root 137: * at 0x00e80000. In reality, both, Z2 and Z3 cards are
1.1.1.3 root 138: * configured in the ZorroII config space. Kickstart 3.1 doesn't
139: * even do a single read or write access to the ZorroIII space.
140: * The original Amiga include files tell the same as the HRM.
141: * ZorroIII: If you set ext_size in er_Flags and give a Z2-size
142: * in er_Type you can very likely add some ZorroII address space
143: * to a ZorroIII card on a real Amiga. This is not implemented
144: * yet.
145: * -- Stefan
1.1.1.11 root 146: *
1.1.1.3 root 147: * Surprising that 0xFF000000 isn't used. Maybe it depends on the
148: * ROM. Anyway, the HRM says that Z3 cards may appear in Z2 config
149: * space, so what we are doing here is correct.
150: * -- Bernd
151: */
1.1 root 152:
1.1.1.3 root 153: /* Autoconfig address space at 0xE80000 */
154: static uae_u8 expamem[65536];
1.1 root 155:
1.1.1.3 root 156: static uae_u8 expamem_lo;
157: static uae_u16 expamem_hi;
1.1 root 158:
1.1.1.2 root 159: /*
1.1.1.3 root 160: * Dummy entries to show that there's no card in a slot
1.1.1.2 root 161: */
1.1 root 162:
1.1.1.3 root 163: static void expamem_map_clear (void)
164: {
1.1.1.10 root 165: write_log ("expamem_map_clear() got called. Shouldn't happen.\n");
1.1.1.3 root 166: }
167:
168: static void expamem_init_clear (void)
169: {
170: memset (expamem, 0xff, sizeof expamem);
171: }
1.1.1.13! root 172:
1.1.1.10 root 173: static void expamem_init_clear2 (void)
174: {
1.1.1.13! root 175: expamem_init_clear ();
1.1.1.10 root 176: ecard = MAX_EXPANSION_BOARDS - 1;
177: }
1.1 root 178:
1.1.1.4 root 179: static uae_u32 expamem_lget (uaecptr) REGPARAM;
180: static uae_u32 expamem_wget (uaecptr) REGPARAM;
181: static uae_u32 expamem_bget (uaecptr) REGPARAM;
182: static void expamem_lput (uaecptr, uae_u32) REGPARAM;
183: static void expamem_wput (uaecptr, uae_u32) REGPARAM;
184: static void expamem_bput (uaecptr, uae_u32) REGPARAM;
1.1 root 185:
1.1.1.3 root 186: addrbank expamem_bank = {
187: expamem_lget, expamem_wget, expamem_bget,
188: expamem_lput, expamem_wput, expamem_bput,
1.1.1.13! root 189: default_xlate, default_check, NULL, "Autoconfig"
1.1.1.3 root 190: };
1.1 root 191:
1.1.1.4 root 192: static uae_u32 REGPARAM2 expamem_lget (uaecptr addr)
1.1 root 193: {
1.1.1.4 root 194: write_log ("warning: READ.L from address $%lx \n", addr);
1.1.1.3 root 195: return 0xfffffffful;
1.1 root 196: }
197:
1.1.1.4 root 198: static uae_u32 REGPARAM2 expamem_wget (uaecptr addr)
1.1 root 199: {
1.1.1.4 root 200: write_log ("warning: READ.W from address $%lx \n", addr);
1.1.1.3 root 201: return 0xffff;
202: }
203:
1.1.1.4 root 204: static uae_u32 REGPARAM2 expamem_bget (uaecptr addr)
1.1.1.3 root 205: {
206: addr &= 0xFFFF;
207: return expamem[addr];
1.1 root 208: }
209:
1.1.1.3 root 210: static void REGPARAM2 expamem_write (uaecptr addr, uae_u32 value)
1.1 root 211: {
1.1.1.3 root 212: addr &= 0xffff;
213: if (addr == 00 || addr == 02 || addr == 0x40 || addr == 0x42) {
214: expamem[addr] = (value & 0xf0);
215: expamem[addr + 2] = (value & 0x0f) << 4;
216: } else {
217: expamem[addr] = ~(value & 0xf0);
218: expamem[addr + 2] = ~((value & 0x0f) << 4);
219: }
220: }
221:
1.1.1.4 root 222: static int REGPARAM2 expamem_type (void)
1.1.1.3 root 223: {
224: return ((expamem[0] | expamem[2] >> 4) & 0xc0);
225: }
226:
1.1.1.4 root 227: static void REGPARAM2 expamem_lput (uaecptr addr, uae_u32 value)
1.1.1.3 root 228: {
1.1.1.4 root 229: write_log ("warning: WRITE.L to address $%lx : value $%lx\n", addr, value);
1.1.1.3 root 230: }
231:
1.1.1.4 root 232: static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value)
1.1.1.3 root 233: {
234: if (expamem_type() != zorroIII)
1.1.1.4 root 235: write_log ("warning: WRITE.W to address $%lx : value $%x\n", addr, value);
1.1.1.3 root 236: else {
237: switch (addr & 0xff) {
238: case 0x44:
239: if (expamem_type() == zorroIII) {
240: expamem_hi = value;
241: (*card_map[ecard]) ();
1.1.1.4 root 242: write_log (" Card %d (Zorro%s) done.\n", ecard + 1, expamem_type() == 0xc0 ? "II" : "III");
1.1.1.3 root 243: ++ecard;
1.1.1.6 root 244: if (ecard < MAX_EXPANSION_BOARDS)
1.1.1.3 root 245: (*card_init[ecard]) ();
246: else
1.1.1.10 root 247: expamem_init_clear2 ();
1.1.1.3 root 248: }
249: break;
250: }
251: }
252: }
253:
1.1.1.4 root 254: static void REGPARAM2 expamem_bput (uaecptr addr, uae_u32 value)
1.1.1.3 root 255: {
256: switch (addr & 0xff) {
257: case 0x30:
258: case 0x32:
259: expamem_hi = 0;
260: expamem_lo = 0;
261: expamem_write (0x48, 0x00);
262: break;
263:
264: case 0x48:
265: if (expamem_type () == zorroII) {
266: expamem_hi = value & 0xFF;
267: (*card_map[ecard]) ();
1.1.1.4 root 268: write_log (" Card %d (Zorro%s) done.\n", ecard + 1, expamem_type() == 0xc0 ? "II" : "III");
1.1.1.3 root 269: ++ecard;
1.1.1.6 root 270: if (ecard < MAX_EXPANSION_BOARDS)
1.1.1.3 root 271: (*card_init[ecard]) ();
272: else
1.1.1.10 root 273: expamem_init_clear2 ();
1.1.1.3 root 274: } else if (expamem_type() == zorroIII)
275: expamem_lo = value;
276: break;
277:
278: case 0x4a:
279: if (expamem_type () == zorroII)
280: expamem_lo = value;
281: break;
282:
283: case 0x4c:
1.1.1.4 root 284: write_log (" Card %d (Zorro %s) had no success.\n", ecard + 1, expamem_type() == 0xc0 ? "II" : "III");
1.1.1.3 root 285: ++ecard;
1.1.1.6 root 286: if (ecard < MAX_EXPANSION_BOARDS)
1.1.1.3 root 287: (*card_init[ecard]) ();
288: else
1.1.1.10 root 289: expamem_init_clear2 ();
1.1.1.3 root 290: break;
291: }
292: }
293:
294: /* ********************************************************** */
295:
296: /*
297: * Fast Memory
298: */
299:
300: static uae_u32 fastmem_mask;
301:
1.1.1.4 root 302: static uae_u32 fastmem_lget (uaecptr) REGPARAM;
303: static uae_u32 fastmem_wget (uaecptr) REGPARAM;
304: static uae_u32 fastmem_bget (uaecptr) REGPARAM;
305: static void fastmem_lput (uaecptr, uae_u32) REGPARAM;
306: static void fastmem_wput (uaecptr, uae_u32) REGPARAM;
307: static void fastmem_bput (uaecptr, uae_u32) REGPARAM;
308: static int fastmem_check (uaecptr addr, uae_u32 size) REGPARAM;
309: static uae_u8 *fastmem_xlate (uaecptr addr) REGPARAM;
1.1.1.3 root 310:
311: static uae_u32 fastmem_start; /* Determined by the OS */
312: static uae_u8 *fastmemory = NULL;
313:
1.1.1.4 root 314: uae_u32 REGPARAM2 fastmem_lget (uaecptr addr)
1.1.1.3 root 315: {
316: uae_u8 *m;
1.1 root 317: addr -= fastmem_start & fastmem_mask;
318: addr &= fastmem_mask;
319: m = fastmemory + addr;
1.1.1.3 root 320: return do_get_mem_long ((uae_u32 *)m);
1.1 root 321: }
322:
1.1.1.4 root 323: uae_u32 REGPARAM2 fastmem_wget (uaecptr addr)
1.1 root 324: {
1.1.1.3 root 325: uae_u8 *m;
1.1 root 326: addr -= fastmem_start & fastmem_mask;
327: addr &= fastmem_mask;
328: m = fastmemory + addr;
1.1.1.3 root 329: return do_get_mem_word ((uae_u16 *)m);
1.1 root 330: }
331:
1.1.1.4 root 332: uae_u32 REGPARAM2 fastmem_bget (uaecptr addr)
1.1 root 333: {
334: addr -= fastmem_start & fastmem_mask;
335: addr &= fastmem_mask;
336: return fastmemory[addr];
337: }
338:
1.1.1.4 root 339: void REGPARAM2 fastmem_lput (uaecptr addr, uae_u32 l)
1.1 root 340: {
1.1.1.3 root 341: uae_u8 *m;
1.1 root 342: addr -= fastmem_start & fastmem_mask;
343: addr &= fastmem_mask;
344: m = fastmemory + addr;
1.1.1.3 root 345: do_put_mem_long ((uae_u32 *)m, l);
1.1 root 346: }
347:
1.1.1.4 root 348: void REGPARAM2 fastmem_wput (uaecptr addr, uae_u32 w)
1.1 root 349: {
1.1.1.3 root 350: uae_u8 *m;
1.1 root 351: addr -= fastmem_start & fastmem_mask;
352: addr &= fastmem_mask;
353: m = fastmemory + addr;
1.1.1.3 root 354: do_put_mem_word ((uae_u16 *)m, w);
1.1 root 355: }
356:
1.1.1.4 root 357: void REGPARAM2 fastmem_bput (uaecptr addr, uae_u32 b)
1.1 root 358: {
359: addr -= fastmem_start & fastmem_mask;
360: addr &= fastmem_mask;
361: fastmemory[addr] = b;
362: }
363:
1.1.1.4 root 364: static int REGPARAM2 fastmem_check (uaecptr addr, uae_u32 size)
1.1 root 365: {
366: addr -= fastmem_start & fastmem_mask;
367: addr &= fastmem_mask;
1.1.1.4 root 368: return (addr + size) <= allocated_fastmem;
1.1 root 369: }
370:
1.1.1.4 root 371: static uae_u8 REGPARAM2 *fastmem_xlate (uaecptr addr)
1.1 root 372: {
373: addr -= fastmem_start & fastmem_mask;
374: addr &= fastmem_mask;
375: return fastmemory + addr;
376: }
377:
378: addrbank fastmem_bank = {
379: fastmem_lget, fastmem_wget, fastmem_bget,
380: fastmem_lput, fastmem_wput, fastmem_bput,
1.1.1.13! root 381: fastmem_xlate, fastmem_check, NULL, "Fast memory"
1.1 root 382: };
383:
384:
385: /*
386: * Filesystem device ROM
1.1.1.3 root 387: * This is very simple, the Amiga shouldn't be doing things with it.
1.1 root 388: */
389:
1.1.1.4 root 390: static uae_u32 filesys_lget (uaecptr) REGPARAM;
391: static uae_u32 filesys_wget (uaecptr) REGPARAM;
392: static uae_u32 filesys_bget (uaecptr) REGPARAM;
393: static void filesys_lput (uaecptr, uae_u32) REGPARAM;
394: static void filesys_wput (uaecptr, uae_u32) REGPARAM;
395: static void filesys_bput (uaecptr, uae_u32) REGPARAM;
1.1 root 396:
1.1.1.3 root 397: static uae_u32 filesys_start; /* Determined by the OS */
1.1.1.8 root 398: uae_u8 *filesysory;
1.1 root 399:
1.1.1.4 root 400: uae_u32 REGPARAM2 filesys_lget (uaecptr addr)
1.1 root 401: {
1.1.1.3 root 402: uae_u8 *m;
1.1 root 403: addr -= filesys_start & 65535;
404: addr &= 65535;
405: m = filesysory + addr;
1.1.1.3 root 406: return do_get_mem_long ((uae_u32 *)m);
1.1 root 407: }
408:
1.1.1.4 root 409: uae_u32 REGPARAM2 filesys_wget (uaecptr addr)
1.1 root 410: {
1.1.1.3 root 411: uae_u8 *m;
1.1 root 412: addr -= filesys_start & 65535;
413: addr &= 65535;
414: m = filesysory + addr;
1.1.1.3 root 415: return do_get_mem_word ((uae_u16 *)m);
1.1 root 416: }
417:
1.1.1.4 root 418: uae_u32 REGPARAM2 filesys_bget (uaecptr addr)
1.1 root 419: {
420: addr -= filesys_start & 65535;
421: addr &= 65535;
422: return filesysory[addr];
423: }
424:
1.1.1.4 root 425: static void REGPARAM2 filesys_lput (uaecptr addr, uae_u32 l)
1.1 root 426: {
1.1.1.3 root 427: write_log ("filesys_lput called\n");
1.1 root 428: }
429:
1.1.1.4 root 430: static void REGPARAM2 filesys_wput (uaecptr addr, uae_u32 w)
1.1 root 431: {
1.1.1.3 root 432: write_log ("filesys_wput called\n");
1.1 root 433: }
434:
1.1.1.4 root 435: static void REGPARAM2 filesys_bput (uaecptr addr, uae_u32 b)
1.1 root 436: {
1.1.1.10 root 437: write_log ("filesys_bput called. This usually means that you are using\n");
438: write_log ("Kickstart 1.2. Please give UAE the \"-a\" option next time\n");
439: write_log ("you start it. If you are _not_ using Kickstart 1.2, then\n");
440: write_log ("there's a bug somewhere.\n");
441: write_log ("Exiting...\n");
1.1.1.3 root 442: uae_quit ();
1.1 root 443: }
444:
445: addrbank filesys_bank = {
446: filesys_lget, filesys_wget, filesys_bget,
447: filesys_lput, filesys_wput, filesys_bput,
1.1.1.13! root 448: default_xlate, default_check, NULL, "Filesystem Autoconfig Area"
1.1 root 449: };
450:
1.1.1.3 root 451: /*
452: * Z3fastmem Memory
453: */
1.1 root 454:
455:
1.1.1.3 root 456: static uae_u32 z3fastmem_mask;
1.1 root 457:
1.1.1.4 root 458: static uae_u32 z3fastmem_lget (uaecptr) REGPARAM;
459: static uae_u32 z3fastmem_wget (uaecptr) REGPARAM;
460: static uae_u32 z3fastmem_bget (uaecptr) REGPARAM;
461: static void z3fastmem_lput (uaecptr, uae_u32) REGPARAM;
462: static void z3fastmem_wput (uaecptr, uae_u32) REGPARAM;
463: static void z3fastmem_bput (uaecptr, uae_u32) REGPARAM;
464: static int z3fastmem_check (uaecptr addr, uae_u32 size) REGPARAM;
465: static uae_u8 *z3fastmem_xlate (uaecptr addr) REGPARAM;
1.1.1.3 root 466:
467: static uae_u32 z3fastmem_start; /* Determined by the OS */
468: static uae_u8 *z3fastmem = NULL;
1.1 root 469:
1.1.1.4 root 470: uae_u32 REGPARAM2 z3fastmem_lget (uaecptr addr)
1.1 root 471: {
1.1.1.3 root 472: uae_u8 *m;
473: addr -= z3fastmem_start & z3fastmem_mask;
474: addr &= z3fastmem_mask;
475: m = z3fastmem + addr;
476: return do_get_mem_long ((uae_u32 *)m);
1.1 root 477: }
478:
1.1.1.4 root 479: uae_u32 REGPARAM2 z3fastmem_wget (uaecptr addr)
1.1 root 480: {
1.1.1.3 root 481: uae_u8 *m;
482: addr -= z3fastmem_start & z3fastmem_mask;
483: addr &= z3fastmem_mask;
484: m = z3fastmem + addr;
485: return do_get_mem_word ((uae_u16 *)m);
1.1 root 486: }
487:
1.1.1.4 root 488: uae_u32 REGPARAM2 z3fastmem_bget (uaecptr addr)
1.1 root 489: {
1.1.1.3 root 490: addr -= z3fastmem_start & z3fastmem_mask;
491: addr &= z3fastmem_mask;
492: return z3fastmem[addr];
1.1 root 493: }
494:
1.1.1.4 root 495: void REGPARAM2 z3fastmem_lput (uaecptr addr, uae_u32 l)
1.1 root 496: {
1.1.1.3 root 497: uae_u8 *m;
498: addr -= z3fastmem_start & z3fastmem_mask;
499: addr &= z3fastmem_mask;
500: m = z3fastmem + addr;
501: do_put_mem_long ((uae_u32 *)m, l);
1.1 root 502: }
503:
1.1.1.4 root 504: void REGPARAM2 z3fastmem_wput (uaecptr addr, uae_u32 w)
1.1 root 505: {
1.1.1.3 root 506: uae_u8 *m;
507: addr -= z3fastmem_start & z3fastmem_mask;
508: addr &= z3fastmem_mask;
509: m = z3fastmem + addr;
510: do_put_mem_word ((uae_u16 *)m, w);
1.1 root 511: }
512:
1.1.1.4 root 513: void REGPARAM2 z3fastmem_bput (uaecptr addr, uae_u32 b)
1.1 root 514: {
1.1.1.3 root 515: addr -= z3fastmem_start & z3fastmem_mask;
516: addr &= z3fastmem_mask;
517: z3fastmem[addr] = b;
1.1 root 518: }
519:
1.1.1.4 root 520: static int REGPARAM2 z3fastmem_check (uaecptr addr, uae_u32 size)
1.1 root 521: {
1.1.1.3 root 522: addr -= z3fastmem_start & z3fastmem_mask;
523: addr &= z3fastmem_mask;
1.1.1.4 root 524: return (addr + size) <= allocated_z3fastmem;
1.1 root 525: }
526:
1.1.1.4 root 527: static uae_u8 REGPARAM2 *z3fastmem_xlate (uaecptr addr)
1.1 root 528: {
1.1.1.3 root 529: addr -= z3fastmem_start & z3fastmem_mask;
530: addr &= z3fastmem_mask;
531: return z3fastmem + addr;
532: }
1.1 root 533:
1.1.1.3 root 534: addrbank z3fastmem_bank = {
535: z3fastmem_lget, z3fastmem_wget, z3fastmem_bget,
536: z3fastmem_lput, z3fastmem_wput, z3fastmem_bput,
1.1.1.13! root 537: z3fastmem_xlate, z3fastmem_check, NULL, "ZorroIII Fast RAM"
1.1.1.3 root 538: };
1.1 root 539:
1.1.1.3 root 540: /* Z3-based UAEGFX-card */
541: uae_u32 gfxmem_mask; /* for memory.c */
542: uae_u8 *gfxmemory;
543: uae_u32 gfxmem_start;
1.1 root 544:
1.1.1.3 root 545: /* ********************************************************** */
1.1 root 546:
1.1.1.2 root 547: /*
1.1 root 548: * Expansion Card (ZORRO II) for 1/2/4/8 MB of Fast Memory
1.1.1.2 root 549: */
1.1 root 550:
1.1.1.3 root 551: static void expamem_map_fastcard (void)
1.1 root 552: {
1.1.1.3 root 553: fastmem_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
1.1.1.8 root 554: map_banks (&fastmem_bank, fastmem_start >> 16, allocated_fastmem >> 16, allocated_fastmem);
1.1.1.4 root 555: write_log ("Fastcard: mapped @$%lx: %dMB fast memory\n", fastmem_start, allocated_fastmem >> 20);
1.1 root 556: }
557:
1.1.1.3 root 558: static void expamem_init_fastcard (void)
1.1 root 559: {
1.1.1.13! root 560: expamem_init_clear ();
1.1.1.4 root 561: if (allocated_fastmem == 0x100000)
1.1.1.3 root 562: expamem_write (0x00, Z2_MEM_1MB + add_memory + zorroII);
1.1.1.4 root 563: else if (allocated_fastmem == 0x200000)
1.1.1.3 root 564: expamem_write (0x00, Z2_MEM_2MB + add_memory + zorroII);
1.1.1.4 root 565: else if (allocated_fastmem == 0x400000)
1.1.1.3 root 566: expamem_write (0x00, Z2_MEM_4MB + add_memory + zorroII);
1.1.1.4 root 567: else if (allocated_fastmem == 0x800000)
1.1.1.3 root 568: expamem_write (0x00, Z2_MEM_8MB + add_memory + zorroII);
1.1 root 569:
570: expamem_write (0x08, care_addr);
571:
572: expamem_write (0x04, 1);
1.1.1.3 root 573:
1.1 root 574: expamem_write (0x10, hackers_id >> 8);
1.1.1.3 root 575: expamem_write (0x14, hackers_id & 0xff);
1.1 root 576:
577: expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
578: expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
579: expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
580: expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
581:
1.1.1.3 root 582: expamem_write (0x28, 0x00); /* Rom-Offset hi */
583: expamem_write (0x2c, 0x00); /* ROM-Offset lo */
1.1 root 584:
585: expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
586: }
587:
1.1.1.3 root 588: /* ********************************************************** */
589:
1.1.1.11 root 590: /*
1.1 root 591: * Filesystem device
592: */
593:
1.1.1.3 root 594: static void expamem_map_filesys (void)
1.1 root 595: {
1.1.1.3 root 596: uaecptr a;
597:
598: filesys_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
1.1.1.8 root 599: map_banks (&filesys_bank, filesys_start >> 16, 1, 0);
1.1.1.5 root 600: write_log ("Filesystem: mapped memory @$%lx.\n", filesys_start);
1.1.1.3 root 601: /* 68k code needs to know this. */
602: a = here ();
1.1.1.10 root 603: org (RTAREA_BASE+0xFFFC);
1.1.1.3 root 604: dl (filesys_start + 0x2000);
605: org (a);
1.1 root 606: }
607:
1.1.1.3 root 608: static void expamem_init_filesys (void)
1.1 root 609: {
1.1.1.5 root 610: /* struct DiagArea - the size has to be large enough to store several device ROMTags */
611: uae_u8 diagarea[] = { 0x90, 0x00, /* da_Config, da_Flags */
1.1.1.11 root 612: 0x02, 0x00, /* da_Size */
613: 0x01, 0x00, /* da_DiagPoint */
614: 0x01, 0x06 /* da_BootPoint */
1.1.1.5 root 615: };
1.1 root 616:
1.1.1.13! root 617: expamem_init_clear ();
1.1.1.3 root 618: expamem_write (0x00, Z2_MEM_64KB | rom_card | zorroII);
1.1 root 619:
1.1.1.3 root 620: expamem_write (0x08, no_shutup);
1.1 root 621:
622: expamem_write (0x04, 2);
623: expamem_write (0x10, hackers_id >> 8);
1.1.1.3 root 624: expamem_write (0x14, hackers_id & 0xff);
1.1 root 625:
626: expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
627: expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
628: expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
629: expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
630:
1.1.1.5 root 631: /* er_InitDiagVec */
1.1.1.3 root 632: expamem_write (0x28, 0x10); /* Rom-Offset hi */
633: expamem_write (0x2c, 0x00); /* ROM-Offset lo */
1.1 root 634:
635: expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
636:
637: /* Build a DiagArea */
1.1.1.3 root 638: memcpy (expamem + 0x1000, diagarea, sizeof diagarea);
639:
1.1 root 640: /* Call DiagEntry */
1.1.1.3 root 641: do_put_mem_word ((uae_u16 *)(expamem + 0x1100), 0x4EF9); /* JMP */
642: do_put_mem_long ((uae_u32 *)(expamem + 0x1102), ROM_filesys_diagentry);
643:
1.1 root 644: /* What comes next is a plain bootblock */
1.1.1.3 root 645: do_put_mem_word ((uae_u16 *)(expamem + 0x1106), 0x4EF9); /* JMP */
646: do_put_mem_long ((uae_u32 *)(expamem + 0x1108), EXPANSION_bootcode);
647:
648: memcpy (filesysory, expamem, 0x3000);
1.1 root 649: }
650:
1.1.1.2 root 651: /*
1.1.1.3 root 652: * Zorro III expansion memory
1.1.1.2 root 653: */
1.1 root 654:
1.1.1.3 root 655: static void expamem_map_z3fastmem (void)
1.1 root 656: {
1.1.1.3 root 657: z3fastmem_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
1.1.1.8 root 658: map_banks (&z3fastmem_bank, z3fastmem_start >> 16, currprefs.z3fastmem_size >> 16,
659: allocated_z3fastmem);
1.1.1.3 root 660:
1.1.1.4 root 661: write_log ("Fastmem (32bit): mapped @$%lx: %d MB Zorro III fast memory \n",
662: z3fastmem_start, allocated_z3fastmem / 0x100000);
1.1.1.3 root 663: }
664:
665: static void expamem_init_z3fastmem (void)
666: {
1.1.1.4 root 667: int code = (allocated_z3fastmem == 0x100000 ? Z2_MEM_1MB
668: : allocated_z3fastmem == 0x200000 ? Z2_MEM_2MB
669: : allocated_z3fastmem == 0x400000 ? Z2_MEM_4MB
670: : allocated_z3fastmem == 0x800000 ? Z2_MEM_8MB
671: : allocated_z3fastmem == 0x1000000 ? Z2_MEM_16MB
672: : allocated_z3fastmem == 0x2000000 ? Z2_MEM_32MB
673: : allocated_z3fastmem == 0x4000000 ? Z2_MEM_64MB
674: : allocated_z3fastmem == 0x8000000 ? Z2_MEM_128MB
675: : allocated_z3fastmem == 0x10000000 ? Z2_MEM_256MB
676: : allocated_z3fastmem == 0x20000000 ? Z2_MEM_512MB
1.1.1.3 root 677: : Z2_MEM_1GB);
1.1.1.13! root 678: expamem_init_clear ();
1.1.1.3 root 679: expamem_write (0x00, add_memory | zorroIII | code);
680:
1.1.1.4 root 681: expamem_write (0x08, no_shutup | force_z3 | (allocated_z3fastmem > 0x800000 ? ext_size : Z3_MEM_AUTO));
1.1.1.3 root 682:
683: expamem_write (0x04, 3);
684:
685: expamem_write (0x10, hackers_id >> 8);
686: expamem_write (0x14, hackers_id & 0xff);
687:
688: expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
689: expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
690: expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
691: expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
692:
693: expamem_write (0x28, 0x00); /* Rom-Offset hi */
694: expamem_write (0x2c, 0x00); /* ROM-Offset lo */
695:
696: expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
1.1 root 697: }
698:
1.1.1.3 root 699: #ifdef PICASSO96
700: /*
701: * Fake Graphics Card (ZORRO III) - BDK
702: */
703:
704: static void expamem_map_gfxcard (void)
1.1 root 705: {
1.1.1.3 root 706: gfxmem_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
1.1.1.8 root 707: map_banks (&gfxmem_bank, gfxmem_start >> 16, allocated_gfxmem >> 16, allocated_gfxmem);
1.1.1.4 root 708: write_log ("UAEGFX-card: mapped @$%lx \n", gfxmem_start);
1.1 root 709: }
1.1.1.3 root 710:
711: static void expamem_init_gfxcard (void)
712: {
1.1.1.13! root 713: expamem_init_clear ();
1.1.1.3 root 714: expamem_write (0x00, zorroIII);
715:
1.1.1.4 root 716: switch (allocated_gfxmem) {
1.1.1.3 root 717: case 0x00100000:
718: expamem_write (0x08, no_shutup | force_z3 | Z3_MEM_1MB);
719: break;
720: case 0x00200000:
721: expamem_write (0x08, no_shutup | force_z3 | Z3_MEM_2MB);
722: break;
723: case 0x00400000:
724: expamem_write (0x08, no_shutup | force_z3 | Z3_MEM_4MB);
725: break;
726: case 0x00800000:
727: expamem_write (0x08, no_shutup | force_z3 | Z3_MEM_8MB);
728: break;
729: }
730:
731: expamem_write (0x04, 96);
732:
733: expamem_write (0x10, hackers_id >> 8);
734: expamem_write (0x14, hackers_id & 0xff);
735:
736: expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
737: expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
738: expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
739: expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
740:
741: expamem_write (0x28, 0x00); /* Rom-Offset hi */
742: expamem_write (0x2c, 0x00); /* ROM-Offset lo */
743:
744: expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
745: }
746: #endif
747:
1.1.1.8 root 748: static long fast_filepos, z3_filepos;
749:
750: static void allocate_expamem (void)
751: {
752: currprefs.fastmem_size = changed_prefs.fastmem_size;
753: currprefs.z3fastmem_size = changed_prefs.z3fastmem_size;
754: currprefs.gfxmem_size = changed_prefs.gfxmem_size;
755:
756: if (allocated_fastmem != currprefs.fastmem_size) {
757: if (fastmemory)
1.1.1.9 root 758: mapped_free (fastmemory);
1.1.1.8 root 759: fastmemory = 0;
760: allocated_fastmem = currprefs.fastmem_size;
761: fastmem_mask = allocated_fastmem - 1;
762:
763: if (allocated_fastmem) {
764: fastmemory = mapped_malloc (allocated_fastmem, "fast");
765: if (fastmemory == 0) {
766: write_log ("Out of memory for fastmem card.\n");
767: allocated_fastmem = 0;
768: }
769: }
770: }
1.1.1.11 root 771: if (currprefs.address_space_24) {
1.1.1.8 root 772: if (z3fastmem)
1.1.1.9 root 773: mapped_free (z3fastmem);
1.1.1.8 root 774: z3fastmem = 0;
1.1.1.11 root 775: allocated_z3fastmem = 0;
1.1.1.8 root 776: if (gfxmemory)
1.1.1.9 root 777: mapped_free (gfxmemory);
1.1.1.8 root 778: gfxmemory = 0;
1.1.1.11 root 779: allocated_gfxmem = 0;
780: } else {
781: if (allocated_z3fastmem != currprefs.z3fastmem_size) {
782: if (z3fastmem)
783: mapped_free (z3fastmem);
784: z3fastmem = 0;
785:
786: allocated_z3fastmem = currprefs.z3fastmem_size;
787: z3fastmem_mask = allocated_z3fastmem - 1;
788:
789: if (allocated_z3fastmem) {
790: z3fastmem = mapped_malloc (allocated_z3fastmem, "z3");
791: if (z3fastmem == 0) {
792: write_log ("Out of memory for 32 bit fast memory.\n");
793: allocated_z3fastmem = 0;
794: }
795: }
796: }
797: if (allocated_gfxmem != currprefs.gfxmem_size) {
798: if (gfxmemory)
799: mapped_free (gfxmemory);
800: gfxmemory = 0;
801:
802: allocated_gfxmem = currprefs.gfxmem_size;
803: gfxmem_mask = allocated_gfxmem - 1;
804:
805: if (allocated_gfxmem) {
806: gfxmemory = mapped_malloc (allocated_gfxmem, "gfx");
807: if (gfxmemory == 0) {
808: write_log ("Out of memory for graphics card memory\n");
809: allocated_gfxmem = 0;
810: }
1.1.1.8 root 811: }
812: }
813: }
814: z3fastmem_bank.baseaddr = z3fastmem;
815: fastmem_bank.baseaddr = fastmemory;
816:
817: if (savestate_state == STATE_RESTORE) {
818: if (allocated_fastmem > 0) {
1.1.1.13! root 819: restore_ram (fast_filepos, fastmemory);
! 820: if (fastmem_start == 0 || fastmem_start & 0xFFFF) {
! 821: write_log ("Statefile most likely corrupt. Using a sane default for fastmem address.\n");
! 822: fastmem_start = 0x200000;
! 823: }
1.1.1.8 root 824: map_banks (&fastmem_bank, fastmem_start >> 16, currprefs.fastmem_size >> 16,
825: allocated_fastmem);
826: }
827: if (allocated_z3fastmem > 0) {
1.1.1.13! root 828: restore_ram (z3_filepos, z3fastmem);
1.1.1.8 root 829: map_banks (&z3fastmem_bank, z3fastmem_start >> 16, currprefs.z3fastmem_size >> 16,
830: allocated_z3fastmem);
831: }
832: }
833: }
834:
835: void expamem_reset (void)
1.1.1.3 root 836: {
1.1.1.13! root 837: int do_mount = currprefs.bootrom && !ersatzkickfile;
1.1.1.3 root 838: int cardno = 0;
839: ecard = 0;
840:
1.1.1.8 root 841: allocate_expamem ();
842:
843: /* check if Kickstart version is below 1.3 */
1.1.1.13! root 844: if (! ersatzkickfile && kickstart_version
1.1.1.8 root 845: && (/* Kickstart 1.0 & 1.1! */
1.1.1.13! root 846: kickstart_version == 0xFFFF
1.1.1.8 root 847: /* Kickstart < 1.3 */
1.1.1.13! root 848: || kickstart_version < 34))
1.1.1.8 root 849: {
850: /* warn user */
851: write_log ("Kickstart version is below 1.3! Disabling autoconfig devices.\n");
852: do_mount = 0;
853: }
854:
1.1.1.3 root 855: if (fastmemory != NULL) {
856: card_init[cardno] = expamem_init_fastcard;
857: card_map[cardno++] = expamem_map_fastcard;
858: }
859: if (z3fastmem != NULL) {
860: card_init[cardno] = expamem_init_z3fastmem;
861: card_map[cardno++] = expamem_map_z3fastmem;
862: }
863: #ifdef PICASSO96
864: if (gfxmemory != NULL) {
865: card_init[cardno] = expamem_init_gfxcard;
866: card_map[cardno++] = expamem_map_gfxcard;
867: }
868: #endif
1.1.1.13! root 869: if (do_mount) {
1.1.1.3 root 870: card_init[cardno] = expamem_init_filesys;
871: card_map[cardno++] = expamem_map_filesys;
872: }
873: while (cardno < MAX_EXPANSION_BOARDS) {
874: card_init[cardno] = expamem_init_clear;
875: card_map[cardno++] = expamem_map_clear;
876: }
877:
878: (*card_init[0]) ();
879: }
880:
1.1.1.4 root 881: void expansion_init (void)
1.1.1.3 root 882: {
1.1.1.8 root 883: z3fastmem = 0;
884: gfxmemory = 0;
885: fastmemory = 0;
886: allocated_z3fastmem = 0;
887: allocated_gfxmem = 0;
888: allocated_fastmem = 0;
889:
890: allocate_expamem ();
891:
1.1.1.13! root 892: filesysory = mapped_malloc (0x10000, "filesys");
1.1.1.8 root 893: if (!filesysory) {
894: write_log ("virtual memory exhausted (filesysory)!\n");
895: exit (0);
1.1.1.3 root 896: }
1.1.1.13! root 897: filesys_bank.baseaddr = filesysory;
1.1.1.3 root 898: }
899:
1.1.1.9 root 900: void expansion_cleanup (void)
901: {
902: if (fastmemory)
903: mapped_free (fastmemory);
904: if (z3fastmem)
905: mapped_free (z3fastmem);
906: if (gfxmemory)
907: mapped_free (gfxmemory);
908: if (filesysory)
909: mapped_free (filesysory);
910: fastmemory = 0;
911: z3fastmem = 0;
912: gfxmemory = 0;
913: filesysory = 0;
914: }
915:
1.1.1.13! root 916: void expansion_clear(void)
! 917: {
! 918: if (fastmemory)
! 919: memset (fastmemory, 0, allocated_fastmem);
! 920: if (z3fastmem)
! 921: memset (z3fastmem, 0, allocated_z3fastmem > 0x800000 ? 0x800000 : allocated_z3fastmem);
! 922: if (gfxmemory)
! 923: memset (gfxmemory, 0, allocated_gfxmem);
! 924: }
! 925:
1.1.1.8 root 926: /* State save/restore code. */
927:
928: uae_u8 *save_fram (int *len)
929: {
930: *len = allocated_fastmem;
931: return fastmemory;
932: }
933:
934: uae_u8 *save_zram (int *len)
935: {
936: *len = allocated_z3fastmem;
937: return z3fastmem;
938: }
939:
940: void restore_fram (int len, long filepos)
941: {
942: fast_filepos = filepos;
943: changed_prefs.fastmem_size = len;
944: }
945:
946: void restore_zram (int len, long filepos)
947: {
948: z3_filepos = filepos;
949: changed_prefs.z3fastmem_size = len;
950: }
951:
1.1.1.11 root 952: uae_u8 *save_expansion (int *len, uae_u8 *dstptr)
1.1.1.8 root 953: {
1.1.1.11 root 954: static uae_u8 t[20];
955: uae_u8 *dst = t, *dstbak = t;
956: if (dstptr)
957: dst = dstbak = dstptr;
1.1.1.8 root 958: save_u32 (fastmem_start);
959: save_u32 (z3fastmem_start);
960: *len = 8;
1.1.1.13! root 961: return dstbak;
1.1.1.8 root 962: }
963:
1.1.1.12 root 964: const uae_u8 *restore_expansion (const uae_u8 *src)
1.1.1.8 root 965: {
966: fastmem_start = restore_u32 ();
967: z3fastmem_start = restore_u32 ();
968: return src;
969: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.