|
|
1.1 ! root 1: /* ! 2: * UAE - The Un*x Amiga Emulator ! 3: * ! 4: * memory management ! 5: * ! 6: * Copyright 1995 Bernd Schmidt ! 7: */ ! 8: ! 9: #define kickmem_size 0x080000 ! 10: ! 11: #define chipmem_start 0x000000 ! 12: #define bogomem_start 0xC00000 ! 13: #define kickmem_start 0xF80000 ! 14: ! 15: extern int ersatzkickfile; ! 16: ! 17: extern char *address_space, *good_address_map; ! 18: ! 19: typedef ULONG (*lget_afunc)(CPTR) REGPARAM; ! 20: typedef UWORD (*wget_afunc)(CPTR) REGPARAM; ! 21: typedef ULONG (*lget_func)(CPTR) REGPARAM; ! 22: typedef UWORD (*wget_func)(CPTR) REGPARAM; ! 23: typedef UBYTE (*bget_func)(CPTR) REGPARAM; ! 24: typedef void (*lput_func)(CPTR,ULONG) REGPARAM; ! 25: typedef void (*wput_func)(CPTR,UWORD) REGPARAM; ! 26: typedef void (*bput_func)(CPTR,UBYTE) REGPARAM; ! 27: typedef UBYTE *(*xlate_func)(CPTR) REGPARAM; ! 28: typedef int (*check_func)(CPTR, ULONG) REGPARAM; ! 29: ! 30: typedef struct { ! 31: /* These ones should be self-explanatory... */ ! 32: lget_afunc alget; ! 33: wget_afunc awget; ! 34: lget_func lget; ! 35: wget_func wget; ! 36: bget_func bget; ! 37: lput_func lput; ! 38: wput_func wput; ! 39: bput_func bput; ! 40: /* Use xlateaddr to translate an Amiga address to a UWORD * that can ! 41: * be used to address memory without calling the wget/wput functions. ! 42: * This doesn't work for all memory banks, so this function may call ! 43: * abort(). */ ! 44: xlate_func xlateaddr; ! 45: /* To prevent calls to abort(), use check before calling xlateaddr. ! 46: * It checks not only that the memory bank can do xlateaddr, but also ! 47: * that the pointer points to an area of at least the specified size. ! 48: * This is used for example to translate bitplane pointers in custom.c */ ! 49: check_func check; ! 50: } addrbank; ! 51: ! 52: extern addrbank chipmem_bank; ! 53: extern addrbank kickmem_bank; ! 54: extern addrbank custom_bank; ! 55: extern addrbank clock_bank; ! 56: extern addrbank cia_bank; ! 57: extern addrbank rtarea_bank; ! 58: extern addrbank expamem_bank; ! 59: extern addrbank fastmem_bank; ! 60: ! 61: extern void rtarea_init (void); ! 62: extern void expamem_init (void); ! 63: extern void expamem_reset (void); ! 64: ! 65: extern ULONG fastmem_size, chipmem_size, bogomem_size; ! 66: ! 67: ! 68: /* Default memory access functions */ ! 69: ! 70: extern int default_check(CPTR addr, ULONG size) REGPARAM; ! 71: extern UBYTE *default_xlate(CPTR addr) REGPARAM; ! 72: extern UWORD default_awget(CPTR addr) REGPARAM; ! 73: extern ULONG default_alget(CPTR addr) REGPARAM; ! 74: ! 75: extern addrbank membanks[65536]; ! 76: static __inline__ unsigned int bankindex(CPTR a) ! 77: { ! 78: return a>>16; ! 79: } ! 80: ! 81: static __inline__ ULONG alongget(CPTR addr) ! 82: { ! 83: return membanks[bankindex(addr)].alget(addr); ! 84: } ! 85: static __inline__ UWORD awordget(CPTR addr) ! 86: { ! 87: return membanks[bankindex(addr)].awget(addr); ! 88: } ! 89: static __inline__ ULONG longget(CPTR addr) ! 90: { ! 91: return membanks[bankindex(addr)].lget(addr); ! 92: } ! 93: static __inline__ UWORD wordget(CPTR addr) ! 94: { ! 95: return membanks[bankindex(addr)].wget(addr); ! 96: } ! 97: static __inline__ UBYTE byteget(CPTR addr) ! 98: { ! 99: return membanks[bankindex(addr)].bget(addr); ! 100: } ! 101: static __inline__ void longput(CPTR addr, ULONG l) ! 102: { ! 103: membanks[bankindex(addr)].lput(addr, l); ! 104: } ! 105: static __inline__ void wordput(CPTR addr, UWORD w) ! 106: { ! 107: membanks[bankindex(addr)].wput(addr, w); ! 108: } ! 109: static __inline__ void byteput(CPTR addr, UBYTE b) ! 110: { ! 111: membanks[bankindex(addr)].bput(addr, b); ! 112: } ! 113: ! 114: static __inline__ int check_addr(CPTR a) ! 115: { ! 116: #if defined(NO_EXCEPTION_3) || CPU_LEVEL > 1 ! 117: return 1; ! 118: #else ! 119: return (a & 1) == 0; ! 120: #endif ! 121: } ! 122: extern int buserr; ! 123: ! 124: extern void memory_init(void); ! 125: extern void map_banks(addrbank *bank, int first, int count); ! 126: ! 127: static __inline__ ULONG get_along(CPTR addr) ! 128: { ! 129: if (check_addr(addr)) ! 130: return longget(addr); ! 131: buserr = 1; ! 132: return 0; ! 133: } ! 134: static __inline__ UWORD get_aword(CPTR addr) ! 135: { ! 136: if (check_addr(addr)) ! 137: return wordget(addr); ! 138: buserr = 1; ! 139: return 0; ! 140: } ! 141: static __inline__ ULONG get_long(CPTR addr) ! 142: { ! 143: if (check_addr(addr)) ! 144: return longget(addr); ! 145: buserr = 1; ! 146: return 0; ! 147: } ! 148: static __inline__ UWORD get_word(CPTR addr) ! 149: { ! 150: if (check_addr(addr)) ! 151: return wordget(addr); ! 152: buserr = 1; ! 153: return 0; ! 154: } ! 155: static __inline__ UBYTE get_byte(CPTR addr) ! 156: { ! 157: return byteget(addr); ! 158: } ! 159: static __inline__ void put_long(CPTR addr, ULONG l) ! 160: { ! 161: if (!check_addr(addr)) ! 162: buserr = 1; ! 163: longput(addr, l); ! 164: } ! 165: static __inline__ void put_word(CPTR addr, UWORD w) ! 166: { ! 167: if (!check_addr(addr)) ! 168: buserr = 1; ! 169: wordput(addr, w); ! 170: } ! 171: static __inline__ void put_byte(CPTR addr, UBYTE b) ! 172: { ! 173: byteput(addr, b); ! 174: } ! 175: ! 176: static __inline__ UBYTE *get_real_address(CPTR addr) ! 177: { ! 178: return membanks[bankindex(addr)].xlateaddr(addr); ! 179: } ! 180: ! 181: static __inline__ int valid_address(CPTR addr, ULONG size) ! 182: { ! 183: return membanks[bankindex(addr)].check(addr, size); ! 184: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.