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

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

unix.superglobalmegacorp.com

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