--- uae/src/memory.c 2018/04/24 17:00:14 1.1.1.9 +++ uae/src/memory.c 2018/04/24 17:05:45 1.1.1.11 @@ -18,6 +18,7 @@ #include "custom.h" #include "events.h" #include "newcpu.h" +#include "autoconf.h" #include "savestate.h" #ifdef USE_MAPPED_MEMORY @@ -79,6 +80,7 @@ __inline__ void byteput (uaecptr addr, u uae_u32 chipmem_mask, kickmem_mask, bogomem_mask, a3000mem_mask; +static int illegal_count; /* A dummy bank that only contains zeros */ static uae_u32 dummy_lget (uaecptr) REGPARAM; @@ -92,8 +94,12 @@ static int dummy_check (uaecptr addr, ua uae_u32 REGPARAM2 dummy_lget (uaecptr addr) { special_mem |= S_READ; - if (currprefs.illegal_mem) - write_log ("Illegal lget at %08lx\n", addr); + if (currprefs.illegal_mem) { + if (illegal_count < 20) { + illegal_count++; + write_log ("Illegal lget at %08lx\n", addr); + } + } return 0xFFFFFFFF; } @@ -101,17 +107,25 @@ uae_u32 REGPARAM2 dummy_lget (uaecptr ad uae_u32 REGPARAM2 dummy_wget (uaecptr addr) { special_mem |= S_READ; - if (currprefs.illegal_mem) - write_log ("Illegal wget at %08lx\n", addr); - + if (currprefs.illegal_mem) { + if (illegal_count < 20) { + illegal_count++; + write_log ("Illegal wget at %08lx\n", addr); + } + } + return 0xFFFF; } uae_u32 REGPARAM2 dummy_bget (uaecptr addr) { special_mem |= S_READ; - if (currprefs.illegal_mem) - write_log ("Illegal bget at %08lx\n", addr); + if (currprefs.illegal_mem) { + if (illegal_count < 20) { + illegal_count++; + write_log ("Illegal bget at %08lx\n", addr); + } + } return 0xFF; } @@ -119,27 +133,43 @@ uae_u32 REGPARAM2 dummy_bget (uaecptr ad void REGPARAM2 dummy_lput (uaecptr addr, uae_u32 l) { special_mem |= S_WRITE; - if (currprefs.illegal_mem) - write_log ("Illegal lput at %08lx\n", addr); + if (currprefs.illegal_mem) { + if (illegal_count < 20) { + illegal_count++; + write_log ("Illegal lput at %08lx\n", addr); + } + } } void REGPARAM2 dummy_wput (uaecptr addr, uae_u32 w) { special_mem |= S_WRITE; - if (currprefs.illegal_mem) - write_log ("Illegal wput at %08lx\n", addr); + if (currprefs.illegal_mem) { + if (illegal_count < 20) { + illegal_count++; + write_log ("Illegal wput at %08lx\n", addr); + } + } } void REGPARAM2 dummy_bput (uaecptr addr, uae_u32 b) { special_mem |= S_WRITE; - if (currprefs.illegal_mem) - write_log ("Illegal bput at %08lx\n", addr); + if (currprefs.illegal_mem) { + if (illegal_count < 20) { + illegal_count++; + write_log ("Illegal bput at %08lx\n", addr); + } + } } int REGPARAM2 dummy_check (uaecptr addr, uae_u32 size) { special_mem |= S_READ; - if (currprefs.illegal_mem) - write_log ("Illegal check at %08lx\n", addr); + if (currprefs.illegal_mem) { + if (illegal_count < 20) { + illegal_count++; + write_log ("Illegal check at %08lx\n", addr); + } + } return 0; } @@ -538,7 +568,7 @@ static int load_kickstart (void) #if defined AMIGA || defined __POS__ #define USE_UAE_ERSATZ "USE_UAE_ERSATZ" if (!getenv (USE_UAE_ERSATZ)) { - fprintf (stderr, "Using current ROM. (create ENV:%s to " + write_log ("Using current ROM. (create ENV:%s to " "use uae's ROM replacement)\n", USE_UAE_ERSATZ); memcpy (kickmemory, (char*)0x1000000 - kickmem_size, kickmem_size); goto chk_sum; @@ -797,7 +827,7 @@ uae_u8 *mapped_malloc (size_t s, char *f return mapped_malloc (s, file); } -void mapped_free (uae_u8 base) +void mapped_free (uae_u8 *base) { shmpiece *x = find_shmpiece (base); if (! x) @@ -892,6 +922,19 @@ void memory_reset (void) allocate_memory (); + if (strcmp (currprefs.romfile, changed_prefs.romfile) != 0 + || strcmp (currprefs.keyfile, changed_prefs.keyfile) != 0) + { + ersatzkickfile = 0; + memcpy (currprefs.romfile, changed_prefs.romfile, sizeof currprefs.romfile); + memcpy (currprefs.keyfile, changed_prefs.keyfile, sizeof currprefs.keyfile); + /* Clear out whatever data remains across a reset. */ + memset (chipmemory, 0, allocated_chipmem); + if (! load_kickstart ()) { + init_ersatz_rom (kickmemory); + ersatzkickfile = 1; + } + } /* Map the chipmem into all of the lower 8MB */ i = allocated_chipmem > 0x200000 ? (allocated_chipmem >> 16) : 32; map_banks (&chipmem_bank, 0x00, i, allocated_chipmem); @@ -920,7 +963,7 @@ void memory_reset (void) map_banks (&a3000mem_bank, a3000mem_start >> 16, allocated_a3000mem >> 16, allocated_a3000mem); - map_banks (&rtarea_bank, 0xF0, 1, 0); + map_banks (&rtarea_bank, RTAREA_BASE >> 16, 1, 0); map_banks (&kickmem_bank, 0xF8, 8, 0); map_banks (&expamem_bank, 0xE8, 1, 0); @@ -953,11 +996,27 @@ void memory_init (void) kickmem_mask = kickmem_size - 1; } +void memory_cleanup( void ) +{ + if (a3000memory) + mapped_free (a3000memory); + if (bogomemory) + mapped_free (bogomemory); + if (kickmemory) + mapped_free (kickmemory); + if (chipmemory) + mapped_free (chipmemory); + + a3000memory = 0; + bogomemory = 0; + kickmemory = 0; + chipmemory = 0; +} + void map_banks (addrbank *bank, int start, int size, int realsize) { int bnr; unsigned long int hioffs = 0, endhioffs = 0x100; - int real_left; addrbank* orgbank = bank; uae_u32 realstart = start; @@ -968,17 +1027,17 @@ void map_banks (addrbank *bank, int star if (!realsize) realsize = size << 16; - real_left = 0; if ((size << 16) < realsize) { - fprintf (stderr, "Please report to bmeyer@cs.monash.edu.au, and mention:\n"); - fprintf (stderr, "Broken mapping, size=%x, realsize=%x\n",size,realsize); - fprintf (stderr, "Start is %x\n",start); - fprintf (stderr, "Reducing memory sizes, especially chipmem, may fix this problem\n"); + write_log ("Please report to bmeyer@cs.monash.edu.au, and mention:\n"); + write_log ("Broken mapping, size=%x, realsize=%x\n",size,realsize); + write_log ("Start is %x\n",start); + write_log ("Reducing memory sizes, especially chipmem, may fix this problem\n"); abort (); } if (start >= 0x100) { + int real_left = 0; for (bnr = start; bnr < start + size; bnr++) { if (!real_left) { realstart = bnr; @@ -992,8 +1051,10 @@ void map_banks (addrbank *bank, int star } return; } + if (currprefs.address_space_24) + endhioffs = 0x10000; for (hioffs = 0; hioffs < endhioffs; hioffs += 0x100) { - real_left=0; + int real_left = 0; for (bnr = start; bnr < start+size; bnr++) { if (!real_left) { realstart = bnr + hioffs;