40 #define DOT0(n) X(n ## _dot) { instr(n)(cpu,ic); \ 41 update_cr0(cpu, reg(ic->arg[0])); } 42 #define DOT1(n) X(n ## _dot) { instr(n)(cpu,ic); \ 43 update_cr0(cpu, reg(ic->arg[1])); } 44 #define DOT2(n) X(n ## _dot) { instr(n)(cpu,ic); \ 45 update_cr0(cpu, reg(ic->arg[2])); } 47 #ifndef CHECK_FOR_FPU_EXCEPTION 48 #define CHECK_FOR_FPU_EXCEPTION { if (!(cpu->cd.ppc.msr & PPC_MSR_FP)) { \ 50 uint64_t low_pc = ((size_t)ic - \ 51 (size_t)cpu->cd.ppc.cur_ic_page) \ 52 / sizeof(struct ppc_instr_call); \ 53 cpu->pc = (cpu->pc & ~((PPC_IC_ENTRIES_PER_PAGE-1) << \ 54 PPC_INSTR_ALIGNMENT_SHIFT)) + (low_pc << \ 55 PPC_INSTR_ALIGNMENT_SHIFT); \ 56 ppc_exception(cpu, PPC_EXCEPTION_FPU); \ 75 fatal(
"PPC: invalid(): INTERNAL ERROR\n");
93 reg(
ic->arg[2]) = (int32_t)
ic->arg[1];
111 reg(
ic->arg[2]) = tmp;
126 uint64_t tmp = (uint32_t)
reg(
ic->arg[0]);
129 tmp2 += (uint32_t)
ic->arg[1];
130 if ((tmp2 >> 32) != (tmp >> 32))
132 reg(
ic->arg[2]) = (uint32_t)tmp2;
147 if (tmp >=
reg(
ic->arg[0]))
163 uint64_t tmp = (uint32_t)
reg(
ic->arg[0]);
166 tmp2 += (uint32_t)
ic->arg[1];
167 if ((tmp2 >> 32) != (tmp >> 32))
169 reg(
ic->arg[2]) = (uint32_t)tmp2;
183 unsigned int bo =
ic->arg[0], bi31m =
ic->arg[1];
185 uint64_t old_pc =
cpu->
pc;
189 ctr_ok = (bo >> 2) & 1;
191 ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) );
192 cond_ok = (bo >> 4) & 1;
193 cond_ok |= ( ((bo >> 3) & 1) == ((
cpu->
cd.
ppc.
cr >> bi31m) & 1) );
194 if (ctr_ok && cond_ok) {
195 uint64_t mask_within_page =
202 if ((old_pc & ~mask_within_page) ==
203 (
cpu->
pc & ~mask_within_page)) {
206 ((
cpu->
pc & mask_within_page) >>
221 uint64_t low_pc, old_pc =
cpu->
pc;
222 unsigned int bo =
ic->arg[0], bi31m =
ic->arg[1] ;
227 ctr_ok = (bo >> 2) & 1;
229 ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) );
230 cond_ok = (bo >> 4) & 1;
231 cond_ok |= ( ((bo >> 3) & 1) == ((
cpu->
cd.
ppc.
cr >> bi31m) & 1) );
234 low_pc = ((size_t)
ic - (
size_t)
235 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call) + 1;
240 if (ctr_ok && cond_ok) {
241 uint64_t mask_within_page =
250 if ((old_pc & ~mask_within_page) ==
251 (
cpu->
pc & ~mask_within_page)) {
254 ((
cpu->
pc & mask_within_page) >>
273 unsigned int bo =
ic->arg[0], bi31m =
ic->arg[1];
274 uint64_t old_pc =
cpu->
pc;
276 int cond_ok = (bo >> 4) & 1;
277 cond_ok |= ( ((bo >> 3) & 1) == ((
cpu->
cd.
ppc.
cr >> bi31m) & 1) );
279 uint64_t mask_within_page =
286 if ((old_pc & ~mask_within_page) ==
287 (
cpu->
pc & ~mask_within_page)) {
290 ((
cpu->
pc & mask_within_page) >>
300 uint64_t low_pc, old_pc =
cpu->
pc;
301 unsigned int bo =
ic->arg[0], bi31m =
ic->arg[1] ;
303 int cond_ok = (bo >> 4) & 1;
304 cond_ok |= ( ((bo >> 3) & 1) == ((
cpu->
cd.
ppc.
cr >> bi31m) & 1) );
307 low_pc = ((size_t)
ic - (
size_t)
308 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call) + 1;
314 uint64_t mask_within_page =
321 if ((old_pc & ~mask_within_page) ==
322 (
cpu->
pc & ~mask_within_page)) {
325 ((
cpu->
pc & mask_within_page) >>
343 cpu->
pc += (int32_t)
ic->arg[0];
365 unsigned int ctr_ok, cond_ok, bi31m =
ic->arg[2], bo =
ic->arg[1];
368 ctr_ok = (bo >> 2) & 1;
370 ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) );
371 cond_ok = (bo >> 4) & 1;
372 cond_ok |= ( ((bo >> 3) & 1) ==
374 if (ctr_ok && cond_ok)
380 unsigned int ctr_ok, cond_ok, bi31m =
ic->arg[2], bo =
ic->arg[1];
384 low_pc = ((size_t)
ic - (
size_t)
385 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call) + 1;
392 ctr_ok = (bo >> 2) & 1;
394 ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) );
395 cond_ok = (bo >> 4) & 1;
396 cond_ok |= ( ((bo >> 3) & 1) ==
398 if (ctr_ok && cond_ok)
410 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
424 unsigned int ctr_ok, cond_ok, bi31m =
ic->arg[2], bo =
ic->arg[1];
427 ctr_ok = (bo >> 2) & 1;
429 ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) );
430 cond_ok = (bo >> 4) & 1;
431 cond_ok |= ( ((bo >> 3) & 1) ==
433 if (ctr_ok && cond_ok)
434 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
436 X(bc_samepage_simple0)
438 int bi31m =
ic->arg[2];
440 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
442 X(bc_samepage_simple1)
444 int bi31m =
ic->arg[2];
446 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
451 unsigned int ctr_ok, cond_ok, bi31m =
ic->arg[2], bo =
ic->arg[1];
455 low_pc = ((size_t)
ic - (
size_t)
456 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call) + 1;
463 ctr_ok = (bo >> 2) & 1;
465 ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) );
466 cond_ok = (bo >> 4) & 1;
467 cond_ok |= ( ((bo >> 3) & 1) ==
469 if (ctr_ok && cond_ok)
470 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
485 cpu->
pc += (int32_t)
ic->arg[0];
515 cpu->
pc += (int32_t)
ic->arg[0];
546 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
564 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
567 low_pc = ((size_t)
cpu->
cd.
ppc.next_ic - (
size_t)
568 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call);
583 uint32_t tmp =
reg(
ic->arg[0]);
585 for (i=0; i<32; i++) {
586 if (tmp & 0x80000000)
603 int64_t tmp =
reg(
ic->arg[0]), tmp2 =
reg(
ic->arg[1]);
604 int bf_shift =
ic->arg[2], c;
627 uint64_t tmp =
reg(
ic->arg[0]), tmp2 =
reg(
ic->arg[1]);
628 int bf_shift =
ic->arg[2], c;
651 int64_t tmp =
reg(
ic->arg[0]), imm = (int32_t)
ic->arg[1];
652 int bf_shift =
ic->arg[2], c;
675 uint64_t tmp =
reg(
ic->arg[0]), imm = (uint32_t)
ic->arg[1];
676 int bf_shift =
ic->arg[2], c;
699 int32_t tmp =
reg(
ic->arg[0]), tmp2 =
reg(
ic->arg[1]);
700 int bf_shift =
ic->arg[2], c;
715 int32_t tmp =
reg(
ic->arg[0]), tmp2 =
reg(
ic->arg[1]);
736 uint32_t tmp =
reg(
ic->arg[0]), tmp2 =
reg(
ic->arg[1]);
737 int bf_shift =
ic->arg[2], c;
760 int32_t tmp =
reg(
ic->arg[0]), imm =
ic->arg[1];
761 int bf_shift =
ic->arg[2], c;
776 int32_t tmp =
reg(
ic->arg[0]), imm =
ic->arg[1];
797 uint32_t tmp =
reg(
ic->arg[0]), imm =
ic->arg[1];
798 int bf_shift =
ic->arg[2], c;
821 unsigned char cacheline[128];
828 addr &= ~(cacheline_size - 1);
829 memset(cacheline, 0,
sizeof(cacheline));
831 while (cleared < cacheline_size) {
832 int to_clear = cacheline_size <
sizeof(cacheline)?
833 cacheline_size :
sizeof(cacheline);
835 unsigned char *
page =
cpu->
cd.
ppc.host_store[addr >> 12];
837 memset(page + (addr & 0xfff), 0, to_clear);
892 *(uint64_t *)
ic->arg[1] = *(uint64_t *)
ic->arg[0];
906 v = *(uint64_t *)
ic->arg[0];
907 *(uint64_t *)
ic->arg[1] = v & 0x7fffffffffffffffULL;
921 v = *(uint64_t *)
ic->arg[0];
922 *(uint64_t *)
ic->arg[1] = v ^ 0x8000000000000000ULL;
936 int bf_shift =
ic->arg[0], c = 0;
947 else if (fra.
f > frb.
f)
1008 if (frb.
f >= 2147483647.0)
1010 else if (frb.
f <= -2147483648.0)
1013 res = (int32_t) frb.
f;
1016 *(uint64_t *)
ic->arg[1] = (uint32_t)res;
1031 double result = 0.0;
1038 result = fra.
f * frc.
f;
1044 else if (result > 0.0)
1053 (*(uint64_t *)
ic->arg[0]) =
1072 uint32_t iw =
ic->arg[2];
1073 int b = (iw >> 11) & 31, c = (iw >> 6) & 31;
1077 double result = 0.0;
1085 result = fra.
f * frc.
f + frb.
f;
1091 else if (result > 0.0)
1100 (*(uint64_t *)
ic->arg[0]) =
1114 uint32_t iw =
ic->arg[2];
1115 int b = (iw >> 11) & 31, c = (iw >> 6) & 31;
1119 double result = 0.0;
1127 result = fra.
f * frc.
f - frb.
f;
1133 else if (result > 0.0)
1142 (*(uint64_t *)
ic->arg[0]) =
1158 double result = 0.0;
1165 result = fra.
f + frb.
f;
1171 else if (result > 0.0)
1180 (*(uint64_t *)
ic->arg[2]) =
1192 double result = 0.0;
1199 result = fra.
f - frb.
f;
1205 else if (result > 0.0)
1214 (*(uint64_t *)
ic->arg[2]) =
1226 double result = 0.0;
1233 result = fra.
f / frb.
f;
1239 else if (result > 0.0)
1248 (*(uint64_t *)
ic->arg[2]) =
1265 int iw =
ic->arg[0], len = 4,
load = 0, xo = (iw >> 1) & 1023;
1266 int i, rc = iw & 1, rt, ra, rb;
1267 uint64_t
addr = 0, value;
1282 rt = (iw >> 21) & 31;
1283 ra = (iw >> 16) & 31;
1284 rb = (iw >> 11) & 31;
1292 fatal(
"ll: rc-bit set?\n");
1297 fatal(
"ll: error: TODO\n");
1302 for (i=0; i<len; i++) {
1307 value |= d[len - 1 - i];
1316 fatal(
"sc: rc-bit not set?\n");
1334 for (i=0; i<len; i++) {
1336 d[len - 1 - i] = value >> (8*i);
1338 d[i] = value >> (8*i);
1343 fatal(
"sc: error: TODO\n");
1369 int sr_num =
ic->arg[0];
1379 int sr_num =
reg(
ic->arg[0]) >> 28;
1403 uint32_t sr_num =
reg(
ic->arg[0]) >> 28;
1415 int rs = (
ic->arg[0] >> 21) & 31;
1416 int ra = (
ic->arg[0] >> 16) & 31;
1417 int sh = ((
ic->arg[0] >> 11) & 31) | ((
ic->arg[0] & 2) << 4);
1418 int mb = ((
ic->arg[0] >> 6) & 31) | (
ic->arg[0] & 0x20);
1419 int rc =
ic->arg[0] & 1;
1423 int b = (tmp >> 63) & 1;
1424 tmp = (tmp << 1) | b;
1428 tmp |= ((uint64_t)1 << (63-mb));
1444 int rs = (
ic->arg[0] >> 21) & 31;
1445 int ra = (
ic->arg[0] >> 16) & 31;
1446 int sh = ((
ic->arg[0] >> 11) & 31) | ((
ic->arg[0] & 2) << 4);
1447 int me = ((
ic->arg[0] >> 6) & 31) | (
ic->arg[0] & 0x20);
1448 int rc =
ic->arg[0] & 1;
1452 int b = (tmp >> 63) & 1;
1453 tmp = (tmp << 1) | b;
1456 tmp &= ~((uint64_t)1 << (63-me));
1470 uint32_t iw =
ic->arg[0];
1471 int rs = (iw >> 21) & 31, ra = (iw >> 16) & 31;
1472 int sh = ((iw >> 11) & 31) | ((iw & 2) << 4);
1473 int mb = ((iw >> 6) & 31) | (iw & 0x20);
1474 int rc =
ic->arg[0] & 1;
1479 int b = (s >> 63) & 1;
1484 tmp |= ((uint64_t)1 << (63-m));
1486 }
while (m != 63 - sh);
1503 uint32_t tmp, iword =
ic->arg[2];
1504 int rs = (iword >> 21) & 31;
1505 int rb = (iword >> 11) & 31;
1508 tmp = (tmp << sh) | (tmp >> (32-sh));
1509 tmp &= (uint32_t)
ic->arg[1];
1510 reg(
ic->arg[0]) = tmp;
1524 uint32_t tmp, iword =
ic->arg[2];
1525 int rs = (iword >> 21) & 31;
1526 int sh = (iword >> 11) & 31;
1528 tmp = (tmp << sh) | (tmp >> (32-sh));
1529 tmp &= (uint32_t)
ic->arg[1];
1530 reg(
ic->arg[0]) = tmp;
1545 uint32_t iword =
ic->arg[2];
1546 int sh = (iword >> 11) & 31;
1547 int mb = (iword >> 6) & 31;
1548 int me = (iword >> 1) & 31;
1551 tmp = (tmp << sh) | (tmp >> (32-sh));
1555 mask = (uint64_t)1 << (31-mb);
1564 reg(
ic->arg[1]) = ra;
1579 uint32_t tmp =
reg(
ic->arg[0]);
1580 int i = 0, j = 0, sh =
ic->arg[2];
1583 if (tmp & 0x80000000)
1589 if (tmp & 0x40000000)
1594 reg(
ic->arg[1]) = (int64_t)(int32_t)tmp;
1606 int bf_shift =
ic->arg[0], bfa_shift =
ic->arg[1];
1607 uint32_t tmp = (
cpu->
cd.
ppc.
cr >> bfa_shift) & 0xf;
1619 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1620 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1628 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1629 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1637 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1638 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1646 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1647 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1655 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1656 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1664 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1665 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1673 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1674 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1756 uint64_t tmp, mask = 0x800000000000ff73ULL;
1802 uint64_t x =
reg(
ic->arg[0]);
1813 x = (y & 0xffffffff00000000ULL) | (x & 0xffffffffULL);
1842 x = (x & ~0x8000) |
ic->arg[0];
1868 reg(
ic->arg[2]) = (uint32_t)(
reg(
ic->arg[0]) * (int32_t)
ic->arg[1]);
1882 int rs =
ic->arg[0];
1884 int low_pc = ((
size_t)
ic - (size_t)
cpu->
cd.
ppc.cur_ic_page)
1885 /
sizeof(
struct ppc_instr_call);
1899 + (d[2] << 8) + d[3];
1902 + (d[1] << 8) + d[0];
1905 addr +=
sizeof(uint32_t);
1911 int rs =
ic->arg[0];
1913 int low_pc = ((
size_t)
ic - (size_t)
cpu->
cd.
ppc.cur_ic_page)
1914 /
sizeof(
struct ppc_instr_call);
1922 d[3] = tmp; d[2] = tmp >> 8;
1923 d[1] = tmp >> 16; d[0] = tmp >> 24;
1925 d[0] = tmp; d[1] = tmp >> 8;
1926 d[2] = tmp >> 16; d[3] = tmp >> 24;
1935 addr +=
sizeof(uint32_t);
1950 int rt =
ic->arg[0], nb =
ic->arg[2];
1953 int low_pc = ((size_t)
ic - (
size_t)
cpu->
cd.
ppc.cur_ic_page)
1954 /
sizeof(
struct ppc_instr_call);
1983 int rs =
ic->arg[0], nb =
ic->arg[2];
1987 int low_pc = ((size_t)
ic - (
size_t)
cpu->
cd.
ppc.cur_ic_page)
1988 /
sizeof(
struct ppc_instr_call);
1994 unsigned char d = cur >> 24;
2022 reg(
ic->arg[2]) = (int32_t)(int8_t)
reg(
ic->arg[0]);
2024 reg(
ic->arg[2]) = (int64_t)(int8_t)
reg(
ic->arg[0]);
2030 reg(
ic->arg[2]) = (int32_t)(int16_t)
reg(
ic->arg[0]);
2032 reg(
ic->arg[2]) = (int64_t)(int16_t)
reg(
ic->arg[0]);
2038 fatal(
"TODO: extsw: invalid instruction\n");
2040 reg(
ic->arg[2]) = (int64_t)(int32_t)
reg(
ic->arg[0]);
2045 << (
reg(
ic->arg[1]) & 31); }
2048 if (sa >= 64)
reg(
ic->arg[2]) = 0;
2049 else reg(
ic->arg[2]) = (uint64_t)
reg(
ic->arg[0]) << (sa & 63); }
2053 uint32_t tmp =
reg(
ic->arg[0]);
2054 int i = 0, j = 0, sh =
reg(
ic->arg[1]) & 31;
2057 if (tmp & 0x80000000)
2063 if (tmp & 0x40000000)
2068 reg(
ic->arg[2]) = (int64_t)(int32_t)tmp;
2072 >> (
reg(
ic->arg[1]) & 31); }
2112 int32_t sum = (int32_t)
reg(
ic->arg[0]) * (int32_t)
reg(
ic->arg[1]);
2113 reg(
ic->arg[2]) = (int32_t)sum;
2119 sum = (int64_t)(int32_t)
reg(
ic->arg[0])
2120 * (int64_t)(int32_t)
reg(
ic->arg[1]);
2121 reg(
ic->arg[2]) = sum >> 32;
2127 sum = (uint64_t)(uint32_t)
reg(
ic->arg[0])
2128 * (uint64_t)(uint32_t)
reg(
ic->arg[1]);
2129 reg(
ic->arg[2]) = sum >> 32;
2134 int32_t a =
reg(
ic->arg[0]), b =
reg(
ic->arg[1]);
2140 reg(
ic->arg[2]) = (uint32_t)sum;
2145 uint32_t a =
reg(
ic->arg[0]), b =
reg(
ic->arg[1]);
2151 reg(
ic->arg[2]) = sum;
2177 uint64_t tmp = (uint32_t)
reg(
ic->arg[0]);
2178 uint64_t tmp2 = tmp;
2180 tmp += (uint32_t)
reg(
ic->arg[1]);
2181 if ((tmp >> 32) != (tmp2 >> 32))
2183 reg(
ic->arg[2]) = (uint32_t)tmp;
2198 uint64_t tmp = (uint32_t)
reg(
ic->arg[0]);
2199 uint64_t tmp2 = tmp;
2201 tmp += (uint32_t)
reg(
ic->arg[1]);
2204 if ((tmp >> 32) != (tmp2 >> 32))
2206 reg(
ic->arg[2]) = (uint32_t)tmp;
2213 uint64_t tmp = (uint32_t)
reg(
ic->arg[0]);
2214 uint64_t tmp2 = tmp;
2218 tmp += 0xffffffffULL;
2219 if ((tmp >> 32) != (tmp2 >> 32))
2221 reg(
ic->arg[2]) = (uint32_t)tmp;
2228 uint64_t tmp = (uint32_t)
reg(
ic->arg[0]);
2229 uint64_t tmp2 = tmp;
2233 if ((tmp >> 32) != (tmp2 >> 32))
2235 reg(
ic->arg[2]) = (uint32_t)tmp;
2267 }
else if (
reg(
ic->arg[1]) >=
reg(
ic->arg[0]))
2275 reg(
ic->arg[2]) =
reg(
ic->arg[1]) -
reg(
ic->arg[0]) - (old_ca? 0 : 1);
2281 uint64_t tmp = (uint32_t)(~
reg(
ic->arg[0]));
2282 tmp += 0xffffffffULL;
2286 if ((tmp >> 32) != 0)
2288 reg(
ic->arg[2]) = (uint32_t)tmp;
2294 uint64_t tmp = (uint32_t)(~
reg(
ic->arg[0]));
2295 uint64_t tmp2 = tmp;
2299 if ((tmp >> 32) != (tmp2 >> 32))
2301 reg(
ic->arg[2]) = (uint32_t)tmp;
2326 uint64_t old_pc, low_pc = ((size_t)
ic - (
size_t)
2327 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call);
2341 [2 + 4 + 8](
cpu,
ic);
2343 if (old_pc == cpu->pc) {
2346 (*(uint64_t *)
ic->arg[0]) &= 0xffffffff;
2349 (*(uint64_t *)
ic->arg[0]) =
2356 uint64_t old_pc, low_pc = ((size_t)
ic - (
size_t)
2357 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call);
2367 ppc32_loadstore_indexed
2371 [2 + 4 + 8](
cpu,
ic);
2373 if (old_pc == cpu->pc) {
2376 (*(uint64_t *)
ic->arg[0]) &= 0xffffffff;
2379 (*(uint64_t *)
ic->arg[0]) =
2393 [3 + 4 + 8](
cpu,
ic);
2401 ppc32_loadstore_indexed
2405 [3 + 4 + 8](
cpu,
ic);
2409 uint64_t *old_arg0 = (uint64_t *)
ic->arg[0];
2418 ic->arg[0] = (size_t)&tmp_val;
2428 ic->arg[0] = (size_t)old_arg0;
2432 uint64_t *old_arg0 = (uint64_t *)
ic->arg[0];
2441 ic->arg[0] = (size_t)&tmp_val;
2445 ppc32_loadstore_indexed
2451 ic->arg[0] = (size_t)old_arg0;
2471 ppc32_loadstore_indexed
2491 int rs =
ic->arg[0];
2499 hi = ((uint64_t)data[0] << 56) +
2500 ((uint64_t)data[1] << 48) +
2501 ((uint64_t)data[2] << 40) +
2502 ((uint64_t)data[3] << 32) +
2503 ((uint64_t)data[4] << 24) +
2504 ((uint64_t)data[5] << 16) +
2505 ((uint64_t)data[6] << 8) +
2506 ((uint64_t)data[7]);
2507 lo = ((uint64_t)data[8] << 56) +
2508 ((uint64_t)data[9] << 48) +
2509 ((uint64_t)data[10] << 40) +
2510 ((uint64_t)data[11] << 32) +
2511 ((uint64_t)data[12] << 24) +
2512 ((uint64_t)data[13] << 16) +
2513 ((uint64_t)data[14] << 8) +
2514 ((uint64_t)data[15]);
2522 int rs =
ic->arg[0];
2535 data[10] = lo >> 40;
2536 data[11] = lo >> 32;
2537 data[12] = lo >> 24;
2538 data[13] = lo >> 16;
2568 fatal(
"[ tlbia ]\n");
2607 cpu->
cd.
ppc.next_ic = ¬hing_call;
2684 uint64_t
addr, low_pc, tmp_addr;
2685 uint32_t iword, mask;
2686 unsigned char *
page;
2687 unsigned char ib[4];
2688 int main_opcode, rt, rs, ra, rb, rc, aa_bit, l_bit, lk_bit, spr, sh,
2689 xo, imm,
load, size, update, zero, bf, bo, bi, bh, oe_bit, n64=0,
2690 bfa, fp, byterev, nb, mb, me;
2691 void (*samepage_function)(
struct cpu *,
struct ppc_instr_call *);
2692 void (*rc_f)(
struct cpu *,
struct ppc_instr_call *);
2695 low_pc = ((size_t)
ic - (
size_t)
cpu->
cd.
ppc.cur_ic_page)
2696 /
sizeof(
struct ppc_instr_call);
2705 page =
cpu->
cd.
ppc.host_load[((uint32_t)addr) >> 12];
2717 page = l3->host_load[x3];
2723 memcpy(ib, page + (addr & 0xfff),
sizeof(ib));
2728 fatal(
"PPC to_be_translated(): " 2729 "read failed: TODO\n");
2736 uint32_t *p = (uint32_t *) ib;
2741 #define DYNTRANS_TO_BE_TRANSLATED_HEAD 2743 #undef DYNTRANS_TO_BE_TRANSLATED_HEAD 2750 main_opcode = iword >> 26;
2752 switch (main_opcode) {
2755 if (iword == 0x12739cc4) {
2763 fatal(
"[ TODO: Unimplemented ALTIVEC, iword" 2764 " = 0x%08" PRIx32
"x ]\n", iword);
2770 rt = (iword >> 21) & 31;
2771 ra = (iword >> 16) & 31;
2772 imm = (int16_t)(iword & 0xffff);
2775 ic->arg[1] = (ssize_t)imm;
2780 rt = (iword >> 21) & 31;
2781 ra = (iword >> 16) & 31;
2782 imm = (int16_t)(iword & 0xffff);
2785 ic->arg[1] = (ssize_t)imm;
2791 bf = (iword >> 23) & 7;
2792 l_bit = (iword >> 21) & 1;
2793 ra = (iword >> 16) & 31;
2795 imm = iword & 0xffff;
2801 imm = (int16_t)(iword & 0xffff);
2812 ic->arg[1] = (ssize_t)imm;
2813 ic->arg[2] = 28 - 4 * bf;
2820 fatal(
"addic for 64-bit: TODO\n");
2823 rt = (iword >> 21) & 31;
2824 ra = (iword >> 16) & 31;
2825 imm = (int16_t)(iword & 0xffff);
2837 rt = (iword >> 21) & 31; ra = (iword >> 16) & 31;
2843 ic->arg[1] = (int16_t)(iword & 0xffff);
2846 if (ra == 0 &&
ic->arg[1] == 0)
2853 rs = (iword >> 21) & 31; ra = (iword >> 16) & 31;
2856 ic->arg[1] = iword & 0xffff;
2866 rs = (iword >> 21) & 31; ra = (iword >> 16) & 31;
2873 ic->arg[1] = iword & 0xffff;
2900 rs = (iword >> 21) & 31;
2901 ra = (iword >> 16) & 31;
2902 imm = (int16_t)iword;
2903 load = 0; zero = 1; size = 0; update = 0; fp = 0;
2905 switch (main_opcode) {
2909 case PPC_HI6_LHAU: load=1; size=1; zero=0; update=1;
break;
2927 if (
ic->f == NULL) {
2934 [size + 4*zero + 8*load + (imm==0? 16 : 0)
2937 if (ra == 0 && update) {
2939 fatal(
"TODO: ra=0 && update?\n");
2950 ic->arg[2] = (ssize_t)imm;
2954 aa_bit = (iword >> 1) & 1;
2956 bo = (iword >> 21) & 31;
2957 bi = (iword >> 16) & 31;
2958 tmp_addr = (int64_t)(int16_t)(iword & 0xfffc);
2961 fatal(
"aa_bit: NOT YET\n");
2966 samepage_function =
instr(bcl_samepage);
2969 if ((bo & 0x14) == 0x04) {
2970 samepage_function = bo & 8?
2971 instr(bc_samepage_simple1) :
2972 instr(bc_samepage_simple0);
2974 samepage_function =
instr(bc_samepage);
2976 ic->arg[0] = (ssize_t)(tmp_addr + (addr & 0xffc));
2982 uint64_t mask_within_page =
2984 uint64_t old_pc =
addr;
2985 uint64_t new_pc = old_pc + (int32_t)tmp_addr;
2986 if ((old_pc & ~mask_within_page) ==
2987 (new_pc & ~mask_within_page)) {
2988 ic->f = samepage_function;
2989 ic->arg[0] = (size_t) (
2991 ((new_pc & mask_within_page) >> 2));
2997 ic->arg[0] = (iword >> 5) & 0x7f;
2998 ic->arg[1] = (addr & 0xfff) + 4;
2999 if (iword == 0x44ee0002) {
3007 aa_bit = (iword & 2) >> 1;
3009 tmp_addr = (int64_t)(int32_t)((iword & 0x03fffffc) << 6);
3010 tmp_addr = (int64_t)tmp_addr >> 6;
3014 samepage_function =
instr(bl_samepage_trace);
3017 samepage_function =
instr(bl_samepage);
3021 samepage_function =
instr(b_samepage);
3023 ic->arg[0] = (ssize_t)(tmp_addr + (addr & 0xffc));
3024 ic->arg[1] = (addr & 0xffc) + 4;
3028 uint64_t mask_within_page =
3030 uint64_t old_pc =
addr;
3031 uint64_t new_pc = old_pc + (int32_t)tmp_addr;
3032 if ((old_pc & ~mask_within_page) ==
3033 (new_pc & ~mask_within_page)) {
3034 ic->f = samepage_function;
3035 ic->arg[0] = (size_t) (
3037 ((new_pc & mask_within_page) >> 2));
3050 ic->arg[0] = (ssize_t)tmp_addr;
3055 xo = (iword >> 1) & 1023;
3060 bo = (iword >> 21) & 31;
3061 bi = (iword >> 16) & 31;
3062 bh = (iword >> 11) & 3;
3070 (bo & 0x14) == 0x14)
3076 fatal(
"TODO: bclr/bcctr " 3077 "bo bit 2 clear!\n");
3086 ic->arg[1] = 31 - bi;
3104 bf = (iword >> 23) & 7;
3105 bfa = (iword >> 18) & 7;
3106 ic->arg[0] = 28 - 4*bf;
3107 ic->arg[1] = 28 - 4*bfa;
3136 ra = (iword >> 16) & 31;
3137 mb = (iword >> 6) & 31;
3138 me = (iword >> 1) & 31;
3142 mask |= ((uint32_t)0x80000000 >> mb);
3147 switch (main_opcode) {
3155 ic->arg[2] = (uint32_t)iword;
3159 rs = (iword >> 21) & 31;
3160 ra = (iword >> 16) & 31;
3164 ic->arg[2] = (uint32_t)iword;
3170 rs = (iword >> 21) & 31;
3171 ra = (iword >> 16) & 31;
3177 ic->arg[2] = (int32_t)(int16_t)iword;
3178 switch (main_opcode) {
3189 xo = (iword >> 2) & 7;
3203 fatal(
"TODO: rld* in 32-bit mode?\n");
3213 xo = (iword >> 1) & 1023;
3218 bf = (iword >> 23) & 7;
3219 l_bit = (iword >> 21) & 1;
3220 ra = (iword >> 16) & 31;
3221 rb = (iword >> 11) & 31;
3239 ic->arg[2] = 28 - 4*bf;
3243 rs = (iword >> 21) & 31;
3244 ra = (iword >> 16) & 31;
3248 fatal(
"TODO: rc\n");
3257 rt = (iword >> 21) & 31;
3258 spr = ((iword >> 6) & 0x3e0) + ((iword >> 16) & 31);
3259 debug_spr_usage(
cpu->
pc, spr);
3267 default:
ic->f =
instr(mfspr);
3272 rs = (iword >> 21) & 31;
3273 spr = ((iword >> 6) & 0x3e0) + ((iword >> 16) & 31);
3274 debug_spr_usage(
cpu->
pc, spr);
3292 rt = (iword >> 21) & 31;
3298 rt = (iword >> 21) & 31;
3305 rs = (iword >> 21) & 31;
3306 l_bit = (iword >> 16) & 1;
3309 fatal(
"TODO: mtmsr l-bit\n");
3313 ic->arg[1] = (addr & 0xfff) + 4;
3319 rs = (iword >> 21) & 31;
3321 int i, fxm = (iword >> 12) & 255;
3323 for (i=0; i<8; i++, fxm <<= 1) {
3328 ic->arg[1] = (uint32_t)tmp;
3336 rt = (iword >> 21) & 31;
3337 rb = (iword >> 11) & 31;
3346 fatal(
"Not yet for 64-bit mode\n");
3353 rt = (iword >> 21) & 31;
3354 ic->arg[0] = (iword >> 16) & 15;
3362 fatal(
"Not yet for 64-bit mode\n");
3368 rs = (iword >> 21) & 31;
3369 ra = (iword >> 16) & 31;
3370 sh = (iword >> 11) & 31;
3393 ra = (iword >> 16) & 31;
3394 rb = (iword >> 11) & 31;
3400 ic->arg[2] = addr & 0xfff;
3418 rb = (iword >> 11) & 31;
3424 rb = (iword >> 11) & 31;
3430 rb = (iword >> 11) & 31;
3441 rt = (iword >> 21) & 31;
3442 spr = ((iword >> 6) & 0x3e0) + ((iword >> 16) & 31);
3445 case 268:
ic->f =
instr(mftb);
break;
3446 case 269:
ic->f =
instr(mftbu);
break;
3448 fatal(
"mftb spr=%i?\n", spr);
3454 rt = (iword >> 21) & 31;
3455 ra = (iword >> 16) & 31;
3475 rs = (iword >> 21) & 31;
3476 ra = (iword >> 16) & 31;
3477 nb = (iword >> 11) & 31;
3483 ic->arg[2] = nb == 0? 32 : nb;
3491 ic->arg[0] = iword & 0x8000;
3496 fatal(
"[ mtdcr: TODO ]\n");
3524 rs = (iword >> 21) & 31;
3525 ra = (iword >> 16) & 31;
3526 rb = (iword >> 11) & 31;
3532 load = 0; zero = 1; size = 0; update = 0;
3533 byterev = 0; fp = 0;
3539 case PPC_31_LHAUX: size=1; load=update=1; zero=0;
break;
3573 if (!byterev &&
ic->f == NULL) {
3576 ppc32_loadstore_indexed
3580 [size + 4*zero + 8*load + 16*update];
3582 if (ra == 0 && update) {
3584 fatal(
"TODO: ra=0 && update?\n");
3604 rs = (iword >> 21) & 31;
3605 ra = (iword >> 16) & 31;
3606 rb = (iword >> 11) & 31;
3611 rc_f =
instr(extsb_dot);
break;
3613 rc_f =
instr(extsh_dot);
break;
3615 rc_f =
instr(extsw_dot);
break;
3617 rc_f =
instr(slw_dot);
break;
3619 rc_f =
instr(sld_dot);
break;
3621 rc_f =
instr(sraw_dot);
break;
3623 rc_f =
instr(srw_dot);
break;
3625 rc_f =
instr(and_dot);
break;
3627 rc_f =
instr(nand_dot);
break;
3629 rc_f =
instr(andc_dot);
break;
3631 rc_f =
instr(nor_dot);
break;
3634 rc_f =
instr(or_dot);
break;
3636 rc_f =
instr(orc_dot);
break;
3638 rc_f =
instr(xor_dot);
break;
3640 rc_f =
instr(eqv_dot);
break;
3664 rt = (iword >> 21) & 31;
3665 ra = (iword >> 16) & 31;
3666 rb = (iword >> 11) & 31;
3667 oe_bit = (iword >> 10) & 1;
3671 fatal(
"oe_bit not yet implemented\n");
3694 ic->f =
instr(add_dot);
break;
3696 ic->f =
instr(adde_dot);
break;
3698 ic->f =
instr(addme_dot);
break;
3700 ic->f =
instr(addze_dot);
break;
3702 ic->f =
instr(divw_dot);
break;
3704 ic->f =
instr(divwu_dot);
break;
3706 ic->f =
instr(mullw_dot);
break;
3708 ic->f =
instr(mulhw_dot);
break;
3710 ic->f =
instr(mulhwu_dot);
break;
3712 ic->f =
instr(subf_dot);
break;
3714 ic->f =
instr(subfc_dot);
break;
3716 ic->f =
instr(subfe_dot);
break;
3718 ic->f =
instr(subfme_dot);
break;
3720 ic->f =
instr(subfze_dot);
break;
3722 fatal(
"RC bit not yet " 3732 fatal(
"Not yet for 64-bit mode\n");
3747 rs = (iword >> 21) & 31;
3748 ra = (iword >> 16) & 31;
3749 rb = (iword >> 11) & 31;
3764 xo = (iword >> 1) & 1023;
3765 rt = (iword >> 21) & 31;
3766 ra = (iword >> 16) & 31;
3767 rb = (iword >> 11) & 31;
3768 rs = (iword >> 6) & 31;
3773 fatal(
"Floating point (59) " 3774 "with rc bit! TODO\n");
3807 xo = (iword >> 1) & 1023;
3808 rt = (iword >> 21) & 31;
3809 ra = (iword >> 16) & 31;
3810 rb = (iword >> 11) & 31;
3811 rs = (iword >> 6) & 31;
3816 fatal(
"Floating point (63) " 3817 "with rc bit! TODO\n");
3856 ic->arg[0] = 28 - 4*(rt >> 2);
3883 for (bi=7; bi>=0; bi--) {
3885 if (iword & (1 << (17+bi)))
3898 #define DYNTRANS_TO_BE_TRANSLATED_TAIL 3900 #undef DYNTRANS_TO_BE_TRANSLATED_TAIL
void(* ppc_loadstore[64])(struct cpu *, struct ppc_instr_call *)
void fatal(const char *fmt,...)
void(* ppc_loadstore_indexed[32])(struct cpu *, struct ppc_instr_call *)
void COMBINE() nop(struct cpu *cpu, struct mips_instr_call *ic, int low_addr)
struct arm_instr_call * ic
#define PPC_FPSCR_FPCC_SHIFT
#define DYNTRANS_L2_64_TABLE
void ieee_interpret_float_value(uint64_t x, struct ieee_float_value *fvp, int fmt)
void COMBINE() ori(struct cpu *cpu, struct mips_instr_call *ic, int low_addr)
void reg_access_msr(struct cpu *cpu, uint64_t *valuep, int writeflag, int check_for_interrupts)
int debugger_n_steps_left_before_interaction
int translation_readahead
#define quick_pc_to_pointers(cpu)
int(* memory_rw)(struct cpu *cpu, struct memory *mem, uint64_t vaddr, unsigned char *data, size_t len, int writeflag, int cache_flags)
int of_emul(struct cpu *cpu)
#define PPC_HI6_ADDIC_DOT
void cpu_functioncall_trace(struct cpu *cpu, uint64_t f)
#define PPC_IC_ENTRIES_PER_PAGE
void cpu_functioncall_trace_return(struct cpu *cpu)
void ppc_exception(struct cpu *cpu, int exception_nr)
#define CACHE_INSTRUCTION
void load(FILE *fh, unsigned char *ptr, unsigned long sz)
#define PPC_HI6_ANDIS_DOT
#define PPC_INSTR_ALIGNMENT_SHIFT
#define PPC_EXCEPTION_FPU
#define CHECK_FOR_FPU_EXCEPTION
void update_cr0(struct cpu *cpu, uint64_t value)
uint64_t ieee_store_float_value(double nf, int fmt)
addr & if(addr >=0x24 &&page !=NULL)
#define DYNTRANS_L3_64_TABLE
struct ppc_cpu_type_def cpu_type
#define INVALIDATE_VADDR_UPPER4
void(* invalidate_translation_caches)(struct cpu *, uint64_t paddr, int flags)