Annotation of uae/src/expansion.c, revision 1.1.1.6

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       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
                    136:  * at 0x00e80000. In reality, both, Z2 and Z3 cards are 
                    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
                    145:  * 
                    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: {
                    164:     fprintf (stderr, "expamem_map_clear() got called. Shouldn't happen.\n");
                    165: }
                    166: 
                    167: static void expamem_init_clear (void)
                    168: {
                    169:     memset (expamem, 0xff, sizeof expamem);
                    170: }
1.1       root      171: 
1.1.1.4   root      172: static uae_u32 expamem_lget (uaecptr) REGPARAM;
                    173: static uae_u32 expamem_wget (uaecptr) REGPARAM;
                    174: static uae_u32 expamem_bget (uaecptr) REGPARAM;
                    175: static void expamem_lput (uaecptr, uae_u32) REGPARAM;
                    176: static void expamem_wput (uaecptr, uae_u32) REGPARAM;
                    177: static void expamem_bput (uaecptr, uae_u32) REGPARAM;
1.1       root      178: 
1.1.1.3   root      179: addrbank expamem_bank = {
                    180:     expamem_lget, expamem_wget, expamem_bget,
                    181:     expamem_lput, expamem_wput, expamem_bput,
                    182:     default_xlate, default_check
                    183: };
1.1       root      184: 
1.1.1.4   root      185: static uae_u32 REGPARAM2 expamem_lget (uaecptr addr)
1.1       root      186: {
1.1.1.4   root      187:     write_log ("warning: READ.L from address $%lx \n", addr);
1.1.1.3   root      188:     return 0xfffffffful;
1.1       root      189: }
                    190: 
1.1.1.4   root      191: static uae_u32 REGPARAM2 expamem_wget (uaecptr addr)
1.1       root      192: {
1.1.1.4   root      193:     write_log ("warning: READ.W from address $%lx \n", addr);
1.1.1.3   root      194:     return 0xffff;
                    195: }
                    196: 
1.1.1.4   root      197: static uae_u32 REGPARAM2 expamem_bget (uaecptr addr)
1.1.1.3   root      198: {
                    199:     addr &= 0xFFFF;
                    200:     return expamem[addr];
1.1       root      201: }
                    202: 
1.1.1.3   root      203: static void REGPARAM2 expamem_write (uaecptr addr, uae_u32 value)
1.1       root      204: {
1.1.1.3   root      205:     addr &= 0xffff;
                    206:     if (addr == 00 || addr == 02 || addr == 0x40 || addr == 0x42) {
                    207:        expamem[addr] = (value & 0xf0);
                    208:        expamem[addr + 2] = (value & 0x0f) << 4;
                    209:     } else {
                    210:        expamem[addr] = ~(value & 0xf0);
                    211:        expamem[addr + 2] = ~((value & 0x0f) << 4);
                    212:     }
                    213: }
                    214: 
1.1.1.4   root      215: static int REGPARAM2 expamem_type (void)
1.1.1.3   root      216: {
                    217:     return ((expamem[0] | expamem[2] >> 4) & 0xc0);
                    218: }
                    219: 
1.1.1.4   root      220: static void REGPARAM2 expamem_lput (uaecptr addr, uae_u32 value)
1.1.1.3   root      221: {
1.1.1.4   root      222:     write_log ("warning: WRITE.L to address $%lx : value $%lx\n", addr, value);
1.1.1.3   root      223: }
                    224: 
1.1.1.4   root      225: static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value)
1.1.1.3   root      226: {
                    227:     if (expamem_type() != zorroIII)
1.1.1.4   root      228:        write_log ("warning: WRITE.W to address $%lx : value $%x\n", addr, value);
1.1.1.3   root      229:     else {
                    230:        switch (addr & 0xff) {
                    231:         case 0x44:
                    232:            if (expamem_type() == zorroIII) {
                    233:                expamem_hi = value;
                    234:                (*card_map[ecard]) ();
1.1.1.4   root      235:                write_log ("   Card %d (Zorro%s) done.\n", ecard + 1, expamem_type() == 0xc0 ? "II" : "III");
1.1.1.3   root      236:                ++ecard;
1.1.1.6 ! root      237:                if (ecard < MAX_EXPANSION_BOARDS)
1.1.1.3   root      238:                    (*card_init[ecard]) ();
                    239:                else
                    240:                    expamem_init_clear ();
                    241:            }
                    242:            break;
                    243:        }
                    244:     }
                    245: }
                    246: 
