fakeFastMem

parent 395371b8
......@@ -36,29 +36,29 @@
/* 00 / 02 */
/* er_Type */
#define Z2_MEM_8MB 0x00 /* Size of Memory Block */
#define Z2_MEM_4MB 0x07
#define Z2_MEM_2MB 0x06
#define Z2_MEM_1MB 0x05
#define Z2_MEM_8MB 0x00 /* Size of Memory Block */
#define Z2_MEM_4MB 0x07
#define Z2_MEM_2MB 0x06
#define Z2_MEM_1MB 0x05
#define Z2_MEM_512KB 0x04
#define Z2_MEM_256KB 0x03
#define Z2_MEM_128KB 0x02
#define Z2_MEM_64KB 0x01
#define Z2_MEM_64KB 0x01
/* extended definitions */
#define Z2_MEM_16MB 0x00
#define Z2_MEM_32MB 0x01
#define Z2_MEM_64MB 0x02
#define Z2_MEM_16MB 0x00
#define Z2_MEM_32MB 0x01
#define Z2_MEM_64MB 0x02
#define Z2_MEM_128MB 0x03
#define Z2_MEM_256MB 0x04
#define Z2_MEM_512MB 0x05
#define Z2_MEM_1GB 0x06
#define Z2_MEM_1GB 0x06
#define chainedconfig 0x08 /* Next config is part of the same card */
#define rom_card 0x10 /* ROM vector is valid */
#define add_memory 0x20 /* Link RAM into free memory list */
#define rom_card 0x10 /* ROM vector is valid */
#define add_memory 0x20 /* Link RAM into free memory list */
#define zorroII 0xc0 /* Type of Expansion Card */
#define zorroIII 0x80
#define zorroII 0xc0 /* Type of Expansion Card */
#define zorroIII 0x80
/* ********************************************************** */
/* 04 - 06 & 10-16 */
......@@ -66,8 +66,8 @@
/* Manufacturer */
#define commodore_g 513 /* Commodore Braunschweig (Germany) */
#define commodore 514 /* Commodore West Chester */
#define gvp 2017 /* GVP */
#define ass 2102 /* Advanced Systems & Software */
#define gvp 2017 /* GVP */
#define ass 2102 /* Advanced Systems & Software */
#define hackers_id 2011 /* Special ID for test cards */
/* Card Type */
......@@ -82,7 +82,7 @@
/* ********************************************************** */
/* 08 - 0A */
/* er_Flags */
#define Z3_MEM_64KB 0x02
#define Z3_MEM_64KB 0x02
#define Z3_MEM_128KB 0x03
#define Z3_MEM_256KB 0x04
#define Z3_MEM_512KB 0x05
......@@ -180,7 +180,7 @@ static void REGPARAM3 expamem_bput (uaecptr, uae_u32) REGPARAM;
addrbank expamem_bank = {
expamem_lget, expamem_wget, expamem_bget,
expamem_lput, expamem_wput, expamem_bput,
default_xlate, default_check, NULL, "Autoconfig",
default_xlate, default_check, NULL, "Autoconfig",
dummy_lgeti, dummy_wgeti, ABFLAG_IO | ABFLAG_SAFE
};
......@@ -230,7 +230,7 @@ static uae_u32 REGPARAM2 expamem_bget (uaecptr addr)
{
uae_u8 b;
#ifdef JIT
special_mem |= SPECIAL_MEM_READ;
special_mem |= SPECIAL_MEM_READ;
#endif
addr &= 0xFFFF;
b = expamem[addr];
......@@ -241,7 +241,7 @@ static uae_u32 REGPARAM2 expamem_bget (uaecptr addr)
static void REGPARAM2 expamem_write (uaecptr addr, uae_u32 value)
{
#ifdef JIT
special_mem |= SPECIAL_MEM_WRITE;
special_mem |= SPECIAL_MEM_WRITE;
#endif
addr &= 0xffff;
if (addr == 00 || addr == 02 || addr == 0x40 || addr == 0x42) {
......@@ -261,15 +261,15 @@ static int REGPARAM2 expamem_type (void)
static void REGPARAM2 expamem_lput (uaecptr addr, uae_u32 value)
{
#ifdef JIT
special_mem |= SPECIAL_MEM_WRITE;
special_mem |= SPECIAL_MEM_WRITE;
#endif
write_log ("warning: WRITE.L to address $%lx : value $%lx\n", addr, value);
write_log ("warning: WRITE.L to address $%lx : value $%lx\n", addr, value);
}
static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value)
{
#ifdef JIT
special_mem |= SPECIAL_MEM_WRITE;
special_mem |= SPECIAL_MEM_WRITE;
#endif
value &= 0xffff;
if (ecard >= cardno)
......@@ -285,10 +285,17 @@ static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value)
p1 = get_word (regs.regs[11] + 0x20);
if (expamem[0] & add_memory) {
// Z3 RAM expansion
if (z3num == 0)
p2 = 0;
while (!p2 && z3num < 3) {
if (z3num == 0 && currprefs.z3fastmem_size)
p2 = z3fastmem_start >> 16;
else
else if (z3num == 1 && currprefs.z3fastmem2_size)
p2 = z3fastmem2_start >> 16;
else if (z3num == 2 && currprefs.z3chipmem_size)
p2 = z3chipmem_start >> 16;
if (!p2)
z3num++;
}
z3num++;
} else {
// Z3 P96 RAM
......@@ -316,7 +323,7 @@ static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value)
static void REGPARAM2 expamem_bput (uaecptr addr, uae_u32 value)
{
#ifdef JIT
special_mem |= SPECIAL_MEM_WRITE;
special_mem |= SPECIAL_MEM_WRITE;
#endif
if (ecard >= cardno)
return;
......@@ -349,7 +356,7 @@ static void REGPARAM2 expamem_bput (uaecptr addr, uae_u32 value)
break;
case 0x4c:
write_log (" Card %d (Zorro %s) had no success.\n", ecard + 1, expamem_type() == 0xc0 ? "II" : "III");
write_log (" Card %d (Zorro%s) had no success.\n", ecard + 1, expamem_type() == 0xc0 ? "II" : "III");
++ecard;
if (ecard < cardno)
(*card_init[ecard]) ();
......@@ -475,7 +482,7 @@ static uae_u8 *REGPARAM2 fastmem_xlate (uaecptr addr)
addrbank fastmem_bank = {
fastmem_lget, fastmem_wget, fastmem_bget,
fastmem_lput, fastmem_wput, fastmem_bput,
fastmem_xlate, fastmem_check, NULL, "Fast memory",
fastmem_xlate, fastmem_check, NULL, "Fast memory",
fastmem_lget, fastmem_wget, ABFLAG_RAM
};
......@@ -503,7 +510,7 @@ static uae_u32 REGPARAM2 catweasel_lget (uaecptr addr)
#ifdef JIT
special_mem |= SPECIAL_MEM_READ;
#endif
write_log ("catweasel_lget @%08X!\n",addr);
write_log ("catweasel_lget @%08X!\n",addr);
return 0;
}
......@@ -512,7 +519,7 @@ static uae_u32 REGPARAM2 catweasel_wget (uaecptr addr)
#ifdef JIT
special_mem |= SPECIAL_MEM_READ;
#endif
write_log ("catweasel_wget @%08X!\n",addr);
write_log ("catweasel_wget @%08X!\n",addr);
return 0;
}
......@@ -685,7 +692,7 @@ static void REGPARAM2 filesys_bput (uaecptr addr, uae_u32 b)
static addrbank filesys_bank = {
filesys_lget, filesys_wget, filesys_bget,
filesys_lput, filesys_wput, filesys_bput,
default_xlate, default_check, NULL, "Filesystem Autoconfig Area",
default_xlate, default_check, NULL, "Filesystem Autoconfig Area",
dummy_lgeti, dummy_wgeti, ABFLAG_IO | ABFLAG_SAFE
};
......@@ -695,9 +702,9 @@ static addrbank filesys_bank = {
* Z3fastmem Memory
*/
static uae_u32 z3fastmem_mask, z3fastmem2_mask;
uaecptr z3fastmem_start, z3fastmem2_start;
static uae_u8 *z3fastmem, *z3fastmem2;
static uae_u32 z3fastmem_mask, z3fastmem2_mask, z3chipmem_mask;
uaecptr z3fastmem_start, z3fastmem2_start, z3chipmem_start;
static uae_u8 *z3fastmem, *z3fastmem2, *z3chipmem;
static uae_u32 REGPARAM2 z3fastmem_lget (uaecptr addr)
{
......@@ -813,6 +820,65 @@ static uae_u8 *REGPARAM2 z3fastmem2_xlate (uaecptr addr)
addr &= z3fastmem2_mask;
return z3fastmem2 + addr;
}
static uae_u32 REGPARAM2 z3chipmem_lget (uaecptr addr)
{
uae_u8 *m;
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
m = z3chipmem + addr;
return do_get_mem_long ((uae_u32 *)m);
}
static uae_u32 REGPARAM2 z3chipmem_wget (uaecptr addr)
{
uae_u8 *m;
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
m = z3chipmem + addr;
return do_get_mem_word ((uae_u16 *)m);
}
static uae_u32 REGPARAM2 z3chipmem_bget (uaecptr addr)
{
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
return z3chipmem[addr];
}
static void REGPARAM2 z3chipmem_lput (uaecptr addr, uae_u32 l)
{
uae_u8 *m;
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
m = z3chipmem + addr;
do_put_mem_long ((uae_u32 *)m, l);
}
static void REGPARAM2 z3chipmem_wput (uaecptr addr, uae_u32 w)
{
uae_u8 *m;
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
m = z3chipmem + addr;
do_put_mem_word ((uae_u16 *)m, w);
}
static void REGPARAM2 z3chipmem_bput (uaecptr addr, uae_u32 b)
{
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
z3chipmem[addr] = b;
}
static int REGPARAM2 z3chipmem_check (uaecptr addr, uae_u32 size)
{
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
return (addr + size) <= allocated_z3chipmem;
}
static uae_u8 *REGPARAM2 z3chipmem_xlate (uaecptr addr)
{
addr -= z3chipmem_start & z3chipmem_mask;
addr &= z3chipmem_mask;
return z3chipmem + addr;
}
addrbank z3fastmem_bank = {
z3fastmem_lget, z3fastmem_wget, z3fastmem_bget,
z3fastmem_lput, z3fastmem_wput, z3fastmem_bput,
......@@ -825,6 +891,12 @@ addrbank z3fastmem2_bank = {
z3fastmem2_xlate, z3fastmem2_check, NULL, "ZorroIII Fast RAM #2",
z3fastmem2_lget, z3fastmem2_wget, ABFLAG_RAM
};
addrbank z3chipmem_bank = {
z3chipmem_lget, z3chipmem_wget, z3chipmem_bget,
z3chipmem_lput, z3chipmem_wput, z3chipmem_bput,
z3chipmem_xlate, z3chipmem_check, NULL, "ZorroIII FakeChipRAM",
z3chipmem_lget, z3chipmem_wget, ABFLAG_RAM
};
/* Z3-based UAEGFX-card */
uae_u32 gfxmem_mask; /* for memory.c */
......@@ -973,6 +1045,11 @@ static void expamem_map_z3fastmem2 (void)
{
expamem_map_z3fastmem_2 (&z3fastmem2_bank, &z3fastmem2_start, currprefs.z3fastmem2_size, allocated_z3fastmem2);
}
static void expamem_map_z3chipmem (void)
{
expamem_map_z3fastmem_2 (&z3chipmem_bank, &z3chipmem_start, currprefs.z3chipmem_size, allocated_z3chipmem);
}
static void expamem_init_z3fastmem_2 (addrbank *bank, uae_u32 start, uae_u32 size, uae_u32 allocated)
{
......@@ -1019,6 +1096,10 @@ static void expamem_init_z3fastmem2 (void)
{
expamem_init_z3fastmem_2 (&z3fastmem2_bank, z3fastmem2_start, currprefs.z3fastmem2_size, allocated_z3fastmem2);
}
static void expamem_init_z3chipmem (void)
{
expamem_init_z3fastmem_2 (&z3chipmem_bank, z3chipmem_start, currprefs.z3chipmem_size, allocated_z3chipmem);
}
#ifdef PICASSO96
/*
......@@ -1076,7 +1157,7 @@ static void expamem_init_gfxcard (void)
#ifdef SAVESTATE
static size_t fast_filepos, z3_filepos, z3_filepos2, p96_filepos;
static size_t fast_filepos, z3_filepos, z3_filepos2, z3_fileposchip, p96_filepos;
#endif
void free_fastmemory (void)
......@@ -1092,6 +1173,7 @@ static void allocate_expamem (void)
currprefs.z3fastmem_size = changed_prefs.z3fastmem_size;
currprefs.z3fastmem2_size = changed_prefs.z3fastmem2_size;
currprefs.gfxmem_size = changed_prefs.gfxmem_size;
currprefs.z3chipmem_size = changed_prefs.z3chipmem_size;
if (allocated_fastmem != currprefs.fastmem_size) {
free_fastmemory ();
......@@ -1141,6 +1223,24 @@ static void allocate_expamem (void)
}
memory_hardreset ();
}
if (allocated_z3chipmem != currprefs.z3chipmem_size) {
if (z3chipmem)
mapped_free (z3chipmem);
z3chipmem = 0;
allocated_z3chipmem = currprefs.z3chipmem_size;
z3chipmem_mask = allocated_z3chipmem - 1;
if (allocated_z3chipmem) {
z3chipmem = mapped_malloc (allocated_z3chipmem, "z3_chip");
if (z3chipmem == 0) {
write_log ("Out of memory for 32 bit fake chip memory.\n");
allocated_z3chipmem = 0;
}
}
memory_hardreset ();
}
#ifdef PICASSO96
if (allocated_gfxmem != currprefs.gfxmem_size) {
if (gfxmemory)
......@@ -1163,6 +1263,7 @@ static void allocate_expamem (void)
z3fastmem_bank.baseaddr = z3fastmem;
z3fastmem2_bank.baseaddr = z3fastmem2;
z3chipmem_bank.baseaddr = z3chipmem;
fastmem_bank.baseaddr = fastmemory;
gfxmem_bank.baseaddr = gfxmemory;
......@@ -1183,6 +1284,11 @@ static void allocate_expamem (void)
map_banks (&z3fastmem2_bank, z3fastmem2_start >> 16, currprefs.z3fastmem2_size >> 16,
allocated_z3fastmem2);
}
if (allocated_z3chipmem > 0) {
restore_ram (z3_fileposchip, z3chipmem);
map_banks (&z3chipmem_bank, z3chipmem_start >> 16, currprefs.z3chipmem_size >> 16,
allocated_z3fastmem2);
}
#ifdef PICASSO96
if (allocated_gfxmem > 0 && gfxmem_start > 0) {
restore_ram (p96_filepos, gfxmemory);
......@@ -1287,9 +1393,9 @@ static void expamem_init_a4091 (void)
void p96memstart(void)
{
/* make sure there is always empty space between Z3 and P96 RAM */
p96ram_start = currprefs.z3fastmem_start + ((currprefs.z3fastmem_size + currprefs.z3fastmem2_size + 0xffffff) & ~0xffffff);
if (p96ram_start == currprefs.z3fastmem_start + currprefs.z3fastmem_size + currprefs.z3fastmem2_size &&
(currprefs.z3fastmem_size + currprefs.z3fastmem2_size < 512 * 1024 * 1024 || currprefs.gfxmem_size < 128 * 1024 * 1024))
p96ram_start = currprefs.z3fastmem_start + ((currprefs.z3fastmem_size + currprefs.z3fastmem2_size + currprefs.z3chipmem_size + 0xffffff) & ~0xffffff);
if (p96ram_start == currprefs.z3fastmem_start + currprefs.z3fastmem_size + currprefs.z3fastmem2_size + currprefs.z3chipmem_size &&
(currprefs.z3fastmem_size + currprefs.z3fastmem2_size + currprefs.z3chipmem_size < 512 * 1024 * 1024 || currprefs.gfxmem_size < 128 * 1024 * 1024))
p96ram_start += 0x1000000;
}
......@@ -1338,6 +1444,15 @@ void expamem_reset (void)
map_banks (&z3fastmem2_bank, z3fastmem2_start >> 16, currprefs.z3fastmem2_size >> 16, allocated_z3fastmem2);
}
}
z3chipmem_start = z3fastmem2_start + currprefs.z3fastmem2_size;
if (currprefs.z3fastmem_size || currprefs.z3fastmem2_size)
z3chipmem_start += 16 * 1024 * 1024;
if (z3chipmem != NULL) {
z3num = 0;
card_init[cardno] = expamem_init_z3chipmem;
card_map[cardno++] = expamem_map_z3chipmem;
map_banks (&z3chipmem_bank, z3chipmem_start >> 16, currprefs.z3chipmem_size >> 16, allocated_z3chipmem);
}
#ifdef CDTV
if (currprefs.cs_cdtvcd) {
card_init[cardno] = expamem_init_cdtv;
......@@ -1429,6 +1544,9 @@ void expansion_init (void)
allocated_z3fastmem2 = 0;
z3fastmem2_mask = z3fastmem2_start = 0;
z3fastmem2 = 0;
allocated_z3chipmem = 0;
z3chipmem_mask = z3chipmem_start = 0;
z3chipmem = 0;
allocate_expamem ();
......@@ -1454,6 +1572,9 @@ void expansion_cleanup (void)
if (z3fastmem2)
mapped_free (z3fastmem2);
z3fastmem2 = 0;
if (z3chipmem)
mapped_free (z3chipmem);
z3chipmem = 0;
#ifdef PICASSO96
if (gfxmemory)
......@@ -1480,6 +1601,8 @@ void expansion_clear(void)
memset (z3fastmem, 0, allocated_z3fastmem > 0x800000 ? 0x800000 : allocated_z3fastmem);
if (z3fastmem2)
memset (z3fastmem2, 0, allocated_z3fastmem2 > 0x800000 ? 0x800000 : allocated_z3fastmem2);
if (z3chipmem)
memset (z3chipmem, 0, allocated_z3chipmem > 0x800000 ? 0x800000 : allocated_z3chipmem);
if (gfxmemory)
memset (gfxmemory, 0, allocated_gfxmem);
}
......@@ -1496,6 +1619,10 @@ uae_u8 *save_fram (int *len)
uae_u8 *save_zram (int *len, int num)
{
if (num < 0) {
*len = allocated_z3chipmem;
return z3chipmem;
}
*len = num ? allocated_z3fastmem2 : allocated_z3fastmem;
return num ? z3fastmem2 : z3fastmem;
}
......@@ -1514,7 +1641,10 @@ void restore_fram (int len, size_t filepos)
void restore_zram (int len, size_t filepos, int num)
{
if (num) {
if (num == -1) {
z3_fileposchip = filepos;
changed_prefs.z3chipmem_size = len;
} else if (num == 1) {
z3_filepos2 = filepos;
changed_prefs.z3fastmem2_size = len;
} else {
......
......@@ -253,6 +253,7 @@ STATIC_INLINE uae_u32 sign_extend8 (uae_u32 v)
static void fdi_decode (const uae_u8 *stream, unsigned int size, uae_u8 *out)
{
unsigned int i;
uae_u8 sign_extend, sixteen_bit, sub_stream_shift;
NODE root;
NODE *current_node;
......@@ -260,7 +261,6 @@ static void fdi_decode (const uae_u8 *stream, unsigned int size, uae_u8 *out)
memset (out, 0, size * 4);
sub_stream_shift = 1;
while (sub_stream_shift) {
unsigned int i;
//sub-stream header decode
sign_extend = *stream++;
......@@ -967,7 +967,7 @@ static void ibm_data (FDI *fdi, const uae_u8 *data, uae_u8 *crc, unsigned int le
{
unsigned int i;
uae_u8 crcbuf[2];
uae_u16 crcv = 0;
uae_u16 crcv;
word_add (fdi, 0x4489);
word_add (fdi, 0x4489);
......@@ -1179,14 +1179,14 @@ static void track_amiga (struct fdi *fdi, unsigned int first_sector, unsigned in
}
static void track_atari_st (struct fdi *fdi, unsigned int max_sector)
{
unsigned int i, gap3 = 0;
unsigned int i, gap3;
uae_u8 *p = fdi->track_src;
switch (max_sector) {
case 9:
case 9:
gap3 = 40;
break;
case 10:
case 10:
gap3 = 24;
break;
}
......@@ -1207,13 +1207,13 @@ static void track_pc (struct fdi *fdi, unsigned int max_sector)
uae_u8 *p = fdi->track_src;
switch (max_sector) {
case 8:
case 8:
gap3 = 116;
break;
case 9:
case 9:
gap3 = 54;
break;
default:
default:
gap3 = 100; /* fixme */
break;
}
......@@ -1823,7 +1823,7 @@ static int decode_lowlevel_track (FDI *fdi, unsigned int track, struct fdi_cache
uae_u32 maxidx, totalavg, weakbits;
unsigned int i, j, len, pulses, indexoffset;
unsigned int avg_free, min_free = 0, max_free = 0, idx_free;
unsigned int idx_off1 = 0, idx_off2 = 0, idx_off3 = 0;
unsigned int idx_off1, idx_off2, idx_off3;
d = fdi->track_dst;
p1 = fdi->track_src;
......
......@@ -63,7 +63,7 @@ extern void wait_cpu_cycle_write_ce020 (uaecptr addr, int mode, uae_u32 v);
#define bogomem_start 0x00C00000
#define cardmem_start 0x00E00000
#define kickmem_start 0x00F80000
extern uaecptr z3fastmem_start, z3fastmem2_start;
extern uaecptr z3fastmem_start, z3fastmem2_start, z3chipmem_start;
extern uaecptr p96ram_start;
extern uaecptr fastmem_start;
extern uaecptr a3000lmem_start, a3000hmem_start;
......
......@@ -80,7 +80,7 @@ uae_u32 allocated_chipmem;
uae_u32 allocated_fastmem;
uae_u32 allocated_bogomem;
uae_u32 allocated_gfxmem;
uae_u32 allocated_z3fastmem, allocated_z3fastmem2;
uae_u32 allocated_z3fastmem, allocated_z3fastmem2, allocated_z3chipmem;
uae_u32 allocated_a3000lmem;
uae_u32 allocated_a3000hmem;
uae_u32 allocated_cardmem;
......
......@@ -445,7 +445,7 @@ configure:4344: $? = 0
configure:4344: result: yes
configure:4350: checking for _doprnt
configure:4350: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/ccQVX6ss.o: In function `main':
/tmp/cckxlJDb.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:67: undefined reference to `_doprnt'
collect2: ld returned 1 exit status
configure:4350: $? = 1
......@@ -533,7 +533,7 @@ configure:4364: $? = 0
configure:4364: result: yes
configure:4364: checking for strcmpi
configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/ccML3BqH.o: In function `main':
/tmp/ccsvYvOq.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `strcmpi'
collect2: ld returned 1 exit status
configure:4364: $? = 1
......@@ -613,7 +613,7 @@ configure: failed program was:
configure:4364: result: no
configure:4364: checking for stricmp
configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/ccLZtbQE.o: In function `main':
/tmp/ccAfsPHv.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `stricmp'
collect2: ld returned 1 exit status
configure:4364: $? = 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment