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