1.1.1.4   root      247: static void REGPARAM2 expamem_bput (uaecptr addr, uae_u32 value)
1.1.1.3   root      248: {
                    249:     switch (addr & 0xff) {
                    250:      case 0x30:
                    251:      case 0x32:
                    252:        expamem_hi = 0;
                    253:        expamem_lo = 0;
                    254:        expamem_write (0x48, 0x00);
                    255:        break;
                    256: 
                    257:      case 0x48:
                    258:        if (expamem_type () == zorroII) {
                    259:            expamem_hi = value & 0xFF;
                    260:            (*card_map[ecard]) ();
1.1.1.4   root      261:            write_log ("   Card %d (Zorro%s) done.\n", ecard + 1, expamem_type() == 0xc0 ? "II" : "III");
1.1.1.3   root      262:            ++ecard;
1.1.1.6 ! root      263:            if (ecard < MAX_EXPANSION_BOARDS)
1.1.1.3   root      264:                (*card_init[ecard]) ();
                    265:            else
                    266:                expamem_init_clear ();
                    267:        } else if (expamem_type() == zorroIII)
                    268:            expamem_lo = value;
                    269:        break;
                    270: 
                    271:      case 0x4a:
                    272:        if (expamem_type () == zorroII)
                    273:            expamem_lo = value;
                    274:        break;
                    275: 
                    276:      case 0x4c:
1.1.1.4   root      277:        write_log ("   Card %d (Zorro %s) had no success.\n", ecard + 1, expamem_type() == 0xc0 ? "II" : "III");
1.1.1.3   root      278:        ++ecard;
1.1.1.6 ! root      279:        if (ecard < MAX_EXPANSION_BOARDS)
1.1.1.3   root      280:            (*card_init[ecard]) ();
                    281:        else
                    282:            expamem_init_clear ();
                    283:        break;
                    284:     }
                    285: }
                    286: 
                    287: /* ********************************************************** */
                    288: 
                    289: /*
                    290:  *  Fast Memory
                    291:  */
                    292: 
                    293: static uae_u32 fastmem_mask;
                    294: 
1.1.1.4   root      295: static uae_u32 fastmem_lget (uaecptr) REGPARAM;
                    296: static uae_u32 fastmem_wget (uaecptr) REGPARAM;
                    297: static uae_u32 fastmem_bget (uaecptr) REGPARAM;
                    298: static void fastmem_lput (uaecptr, uae_u32) REGPARAM;
                    299: static void fastmem_wput (uaecptr, uae_u32) REGPARAM;
                    300: static void fastmem_bput (uaecptr, uae_u32) REGPARAM;
                    301: static int fastmem_check (uaecptr addr, uae_u32 size) REGPARAM;
                    302: static uae_u8 *fastmem_xlate (uaecptr addr) REGPARAM;
1.1.1.3   root      303: 
                    304: static uae_u32 fastmem_start; /* Determined by the OS */
                    305: static uae_u8 *fastmemory = NULL;
                    306: 
1.1.1.4   root      307: uae_u32 REGPARAM2 fastmem_lget (uaecptr addr)
1.1.1.3   root      308: {
                    309:     uae_u8 *m;
1.1       root      310:     addr -= fastmem_start & fastmem_mask;
                    311:     addr &= fastmem_mask;
                    312:     m = fastmemory + addr;
1.1.1.3   root      313:     return do_get_mem_long ((uae_u32 *)m);
1.1       root      314: }
                    315: 
1.1.1.4   root      316: uae_u32 REGPARAM2 fastmem_wget (uaecptr addr)
1.1       root      317: {
1.1.1.3   root      318:     uae_u8 *m;
1.1       root      319:     addr -= fastmem_start & fastmem_mask;
                    320:     addr &= fastmem_mask;
                    321:     m = fastmemory + addr;
1.1.1.3   root      322:     return do_get_mem_word ((uae_u16 *)m);
1.1       root      323: }
                    324: 
