uae_u8 *mapped_malloc (size_t s, char *file) { int id; void *answer; shmpiece *x; if (!canbang) return xmalloc (s); id = shmget (IPC_PRIVATE, s, 0x1ff, file); if (id == 1) { canbang = 0; return mapped_malloc (s, file); } answer = shmat (id, 0, 0); shmctl (id, IPC_RMID, NULL); if (answer != (void *) -1) { x = xmalloc (sizeof (shmpiece)); x->native_address = answer; x->id = id; x->size = s; x->next = shm_start; x->prev = NULL; if (x->next) x->next->prev = x; shm_start = x; return answer; } canbang = 0; return mapped_malloc (s, file); }
static int load_extendedkickstart (void) { struct zfile *f; int size; if (strlen (currprefs.romextfile) == 0) return 0; f = zfile_open (currprefs.romextfile, "rb"); if (!f) { printf ("No extended Kickstart ROM found"); return 0; } zfile_fseek (f, 0, SEEK_END); size = zfile_ftell (f); if (size > 300000) extendedkickmem_size = 524288; else extendedkickmem_size = 262144; zfile_fseek (f, 0, SEEK_SET); switch (extromtype ()) { case EXTENDED_ROM_CDTV: extendedkickmemory = (uae_u8 *) mapped_malloc (extendedkickmem_size, "rom_f0"); extendedkickmem_bank.baseaddr = (uae_u8 *) extendedkickmemory; break; case EXTENDED_ROM_CD32: extendedkickmemory = (uae_u8 *) mapped_malloc (extendedkickmem_size, "rom_e0"); extendedkickmem_bank.baseaddr = (uae_u8 *) extendedkickmemory; break; } read_kickstart (f, extendedkickmemory, 524288, 0, 0); return 1; }
static void allocate_memory (void) { if (allocated_chipmem != prefs_chipmem_size) { if (chipmemory) mapped_free (chipmemory); chipmemory = 0; allocated_chipmem = prefs_chipmem_size; chipmem_mask = allocated_chipmem - 1; chipmemory = (uae_u8 *)mapped_malloc (allocated_chipmem, "chip"); if (chipmemory == 0) { write_log ("Fatal error: out of memory for chipmem.\n"); allocated_chipmem = 0; } else do_put_mem_long ((uae_u32 *)(chipmemory + 4), swab_l(0)); } if (savestate_state == STATE_RESTORE) { fseek (savestate_file, chip_filepos, SEEK_SET); #ifdef USE_LIB7Z void *tmp=malloc(compressed_size); int outSize=allocated_chipmem; int inSize=compressed_size; SRes res; fread (tmp, 1, compressed_size, savestate_file); res=Lzma_Decode((Byte *)chipmemory, (size_t *)&outSize, (const Byte *)tmp, (size_t *)&inSize); free(tmp); if(res != SZ_OK) { allocated_chipmem=compressed_size; fseek (savestate_file, chip_filepos, SEEK_SET); } if(res != SZ_OK) #endif fread (chipmemory, 1, allocated_chipmem, savestate_file); if (allocated_bogomem > 0) { fseek (savestate_file, bogo_filepos, SEEK_SET); fread (bogomemory, 1, allocated_bogomem, savestate_file); } } chipmem_bank.baseaddr = chipmemory; bogomem_bank.baseaddr = bogomemory; chipmemory_word=(uae_u16 *)chipmemory; }
static void rtarea_init_mem (void) { rtarea = mapped_malloc (0x10000, "rtarea"); if (!rtarea) { write_log ("virtual memory exhausted (rtarea)!\n"); return; } /* TODO: *** reinitializing rtarea with filesys/expansion code *** * Moved here from memory_reset(), so we don't lose all the extension/filesys * traps that will be set up later */ rtarea_cleanup(); /* FAMEC fast (direct) memory access instead of functions */ rtarea_bank.baseaddr = rtarea; }
static void allocate_memory (void) { if (allocated_chipmem != prefs_chipmem_size) { if (chipmemory) mapped_free (chipmemory); chipmemory = 0; allocated_chipmem = prefs_chipmem_size; chipmem_mask = allocated_chipmem - 1; chipmemory = mapped_malloc (allocated_chipmem, "chip"); if (chipmemory == 0) { write_log ("Fatal error: out of memory for chipmem.\n"); allocated_chipmem = 0; } else do_put_mem_long ((uae_u32 *)(chipmemory + 4), swab_l(0)); } chipmem_bank.baseaddr = chipmemory; bogomem_bank.baseaddr = bogomemory; chipmemory_word=(uae_u16 *)chipmemory; }
static void allocate_memory (void) { if (allocated_chipmem != currprefs.chipmem_size) { uae_u32 memsize; if (chipmemory) mapped_free (chipmemory); chipmemory = 0; memsize = allocated_chipmem = currprefs.chipmem_size; chipmem_mask = allocated_chipmem - 1; if (memsize < 0x100000) memsize = 0x100000; chipmemory = mapped_malloc (memsize, "chip"); if (chipmemory == 0) { printf ("Fatal error: out of memory for chipmem.\n"); allocated_chipmem = 0; } else { need_hardreset = 1; if (memsize != allocated_chipmem) memset (chipmemory + allocated_chipmem, 0xff, memsize - allocated_chipmem); } } chipmem_full_mask = allocated_chipmem - 1; if ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) && allocated_chipmem < 0x100000) chipmem_full_mask = 0x100000 - 1; if (allocated_bogomem != currprefs.bogomem_size) { if (bogomemory) mapped_free (bogomemory); bogomemory = 0; allocated_bogomem = currprefs.bogomem_size; bogomem_mask = allocated_bogomem - 1; if (allocated_bogomem) { bogomemory = mapped_malloc (allocated_bogomem, "bogo"); if (bogomemory == 0) { printf ("Out of memory for bogomem.\n"); allocated_bogomem = 0; } } need_hardreset = 1; } if (allocated_a3000lmem != currprefs.mbresmem_low_size) { if (a3000lmemory) mapped_free (a3000lmemory); a3000lmemory = 0; allocated_a3000lmem = currprefs.mbresmem_low_size; a3000lmem_mask = allocated_a3000lmem - 1; a3000lmem_start = 0x08000000 - allocated_a3000lmem; if (allocated_a3000lmem) { a3000lmemory = mapped_malloc (allocated_a3000lmem, "ramsey_low"); if (a3000lmemory == 0) { printf ("Out of memory for a3000lowmem.\n"); allocated_a3000lmem = 0; } } need_hardreset = 1; } if (allocated_a3000hmem != currprefs.mbresmem_high_size) { if (a3000hmemory) mapped_free (a3000hmemory); a3000hmemory = 0; allocated_a3000hmem = currprefs.mbresmem_high_size; a3000hmem_mask = allocated_a3000hmem - 1; a3000hmem_start = 0x08000000; if (allocated_a3000hmem) { a3000hmemory = mapped_malloc (allocated_a3000hmem, "ramsey_high"); if (a3000hmemory == 0) { printf ("Out of memory for a3000highmem.\n"); allocated_a3000hmem = 0; } } need_hardreset = 1; } if (savestate_state == STATE_RESTORE) { restore_ram (chip_filepos, chipmemory); if (allocated_bogomem > 0) { restore_ram (bogo_filepos, bogomemory); } if (allocated_a3000lmem > 0) restore_ram (a3000lmem_filepos, a3000lmemory); if (allocated_a3000hmem > 0) restore_ram (a3000hmem_filepos, a3000hmemory); } chipmem_bank.baseaddr = chipmemory; bogomem_bank.baseaddr = bogomemory; a3000lmem_bank.baseaddr = a3000lmemory; a3000hmem_bank.baseaddr = a3000hmemory; }