--- hatari/src/includes/stMemory.h 2019/04/01 07:13:41 1.1.1.7 +++ hatari/src/includes/stMemory.h 2019/04/09 08:59:25 1.1.1.15 @@ -1,17 +1,18 @@ /* Hatari - stMemory.h - This file is distributed under the GNU Public License, version 2 or at - your option any later version. Read the file gpl.txt for details. + This file is distributed under the GNU General Public License, version 2 + or at your option any later version. Read the file gpl.txt for details. */ #ifndef HATARI_STMEMORY_H #define HATARI_STMEMORY_H -#include "config.h" +#include "main.h" #include "sysdeps.h" #include "maccess.h" -#include "main.h" +#include "memory.h" + #if ENABLE_SMALL_MEM extern Uint8 *STRam; @@ -22,121 +23,49 @@ extern Uint8 STRam[16*1024*1024]; #define RomMem STRam #endif /* ENABLE_SMALL_MEM */ -extern Uint32 STRamEnd; - -/* Offset ST address to PC pointer: */ -#define STRAM_ADDR(Var) ((unsigned long)STRam+((Uint32)(Var) & 0x00ffffff)) +extern uae_u8 *TTmemory; +extern uae_u32 TTmem_size; +extern Uint32 STRamEnd; -/*-----------------------------------------------------------------------*/ -/* - Write 32-bit word into ST memory space. - NOTE - value will be convert to 68000 endian -*/ -static inline void STMemory_WriteLong(Uint32 Address, Uint32 Var) -{ - Address &= 0xffffff; -#if ENABLE_SMALL_MEM - if (Address >= 0xe00000) - do_put_mem_long(&ROMmemory[Address-0xe00000], Var); - else - do_put_mem_long(&STRam[Address], Var); -#else - do_put_mem_long(&STRam[Address], Var); -#endif -} - -/*-----------------------------------------------------------------------*/ -/* - Write 16-bit word into ST memory space. - NOTE - value will be convert to 68000 endian. -*/ -static inline void STMemory_WriteWord(Uint32 Address, Uint16 Var) -{ - Address &= 0xffffff; -#if ENABLE_SMALL_MEM - if (Address >= 0xe00000) - do_put_mem_word(&ROMmemory[Address-0xe00000], Var); - else - do_put_mem_word(&STRam[Address], Var); -#else - do_put_mem_word(&STRam[Address], Var); -#endif -} - -/*-----------------------------------------------------------------------*/ -/* - Write 8-bit byte into ST memory space. -*/ -static inline void STMemory_WriteByte(Uint32 Address, Uint8 Var) -{ - Address &= 0xffffff; -#if ENABLE_SMALL_MEM - if (Address >= 0xe00000) - ROMmemory[Address-0xe00000] = Var; - else - STRam[Address] = Var; -#else - STRam[Address] = Var; -#endif -} +#define MEM_BANK_SIZE_128 ( 128 * 1024 ) /* 00b */ +#define MEM_BANK_SIZE_512 ( 512 * 1024 ) /* 01b */ +#define MEM_BANK_SIZE_2048 ( 2048 * 1024 ) /* 10b */ +#define MEM_BANK_SIZE_8192 ( 8192 * 1024 ) /* for TT */ -/*-----------------------------------------------------------------------*/ -/* - Read 32-bit word from ST memory space. - NOTE - value will be converted to PC endian. -*/ -static inline Uint32 STMemory_ReadLong(Uint32 Address) -{ - Address &= 0xffffff; -#if ENABLE_SMALL_MEM - if (Address >= 0xe00000) - return do_get_mem_long(&ROMmemory[Address-0xe00000]); - else - return do_get_mem_long(&STRam[Address]); -#else - return do_get_mem_long(&STRam[Address]); -#endif -} +extern Uint32 RAM_Bank0_Size; +extern Uint32 RAM_Bank1_Size; -/*-----------------------------------------------------------------------*/ -/* - Read 16-bit word from ST memory space. - NOTE - value will be converted to PC endian. -*/ -static inline Uint16 STMemory_ReadWord(Uint32 Address) -{ - Address &= 0xffffff; -#if ENABLE_SMALL_MEM - if (Address >= 0xe00000) - return do_get_mem_word(&ROMmemory[Address-0xe00000]); - else - return do_get_mem_word(&STRam[Address]); -#else - return do_get_mem_word(&STRam[Address]); -#endif -} +extern Uint32 MMU_Bank0_Size; +extern Uint32 MMU_Bank1_Size; -/*-----------------------------------------------------------------------*/ -/* - Read 8-bit byte from ST memory space -*/ -static inline Uint8 STMemory_ReadByte(Uint32 Address) -{ - Address &= 0xffffff; -#if ENABLE_SMALL_MEM - if (Address >= 0xe00000) - return ROMmemory[Address-0xe00000]; - else - return STRam[Address]; -#else - return STRam[Address]; -#endif -} +extern void STMemory_Init ( int RAM_Size_Byte ); +extern void STMemory_Reset ( bool bCold ); -extern void STMemory_Clear(Uint32 StartAddress, Uint32 EndAddress); +extern bool STMemory_SafeClear(Uint32 addr, unsigned int len); +extern bool STMemory_SafeCopy(Uint32 addr, Uint8 *src, unsigned int len, const char *name); +extern void STMemory_MemorySnapShot_Capture(bool bSave); extern void STMemory_SetDefaultConfig(void); +extern bool STMemory_CheckAreaType ( Uint32 addr , int size , int mem_type ); +extern bool STMemory_CheckRegionBusError ( Uint32 addr ); +extern void *STMemory_STAddrToPointer ( Uint32 addr ); + +extern void STMemory_Write ( Uint32 addr , Uint32 val , int size ); +extern void STMemory_WriteLong ( Uint32 addr , Uint32 val ); +extern void STMemory_WriteWord ( Uint32 addr , Uint16 val ); +extern void STMemory_WriteByte ( Uint32 addr , Uint8 val ); +extern Uint32 STMemory_Read ( Uint32 addr , int size ); +extern Uint32 STMemory_ReadLong ( Uint32 addr ); +extern Uint16 STMemory_ReadWord ( Uint32 addr ); +extern Uint8 STMemory_ReadByte ( Uint32 addr ); + +extern void STMemory_MMU_Config_ReadByte ( void ); +extern void STMemory_MMU_Config_WriteByte ( void ); + +extern int STMemory_RAM_Validate_Size_KB ( int TotalMem ); +extern bool STMemory_RAM_SetBankSize ( int TotalMem , Uint32 *pBank0_Size , Uint32 *pBank1_Size , Uint8 *pMMU_Conf ); +extern Uint32 STMemory_MMU_Translate_Addr ( Uint32 addr_logical ); #endif