|
|
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: uae_u8 *cache_alloc (int);
25: 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:
31: extern uae_u8 NEXTVideo[256*1024];
32:
33: extern uae_u8 NEXTColorVideo[2*1024*1024];
34:
35:
36: /* Enabling this adds one additional native memory reference per 68k memory
37: * access, but saves one shift (on the x86). Enabling this is probably
38: * better for the cache. My favourite benchmark (PP2) doesn't show a
39: * difference, so I leave this enabled. */
40: #if 1 || defined SAVE_MEMORY
41: #define SAVE_MEMORY_BANKS
42: #endif
43:
44: void memory_hardreset (void);
45:
46: typedef uae_u32 (*mem_get_func)(uaecptr) REGPARAM;
47: typedef void (*mem_put_func)(uaecptr, uae_u32) REGPARAM;
48: typedef uae_u8 *(*xlate_func)(uaecptr) REGPARAM;
49: typedef int (*check_func)(uaecptr, uae_u32) REGPARAM;
50:
51: extern char *address_space, *good_address_map;
52:
53: uae_u32 wait_cpu_cycle_read (uaecptr addr, int mode);
54: void wait_cpu_cycle_write (uaecptr addr, int mode, uae_u32 v);
55: uae_u32 wait_cpu_cycle_read_ce020 (uaecptr addr, int mode);
56: void wait_cpu_cycle_write_ce020 (uaecptr addr, int mode, uae_u32 v);
57:
58: enum { ABFLAG_UNK = 0, ABFLAG_RAM = 1, ABFLAG_ROM = 2, ABFLAG_ROMIN = 4, ABFLAG_IO = 8, ABFLAG_NONE = 16, ABFLAG_SAFE = 32 };
59: typedef struct {
60: /* These ones should be self-explanatory... */
61: mem_get_func lget, wget, bget;
62: mem_put_func lput, wput, bput;
63: mem_get_func lgeti, wgeti;
64: int flags;
65: } addrbank;
66:
67: extern uae_u8 ce_cachable[65536];
68:
69: #define bankindex(addr) (((uaecptr)(addr)) >> 16)
70:
71: #ifdef SAVE_MEMORY_BANKS
72: extern addrbank *mem_banks[65536];
73: #define get_mem_bank(addr) (*mem_banks[bankindex(addr)])
74: #define put_mem_bank(addr, b) (mem_banks[bankindex(addr)] = (b))
75: #else
76: extern addrbank mem_banks[65536];
77: #define get_mem_bank(addr) (mem_banks[bankindex(addr)])
78: #define put_mem_bank(addr, b) (mem_banks[bankindex(addr)] = *(b))
79: #endif
80:
81: const char* memory_init(int *membanks);
82: void memory_uninit (void);
83: void map_banks(addrbank *bank, int first, int count);
84:
85: #ifndef NO_INLINE_MEMORY_ACCESS
86:
87: #define longget(addr) (call_mem_get_func(get_mem_bank(addr).lget, addr))
88: #define wordget(addr) (call_mem_get_func(get_mem_bank(addr).wget, addr))
89: #define byteget(addr) (call_mem_get_func(get_mem_bank(addr).bget, addr))
90: #define longput(addr,l) (call_mem_put_func(get_mem_bank(addr).lput, addr, l))
91: #define wordput(addr,w) (call_mem_put_func(get_mem_bank(addr).wput, addr, w))
92: #define byteput(addr,b) (call_mem_put_func(get_mem_bank(addr).bput, addr, b))
93:
94: #else
95:
96: uae_u32 alongget(uaecptr addr);
97: uae_u32 awordget(uaecptr addr);
98: uae_u32 longget(uaecptr addr);
99: uae_u32 wordget(uaecptr addr);
100: uae_u32 byteget(uaecptr addr);
101: void longput(uaecptr addr, uae_u32 l);
102: void wordput(uaecptr addr, uae_u32 w);
103: void byteput(uaecptr addr, uae_u32 b);
104:
105: #endif
106:
107: #define longget(addr) (call_mem_get_func(get_mem_bank(addr).lget, addr))
108: #define wordget(addr) (call_mem_get_func(get_mem_bank(addr).wget, addr))
109: #define byteget(addr) (call_mem_get_func(get_mem_bank(addr).bget, addr))
110: #define longgeti(addr) (call_mem_get_func(get_mem_bank(addr).lgeti, addr))
111: #define wordgeti(addr) (call_mem_get_func(get_mem_bank(addr).wgeti, 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: static inline uae_u32 get_long(uaecptr addr)
117: {
118: return longget(addr);
119: }
120:
121: static inline uae_u32 get_word(uaecptr addr)
122: {
123: return wordget(addr);
124: }
125:
126: static inline uae_u32 get_byte(uaecptr addr)
127: {
128: return byteget(addr);
129: }
130:
131: static inline void put_long(uaecptr addr, uae_u32 l)
132: {
133: longput(addr, l);
134: }
135:
136: static inline void put_word(uaecptr addr, uae_u32 w)
137: {
138: wordput(addr, w);
139: }
140:
141: static inline void put_byte(uaecptr addr, uae_u32 b)
142: {
143: byteput(addr, b);
144: }
145:
146: static inline uae_u32 get_longi(uaecptr addr)
147: {
148: return longgeti (addr);
149: }
150:
151: static inline uae_u32 get_wordi(uaecptr addr)
152: {
153: return wordgeti (addr);
154: }
155:
156: #endif /* UAE_MEMORY_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.