|
|
1.1 ! root 1: /* ! 2: * UAE - The Un*x Amiga Emulator ! 3: * ! 4: * memory management ! 5: * ! 6: * Copyright 1995 Bernd Schmidt ! 7: */ ! 8: ! 9: #ifndef UAEMEMORY ! 10: #define UAEMEMORY ! 11: ! 12: ! 13: /* Enabling this adds one additional native memory reference per 68k memory ! 14: * access, but saves one shift (on the x86). Enabling this is probably ! 15: * better for the cache. My favourite benchmark (PP2) doesn't show a ! 16: * difference, so I leave this enabled. */ ! 17: #if 1 || defined SAVE_MEMORY ! 18: #define SAVE_MEMORY_BANKS ! 19: #endif ! 20: ! 21: extern int special_mem; ! 22: #define S_READ 1 ! 23: #define S_WRITE 2 ! 24: ! 25: typedef uae_u32 (*mem_get_func)(uaecptr) REGPARAM; ! 26: typedef void (*mem_put_func)(uaecptr, uae_u32) REGPARAM; ! 27: typedef uae_u8 *(*xlate_func)(uaecptr) REGPARAM; ! 28: typedef int (*check_func)(uaecptr, uae_u32) REGPARAM; ! 29: ! 30: extern char *address_space, *good_address_map; ! 31: extern uae_u8 *chipmemory; ! 32: ! 33: extern uae_u32 allocated_chipmem; ! 34: extern uae_u32 allocated_fastmem; ! 35: extern uae_u32 allocated_bogomem; ! 36: extern uae_u32 allocated_gfxmem; ! 37: extern uae_u32 allocated_z3fastmem; ! 38: extern uae_u32 allocated_a3000mem; ! 39: ! 40: #undef DIRECT_MEMFUNCS_SUCCESSFUL ! 41: /*#include "machdep/maccess.h"*/ ! 42: ! 43: #ifndef CAN_MAP_MEMORY ! 44: #undef USE_COMPILER ! 45: #endif ! 46: ! 47: #if defined(USE_COMPILER) && !defined(USE_MAPPED_MEMORY) ! 48: #define USE_MAPPED_MEMORY ! 49: #endif ! 50: ! 51: #define ROMmem_size TOSSize ! 52: #define ROMmem_start TOSAddress ! 53: ! 54: #define STmem_start 0x00000000 ! 55: #define TTmem_start 0x01000000 ! 56: ! 57: #define IOmem_start 0x00FF8000 ! 58: #define IOmem_size 32768 ! 59: ! 60: typedef struct { ! 61: /* These ones should be self-explanatory... */ ! 62: mem_get_func lget, wget, bget; ! 63: mem_put_func lput, wput, bput; ! 64: /* Use xlateaddr to translate an Amiga address to a uae_u8 * that can ! 65: * be used to address memory without calling the wget/wput functions. ! 66: * This doesn't work for all memory banks, so this function may call ! 67: * abort(). */ ! 68: xlate_func xlateaddr; ! 69: /* To prevent calls to abort(), use check before calling xlateaddr. ! 70: * It checks not only that the memory bank can do xlateaddr, but also ! 71: * that the pointer points to an area of at least the specified size. ! 72: * This is used for example to translate bitplane pointers in custom.c */ ! 73: check_func check; ! 74: } addrbank; ! 75: ! 76: extern uae_u8 filesysory[65536]; ! 77: ! 78: extern addrbank STmem_bank; ! 79: extern addrbank ROMmem_bank; ! 80: extern addrbank custom_bank; ! 81: extern addrbank TTmem_bank; ! 82: ! 83: extern void rtarea_init (void); ! 84: extern void rtarea_setup (void); ! 85: extern void expamem_init (void); ! 86: extern void expamem_reset (void); ! 87: ! 88: extern uae_u32 gfxmem_start; ! 89: extern uae_u8 *gfxmemory; ! 90: extern uae_u32 gfxmem_mask; ! 91: extern int address_space_24; ! 92: ! 93: /* Default memory access functions */ ! 94: ! 95: extern int default_check(uaecptr addr, uae_u32 size) REGPARAM; ! 96: extern uae_u8 *default_xlate(uaecptr addr) REGPARAM; ! 97: ! 98: #define bankindex(addr) (((uaecptr)(addr)) >> 16) ! 99: ! 100: #ifdef SAVE_MEMORY_BANKS ! 101: extern addrbank *mem_banks[65536]; ! 102: #define get_mem_bank(addr) (*mem_banks[bankindex(addr)]) ! 103: #define put_mem_bank(addr, b) (mem_banks[bankindex(addr)] = (b)) ! 104: #else ! 105: extern addrbank mem_banks[65536]; ! 106: #define get_mem_bank(addr) (mem_banks[bankindex(addr)]) ! 107: #define put_mem_bank(addr, b) (mem_banks[bankindex(addr)] = *(b)) ! 108: #endif ! 109: ! 110: extern void memory_init(void); ! 111: extern void map_banks(addrbank *bank, int first, int count); ! 112: ! 113: #ifndef NO_INLINE_MEMORY_ACCESS ! 114: ! 115: #define longget(addr) (call_mem_get_func(get_mem_bank(addr).lget, addr)) ! 116: #define wordget(addr) (call_mem_get_func(get_mem_bank(addr).wget, addr)) ! 117: #define byteget(addr) (call_mem_get_func(get_mem_bank(addr).bget, addr)) ! 118: #define longput(addr,l) (call_mem_put_func(get_mem_bank(addr).lput, addr, l)) ! 119: #define wordput(addr,w) (call_mem_put_func(get_mem_bank(addr).wput, addr, w)) ! 120: #define byteput(addr,b) (call_mem_put_func(get_mem_bank(addr).bput, addr, b)) ! 121: ! 122: #else ! 123: ! 124: extern uae_u32 alongget(uaecptr addr); ! 125: extern uae_u32 awordget(uaecptr addr); ! 126: extern uae_u32 longget(uaecptr addr); ! 127: extern uae_u32 wordget(uaecptr addr); ! 128: extern uae_u32 byteget(uaecptr addr); ! 129: extern void longput(uaecptr addr, uae_u32 l); ! 130: extern void wordput(uaecptr addr, uae_u32 w); ! 131: extern void byteput(uaecptr addr, uae_u32 b); ! 132: ! 133: #endif ! 134: ! 135: #ifndef MD_HAVE_MEM_1_FUNCS ! 136: ! 137: #define longget_1 longget ! 138: #define wordget_1 wordget ! 139: #define byteget_1 byteget ! 140: #define longput_1 longput ! 141: #define wordput_1 wordput ! 142: #define byteput_1 byteput ! 143: ! 144: #endif ! 145: ! 146: STATIC_INLINE uae_u32 get_long(uaecptr addr) ! 147: { ! 148: return longget_1(addr); ! 149: } ! 150: STATIC_INLINE uae_u32 get_word(uaecptr addr) ! 151: { ! 152: return wordget_1(addr); ! 153: } ! 154: STATIC_INLINE uae_u32 get_byte(uaecptr addr) ! 155: { ! 156: return byteget_1(addr); ! 157: } ! 158: STATIC_INLINE void put_long(uaecptr addr, uae_u32 l) ! 159: { ! 160: longput_1(addr, l); ! 161: } ! 162: STATIC_INLINE void put_word(uaecptr addr, uae_u32 w) ! 163: { ! 164: wordput_1(addr, w); ! 165: } ! 166: STATIC_INLINE void put_byte(uaecptr addr, uae_u32 b) ! 167: { ! 168: byteput_1(addr, b); ! 169: } ! 170: ! 171: STATIC_INLINE uae_u8 *get_real_address(uaecptr addr) ! 172: { ! 173: return get_mem_bank(addr).xlateaddr(addr); ! 174: } ! 175: ! 176: STATIC_INLINE int valid_address(uaecptr addr, uae_u32 size) ! 177: { ! 178: return get_mem_bank(addr).check(addr, size); ! 179: } ! 180: ! 181: /* For faster access in custom chip emulation. */ ! 182: extern uae_u32 chipmem_lget (uaecptr) REGPARAM; ! 183: extern uae_u32 chipmem_wget (uaecptr) REGPARAM; ! 184: extern uae_u32 chipmem_bget (uaecptr) REGPARAM; ! 185: extern void chipmem_lput (uaecptr, uae_u32) REGPARAM; ! 186: extern void chipmem_wput (uaecptr, uae_u32) REGPARAM; ! 187: extern void chipmem_bput (uaecptr, uae_u32) REGPARAM; ! 188: ! 189: ! 190: #endif /* UAEMEMORY */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.