1.1.1.4   root      325: uae_u32 REGPARAM2 fastmem_bget (uaecptr addr)
1.1       root      326: {
                    327:     addr -= fastmem_start & fastmem_mask;
                    328:     addr &= fastmem_mask;
                    329:     return fastmemory[addr];
                    330: }
                    331: 
1.1.1.4   root      332: void REGPARAM2 fastmem_lput (uaecptr addr, uae_u32 l)
1.1       root      333: {
1.1.1.3   root      334:     uae_u8 *m;
1.1       root      335:     addr -= fastmem_start & fastmem_mask;
                    336:     addr &= fastmem_mask;
                    337:     m = fastmemory + addr;
1.1.1.3   root      338:     do_put_mem_long ((uae_u32 *)m, l);
1.1       root      339: }
                    340: 
1.1.1.4   root      341: void REGPARAM2 fastmem_wput (uaecptr addr, uae_u32 w)
1.1       root      342: {
1.1.1.3   root      343:     uae_u8 *m;
1.1       root      344:     addr -= fastmem_start & fastmem_mask;
                    345:     addr &= fastmem_mask;
                    346:     m = fastmemory + addr;
1.1.1.3   root      347:     do_put_mem_word ((uae_u16 *)m, w);
1.1       root      348: }
                    349: 
1.1.1.4   root      350: void REGPARAM2 fastmem_bput (uaecptr addr, uae_u32 b)
1.1       root      351: {
                    352:     addr -= fastmem_start & fastmem_mask;
                    353:     addr &= fastmem_mask;
                    354:     fastmemory[addr] = b;
                    355: }
                    356: 
1.1.1.4   root      357: static int REGPARAM2 fastmem_check (uaecptr addr, uae_u32 size)
1.1       root      358: {
                    359:     addr -= fastmem_start & fastmem_mask;
                    360:     addr &= fastmem_mask;
1.1.1.4   root      361:     return (addr + size) <= allocated_fastmem;
1.1       root      362: }
                    363: 
1.1.1.4   root      364: static uae_u8 REGPARAM2 *fastmem_xlate (uaecptr addr)
1.1       root      365: {
                    366:     addr -= fastmem_start & fastmem_mask;
                    367:     addr &= fastmem_mask;
                    368:     return fastmemory + addr;
                    369: }
                    370: 
                    371: addrbank fastmem_bank = {
                    372:     fastmem_lget, fastmem_wget, fastmem_bget,
                    373:     fastmem_lput, fastmem_wput, fastmem_bput,
                    374:     fastmem_xlate, fastmem_check
                    375: };
                    376: 
                    377: 
                    378: /*
                    379:  * Filesystem device ROM
1.1.1.3   root      380:  * This is very simple, the Amiga shouldn't be doing things with it.
1.1       root      381:  */
                    382: 
1.1.1.4   root      383: static uae_u32 filesys_lget (uaecptr) REGPARAM;
                    384: static uae_u32 filesys_wget (uaecptr) REGPARAM;
                    385: static uae_u32 filesys_bget (uaecptr) REGPARAM;
                    386: static void filesys_lput (uaecptr, uae_u32) REGPARAM;
                    387: static void filesys_wput (uaecptr, uae_u32) REGPARAM;
                    388: static void filesys_bput (uaecptr, uae_u32) REGPARAM;
1.1       root      389: 
1.1.1.3   root      390: static uae_u32 filesys_start; /* Determined by the OS */
                    391: uae_u8 filesysory[65536];
1.1       root      392: 
1.1.1.4   root      393: uae_u32 REGPARAM2 filesys_lget (uaecptr addr)
1.1       root      394: {
1.1.1.3   root      395:     uae_u8 *m;
1.1       root      396:     addr -= filesys_start & 65535;
                    397:     addr &= 65535;
                    398:     m = filesysory + addr;
1.1.1.3   root      399:     return do_get_mem_long ((uae_u32 *)m);
1.1       root      400: }
                    401: 
1.1.1.4   root      402: uae_u32 REGPARAM2 filesys_wget (uaecptr addr)
1.1       root      403: {
1.1.1.3   root      404:     uae_u8 *m;
1.1       root      405:     addr -= filesys_start & 65535;
                    406:     addr &= 65535;
                    407:     m = filesysory + addr;
1.1.1.3   root      408:     return do_get_mem_word ((uae_u16 *)m);
1.1       root      409: }
                    410: 
