Annotation of previous/src/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
                      7:   *
                      8:   * Adaptation to Hatari by Thomas Huth
                      9:   *
                     10:   * This file is distributed under the GNU Public License, version 2 or at
                     11:   * your option any later version. Read the file gpl.txt for details.
                     12:   */
                     13: 
                     14: #ifndef UAE_MEMORY_H
                     15: #define UAE_MEMORY_H
                     16: 
                     17: #include "maccess.h"
                     18: 
                     19: #ifdef JIT
                     20: extern int special_mem;
                     21: #define S_READ 1
                     22: #define S_WRITE 2
                     23: 
                     24: extern uae_u8 *cache_alloc (int);
                     25: extern void cache_free (uae_u8*);
                     26: #endif
                     27: 
                     28: #define call_mem_get_func(func, addr) ((*func)(addr))
                     29: #define call_mem_put_func(func, addr, v) ((*func)(addr, v))
                     30: 
1.1.1.2 ! root       31: #define NEXT_SCREEN_SIZE        0x00040000
1.1       root       32: extern uae_u8 NEXTVideo[256*1024];
                     33: 
1.1.1.2 ! root       34: #define NEXT_COLORSCREEN_SIZE   0x00200000
        !            35: extern uae_u8 NEXTColorVideo[2*1024*1024];
        !            36: 
        !            37: uae_u32 MemBank_Size[4]; // experimental, sizes for all 4 memory banks
        !            38: 
1.1       root       39: 
                     40: /* Enabling this adds one additional native memory reference per 68k memory
                     41:  * access, but saves one shift (on the x86). Enabling this is probably
                     42:  * better for the cache. My favourite benchmark (PP2) doesn't show a
                     43:  * difference, so I leave this enabled. */
                     44: #if 1 || defined SAVE_MEMORY
                     45: #define SAVE_MEMORY_BANKS
                     46: #endif
                     47: 
                     48: extern void memory_hardreset (void);
                     49: 
                     50: typedef uae_u32 (*mem_get_func)(uaecptr) REGPARAM;
                     51: typedef void (*mem_put_func)(uaecptr, uae_u32) REGPARAM;
                     52: typedef uae_u8 *(*xlate_func)(uaecptr) REGPARAM;
                     53: typedef int (*check_func)(uaecptr, uae_u32) REGPARAM;
                     54: 
                     55: extern char *address_space, *good_address_map;
                     56: 
                     57: extern uae_u32 wait_cpu_cycle_read (uaecptr addr, int mode);
                     58: extern void wait_cpu_cycle_write (uaecptr addr, int mode, uae_u32 v);
                     59: extern uae_u32 wait_cpu_cycle_read_ce020 (uaecptr addr, int mode);
                     60: extern void wait_cpu_cycle_write_ce020 (uaecptr addr, int mode, uae_u32 v);
                     61: 
                     62: enum { ABFLAG_UNK = 0, ABFLAG_RAM = 1, ABFLAG_ROM = 2, ABFLAG_ROMIN = 4, ABFLAG_IO = 8, ABFLAG_NONE = 16, ABFLAG_SAFE = 32 };
                     63: typedef struct {
                     64:        /* These ones should be self-explanatory... */
                     65:        mem_get_func lget, wget, bget;
                     66:        mem_put_func lput, wput, bput;
                     67:        /* Use xlateaddr to translate an Amiga address to a uae_u8 * that can
                     68:        * be used to address memory without calling the wget/wput functions.
                     69:        * This doesn't work for all memory banks, so this function may call
                     70:        * abort(). */
                     71:        xlate_func xlateaddr;
                     72:        /* To prevent calls to abort(), use check before calling xlateaddr.
                     73:        * It checks not only that the memory bank can do xlateaddr, but also
                     74:        * that the pointer points to an area of at least the specified size.
                     75:        * This is used for example to translate bitplane pointers in custom.c */
                     76:        check_func check;
                     77:        /* For those banks that refer to real memory, we can save the whole trouble
                     78:        of going through function calls, and instead simply grab the memory
                     79:        ourselves. This holds the memory address where the start of memory is
                     80:        for this particular bank. */
                     81:        uae_u8 *baseaddr;
                     82:        TCHAR *name;
                     83:        /* for instruction opcode/operand fetches */
                     84:        mem_get_func lgeti, wgeti;
                     85:        int flags;
                     86: } addrbank;
                     87: 
                     88: #define CE_MEMBANK_FAST 0
                     89: #define CE_MEMBANK_CHIP 1
                     90: #define CE_MEMBANK_CIA 2
                     91: #define CE_MEMBANK_FAST16BIT 3
                     92: extern uae_u8 ce_banktype[65536], ce_cachable[65536];
                     93: 
                     94: 
                     95: #define bankindex(addr) (((uaecptr)(addr)) >> 16)
                     96: 
                     97: #ifdef SAVE_MEMORY_BANKS
                     98: extern addrbank *mem_banks[65536];
                     99: #define get_mem_bank(addr) (*mem_banks[bankindex(addr)])
                    100: #define put_mem_bank(addr, b) (mem_banks[bankindex(addr)] = (b))
                    101: #else
                    102: extern addrbank mem_banks[65536];
                    103: #define get_mem_bank(addr) (mem_banks[bankindex(addr)])
                    104: #define put_mem_bank(addr, b) (mem_banks[bankindex(addr)] = *(b))
                    105: #endif
                    106: 
