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