1.1.1.4   root      411: uae_u32 REGPARAM2 filesys_bget (uaecptr addr)
1.1       root      412: {
                    413:     addr -= filesys_start & 65535;
                    414:     addr &= 65535;
                    415:     return filesysory[addr];
                    416: }
                    417: 
1.1.1.4   root      418: static void REGPARAM2 filesys_lput (uaecptr addr, uae_u32 l)
1.1       root      419: {
1.1.1.3   root      420:     write_log ("filesys_lput called\n");
1.1       root      421: }
                    422: 
1.1.1.4   root      423: static void REGPARAM2 filesys_wput (uaecptr addr, uae_u32 w)
1.1       root      424: {
1.1.1.3   root      425:     write_log ("filesys_wput called\n");
1.1       root      426: }
                    427: 
1.1.1.4   root      428: static void REGPARAM2 filesys_bput (uaecptr addr, uae_u32 b)
1.1       root      429: {
1.1.1.3   root      430:     fprintf (stderr, "filesys_bput called. This usually means that you are using\n");
                    431:     fprintf (stderr, "Kickstart 1.2. Please give UAE the \"-a\" option next time\n");
                    432:     fprintf (stderr, "you start it. If you are _not_ using Kickstart 1.2, then\n");
                    433:     fprintf (stderr, "there's a bug somewhere.\n");
                    434:     fprintf (stderr, "Exiting...\n");
                    435:     uae_quit ();
1.1       root      436: }
                    437: 
                    438: addrbank filesys_bank = {
                    439:     filesys_lget, filesys_wget, filesys_bget,
                    440:     filesys_lput, filesys_wput, filesys_bput,
                    441:     default_xlate, default_check
                    442: };
                    443: 
1.1.1.3   root      444: /*
                    445:  *  Z3fastmem Memory
                    446:  */
1.1       root      447: 
                    448: 
1.1.1.3   root      449: static uae_u32 z3fastmem_mask;
1.1       root      450: 
1.1.1.4   root      451: static uae_u32 z3fastmem_lget (uaecptr) REGPARAM;
                    452: static uae_u32 z3fastmem_wget (uaecptr) REGPARAM;
                    453: static uae_u32 z3fastmem_bget (uaecptr) REGPARAM;
                    454: static void z3fastmem_lput (uaecptr, uae_u32) REGPARAM;
                    455: static void z3fastmem_wput (uaecptr, uae_u32) REGPARAM;
                    456: static void z3fastmem_bput (uaecptr, uae_u32) REGPARAM;
                    457: static int z3fastmem_check (uaecptr addr, uae_u32 size) REGPARAM;
                    458: static uae_u8 *z3fastmem_xlate (uaecptr addr) REGPARAM;
1.1.1.3   root      459: 
                    460: static uae_u32 z3fastmem_start; /* Determined by the OS */
                    461: static uae_u8 *z3fastmem = NULL;
1.1       root      462: 
1.1.1.4   root      463: uae_u32 REGPARAM2 z3fastmem_lget (uaecptr addr)
1.1       root      464: {
1.1.1.3   root      465:     uae_u8 *m;
                    466:     addr -= z3fastmem_start & z3fastmem_mask;
                    467:     addr &= z3fastmem_mask;
                    468:     m = z3fastmem + addr;
                    469:     return do_get_mem_long ((uae_u32 *)m);
1.1       root      470: }
                    471: 
1.1.1.4   root      472: uae_u32 REGPARAM2 z3fastmem_wget (uaecptr addr)
1.1       root      473: {
1.1.1.3   root      474:     uae_u8 *m;
                    475:     addr -= z3fastmem_start & z3fastmem_mask;
                    476:     addr &= z3fastmem_mask;
                    477:     m = z3fastmem + addr;
                    478:     return do_get_mem_word ((uae_u16 *)m);
1.1       root      479: }
                    480: 