1.1.1.2 ! root      107: extern const char* memory_init(int *membanks);
1.1       root      108: extern void memory_uninit (void);
                    109: extern void map_banks(addrbank *bank, int first, int count);
                    110: 
                    111: #ifndef NO_INLINE_MEMORY_ACCESS
                    112: 
                    113: #define longget(addr) (call_mem_get_func(get_mem_bank(addr).lget, addr))
                    114: #define wordget(addr) (call_mem_get_func(get_mem_bank(addr).wget, addr))
                    115: #define byteget(addr) (call_mem_get_func(get_mem_bank(addr).bget, addr))
                    116: #define longput(addr,l) (call_mem_put_func(get_mem_bank(addr).lput, addr, l))
                    117: #define wordput(addr,w) (call_mem_put_func(get_mem_bank(addr).wput, addr, w))
                    118: #define byteput(addr,b) (call_mem_put_func(get_mem_bank(addr).bput, addr, b))
                    119: 
                    120: #else
                    121: 
                    122: extern uae_u32 alongget(uaecptr addr);
                    123: extern uae_u32 awordget(uaecptr addr);
                    124: extern uae_u32 longget(uaecptr addr);
                    125: extern uae_u32 wordget(uaecptr addr);
                    126: extern uae_u32 byteget(uaecptr addr);
                    127: extern void longput(uaecptr addr, uae_u32 l);
                    128: extern void wordput(uaecptr addr, uae_u32 w);
                    129: extern void byteput(uaecptr addr, uae_u32 b);
                    130: 
                    131: #endif
                    132: 
                    133: #define longget(addr) (call_mem_get_func(get_mem_bank(addr).lget, addr))
                    134: #define wordget(addr) (call_mem_get_func(get_mem_bank(addr).wget, addr))
                    135: #define byteget(addr) (call_mem_get_func(get_mem_bank(addr).bget, addr))
                    136: #define longgeti(addr) (call_mem_get_func(get_mem_bank(addr).lgeti, addr))
                    137: #define wordgeti(addr) (call_mem_get_func(get_mem_bank(addr).wgeti, addr))
                    138: #define longput(addr,l) (call_mem_put_func(get_mem_bank(addr).lput, addr, l))
                    139: #define wordput(addr,w) (call_mem_put_func(get_mem_bank(addr).wput, addr, w))
                    140: #define byteput(addr,b) (call_mem_put_func(get_mem_bank(addr).bput, addr, b))
                    141: 
                    142: static inline uae_u32 get_long(uaecptr addr)
                    143: {
                    144:     return longget(addr);
                    145: }
                    146: 
                    147: static inline uae_u32 get_word(uaecptr addr)
                    148: {
                    149:     return wordget(addr);
                    150: }
                    151: 
                    152: static inline uae_u32 get_byte(uaecptr addr)
                    153: {
                    154:     return byteget(addr);
                    155: }
                    156: 
                    157: static inline void put_long(uaecptr addr, uae_u32 l)
                    158: {
                    159:     longput(addr, l);
                    160: }
                    161: 
                    162: static inline void put_word(uaecptr addr, uae_u32 w)
                    163: {
                    164:     wordput(addr, w);
                    165: }
                    166: 
                    167: static inline void put_byte(uaecptr addr, uae_u32 b)
                    168: {
                    169:     byteput(addr, b);
                    170: }
                    171: 
                    172: static inline uae_u8 *get_real_address(uaecptr addr)
                    173: {
                    174:     return get_mem_bank(addr).xlateaddr(addr);
                    175: }
                    176: 
                    177: static inline int valid_address(uaecptr addr, uae_u32 size)
                    178: {
                    179:     return get_mem_bank(addr).check(addr, size);
                    180: }
                    181: 
                    182: static inline uae_u32 get_longi(uaecptr addr)
                    183: {
                    184:        return longgeti (addr);
                    185: }
                    186: 
                    187: static inline uae_u32 get_wordi(uaecptr addr)
                    188: {
                    189:        return wordgeti (addr);
                    190: }
                    191: 
                    192: #endif /* UAE_MEMORY_H */

unix.superglobalmegacorp.com

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