Annotation of hatari/src/uae-cpu/memory.h, revision 1.1.1.2

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.