ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/memory.h
Revision: 1.9
Committed: 2012-03-30T01:25:46Z (12 years, 7 months ago) by asvitkine
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +21 -7 lines
Log Message:
Add GPLv2 notices to files from UAE Amiga Emulator, as retrieved from the
COPYING file of uae-0.8.29, retrieved from http://www.amigaemulator.org/
via uae-0.8.29.tar.bz2 (MD5 = 54abbabb5e8580b679c52de019141d61).

File Contents

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