1.1.1.4   root      481: uae_u32 REGPARAM2 z3fastmem_bget (uaecptr addr)
1.1       root      482: {
1.1.1.3   root      483:     addr -= z3fastmem_start & z3fastmem_mask;
                    484:     addr &= z3fastmem_mask;
                    485:     return z3fastmem[addr];
1.1       root      486: }
                    487: 
1.1.1.4   root      488: void REGPARAM2 z3fastmem_lput (uaecptr addr, uae_u32 l)
1.1       root      489: {
1.1.1.3   root      490:     uae_u8 *m;
                    491:     addr -= z3fastmem_start & z3fastmem_mask;
                    492:     addr &= z3fastmem_mask;
                    493:     m = z3fastmem + addr;
                    494:     do_put_mem_long ((uae_u32 *)m, l);
1.1       root      495: }
                    496: 
1.1.1.4   root      497: void REGPARAM2 z3fastmem_wput (uaecptr addr, uae_u32 w)
1.1       root      498: {
1.1.1.3   root      499:     uae_u8 *m;
                    500:     addr -= z3fastmem_start & z3fastmem_mask;
                    501:     addr &= z3fastmem_mask;
                    502:     m = z3fastmem + addr;
                    503:     do_put_mem_word ((uae_u16 *)m, w);
1.1       root      504: }
                    505: 
1.1.1.4   root      506: void REGPARAM2 z3fastmem_bput (uaecptr addr, uae_u32 b)
1.1       root      507: {
1.1.1.3   root      508:     addr -= z3fastmem_start & z3fastmem_mask;
                    509:     addr &= z3fastmem_mask;
                    510:     z3fastmem[addr] = b;
1.1       root      511: }
                    512: 
1.1.1.4   root      513: static int REGPARAM2 z3fastmem_check (uaecptr addr, uae_u32 size)
1.1       root      514: {
1.1.1.3   root      515:     addr -= z3fastmem_start & z3fastmem_mask;
                    516:     addr &= z3fastmem_mask;
1.1.1.4   root      517:     return (addr + size) <= allocated_z3fastmem;
1.1       root      518: }
                    519: 
1.1.1.4   root      520: static uae_u8 REGPARAM2 *z3fastmem_xlate (uaecptr addr)
1.1       root      521: {
1.1.1.3   root      522:     addr -= z3fastmem_start & z3fastmem_mask;
                    523:     addr &= z3fastmem_mask;
                    524:     return z3fastmem + addr;
                    525: }
1.1       root      526: 
1.1.1.3   root      527: addrbank z3fastmem_bank = {
                    528:     z3fastmem_lget, z3fastmem_wget, z3fastmem_bget,
                    529:     z3fastmem_lput, z3fastmem_wput, z3fastmem_bput,
                    530:     z3fastmem_xlate, z3fastmem_check
                    531: };
1.1       root      532: 
1.1.1.3   root      533: /* Z3-based UAEGFX-card */
                    534: uae_u32 gfxmem_mask; /* for memory.c */
                    535: uae_u8 *gfxmemory;
                    536: uae_u32 gfxmem_start;
1.1       root      537: 
1.1.1.3   root      538: /* ********************************************************** */
1.1       root      539: 
1.1.1.2   root      540: /*
1.1       root      541:  *     Expansion Card (ZORRO II) for 1/2/4/8 MB of Fast Memory
1.1.1.2   root      542:  */
1.1       root      543: 
1.1.1.3   root      544: static void expamem_map_fastcard (void)
1.1       root      545: {
1.1.1.3   root      546:     fastmem_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
1.1.1.4   root      547:     map_banks (&fastmem_bank, fastmem_start >> 16, allocated_fastmem >> 16);
                    548:     write_log ("Fastcard: mapped @$%lx: %dMB fast memory\n", fastmem_start, allocated_fastmem >> 20);
1.1       root      549: }
                    550: 
