--- uae/src/expansion.c 2018/04/24 17:01:53 1.1.1.9 +++ uae/src/expansion.c 2018/04/24 17:16:30 1.1.1.12 @@ -1,4 +1,4 @@ - /* + /* * UAE - The Un*x Amiga Emulator * * AutoConfig (tm) Expansions (ZorroII/III) @@ -12,7 +12,6 @@ #include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" #include "uae.h" #include "memory.h" @@ -134,7 +133,7 @@ static int ecard = 0; /* Please note: ZorroIII implementation seems to work different * than described in the HRM. This claims that ZorroIII config * address is 0xff000000 while the ZorroII config space starts - * at 0x00e80000. In reality, both, Z2 and Z3 cards are + * at 0x00e80000. In reality, both, Z2 and Z3 cards are * configured in the ZorroII config space. Kickstart 3.1 doesn't * even do a single read or write access to the ZorroIII space. * The original Amiga include files tell the same as the HRM. @@ -143,7 +142,7 @@ static int ecard = 0; * to a ZorroIII card on a real Amiga. This is not implemented * yet. * -- Stefan - * + * * Surprising that 0xFF000000 isn't used. Maybe it depends on the * ROM. Anyway, the HRM says that Z3 cards may appear in Z2 config * space, so what we are doing here is correct. @@ -162,13 +161,18 @@ static uae_u16 expamem_hi; static void expamem_map_clear (void) { - fprintf (stderr, "expamem_map_clear() got called. Shouldn't happen.\n"); + write_log ("expamem_map_clear() got called. Shouldn't happen.\n"); } static void expamem_init_clear (void) { memset (expamem, 0xff, sizeof expamem); } +static void expamem_init_clear2 (void) +{ + expamem_init_clear(); + ecard = MAX_EXPANSION_BOARDS - 1; +} static uae_u32 expamem_lget (uaecptr) REGPARAM; static uae_u32 expamem_wget (uaecptr) REGPARAM; @@ -244,7 +248,7 @@ static void REGPARAM2 expamem_wput (uaec if (ecard < MAX_EXPANSION_BOARDS) (*card_init[ecard]) (); else - expamem_init_clear (); + expamem_init_clear2 (); } break; } @@ -271,7 +275,7 @@ static void REGPARAM2 expamem_bput (uaec if (ecard < MAX_EXPANSION_BOARDS) (*card_init[ecard]) (); else - expamem_init_clear (); + expamem_init_clear2 (); } else if (expamem_type() == zorroIII) expamem_lo = value; break; @@ -287,7 +291,7 @@ static void REGPARAM2 expamem_bput (uaec if (ecard < MAX_EXPANSION_BOARDS) (*card_init[ecard]) (); else - expamem_init_clear (); + expamem_init_clear2 (); break; } } @@ -441,11 +445,11 @@ static void REGPARAM2 filesys_wput (uaec static void REGPARAM2 filesys_bput (uaecptr addr, uae_u32 b) { special_mem |= S_WRITE; - fprintf (stderr, "filesys_bput called. This usually means that you are using\n"); - fprintf (stderr, "Kickstart 1.2. Please give UAE the \"-a\" option next time\n"); - fprintf (stderr, "you start it. If you are _not_ using Kickstart 1.2, then\n"); - fprintf (stderr, "there's a bug somewhere.\n"); - fprintf (stderr, "Exiting...\n"); + write_log ("filesys_bput called. This usually means that you are using\n"); + write_log ("Kickstart 1.2. Please give UAE the \"-a\" option next time\n"); + write_log ("you start it. If you are _not_ using Kickstart 1.2, then\n"); + write_log ("there's a bug somewhere.\n"); + write_log ("Exiting...\n"); uae_quit (); } @@ -594,7 +598,7 @@ static void expamem_init_fastcard (void) /* ********************************************************** */ -/* +/* * Filesystem device */ @@ -607,7 +611,7 @@ static void expamem_map_filesys (void) write_log ("Filesystem: mapped memory @$%lx.\n", filesys_start); /* 68k code needs to know this. */ a = here (); - org (0xF0FFFC); + org (RTAREA_BASE+0xFFFC); dl (filesys_start + 0x2000); org (a); } @@ -616,9 +620,9 @@ static void expamem_init_filesys (void) { /* struct DiagArea - the size has to be large enough to store several device ROMTags */ uae_u8 diagarea[] = { 0x90, 0x00, /* da_Config, da_Flags */ - 0x02, 0x00, /* da_Size */ - 0x01, 0x00, /* da_DiagPoint */ - 0x01, 0x06 /* da_BootPoint */ + 0x02, 0x00, /* da_Size */ + 0x01, 0x00, /* da_DiagPoint */ + 0x01, 0x06 /* da_BootPoint */ }; expamem_init_clear(); @@ -775,39 +779,49 @@ static void allocate_expamem (void) } } } - if (allocated_z3fastmem != currprefs.z3fastmem_size) { + if (currprefs.address_space_24) { if (z3fastmem) mapped_free (z3fastmem); z3fastmem = 0; - - allocated_z3fastmem = currprefs.z3fastmem_size; - z3fastmem_mask = allocated_z3fastmem - 1; - - if (allocated_z3fastmem) { - z3fastmem = mapped_malloc (allocated_z3fastmem, "z3"); - if (z3fastmem == 0) { - write_log ("Out of memory for 32 bit fast memory.\n"); - allocated_z3fastmem = 0; - } - } - } - if (allocated_gfxmem != currprefs.gfxmem_size) { + allocated_z3fastmem = 0; if (gfxmemory) mapped_free (gfxmemory); gfxmemory = 0; - - allocated_gfxmem = currprefs.gfxmem_size; - gfxmem_mask = allocated_gfxmem - 1; - - if (allocated_gfxmem) { - gfxmemory = mapped_malloc (allocated_gfxmem, "gfx"); - if (gfxmemory == 0) { - write_log ("Out of memory for graphics card memory\n"); - allocated_gfxmem = 0; + allocated_gfxmem = 0; + } else { + if (allocated_z3fastmem != currprefs.z3fastmem_size) { + if (z3fastmem) + mapped_free (z3fastmem); + z3fastmem = 0; + + allocated_z3fastmem = currprefs.z3fastmem_size; + z3fastmem_mask = allocated_z3fastmem - 1; + + if (allocated_z3fastmem) { + z3fastmem = mapped_malloc (allocated_z3fastmem, "z3"); + if (z3fastmem == 0) { + write_log ("Out of memory for 32 bit fast memory.\n"); + allocated_z3fastmem = 0; + } + } + } + if (allocated_gfxmem != currprefs.gfxmem_size) { + if (gfxmemory) + mapped_free (gfxmemory); + gfxmemory = 0; + + allocated_gfxmem = currprefs.gfxmem_size; + gfxmem_mask = allocated_gfxmem - 1; + + if (allocated_gfxmem) { + gfxmemory = mapped_malloc (allocated_gfxmem, "gfx"); + if (gfxmemory == 0) { + write_log ("Out of memory for graphics card memory\n"); + allocated_gfxmem = 0; + } } } } - z3fastmem_bank.baseaddr = z3fastmem; fastmem_bank.baseaddr = fastmemory; @@ -846,6 +860,9 @@ void expamem_reset (void) write_log ("Kickstart version is below 1.3! Disabling autoconfig devices.\n"); do_mount = 0; } + /* No need for filesystem stuff if there aren't any mounted. */ + if (nr_units (currprefs.mountinfo) == 0) + do_mount = 0; if (fastmemory != NULL) { card_init[cardno] = expamem_init_fastcard; @@ -890,7 +907,6 @@ void expansion_init (void) exit (0); } filesys_bank.baseaddr = (uae_u8*)filesysory; - } void expansion_cleanup (void) @@ -935,16 +951,19 @@ void restore_zram (int len, long filepos changed_prefs.z3fastmem_size = len; } -uae_u8 *save_expansion (int *len) +uae_u8 *save_expansion (int *len, uae_u8 *dstptr) { - static uae_u8 t[20], *dst = t; + static uae_u8 t[20]; + uae_u8 *dst = t, *dstbak = t; + if (dstptr) + dst = dstbak = dstptr; save_u32 (fastmem_start); save_u32 (z3fastmem_start); *len = 8; return dst; } -uae_u8 *restore_expansion (uae_u8 *src) +const uae_u8 *restore_expansion (const uae_u8 *src) { fastmem_start = restore_u32 (); z3fastmem_start = restore_u32 ();