--- uae/src/include/memory.h 2018/04/24 16:39:19 1.1.1.2 +++ uae/src/include/memory.h 2018/04/24 16:40:14 1.1.1.3 @@ -1,20 +1,30 @@ - /* + /* * UAE - The Un*x Amiga Emulator - * + * * memory management - * + * * Copyright 1995 Bernd Schmidt */ -typedef ULONG (*mem_get_func)(CPTR) REGPARAM; -typedef void (*mem_put_func)(CPTR, ULONG) REGPARAM; -typedef UBYTE *(*xlate_func)(CPTR) REGPARAM; -typedef int (*check_func)(CPTR, ULONG) REGPARAM; +/* Enabling this adds one additional native memory reference per 68k memory + * access, but saves one shift (on the x86). Enabling this is probably + * better for the cache. My favourite benchmark (PP2) doesn't show a + * difference, so I leave this enabled. */ + +#if 1 || defined SAVE_MEMORY +#define SAVE_MEMORY_BANKS +#endif + +typedef uae_u32 (*mem_get_func)(uaecptr) REGPARAM; +typedef void (*mem_put_func)(uaecptr, uae_u32) REGPARAM; +typedef uae_u8 *(*xlate_func)(uaecptr) REGPARAM; +typedef int (*check_func)(uaecptr, uae_u32) REGPARAM; extern char *address_space, *good_address_map; -extern UBYTE *chipmemory; +extern uae_u8 *chipmemory; #undef DIRECT_MEMFUNCS_SUCCESSFUL +#include "osdep/memory.h" #include "machdep/memory.h" #ifndef CAN_MAP_MEMORY @@ -27,28 +37,31 @@ extern UBYTE *chipmemory; #define kickmem_size 0x080000 -#define chipmem_start 0x000000 -#define bogomem_start 0xC00000 -#define kickmem_start 0xF80000 +#define chipmem_start 0x00000000 +#define bogomem_start 0x00C00000 +#define a3000mem_start 0x07000000 +#define kickmem_start 0x00F80000 extern int ersatzkickfile; typedef struct { /* These ones should be self-explanatory... */ - mem_get_func alget, awget, lget, wget, bget; + mem_get_func lget, wget, bget; mem_put_func lput, wput, bput; - /* Use xlateaddr to translate an Amiga address to a UBYTE * that can - * be used to address memory without calling the wget/wput functions. + /* Use xlateaddr to translate an Amiga address to a uae_u8 * that can + * be used to address memory without calling the wget/wput functions. * This doesn't work for all memory banks, so this function may call * abort(). */ xlate_func xlateaddr; /* To prevent calls to abort(), use check before calling xlateaddr. * It checks not only that the memory bank can do xlateaddr, but also - * that the pointer points to an area of at least the specified size. + * that the pointer points to an area of at least the specified size. * This is used for example to translate bitplane pointers in custom.c */ check_func check; } addrbank; +extern uae_u8 filesysory[65536]; + extern addrbank chipmem_bank; extern addrbank kickmem_bank; extern addrbank custom_bank; @@ -57,68 +70,63 @@ extern addrbank cia_bank; extern addrbank rtarea_bank; extern addrbank expamem_bank; extern addrbank fastmem_bank; +extern addrbank gfxmem_bank; extern void rtarea_init (void); extern void rtarea_setup (void); extern void expamem_init (void); extern void expamem_reset (void); -extern ULONG fastmem_size, chipmem_size, bogomem_size; +extern uae_u32 z3fastmem_size, fastmem_size, chipmem_size, bogomem_size, a3000mem_size, gfxmem_size; +extern uae_u32 gfxmem_start; +extern uae_u8 *gfxmemory; +extern uae_u32 gfxmem_mask; +extern int address_space_24; /* Default memory access functions */ -extern int default_check(CPTR addr, ULONG size) REGPARAM; -extern UBYTE *default_xlate(CPTR addr) REGPARAM; -extern ULONG default_awget(CPTR addr) REGPARAM; -extern ULONG default_alget(CPTR addr) REGPARAM; +extern int default_check(uaecptr addr, uae_u32 size) REGPARAM; +extern uae_u8 *default_xlate(uaecptr addr) REGPARAM; -extern addrbank membanks[65536]; -static __inline__ unsigned int bankindex(CPTR a) -{ - return a>>16; -} +#define bankindex(addr) (((uaecptr)(addr)) >> 16) -static __inline__ int check_addr(CPTR a) -{ -#if defined(NO_EXCEPTION_3) || CPU_LEVEL > 1 - return 1; +#ifdef SAVE_MEMORY_BANKS +extern addrbank *mem_banks[65536]; +#define get_mem_bank(addr) (*mem_banks[bankindex(addr)]) +#define put_mem_bank(addr, b) (mem_banks[bankindex(addr)] = (b)) #else - return (a & 1) == 0; +extern addrbank mem_banks[65536]; +#define get_mem_bank(addr) (mem_banks[bankindex(addr)]) +#define put_mem_bank(addr, b) (mem_banks[bankindex(addr)] = *(b)) #endif -} -extern int buserr; - -extern void memory_init(void); + +extern void memory_init(void); extern void map_banks(addrbank *bank, int first, int count); #ifndef NO_INLINE_MEMORY_ACCESS -#define alongget(addr) (call_mem_get_func(membanks[bankindex(addr)].alget, addr)) -#define awordget(addr) (call_mem_get_func(membanks[bankindex(addr)].awget, addr)) -#define longget(addr) (call_mem_get_func(membanks[bankindex(addr)].lget, addr)) -#define wordget(addr) (call_mem_get_func(membanks[bankindex(addr)].wget, addr)) -#define byteget(addr) (call_mem_get_func(membanks[bankindex(addr)].bget, addr)) -#define longput(addr,l) (call_mem_put_func(membanks[bankindex(addr)].lput, addr, l)) -#define wordput(addr,w) (call_mem_put_func(membanks[bankindex(addr)].wput, addr, w)) -#define byteput(addr,b) (call_mem_put_func(membanks[bankindex(addr)].bput, addr, b)) +#define longget(addr) (call_mem_get_func(get_mem_bank(addr).lget, addr)) +#define wordget(addr) (call_mem_get_func(get_mem_bank(addr).wget, addr)) +#define byteget(addr) (call_mem_get_func(get_mem_bank(addr).bget, addr)) +#define longput(addr,l) (call_mem_put_func(get_mem_bank(addr).lput, addr, l)) +#define wordput(addr,w) (call_mem_put_func(get_mem_bank(addr).wput, addr, w)) +#define byteput(addr,b) (call_mem_put_func(get_mem_bank(addr).bput, addr, b)) #else -extern ULONG alongget(CPTR addr); -extern ULONG awordget(CPTR addr); -extern ULONG longget(CPTR addr); -extern ULONG wordget(CPTR addr); -extern ULONG byteget(CPTR addr); -extern void longput(CPTR addr, ULONG l); -extern void wordput(CPTR addr, ULONG w); -extern void byteput(CPTR addr, ULONG b); +extern uae_u32 alongget(uaecptr addr); +extern uae_u32 awordget(uaecptr addr); +extern uae_u32 longget(uaecptr addr); +extern uae_u32 wordget(uaecptr addr); +extern uae_u32 byteget(uaecptr addr); +extern void longput(uaecptr addr, uae_u32 l); +extern void wordput(uaecptr addr, uae_u32 w); +extern void byteput(uaecptr addr, uae_u32 b); #endif #ifndef MD_HAVE_MEM_1_FUNCS -#define alongget_1 alongget -#define awordget_1 awordget #define longget_1 longget #define wordget_1 wordget #define byteget_1 byteget @@ -128,61 +136,37 @@ extern void byteput(CPTR addr, ULONG b); #endif -static __inline__ ULONG get_along(CPTR addr) -{ - if (check_addr(addr)) - return longget_1(addr); - buserr = 1; - return 0; -} -static __inline__ ULONG get_aword(CPTR addr) -{ - if (check_addr(addr)) - return wordget_1(addr); - buserr = 1; - return 0; -} -static __inline__ ULONG get_long(CPTR addr) +static __inline__ uae_u32 get_long(uaecptr addr) { - if (check_addr(addr)) - return longget_1(addr); - buserr = 1; - return 0; + return longget_1(addr); } -static __inline__ ULONG get_word(CPTR addr) +static __inline__ uae_u32 get_word(uaecptr addr) { - if (check_addr(addr)) - return wordget_1(addr); - buserr = 1; - return 0; + return wordget_1(addr); } -static __inline__ ULONG get_byte(CPTR addr) +static __inline__ uae_u32 get_byte(uaecptr addr) { - return byteget_1(addr); + return byteget_1(addr); } -static __inline__ void put_long(CPTR addr, ULONG l) +static __inline__ void put_long(uaecptr addr, uae_u32 l) { - if (!check_addr(addr)) - buserr = 1; longput_1(addr, l); } -static __inline__ void put_word(CPTR addr, ULONG w) +static __inline__ void put_word(uaecptr addr, uae_u32 w) { - if (!check_addr(addr)) - buserr = 1; wordput_1(addr, w); } -static __inline__ void put_byte(CPTR addr, ULONG b) +static __inline__ void put_byte(uaecptr addr, uae_u32 b) { byteput_1(addr, b); } -static __inline__ UBYTE *get_real_address(CPTR addr) +static __inline__ uae_u8 *get_real_address(uaecptr addr) { - return membanks[bankindex(addr)].xlateaddr(addr); + return get_mem_bank(addr).xlateaddr(addr); } -static __inline__ int valid_address(CPTR addr, ULONG size) +static __inline__ int valid_address(uaecptr addr, uae_u32 size) { - return membanks[bankindex(addr)].check(addr, size); + return get_mem_bank(addr).check(addr, size); }