1.1.1.3   root      551: static void expamem_init_fastcard (void)
1.1       root      552: {
                    553:     expamem_init_clear();
1.1.1.4   root      554:     if (allocated_fastmem == 0x100000)
1.1.1.3   root      555:        expamem_write (0x00, Z2_MEM_1MB + add_memory + zorroII);
1.1.1.4   root      556:     else if (allocated_fastmem == 0x200000)
1.1.1.3   root      557:        expamem_write (0x00, Z2_MEM_2MB + add_memory + zorroII);
1.1.1.4   root      558:     else if (allocated_fastmem == 0x400000)
1.1.1.3   root      559:        expamem_write (0x00, Z2_MEM_4MB + add_memory + zorroII);
1.1.1.4   root      560:     else if (allocated_fastmem == 0x800000)
1.1.1.3   root      561:        expamem_write (0x00, Z2_MEM_8MB + add_memory + zorroII);
1.1       root      562: 
                    563:     expamem_write (0x08, care_addr);
                    564: 
                    565:     expamem_write (0x04, 1);
1.1.1.3   root      566: 
1.1       root      567:     expamem_write (0x10, hackers_id >> 8);
1.1.1.3   root      568:     expamem_write (0x14, hackers_id & 0xff);
1.1       root      569: 
                    570:     expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
                    571:     expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
                    572:     expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
                    573:     expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
                    574: 
1.1.1.3   root      575:     expamem_write (0x28, 0x00); /* Rom-Offset hi */
                    576:     expamem_write (0x2c, 0x00); /* ROM-Offset lo */
1.1       root      577: 
                    578:     expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
                    579: }
                    580: 
1.1.1.3   root      581: /* ********************************************************** */
                    582: 
1.1       root      583: /* 
                    584:  * Filesystem device
                    585:  */
                    586: 
1.1.1.3   root      587: static void expamem_map_filesys (void)
1.1       root      588: {
1.1.1.3   root      589:     uaecptr a;
                    590: 
                    591:     filesys_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
                    592:     map_banks (&filesys_bank, filesys_start >> 16, 1);
1.1.1.5   root      593:     write_log ("Filesystem: mapped memory @$%lx.\n", filesys_start);
1.1.1.3   root      594:     /* 68k code needs to know this. */
                    595:     a = here ();
                    596:     org (0xF0FFFC);
                    597:     dl (filesys_start + 0x2000);
                    598:     org (a);
1.1       root      599: }
                    600: 
1.1.1.3   root      601: static void expamem_init_filesys (void)
1.1       root      602: {
1.1.1.5   root      603:     /* struct DiagArea - the size has to be large enough to store several device ROMTags */
                    604:     uae_u8 diagarea[] = { 0x90, 0x00, /* da_Config, da_Flags */
                    605:                           0x02, 0x00, /* da_Size */
                    606:                           0x01, 0x00, /* da_DiagPoint */
                    607:                           0x01, 0x06  /* da_BootPoint */
                    608:     };
1.1       root      609: 
                    610:     expamem_init_clear();
1.1.1.3   root      611:     expamem_write (0x00, Z2_MEM_64KB | rom_card | zorroII);
1.1       root      612: 
1.1.1.3   root      613:     expamem_write (0x08, no_shutup);
1.1       root      614: 
                    615:     expamem_write (0x04, 2);
                    616:     expamem_write (0x10, hackers_id >> 8);
1.1.1.3   root      617:     expamem_write (0x14, hackers_id & 0xff);
1.1       root      618: 
                    619:     expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
                    620:     expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
                    621:     expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
                    622:     expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
                    623: 
1.1.1.5   root      624:     /* er_InitDiagVec */
1.1.1.3   root      625:     expamem_write (0x28, 0x10); /* Rom-Offset hi */
                    626:     expamem_write (0x2c, 0x00); /* ROM-Offset lo */
1.1       root      627: 
                    628:     expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
                    629: 
                    630:     /* Build a DiagArea */
1.1.1.3   root      631:     memcpy (expamem + 0x1000, diagarea, sizeof diagarea);
                    632: 
1.1       root      633:     /* Call DiagEntry */
1.1.1.3   root      634:     do_put_mem_word ((uae_u16 *)(expamem + 0x1100), 0x4EF9); /* JMP */
                    635:     do_put_mem_long ((uae_u32 *)(expamem + 0x1102), ROM_filesys_diagentry);
                    636: 
1.1       root      637:     /* What comes next is a plain bootblock */
1.1.1.3   root      638:     do_put_mem_word ((uae_u16 *)(expamem + 0x1106), 0x4EF9); /* JMP */
                    639:     do_put_mem_long ((uae_u32 *)(expamem + 0x1108), EXPANSION_bootcode);
                    640: 
                    641:     memcpy (filesysory, expamem, 0x3000);
1.1       root      642: }
                    643: 
