|
|
1.1 ! root 1: /* ! 2: * UAE - The Un*x Amiga Emulator ! 3: * ! 4: * Expansion Slots ! 5: * ! 6: * (c) 1996 Stefan Reinauer ! 7: */ ! 8: ! 9: #include "sysconfig.h" ! 10: #include "sysdeps.h" ! 11: ! 12: #include "config.h" ! 13: #include "options.h" ! 14: #include "memory.h" ! 15: #include "custom.h" ! 16: #include "newcpu.h" ! 17: #include "autoconf.h" ! 18: ! 19: #define MAX_EXPANSION_BOARDS 5 ! 20: ! 21: /* 00 / 02 */ ! 22: ! 23: #define MEM_8MB 0x00 /* Size of Memory Block */ ! 24: #define MEM_4MB 0x07 ! 25: #define MEM_2MB 0x06 ! 26: #define MEM_1MB 0x05 ! 27: #define MEM_512KB 0x04 ! 28: #define MEM_256KB 0x03 ! 29: #define MEM_128KB 0x02 ! 30: #define MEM_64KB 0x01 ! 31: ! 32: #define same_slot 0x08 /* Next card is in the same Slot */ ! 33: #define rom_card 0x10 /* Card has valid ROM */ ! 34: #define add_memory 0x20 /* Add Memory to List of Free Ram */ ! 35: ! 36: #define generic 0xc0 /* Type of Expansion Card */ ! 37: #define future1 0x00 ! 38: #define future2 0x40 ! 39: #define future3 0x80 ! 40: ! 41: /* ********************************************************** */ ! 42: ! 43: /* Card Data - Where can I get a complete List of these ???? */ ! 44: ! 45: /* 04 - 06 & 10-16 */ ! 46: #define commodore_g 513 /* Commodore Braunschweig (Germany) */ ! 47: #define commodore 514 /* Commodore West Chester */ ! 48: #define gvp 2017 /* GVP */ ! 49: #define hackers_id 2011 ! 50: ! 51: #define commodore_a2091 3 /* A2091 / A590 Card from C= */ ! 52: #define commodore_a2091_ram 10 /* A2091 / A590 Ram on HD-Card */ ! 53: #define commodore_a2232 70 /* A2232 Multiport Expansion */ ! 54: ! 55: #define gvp_series_2_scsi 11 ! 56: #define gvp_iv_24_gfx 32 ! 57: ! 58: /* ********************************************************** */ ! 59: /* 08-0A */ ! 60: ! 61: #define no_shutup 64 /* Card cannot receive Shut_up_forever */ ! 62: #define care_addr 128 /* Adress HAS to be $200000-$9fffff */ ! 63: ! 64: /* ********************************************************** */ ! 65: ! 66: /* 40-42 */ ! 67: #define enable_irq 1 /* enable Interrupt */ ! 68: #define reset_card 4 /* Reset of Expansion Card */ ! 69: #define card_int2 16 /* READ ONLY: IRQ 2 occured */ ! 70: #define card_irq6 32 /* READ ONLY: IRQ 6 occured */ ! 71: #define card_irq7 64 /* READ ONLY: IRQ 7 occured */ ! 72: #define does_irq 128 /* READ ONLY: Karte loest ger. IRQ aus*/ ! 73: ! 74: /* ********************************************************** */ ! 75: ! 76: /* ROM defines */ ! 77: ! 78: #define rom_4bit (0x00<<14) /* ROM width */ ! 79: #define rom_8bit (0x01<<14) ! 80: #define rom_16bit (0x02<<14) ! 81: ! 82: #define rom_never (0x00<<12) /* Never run Boot Code */ ! 83: #define rom_install (0x01<<12) /* run code at install time */ ! 84: #define rom_binddrv (0x02<<12) /* run code with binddrivers */ ! 85: ! 86: CPTR ROM_filesys_resname = 0, ROM_filesys_resid = 0; ! 87: CPTR ROM_filesys_diagentry = 0; ! 88: CPTR ROM_hardfile_resname = 0, ROM_hardfile_resid = 0; ! 89: CPTR ROM_hardfile_init = 0; ! 90: ! 91: /* ********************************************************** */ ! 92: ! 93: static void expamem_init_clear(void); ! 94: static void expamem_map_clear(void); ! 95: static void expamem_init_fastcard(void); ! 96: static void expamem_map_fastcard(void); ! 97: static void expamem_init_filesys(void); ! 98: static void expamem_map_filesys(void); ! 99: ! 100: void (*card_init[MAX_EXPANSION_BOARDS])(void); ! 101: void (*card_map[MAX_EXPANSION_BOARDS])(void); ! 102: ! 103: int ecard = 0; ! 104: ! 105: /* ********************************************************** ! 106: * Fast Memory ! 107: * ********************************************************** */ ! 108: ! 109: static ULONG fastmem_mask; ! 110: ! 111: static ULONG fastmem_alget(CPTR) REGPARAM; ! 112: static UWORD fastmem_awget(CPTR) REGPARAM; ! 113: static ULONG fastmem_lget(CPTR) REGPARAM; ! 114: static UWORD fastmem_wget(CPTR) REGPARAM; ! 115: static UBYTE fastmem_bget(CPTR) REGPARAM; ! 116: static void fastmem_lput(CPTR, ULONG) REGPARAM; ! 117: static void fastmem_wput(CPTR, UWORD) REGPARAM; ! 118: static void fastmem_bput(CPTR, UBYTE) REGPARAM; ! 119: static int fastmem_check(CPTR addr, ULONG size) REGPARAM; ! 120: static UBYTE *fastmem_xlate(CPTR addr) REGPARAM; ! 121: ! 122: static ULONG fastmem_start; /* Determined by the OS */ ! 123: static UBYTE *fastmemory = NULL; ! 124: ! 125: ULONG fastmem_alget(CPTR addr) ! 126: { ! 127: UBYTE *m; ! 128: addr -= fastmem_start & fastmem_mask; ! 129: addr &= fastmem_mask; ! 130: m = fastmemory + addr; ! 131: return (((ULONG)m[0] << 24) + ((ULONG)m[1] << 16) ! 132: + ((ULONG)m[2] << 8) + ((ULONG)m[3])); ! 133: } ! 134: ! 135: UWORD fastmem_awget(CPTR addr) ! 136: { ! 137: UBYTE *m; ! 138: addr -= fastmem_start & fastmem_mask; ! 139: addr &= fastmem_mask; ! 140: m = fastmemory + addr; ! 141: return ((UWORD)m[0] << 8) + m[1]; ! 142: } ! 143: ! 144: ULONG fastmem_lget(CPTR addr) ! 145: { ! 146: UBYTE *m; ! 147: addr -= fastmem_start & fastmem_mask; ! 148: addr &= fastmem_mask; ! 149: m = fastmemory + addr; ! 150: return (((ULONG)m[0] << 24) + ((ULONG)m[1] << 16) ! 151: + ((ULONG)m[2] << 8) + ((ULONG)m[3])); ! 152: } ! 153: ! 154: UWORD fastmem_wget(CPTR addr) ! 155: { ! 156: UBYTE *m; ! 157: addr -= fastmem_start & fastmem_mask; ! 158: addr &= fastmem_mask; ! 159: m = fastmemory + addr; ! 160: return ((UWORD)m[0] << 8) + m[1]; ! 161: } ! 162: ! 163: UBYTE fastmem_bget(CPTR addr) ! 164: { ! 165: addr -= fastmem_start & fastmem_mask; ! 166: addr &= fastmem_mask; ! 167: return fastmemory[addr]; ! 168: } ! 169: ! 170: void fastmem_lput(CPTR addr, ULONG l) ! 171: { ! 172: UBYTE *m; ! 173: addr -= fastmem_start & fastmem_mask; ! 174: addr &= fastmem_mask; ! 175: m = fastmemory + addr; ! 176: m[0] = l >> 24; ! 177: m[1] = l >> 16; ! 178: m[2] = l >> 8; ! 179: m[3] = l; ! 180: } ! 181: ! 182: void fastmem_wput(CPTR addr, UWORD w) ! 183: { ! 184: UBYTE *m; ! 185: addr -= fastmem_start & fastmem_mask; ! 186: addr &= fastmem_mask; ! 187: m = fastmemory + addr; ! 188: m[0] = w >> 8; ! 189: m[1] = w; ! 190: } ! 191: ! 192: void fastmem_bput(CPTR addr, UBYTE b) ! 193: { ! 194: addr -= fastmem_start & fastmem_mask; ! 195: addr &= fastmem_mask; ! 196: fastmemory[addr] = b; ! 197: } ! 198: ! 199: static int fastmem_check(CPTR addr, ULONG size) ! 200: { ! 201: addr -= fastmem_start & fastmem_mask; ! 202: addr &= fastmem_mask; ! 203: return (addr + size) < fastmem_size; ! 204: } ! 205: ! 206: static UBYTE *fastmem_xlate(CPTR addr) ! 207: { ! 208: addr -= fastmem_start & fastmem_mask; ! 209: addr &= fastmem_mask; ! 210: return fastmemory + addr; ! 211: } ! 212: ! 213: addrbank fastmem_bank = { ! 214: fastmem_alget, fastmem_awget, ! 215: fastmem_lget, fastmem_wget, fastmem_bget, ! 216: fastmem_lput, fastmem_wput, fastmem_bput, ! 217: fastmem_xlate, fastmem_check ! 218: }; ! 219: ! 220: ! 221: /* ! 222: * Filesystem device ROM ! 223: * This is very simple, the Amiga shouldn't be doing things with it. No support ! 224: * for 68020 unaligned addressing etc. ! 225: */ ! 226: ! 227: static ULONG filesys_lget(CPTR) REGPARAM; ! 228: static UWORD filesys_wget(CPTR) REGPARAM; ! 229: static UBYTE filesys_bget(CPTR) REGPARAM; ! 230: static void filesys_lput(CPTR, ULONG) REGPARAM; ! 231: static void filesys_wput(CPTR, UWORD) REGPARAM; ! 232: static void filesys_bput(CPTR, UBYTE) REGPARAM; ! 233: ! 234: static ULONG filesys_start; /* Determined by the OS */ ! 235: static UBYTE filesysory[65536]; ! 236: ! 237: ULONG filesys_lget(CPTR addr) ! 238: { ! 239: UBYTE *m; ! 240: addr -= filesys_start & 65535; ! 241: addr &= 65535; ! 242: m = filesysory + addr; ! 243: return (((ULONG)m[0] << 24) + ((ULONG)m[1] << 16) ! 244: + ((ULONG)m[2] << 8) + ((ULONG)m[3])); ! 245: } ! 246: ! 247: UWORD filesys_wget(CPTR addr) ! 248: { ! 249: UBYTE *m; ! 250: addr -= filesys_start & 65535; ! 251: addr &= 65535; ! 252: m = filesysory + addr; ! 253: return ((UWORD)m[0] << 8) + m[1]; ! 254: } ! 255: ! 256: UBYTE filesys_bget(CPTR addr) ! 257: { ! 258: addr -= filesys_start & 65535; ! 259: addr &= 65535; ! 260: return filesysory[addr]; ! 261: } ! 262: ! 263: static void filesys_lput(CPTR addr, ULONG l) ! 264: { ! 265: fprintf(stderr, "filesys_lput called\n"); ! 266: } ! 267: ! 268: static void filesys_wput(CPTR addr, UWORD w) ! 269: { ! 270: fprintf(stderr, "filesys_wput called\n"); ! 271: } ! 272: ! 273: static void filesys_bput(CPTR addr, UBYTE b) ! 274: { ! 275: fprintf(stderr, "filesys_bput called\n"); ! 276: } ! 277: ! 278: addrbank filesys_bank = { ! 279: default_alget, default_awget, ! 280: filesys_lget, filesys_wget, filesys_bget, ! 281: filesys_lput, filesys_wput, filesys_bput, ! 282: default_xlate, default_check ! 283: }; ! 284: ! 285: ! 286: /* ******************************************************* */ ! 287: ! 288: /* Autoconfig address space at 0xE80000 */ ! 289: static UBYTE expamem[65536]; ! 290: ! 291: static UBYTE expamem_lo; ! 292: static UBYTE expamem_hi; ! 293: ! 294: static ULONG expamem_lget(CPTR) REGPARAM; ! 295: static UWORD expamem_wget(CPTR) REGPARAM; ! 296: static UBYTE expamem_bget(CPTR) REGPARAM; ! 297: static void expamem_lput(CPTR, ULONG) REGPARAM; ! 298: static void expamem_wput(CPTR, UWORD) REGPARAM; ! 299: static void expamem_bput(CPTR, UBYTE) REGPARAM; ! 300: ! 301: addrbank expamem_bank = { ! 302: expamem_lget, expamem_wget, ! 303: expamem_lget, expamem_wget, expamem_bget, ! 304: expamem_lput, expamem_wput, expamem_bput, ! 305: default_xlate, default_check ! 306: }; ! 307: ! 308: static ULONG expamem_lget(CPTR addr) ! 309: { ! 310: fprintf(stderr,"warning: READ.L from address $%lx \n",addr); ! 311: return 0xffffffff; ! 312: } ! 313: ! 314: static UWORD expamem_wget(CPTR addr) ! 315: { ! 316: fprintf(stderr,"warning: READ.W from address $%lx \n",addr); ! 317: return 0xffff; ! 318: } ! 319: ! 320: static UBYTE expamem_bget(CPTR addr) ! 321: { ! 322: UBYTE value; ! 323: addr &= 0xFFFF; ! 324: return expamem[addr]; ! 325: } ! 326: ! 327: static void expamem_write(CPTR addr, UBYTE value) ! 328: { ! 329: addr &= 0xffff; ! 330: if (addr==00 || addr==02 || addr==0x40 || addr==0x42) { ! 331: expamem[addr] = (value & 0xf0); ! 332: expamem[addr+2] = (value & 0x0f) << 4; ! 333: } else { ! 334: expamem[addr] = ~(value & 0xf0); ! 335: expamem[addr+2] = ~((value & 0x0f) << 4); ! 336: } ! 337: } ! 338: ! 339: static void expamem_lput(CPTR addr, ULONG value) ! 340: { ! 341: fprintf(stderr,"warning: WRITE.L to address $%lx : value $%lx\n",addr,value); ! 342: } ! 343: ! 344: static void expamem_wput(CPTR addr, UWORD value) ! 345: { ! 346: fprintf(stderr,"warning: WRITE.W to address $%lx : value $%x\n",addr,value); ! 347: } ! 348: ! 349: static void expamem_bput(CPTR addr, UBYTE value) ! 350: { ! 351: switch (addr&0xff) { ! 352: case 0x30: ! 353: case 0x32: ! 354: expamem_hi = 0; ! 355: expamem_lo = 0; ! 356: expamem_write (0x48, 0x00); ! 357: break; ! 358: ! 359: case 0x48: ! 360: expamem_hi = value; ! 361: (*card_map[ecard])(); ! 362: fprintf (stderr," Card %d done.\n",ecard+1); ! 363: ++ecard; ! 364: if (ecard <= MAX_EXPANSION_BOARDS) ! 365: (*card_init[ecard])(); ! 366: else ! 367: expamem_init_clear(); ! 368: break; ! 369: ! 370: case 0x4a: ! 371: expamem_lo = value; ! 372: break; ! 373: ! 374: case 0x4c: ! 375: fprintf (stderr," Card %d had no success.\n",ecard+1); ! 376: ++ecard; ! 377: if (ecard <= MAX_EXPANSION_BOARDS) ! 378: (*card_init[ecard])(); ! 379: else ! 380: expamem_init_clear(); ! 381: break; ! 382: } ! 383: } ! 384: ! 385: void expamem_reset() ! 386: { ! 387: int cardno = 0; ! 388: ! 389: ecard = 0; ! 390: ! 391: if (fastmemory != NULL) { ! 392: card_init[cardno] = expamem_init_fastcard; ! 393: card_map[cardno++] = expamem_map_fastcard; ! 394: } ! 395: ! 396: if (automount_uaedev && !ersatzkickfile) { ! 397: card_init[cardno] = expamem_init_filesys; ! 398: card_map[cardno++] = expamem_map_filesys; ! 399: } ! 400: ! 401: while (cardno < MAX_EXPANSION_BOARDS) { ! 402: card_init[cardno] = expamem_init_clear; ! 403: card_map[cardno++] = expamem_map_clear; ! 404: } ! 405: ! 406: (*card_init[0])(); ! 407: } ! 408: ! 409: void expansion_init(void) ! 410: { ! 411: if (fastmem_size > 0) { ! 412: fastmem_mask = fastmem_size - 1; ! 413: fastmemory = (UBYTE *)calloc(fastmem_size,1); ! 414: if (fastmemory == NULL) { ! 415: fprintf (stderr,"Out of memory for fastmem card.\n"); ! 416: } ! 417: } ! 418: } ! 419: ! 420: /* *************************************************************** ! 421: * Expansion Card (ZORRO II) for 1/2/4/8 MB of Fast Memory ! 422: * *************************************************************** */ ! 423: ! 424: void expamem_map_fastcard() ! 425: { ! 426: fastmem_start = ((expamem_hi|(expamem_lo>>4)) << 16); ! 427: map_banks (&fastmem_bank, fastmem_start >> 16, fastmem_size >> 16); ! 428: fprintf (stderr,"Fastcard: mapped @$%lx: %dMB fast memory\n",fastmem_start, fastmem_size >>20); ! 429: } ! 430: ! 431: void expamem_init_fastcard() ! 432: { ! 433: expamem_init_clear(); ! 434: if (fastmem_size==0x100000) ! 435: expamem_write (0x00, MEM_1MB+add_memory+generic); ! 436: else if (fastmem_size==0x200000) ! 437: expamem_write (0x00, MEM_2MB+add_memory+generic); ! 438: else if (fastmem_size==0x400000) ! 439: expamem_write (0x00, MEM_4MB+add_memory+generic); ! 440: else if (fastmem_size==0x800000) ! 441: expamem_write (0x00, MEM_8MB+add_memory+generic); ! 442: ! 443: expamem_write (0x08, care_addr); ! 444: ! 445: expamem_write (0x04, 1); ! 446: expamem_write (0x10, hackers_id >> 8); ! 447: expamem_write (0x14, hackers_id & 0x0f); ! 448: ! 449: expamem_write (0x18, 0x00); /* ser.no. Byte 0 */ ! 450: expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */ ! 451: expamem_write (0x20, 0x00); /* ser.no. Byte 2 */ ! 452: expamem_write (0x24, 0x01); /* ser.no. Byte 3 */ ! 453: ! 454: expamem_write (0x28, 0x00); /* Rom-Offset hi */ ! 455: expamem_write (0x2c, 0x00); /* ROM-Offset lo */ ! 456: ! 457: expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/ ! 458: } ! 459: ! 460: /* ! 461: * Filesystem device ! 462: */ ! 463: ! 464: void expamem_map_filesys() ! 465: { ! 466: filesys_start=((expamem_hi | (expamem_lo >> 4)) << 16); ! 467: map_banks(&filesys_bank, filesys_start >> 16, 1); ! 468: } ! 469: ! 470: void expamem_init_filesys() ! 471: { ! 472: UBYTE diagarea[] = { 0x90, 0x00, 0x01, 0x0C, 0x01, 0x00, 0x01, 0x06 }; ! 473: ! 474: expamem_init_clear(); ! 475: expamem_write (0x00, MEM_64KB | rom_card | generic); ! 476: ! 477: expamem_write (0x08, care_addr | no_shutup); ! 478: ! 479: expamem_write (0x04, 2); ! 480: expamem_write (0x10, hackers_id >> 8); ! 481: expamem_write (0x14, hackers_id & 0x0f); ! 482: ! 483: expamem_write (0x18, 0x00); /* ser.no. Byte 0 */ ! 484: expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */ ! 485: expamem_write (0x20, 0x00); /* ser.no. Byte 2 */ ! 486: expamem_write (0x24, 0x01); /* ser.no. Byte 3 */ ! 487: ! 488: expamem_write (0x28, 0x10); /* Rom-Offset hi */ ! 489: expamem_write (0x2c, 0x00); /* ROM-Offset lo */ ! 490: ! 491: expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/ ! 492: ! 493: /* Build a DiagArea */ ! 494: memcpy(expamem + 0x1000, diagarea, sizeof diagarea); ! 495: ! 496: /* Call DiagEntry */ ! 497: expamem[0x1100] = 0x4E; ! 498: expamem[0x1101] = 0xF9; /* JMP */ ! 499: expamem[0x1102] = ROM_filesys_diagentry>>24; ! 500: expamem[0x1103] = ROM_filesys_diagentry>>16; ! 501: expamem[0x1104] = ROM_filesys_diagentry>>8; ! 502: expamem[0x1105] = ROM_filesys_diagentry; ! 503: ! 504: /* What comes next is a plain bootblock */ ! 505: expamem[0x1106] = 0x4E; ! 506: expamem[0x1107] = 0xF9; /* JMP */ ! 507: expamem[0x1108] = EXPANSION_bootcode>>24; ! 508: expamem[0x1109] = EXPANSION_bootcode>>16; ! 509: expamem[0x110A] = EXPANSION_bootcode>>8; ! 510: expamem[0x110B] = EXPANSION_bootcode; ! 511: memcpy(filesysory, expamem, 0x2000); ! 512: } ! 513: ! 514: /* ********************************************************* ! 515: * Dummy Entries to show that there's no card in a slot ! 516: * ********************************************************* */ ! 517: ! 518: void expamem_map_clear() ! 519: { ! 520: fprintf(stderr, "expamem_map_clear() got called. Shouldn't happen.\n"); ! 521: } ! 522: ! 523: void expamem_init_clear() ! 524: { ! 525: memset (expamem,0xff,sizeof expamem); ! 526: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.