ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/memory.h
Revision: 1.8
Committed: 2009-03-03T08:01:48Z (15 years, 5 months ago) by asvitkine
Content type: text/plain
Branch: MAIN
Changes since 1.7: +1 -2 lines
Log Message:
change #else #if into #elif in case both are defined

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * UAE - The Un*x Amiga Emulator
3     *
4     * memory management
5     *
6     * Copyright 1995 Bernd Schmidt
7     */
8    
9     #ifndef UAE_MEMORY_H
10     #define UAE_MEMORY_H
11    
12 gbeauche 1.2 #if !DIRECT_ADDRESSING && !REAL_ADDRESSING
13    
14 cebix 1.1 /* Enabling this adds one additional native memory reference per 68k memory
15     * access, but saves one shift (on the x86). Enabling this is probably
16     * better for the cache. My favourite benchmark (PP2) doesn't show a
17     * difference, so I leave this enabled. */
18    
19     #if 1 || defined SAVE_MEMORY
20     #define SAVE_MEMORY_BANKS
21     #endif
22    
23     typedef uae_u32 (REGPARAM2 *mem_get_func)(uaecptr) REGPARAM;
24     typedef void (REGPARAM2 *mem_put_func)(uaecptr, uae_u32) REGPARAM;
25     typedef uae_u8 *(REGPARAM2 *xlate_func)(uaecptr) REGPARAM;
26    
27     #undef DIRECT_MEMFUNCS_SUCCESSFUL
28    
29     #ifndef CAN_MAP_MEMORY
30     #undef USE_COMPILER
31     #endif
32    
33     #if defined(USE_COMPILER) && !defined(USE_MAPPED_MEMORY)
34     #define USE_MAPPED_MEMORY
35     #endif
36    
37     typedef struct {
38     /* These ones should be self-explanatory... */
39     mem_get_func lget, wget, bget;
40     mem_put_func lput, wput, bput;
41     /* Use xlateaddr to translate an Amiga address to a uae_u8 * that can
42     * be used to address memory without calling the wget/wput functions.
43     * This doesn't work for all memory banks, so this function may call
44     * abort(). */
45     xlate_func xlateaddr;
46     } addrbank;
47    
48     extern uae_u8 filesysory[65536];
49    
50     extern addrbank ram_bank; // Mac RAM
51     extern addrbank rom_bank; // Mac ROM
52     extern addrbank frame_bank; // Frame buffer
53    
54     /* Default memory access functions */
55    
56     extern uae_u8 *REGPARAM2 default_xlate(uaecptr addr) REGPARAM;
57    
58     #define bankindex(addr) (((uaecptr)(addr)) >> 16)
59    
60     #ifdef SAVE_MEMORY_BANKS
61     extern addrbank *mem_banks[65536];
62     #define get_mem_bank(addr) (*mem_banks[bankindex(addr)])
63     #define put_mem_bank(addr, b) (mem_banks[bankindex(addr)] = (b))
64     #else
65     extern addrbank mem_banks[65536];
66     #define get_mem_bank(addr) (mem_banks[bankindex(addr)])
67     #define put_mem_bank(addr, b) (mem_banks[bankindex(addr)] = *(b))
68     #endif
69    
70     extern void memory_init(void);
71     extern void map_banks(addrbank *bank, int first, int count);
72    
73     #ifndef NO_INLINE_MEMORY_ACCESS
74    
75     #define longget(addr) (call_mem_get_func(get_mem_bank(addr).lget, addr))
76     #define wordget(addr) (call_mem_get_func(get_mem_bank(addr).wget, addr))
77     #define byteget(addr) (call_mem_get_func(get_mem_bank(addr).bget, addr))
78     #define longput(addr,l) (call_mem_put_func(get_mem_bank(addr).lput, addr, l))
79     #define wordput(addr,w) (call_mem_put_func(get_mem_bank(addr).wput, addr, w))
80     #define byteput(addr,b) (call_mem_put_func(get_mem_bank(addr).bput, addr, b))
81    
82     #else
83    
84     extern uae_u32 longget(uaecptr addr);
85     extern uae_u32 wordget(uaecptr addr);
86     extern uae_u32 byteget(uaecptr addr);
87     extern void longput(uaecptr addr, uae_u32 l);
88     extern void wordput(uaecptr addr, uae_u32 w);
89     extern void byteput(uaecptr addr, uae_u32 b);
90    
91     #endif
92    
93     #ifndef MD_HAVE_MEM_1_FUNCS
94    
95     #define longget_1 longget
96     #define wordget_1 wordget
97     #define byteget_1 byteget
98     #define longput_1 longput
99     #define wordput_1 wordput
100     #define byteput_1 byteput
101    
102     #endif
103    
104 gbeauche 1.2 #endif /* !DIRECT_ADDRESSING && !REAL_ADDRESSING */
105    
106 cebix 1.1 #if REAL_ADDRESSING
107 gbeauche 1.3 const uintptr MEMBaseDiff = 0;
108 asvitkine 1.8 #elif DIRECT_ADDRESSING
109 gbeauche 1.2 extern uintptr MEMBaseDiff;
110 gbeauche 1.4 #endif
111    
112 cebix 1.5 #if REAL_ADDRESSING || DIRECT_ADDRESSING
113 gbeauche 1.4 static __inline__ uae_u8 *do_get_real_address(uaecptr addr)
114     {
115     return (uae_u8 *)MEMBaseDiff + addr;
116     }
117     static __inline__ uae_u32 do_get_virtual_address(uae_u8 *addr)
118     {
119     return (uintptr)addr - MEMBaseDiff;
120     }
121 cebix 1.1 static __inline__ uae_u32 get_long(uaecptr addr)
122     {
123 gbeauche 1.2 uae_u32 * const m = (uae_u32 *)do_get_real_address(addr);
124     return do_get_mem_long(m);
125 cebix 1.1 }
126     static __inline__ uae_u32 get_word(uaecptr addr)
127     {
128 gbeauche 1.2 uae_u16 * const m = (uae_u16 *)do_get_real_address(addr);
129     return do_get_mem_word(m);
130 cebix 1.1 }
131     static __inline__ uae_u32 get_byte(uaecptr addr)
132     {
133 gbeauche 1.2 uae_u8 * const m = (uae_u8 *)do_get_real_address(addr);
134     return do_get_mem_byte(m);
135 cebix 1.1 }
136     static __inline__ void put_long(uaecptr addr, uae_u32 l)
137     {
138 gbeauche 1.2 uae_u32 * const m = (uae_u32 *)do_get_real_address(addr);
139     do_put_mem_long(m, l);
140 cebix 1.1 }
141     static __inline__ void put_word(uaecptr addr, uae_u32 w)
142     {
143 gbeauche 1.2 uae_u16 * const m = (uae_u16 *)do_get_real_address(addr);
144     do_put_mem_word(m, w);
145 cebix 1.1 }
146     static __inline__ void put_byte(uaecptr addr, uae_u32 b)
147     {
148 gbeauche 1.2 uae_u8 * const m = (uae_u8 *)do_get_real_address(addr);
149     do_put_mem_byte(m, b);
150 cebix 1.1 }
151     static __inline__ uae_u8 *get_real_address(uaecptr addr)
152     {
153 gbeauche 1.2 return do_get_real_address(addr);
154     }
155     static __inline__ uae_u32 get_virtual_address(uae_u8 *addr)
156     {
157     return do_get_virtual_address(addr);
158 cebix 1.1 }
159     #else
160     static __inline__ uae_u32 get_long(uaecptr addr)
161     {
162     return longget_1(addr);
163     }
164     static __inline__ uae_u32 get_word(uaecptr addr)
165     {
166     return wordget_1(addr);
167     }
168     static __inline__ uae_u32 get_byte(uaecptr addr)
169     {
170     return byteget_1(addr);
171     }
172     static __inline__ void put_long(uaecptr addr, uae_u32 l)
173     {
174     longput_1(addr, l);
175     }
176     static __inline__ void put_word(uaecptr addr, uae_u32 w)
177     {
178     wordput_1(addr, w);
179     }
180     static __inline__ void put_byte(uaecptr addr, uae_u32 b)
181     {
182     byteput_1(addr, b);
183     }
184     static __inline__ uae_u8 *get_real_address(uaecptr addr)
185     {
186     return get_mem_bank(addr).xlateaddr(addr);
187     }
188 gbeauche 1.2 /* gb-- deliberately not implemented since it shall not be used... */
189     extern uae_u32 get_virtual_address(uae_u8 *addr);
190     #endif /* DIRECT_ADDRESSING || REAL_ADDRESSING */
191    
192     #endif /* MEMORY_H */
193 cebix 1.1