1.1.1.2   root      644: /*
1.1.1.3   root      645:  * Zorro III expansion memory
1.1.1.2   root      646:  */
1.1       root      647: 
1.1.1.3   root      648: static void expamem_map_z3fastmem (void)
1.1       root      649: {
1.1.1.3   root      650:     z3fastmem_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
1.1.1.4   root      651:     map_banks (&z3fastmem_bank, z3fastmem_start >> 16, currprefs.z3fastmem_size >> 16);
1.1.1.3   root      652: 
1.1.1.4   root      653:     write_log ("Fastmem (32bit): mapped @$%lx: %d MB Zorro III fast memory \n",
                    654:               z3fastmem_start, allocated_z3fastmem / 0x100000);
1.1.1.3   root      655: }
                    656: 
                    657: static void expamem_init_z3fastmem (void)
                    658: {
1.1.1.4   root      659:     int code = (allocated_z3fastmem == 0x100000 ? Z2_MEM_1MB
                    660:                : allocated_z3fastmem == 0x200000 ? Z2_MEM_2MB
                    661:                : allocated_z3fastmem == 0x400000 ? Z2_MEM_4MB
                    662:                : allocated_z3fastmem == 0x800000 ? Z2_MEM_8MB
                    663:                : allocated_z3fastmem == 0x1000000 ? Z2_MEM_16MB
                    664:                : allocated_z3fastmem == 0x2000000 ? Z2_MEM_32MB
                    665:                : allocated_z3fastmem == 0x4000000 ? Z2_MEM_64MB
                    666:                : allocated_z3fastmem == 0x8000000 ? Z2_MEM_128MB
                    667:                : allocated_z3fastmem == 0x10000000 ? Z2_MEM_256MB
                    668:                : allocated_z3fastmem == 0x20000000 ? Z2_MEM_512MB
1.1.1.3   root      669:                : Z2_MEM_1GB);
                    670:     expamem_init_clear();
                    671:     expamem_write (0x00, add_memory | zorroIII | code);
                    672: 
1.1.1.4   root      673:     expamem_write (0x08, no_shutup | force_z3 | (allocated_z3fastmem > 0x800000 ? ext_size : Z3_MEM_AUTO));
1.1.1.3   root      674: 
                    675:     expamem_write (0x04, 3);
                    676: 
                    677:     expamem_write (0x10, hackers_id >> 8);
                    678:     expamem_write (0x14, hackers_id & 0xff);
                    679: 
                    680:     expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
                    681:     expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
                    682:     expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
                    683:     expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
                    684: 
                    685:     expamem_write (0x28, 0x00); /* Rom-Offset hi */
                    686:     expamem_write (0x2c, 0x00); /* ROM-Offset lo */
                    687: 
                    688:     expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
1.1       root      689: }
                    690: 
1.1.1.3   root      691: #ifdef PICASSO96
                    692: /*
                    693:  *  Fake Graphics Card (ZORRO III) - BDK
                    694:  */
                    695: 
                    696: static void expamem_map_gfxcard (void)
