[PATCH 13/20] Add memory bank handling for the Jaguar code |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- Subject: [PATCH 13/20] Add memory bank handling for the Jaguar code
- From: Thomas Huth <huth@xxxxxxxxxxxxx>
- Date: Sat, 13 Jan 2024 07:37:38 +0100
---
src/cpu/memory.c | 8 ++---
src/cpu/memory.h | 2 ++
src/jaguar/memory.c | 75 +++++++++++++++++++++++++++++++++++++++++++++
src/jaguar/memory.h | 2 ++
4 files changed, 83 insertions(+), 4 deletions(-)
diff --git a/src/cpu/memory.c b/src/cpu/memory.c
index 7bf97d2c..6a331dfa 100644
--- a/src/cpu/memory.c
+++ b/src/cpu/memory.c
@@ -1480,8 +1480,10 @@ bool mapped_malloc (addrbank *ab)
#endif
-static void init_mem_banks (void)
+void init_mem_banks(void)
{
+ last_address_space_24 = ConfigureParams.System.bAddressSpace24;
+
// unsigned so i << 16 won't overflow to negative when i >= 32768
for (unsigned int i = 0; i < MEMORY_BANKS; i++)
put_mem_bank (i << 16, &dummy_bank, 0);
@@ -1491,7 +1493,7 @@ static void init_mem_banks (void)
}
-static void init_bank (addrbank *ab , uae_u32 size)
+void init_bank(addrbank *ab , uae_u32 size)
{
ab->allocated_size = size;
ab->startmask = ab->start;
@@ -1649,8 +1651,6 @@ void memory_init(uae_u32 NewSTMemSize, uae_u32 NewTTMemSize, uae_u32 NewRomMemSt
{
int addr;
- last_address_space_24 = ConfigureParams.System.bAddressSpace24;
-
/* Round to next multiple of 65536 bytes */
STmem_size = (NewSTMemSize + 65535) & 0xFFFF0000;
TTmem_size = (NewTTMemSize + 65535) & 0xFFFF0000;
diff --git a/src/cpu/memory.h b/src/cpu/memory.h
index 11756438..c31d56bd 100644
--- a/src/cpu/memory.h
+++ b/src/cpu/memory.h
@@ -517,6 +517,8 @@ extern addrbank *get_mem_bank_real(uaecptr);
#endif
#ifdef WINUAE_FOR_HATARI
+extern void init_mem_banks(void);
+extern void init_bank(addrbank *ab , uae_u32 size);
extern bool memory_region_bus_error ( uaecptr addr );
extern bool memory_region_iomem ( uaecptr addr );
extern void memory_map_Standard_RAM ( uint32_t MMU_Bank0_Size , uint32_t MMU_Bank1_Size );
diff --git a/src/jaguar/memory.c b/src/jaguar/memory.c
index 037a44c6..cd78a527 100644
--- a/src/jaguar/memory.c
+++ b/src/jaguar/memory.c
@@ -11,6 +11,9 @@
//
#include "memory.h"
+#include "m68k.h"
+#include "../cpu/sysdeps.h"
+#include "../cpu/memory.h"
uint8 jagMemSpace[0xF20000]; // The entire memory space of the Jaguar...!
@@ -30,3 +33,75 @@ uint16 rrxd; // Dual register with $F1A14C
const char * whoName[9] =
{ "Unknown", "Jaguar", "DSP", "GPU", "TOM", "JERRY", "M68K", "Blitter", "OP" };
+
+static uae_u32 REGPARAM3 jagmem_lget(uaecptr addr)
+{
+ addr &= 0xffffff;
+ return m68k_read_memory_32(addr);
+}
+
+static uae_u32 REGPARAM3 jagmem_wget(uaecptr addr)
+{
+ addr &= 0xffffff;
+ return m68k_read_memory_16(addr);
+}
+
+static uae_u32 REGPARAM3 jagmem_bget(uaecptr addr)
+{
+ addr &= 0xffffff;
+ return m68k_read_memory_8(addr);
+}
+
+static void REGPARAM3 jagmem_lput(uaecptr addr, uae_u32 l)
+{
+ addr &= 0xffffff;
+ m68k_write_memory_32(addr, l);
+}
+
+static void REGPARAM3 jagmem_wput(uaecptr addr, uae_u32 w)
+{
+ addr &= 0xffffff;
+ m68k_write_memory_16(addr, w);
+}
+
+static void REGPARAM3 jagmem_bput(uaecptr addr, uae_u32 b)
+{
+ addr &= 0xffffff;
+ m68k_write_memory_8(addr, b);
+}
+
+static int REGPARAM3 jagmem_check(uaecptr addr, uae_u32 size)
+{
+ addr &= 0xffffff;
+ return (addr + size) <= 0xF20000;
+}
+
+static uae_u8 * REGPARAM3 jagmem_xlate(uaecptr addr)
+{
+ addr &= 0xffffff;
+ return jagMemSpace + addr;
+}
+
+
+static addrbank jagmem_bank =
+{
+ jagmem_lget, jagmem_wget, jagmem_bget,
+ jagmem_lput, jagmem_wput, jagmem_bput,
+ jagmem_xlate, jagmem_check, NULL, "ja_mem" , "Jag memory",
+ jagmem_lget, jagmem_wget, ABFLAG_IO
+};
+
+void jag_memory_handler_init(void)
+{
+ dummy_bank.baseaddr = NULL;
+ init_bank(&dummy_bank, 0);
+
+ init_mem_banks();
+
+ /* Set the infos about memory pointers for each mem bank */
+ jagmem_bank.baseaddr = jagMemSpace;
+ jagmem_bank.mask = 0xffffff;
+ jagmem_bank.start = 0;
+ init_bank(&jagmem_bank, 0xf20000);
+ map_banks_ce(&jagmem_bank, 0, 0xf20000 >> 16, 0, CE_MEMBANK_CHIP16, CACHE_ENABLE_INS);
+}
diff --git a/src/jaguar/memory.h b/src/jaguar/memory.h
index 612e0e18..5a69ab39 100644
--- a/src/jaguar/memory.h
+++ b/src/jaguar/memory.h
@@ -25,6 +25,8 @@ extern uint16 lrxd, rrxd;
enum { UNKNOWN, JAGUAR, DSP, GPU, TOM, JERRY, M68K, BLITTER, OP };
extern const char * whoName[9];
+void jag_memory_handler_init(void);
+
// Some handy macros to help converting native endian to big endian (jaguar native)
// & vice versa
--
2.48.1
--MP_/VkVZp1l8MIESxWVe2vPSxV2
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=0014-Glue-the-Jaguar-code-to-the-WinUAE-m68k-CPU-emulatio.patch