1 |
/* |
2 |
* PearPC |
3 |
* ppc_mmu.h |
4 |
* |
5 |
* Copyright (C) 2003, 2004 Sebastian Biallas (sb@biallas.net) |
6 |
* |
7 |
* This program is free software; you can redistribute it and/or modify |
8 |
* it under the terms of the GNU General Public License version 2 as |
9 |
* published by the Free Software Foundation. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
*/ |
20 |
|
21 |
#ifndef __PPC_MMU_H__ |
22 |
#define __PPC_MMU_H__ |
23 |
|
24 |
#include "system/types.h" |
25 |
|
26 |
extern byte *gMemory; |
27 |
extern uint32 gMemorySize; |
28 |
|
29 |
#define PPC_MMU_READ 1 |
30 |
#define PPC_MMU_WRITE 2 |
31 |
#define PPC_MMU_CODE 4 |
32 |
#define PPC_MMU_SV 8 |
33 |
#define PPC_MMU_NO_EXC 16 |
34 |
|
35 |
#define PPC_MMU_OK 0 |
36 |
#define PPC_MMU_EXC 1 |
37 |
#define PPC_MMU_FATAL 2 |
38 |
|
39 |
int FASTCALL ppc_effective_to_physical(uint32 addr, int flags, uint32 &result); |
40 |
int FASTCALL ppc_effective_to_physical_vm(uint32 addr, int flags, uint32 &result); |
41 |
bool FASTCALL ppc_mmu_set_sdr1(uint32 newval, bool quiesce); |
42 |
void ppc_mmu_tlb_invalidate(); |
43 |
|
44 |
int FASTCALL ppc_read_physical_dword(uint32 addr, uint64 &result); |
45 |
int FASTCALL ppc_read_physical_word(uint32 addr, uint32 &result); |
46 |
int FASTCALL ppc_read_physical_half(uint32 addr, uint16 &result); |
47 |
int FASTCALL ppc_read_physical_byte(uint32 addr, uint8 &result); |
48 |
|
49 |
int FASTCALL ppc_read_effective_code(uint32 addr, uint32 &result); |
50 |
int FASTCALL ppc_read_effective_dword(uint32 addr, uint64 &result); |
51 |
int FASTCALL ppc_read_effective_word(uint32 addr, uint32 &result); |
52 |
int FASTCALL ppc_read_effective_half(uint32 addr, uint16 &result); |
53 |
int FASTCALL ppc_read_effective_byte(uint32 addr, uint8 &result); |
54 |
|
55 |
int FASTCALL ppc_write_physical_dword(uint32 addr, uint64 data); |
56 |
int FASTCALL ppc_write_physical_word(uint32 addr, uint32 data); |
57 |
int FASTCALL ppc_write_physical_half(uint32 addr, uint16 data); |
58 |
int FASTCALL ppc_write_physical_byte(uint32 addr, uint8 data); |
59 |
|
60 |
int FASTCALL ppc_write_effective_dword(uint32 addr, uint64 data); |
61 |
int FASTCALL ppc_write_effective_word(uint32 addr, uint32 data); |
62 |
int FASTCALL ppc_write_effective_half(uint32 addr, uint16 data); |
63 |
int FASTCALL ppc_write_effective_byte(uint32 addr, uint8 data); |
64 |
|
65 |
int FASTCALL ppc_direct_physical_memory_handle(uint32 addr, byte *&ptr); |
66 |
int FASTCALL ppc_direct_effective_memory_handle(uint32 addr, byte *&ptr); |
67 |
int FASTCALL ppc_direct_effective_memory_handle_code(uint32 addr, byte *&ptr); |
68 |
bool FASTCALL ppc_mmu_page_create(uint32 ea, uint32 pa); |
69 |
bool FASTCALL ppc_mmu_page_free(uint32 ea); |
70 |
bool FASTCALL ppc_init_physical_memory(uint size); |
71 |
|
72 |
/* |
73 |
pte: (page table entry) |
74 |
1st word: |
75 |
0 V Valid |
76 |
1-24 VSID Virtual Segment ID |
77 |
25 H Hash function |
78 |
26-31 API Abbreviated page index |
79 |
2nd word: |
80 |
0-19 RPN Physical page number |
81 |
20-22 res |
82 |
23 R Referenced bit |
83 |
24 C Changed bit |
84 |
25-28 WIMG Memory/cache control bits |
85 |
29 res |
86 |
30-31 PP Page protection bits |
87 |
*/ |
88 |
|
89 |
/* |
90 |
* MMU Opcodes |
91 |
*/ |
92 |
void ppc_opc_dcbz(); |
93 |
|
94 |
void ppc_opc_lbz(); |
95 |
void ppc_opc_lbzu(); |
96 |
void ppc_opc_lbzux(); |
97 |
void ppc_opc_lbzx(); |
98 |
void ppc_opc_lfd(); |
99 |
void ppc_opc_lfdu(); |
100 |
void ppc_opc_lfdux(); |
101 |
void ppc_opc_lfdx(); |
102 |
void ppc_opc_lfs(); |
103 |
void ppc_opc_lfsu(); |
104 |
void ppc_opc_lfsux(); |
105 |
void ppc_opc_lfsx(); |
106 |
void ppc_opc_lha(); |
107 |
void ppc_opc_lhau(); |
108 |
void ppc_opc_lhaux(); |
109 |
void ppc_opc_lhax(); |
110 |
void ppc_opc_lhbrx(); |
111 |
void ppc_opc_lhz(); |
112 |
void ppc_opc_lhzu(); |
113 |
void ppc_opc_lhzux(); |
114 |
void ppc_opc_lhzx(); |
115 |
void ppc_opc_lmw(); |
116 |
void ppc_opc_lswi(); |
117 |
void ppc_opc_lswx(); |
118 |
void ppc_opc_lwarx(); |
119 |
void ppc_opc_lwbrx(); |
120 |
void ppc_opc_lwz(); |
121 |
void ppc_opc_lwzu(); |
122 |
void ppc_opc_lwzux(); |
123 |
void ppc_opc_lwzx(); |
124 |
void ppc_opc_lvx(); /* for altivec support */ |
125 |
void ppc_opc_lvxl(); |
126 |
void ppc_opc_lvebx(); |
127 |
void ppc_opc_lvehx(); |
128 |
void ppc_opc_lvewx(); |
129 |
void ppc_opc_lvsl(); |
130 |
void ppc_opc_lvsr(); |
131 |
void ppc_opc_dst(); |
132 |
|
133 |
void ppc_opc_stb(); |
134 |
void ppc_opc_stbu(); |
135 |
void ppc_opc_stbux(); |
136 |
void ppc_opc_stbx(); |
137 |
void ppc_opc_stfd(); |
138 |
void ppc_opc_stfdu(); |
139 |
void ppc_opc_stfdux(); |
140 |
void ppc_opc_stfdx(); |
141 |
void ppc_opc_stfiwx(); |
142 |
void ppc_opc_stfs(); |
143 |
void ppc_opc_stfsu(); |
144 |
void ppc_opc_stfsux(); |
145 |
void ppc_opc_stfsx(); |
146 |
void ppc_opc_sth(); |
147 |
void ppc_opc_sthbrx(); |
148 |
void ppc_opc_sthu(); |
149 |
void ppc_opc_sthux(); |
150 |
void ppc_opc_sthx(); |
151 |
void ppc_opc_stmw(); |
152 |
void ppc_opc_stswi(); |
153 |
void ppc_opc_stswx(); |
154 |
void ppc_opc_stw(); |
155 |
void ppc_opc_stwbrx(); |
156 |
void ppc_opc_stwcx_(); |
157 |
void ppc_opc_stwu(); |
158 |
void ppc_opc_stwux(); |
159 |
void ppc_opc_stwx(); |
160 |
void ppc_opc_stvx(); /* for altivec support */ |
161 |
void ppc_opc_stvxl(); |
162 |
void ppc_opc_stvebx(); |
163 |
void ppc_opc_stvehx(); |
164 |
void ppc_opc_stvewx(); |
165 |
void ppc_opc_dstst(); |
166 |
void ppc_opc_dss(); |
167 |
|
168 |
#include "jitc_types.h" |
169 |
|
170 |
JITCFlow ppc_opc_gen_dcbz(); |
171 |
|
172 |
JITCFlow ppc_opc_gen_lbz(); |
173 |
JITCFlow ppc_opc_gen_lbzu(); |
174 |
JITCFlow ppc_opc_gen_lbzux(); |
175 |
JITCFlow ppc_opc_gen_lbzx(); |
176 |
JITCFlow ppc_opc_gen_lfd(); |
177 |
JITCFlow ppc_opc_gen_lfdu(); |
178 |
JITCFlow ppc_opc_gen_lfdux(); |
179 |
JITCFlow ppc_opc_gen_lfdx(); |
180 |
JITCFlow ppc_opc_gen_lfs(); |
181 |
JITCFlow ppc_opc_gen_lfsu(); |
182 |
JITCFlow ppc_opc_gen_lfsux(); |
183 |
JITCFlow ppc_opc_gen_lfsx(); |
184 |
JITCFlow ppc_opc_gen_lha(); |
185 |
JITCFlow ppc_opc_gen_lhau(); |
186 |
JITCFlow ppc_opc_gen_lhaux(); |
187 |
JITCFlow ppc_opc_gen_lhax(); |
188 |
JITCFlow ppc_opc_gen_lhbrx(); |
189 |
JITCFlow ppc_opc_gen_lhz(); |
190 |
JITCFlow ppc_opc_gen_lhzu(); |
191 |
JITCFlow ppc_opc_gen_lhzux(); |
192 |
JITCFlow ppc_opc_gen_lhzx(); |
193 |
JITCFlow ppc_opc_gen_lmw(); |
194 |
JITCFlow ppc_opc_gen_lswi(); |
195 |
JITCFlow ppc_opc_gen_lswx(); |
196 |
JITCFlow ppc_opc_gen_lwarx(); |
197 |
JITCFlow ppc_opc_gen_lwbrx(); |
198 |
JITCFlow ppc_opc_gen_lwz(); |
199 |
JITCFlow ppc_opc_gen_lwzu(); |
200 |
JITCFlow ppc_opc_gen_lwzux(); |
201 |
JITCFlow ppc_opc_gen_lwzx(); |
202 |
JITCFlow ppc_opc_gen_lvx(); /* for altivec support */ |
203 |
JITCFlow ppc_opc_gen_lvxl(); |
204 |
JITCFlow ppc_opc_gen_lvebx(); |
205 |
JITCFlow ppc_opc_gen_lvehx(); |
206 |
JITCFlow ppc_opc_gen_lvewx(); |
207 |
JITCFlow ppc_opc_gen_lvsl(); |
208 |
JITCFlow ppc_opc_gen_lvsr(); |
209 |
JITCFlow ppc_opc_gen_dst(); |
210 |
|
211 |
JITCFlow ppc_opc_gen_stb(); |
212 |
JITCFlow ppc_opc_gen_stbu(); |
213 |
JITCFlow ppc_opc_gen_stbux(); |
214 |
JITCFlow ppc_opc_gen_stbx(); |
215 |
JITCFlow ppc_opc_gen_stfd(); |
216 |
JITCFlow ppc_opc_gen_stfdu(); |
217 |
JITCFlow ppc_opc_gen_stfdux(); |
218 |
JITCFlow ppc_opc_gen_stfdx(); |
219 |
JITCFlow ppc_opc_gen_stfiwx(); |
220 |
JITCFlow ppc_opc_gen_stfs(); |
221 |
JITCFlow ppc_opc_gen_stfsu(); |
222 |
JITCFlow ppc_opc_gen_stfsux(); |
223 |
JITCFlow ppc_opc_gen_stfsx(); |
224 |
JITCFlow ppc_opc_gen_sth(); |
225 |
JITCFlow ppc_opc_gen_sthbrx(); |
226 |
JITCFlow ppc_opc_gen_sthu(); |
227 |
JITCFlow ppc_opc_gen_sthux(); |
228 |
JITCFlow ppc_opc_gen_sthx(); |
229 |
JITCFlow ppc_opc_gen_stmw(); |
230 |
JITCFlow ppc_opc_gen_stswi(); |
231 |
JITCFlow ppc_opc_gen_stswx(); |
232 |
JITCFlow ppc_opc_gen_stw(); |
233 |
JITCFlow ppc_opc_gen_stwbrx(); |
234 |
JITCFlow ppc_opc_gen_stwcx_(); |
235 |
JITCFlow ppc_opc_gen_stwu(); |
236 |
JITCFlow ppc_opc_gen_stwux(); |
237 |
JITCFlow ppc_opc_gen_stwx(); |
238 |
JITCFlow ppc_opc_gen_stvx(); /* for altivec support */ |
239 |
JITCFlow ppc_opc_gen_stvxl(); |
240 |
JITCFlow ppc_opc_gen_stvebx(); |
241 |
JITCFlow ppc_opc_gen_stvehx(); |
242 |
JITCFlow ppc_opc_gen_stvewx(); |
243 |
JITCFlow ppc_opc_gen_dstst(); |
244 |
JITCFlow ppc_opc_gen_dss(); |
245 |
|
246 |
#endif |
247 |
|