1.1       root      697: {
1.1.1.3   root      698:     gfxmem_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
1.1.1.4   root      699:     map_banks (&gfxmem_bank, gfxmem_start >> 16, allocated_gfxmem >> 16);
                    700:     write_log ("UAEGFX-card: mapped @$%lx \n", gfxmem_start);
1.1       root      701: }
1.1.1.3   root      702: 
                    703: static void expamem_init_gfxcard (void)
                    704: {
                    705:     expamem_init_clear();
                    706:     expamem_write (0x00, zorroIII);
                    707: 
1.1.1.4   root      708:     switch (allocated_gfxmem) {
1.1.1.3   root      709:      case 0x00100000:
                    710:        expamem_write (0x08, no_shutup | force_z3 | Z3_MEM_1MB);
                    711:        break;
                    712:      case 0x00200000:
                    713:        expamem_write (0x08, no_shutup | force_z3 | Z3_MEM_2MB);
                    714:        break;
                    715:      case 0x00400000:
                    716:        expamem_write (0x08, no_shutup | force_z3 | Z3_MEM_4MB);
                    717:        break;
                    718:      case 0x00800000:
                    719:        expamem_write (0x08, no_shutup | force_z3 | Z3_MEM_8MB);
                    720:        break;
                    721:     }
                    722: 
                    723:     expamem_write (0x04, 96);
                    724: 
                    725:     expamem_write (0x10, hackers_id >> 8);
                    726:     expamem_write (0x14, hackers_id & 0xff);
                    727: 
                    728:     expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
                    729:     expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
                    730:     expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
                    731:     expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
                    732: 
                    733:     expamem_write (0x28, 0x00); /* Rom-Offset hi */
                    734:     expamem_write (0x2c, 0x00); /* ROM-Offset lo */
                    735: 
                    736:     expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
                    737: }
                    738: #endif
                    739: 
                    740: void expamem_reset()
                    741: {
                    742:     int cardno = 0;
                    743:     ecard = 0;
                    744: 
                    745:     if (fastmemory != NULL) {
                    746:        card_init[cardno] = expamem_init_fastcard;
                    747:        card_map[cardno++] = expamem_map_fastcard;
                    748:     }
                    749:     if (z3fastmem != NULL) {
                    750:        card_init[cardno] = expamem_init_z3fastmem;
                    751:        card_map[cardno++] = expamem_map_z3fastmem;
                    752:     }
                    753: #ifdef PICASSO96
                    754:     if (gfxmemory != NULL) {
                    755:        card_init[cardno] = expamem_init_gfxcard;
                    756:        card_map[cardno++] = expamem_map_gfxcard;
                    757:     }
                    758: #endif
                    759:     if (currprefs.automount_uaedev && !ersatzkickfile) {
                    760:        card_init[cardno] = expamem_init_filesys;
                    761:        card_map[cardno++] = expamem_map_filesys;
                    762:     }
                    763:     while (cardno < MAX_EXPANSION_BOARDS) {
                    764:        card_init[cardno] = expamem_init_clear;
                    765:        card_map[cardno++] = expamem_map_clear;
                    766:     }
                    767: 
                    768:     (*card_init[0]) ();
                    769: }
                    770: 
1.1.1.4   root      771: void expansion_init (void)
1.1.1.3   root      772: {
1.1.1.4   root      773:     allocated_fastmem = currprefs.fastmem_size;
                    774:     allocated_z3fastmem = currprefs.z3fastmem_size;
                    775:     allocated_gfxmem = currprefs.gfxmem_size;
                    776: 
                    777:     if (allocated_fastmem > 0) {
1.1.1.3   root      778:        do {
1.1.1.4   root      779:            fastmem_mask = allocated_fastmem - 1;
                    780:            fastmemory = (uae_u8 *)malloc (allocated_fastmem);
                    781:            if (fastmemory == 0)
                    782:                allocated_fastmem >>= 1;
                    783:        } while (fastmemory == 0 && allocated_fastmem >= 1024 * 1024);
                    784: 
                    785:        if (fastmemory == 0) {
1.1.1.3   root      786:            write_log ("Out of memory for fastmem card.\n");
1.1.1.4   root      787:            allocated_fastmem = 0;
1.1.1.3   root      788:        }
                    789:     }
1.1.1.4   root      790:     if (allocated_z3fastmem > 0) {
                    791:        z3fastmem_mask = allocated_z3fastmem - 1;
                    792:        z3fastmem = (uae_u8 *)malloc (allocated_z3fastmem);
                    793:        if (z3fastmem == 0) {
                    794:            write_log ("Out of memory for 32 bit fast memory.\n");
                    795:            allocated_z3fastmem = 0;
1.1.1.3   root      796:        }
                    797:     }
1.1.1.4   root      798:     if (allocated_gfxmem > 0) {
                    799:        gfxmem_mask = allocated_gfxmem - 1;
                    800:        gfxmemory = (uae_u8 *)malloc (allocated_gfxmem);
                    801:        if (gfxmemory == 0) {
                    802:            write_log ("Out of memory for graphics card memory\n");
                    803:            allocated_gfxmem = 0;
1.1.1.3   root      804:        }
                    805:     }
                    806: }
                    807: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.