847 |
|
lp[7] = htonl(0x00040004); // Inst cache assoc/Data cache assoc |
848 |
|
lp[8] = htonl(0x00400002); // TLB total size/TLB assoc |
849 |
|
break; |
850 |
< |
case 8: // 750 |
850 |
> |
case 8: // 750, 750FX |
851 |
> |
case 0x7000: |
852 |
|
lp[0] = htonl(0x1000); // Page size |
853 |
|
lp[1] = htonl(0x8000); // Data cache size |
854 |
|
lp[2] = htonl(0x8000); // Inst cache size |
872 |
|
lp[8] = htonl(0x00800002); // TLB total size/TLB assoc |
873 |
|
break; |
874 |
|
// case 11: // X704? |
875 |
< |
case 12: // 7400, 7410 |
875 |
> |
case 12: // 7400, 7410, 7450, 7455, 7457 |
876 |
|
case 0x800c: |
877 |
+ |
case 0x8000: |
878 |
+ |
case 0x8001: |
879 |
+ |
case 0x8002: |
880 |
|
lp[0] = htonl(0x1000); // Page size |
881 |
|
lp[1] = htonl(0x8000); // Data cache size |
882 |
|
lp[2] = htonl(0x8000); // Inst cache size |
1062 |
|
static bool patch_68k_emul(void) |
1063 |
|
{ |
1064 |
|
uint32 *lp; |
1065 |
< |
uint32 base; |
1065 |
> |
uint32 base, loc; |
1066 |
|
|
1067 |
|
// Overwrite twi instructions |
1068 |
|
static const uint8 twi_dat[] = {0x0f, 0xff, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x01, 0x0f, 0xff, 0x00, 0x02}; |
1126 |
|
// Extra routine for 68k emulator start |
1127 |
|
lp = (uint32 *)(ROM_BASE + 0x36f900); |
1128 |
|
*lp++ = htonl(0x7c2903a6); // mtctr r1 |
1125 |
– |
#if EMULATED_PPC |
1126 |
– |
*lp++ = htonl(NativeOpcode(NATIVE_DISABLE_INTERRUPT)); |
1127 |
– |
#else |
1129 |
|
*lp++ = htonl(0x80200000 + XLM_IRQ_NEST); // lwz r1,XLM_IRQ_NEST |
1130 |
|
*lp++ = htonl(0x38210001); // addi r1,r1,1 |
1131 |
|
*lp++ = htonl(0x90200000 + XLM_IRQ_NEST); // stw r1,XLM_IRQ_NEST |
1131 |
– |
#endif |
1132 |
|
*lp++ = htonl(0x80200000 + XLM_KERNEL_DATA);// lwz r1,XLM_KERNEL_DATA |
1133 |
|
*lp++ = htonl(0x90c10018); // stw r6,0x18(r1) |
1134 |
|
*lp++ = htonl(0x7cc902a6); // mfctr r6 |
1156 |
|
// Extra routine for Mixed Mode |
1157 |
|
lp = (uint32 *)(ROM_BASE + 0x36fa00); |
1158 |
|
*lp++ = htonl(0x7c2903a6); // mtctr r1 |
1159 |
– |
#if EMULATED_PPC |
1160 |
– |
*lp++ = htonl(NativeOpcode(NATIVE_DISABLE_INTERRUPT)); |
1161 |
– |
#else |
1159 |
|
*lp++ = htonl(0x80200000 + XLM_IRQ_NEST); // lwz r1,XLM_IRQ_NEST |
1160 |
|
*lp++ = htonl(0x38210001); // addi r1,r1,1 |
1161 |
|
*lp++ = htonl(0x90200000 + XLM_IRQ_NEST); // stw r1,XLM_IRQ_NEST |
1165 |
– |
#endif |
1162 |
|
*lp++ = htonl(0x80200000 + XLM_KERNEL_DATA);// lwz r1,XLM_KERNEL_DATA |
1163 |
|
*lp++ = htonl(0x90c10018); // stw r6,0x18(r1) |
1164 |
|
*lp++ = htonl(0x7cc902a6); // mfctr r6 |
1186 |
|
// Extra routine for Reset/FC1E opcode |
1187 |
|
lp = (uint32 *)(ROM_BASE + 0x36fb00); |
1188 |
|
*lp++ = htonl(0x7c2903a6); // mtctr r1 |
1193 |
– |
#if EMULATED_PPC |
1194 |
– |
*lp++ = htonl(NativeOpcode(NATIVE_DISABLE_INTERRUPT)); |
1195 |
– |
#else |
1189 |
|
*lp++ = htonl(0x80200000 + XLM_IRQ_NEST); // lwz r1,XLM_IRQ_NEST |
1190 |
|
*lp++ = htonl(0x38210001); // addi r1,r1,1 |
1191 |
|
*lp++ = htonl(0x90200000 + XLM_IRQ_NEST); // stw r1,XLM_IRQ_NEST |
1199 |
– |
#endif |
1192 |
|
*lp++ = htonl(0x80200000 + XLM_KERNEL_DATA);// lwz r1,XLM_KERNEL_DATA |
1193 |
|
*lp++ = htonl(0x90c10018); // stw r6,0x18(r1) |
1194 |
|
*lp++ = htonl(0x7cc902a6); // mfctr r6 |
1216 |
|
// Extra routine for FE0A opcode (QuickDraw 3D needs this) |
1217 |
|
lp = (uint32 *)(ROM_BASE + 0x36fc00); |
1218 |
|
*lp++ = htonl(0x7c2903a6); // mtctr r1 |
1227 |
– |
#if EMULATED_PPC |
1228 |
– |
*lp++ = htonl(NativeOpcode(NATIVE_DISABLE_INTERRUPT)); |
1229 |
– |
#else |
1219 |
|
*lp++ = htonl(0x80200000 + XLM_IRQ_NEST); // lwz r1,XLM_IRQ_NEST |
1220 |
|
*lp++ = htonl(0x38210001); // addi r1,r1,1 |
1221 |
|
*lp++ = htonl(0x90200000 + XLM_IRQ_NEST); // stw r1,XLM_IRQ_NEST |
1233 |
– |
#endif |
1222 |
|
*lp++ = htonl(0x80200000 + XLM_KERNEL_DATA);// lwz r1,XLM_KERNEL_DATA |
1223 |
|
*lp++ = htonl(0x90c10018); // stw r6,0x18(r1) |
1224 |
|
*lp++ = htonl(0x7cc902a6); // mfctr r6 |
1254 |
|
return false; |
1255 |
|
dr_found: |
1256 |
|
lp++; |
1257 |
< |
*lp = htonl(0x48000000 + 0xf000 - (((uint32)lp - ROM_BASE) & 0xffff)); // b DR_CACHE_BASE+0x1f000 |
1258 |
< |
lp = (uint32 *)(ROM_BASE + 0x37f000); |
1259 |
< |
*lp++ = htonl(0x3c000000 + ((ROM_BASE + 0x46d0a4) >> 16)); // lis r0,xxx |
1260 |
< |
*lp++ = htonl(0x60000000 + ((ROM_BASE + 0x46d0a4) & 0xffff)); // ori r0,r0,xxx |
1261 |
< |
*lp++ = htonl(0x7c0903a6); // mtctr r0 |
1262 |
< |
*lp = htonl(POWERPC_BCTR); // bctr |
1257 |
> |
loc = (uint32)lp - ROM_BASE; |
1258 |
> |
if ((base = powerpc_branch_target(ROM_BASE + loc)) == 0) base = ROM_BASE + loc; |
1259 |
> |
static const uint8 dr_ret_dat[] = {0x80, 0xbf, 0x08, 0x14, 0x53, 0x19, 0x4d, 0xac, 0x7c, 0xa8, 0x03, 0xa6}; |
1260 |
> |
if ((base = find_rom_data(base - ROM_BASE, 0x380000, dr_ret_dat, sizeof(dr_ret_dat))) == 0) return false; |
1261 |
> |
D(bug("dr_ret %08lx\n", base)); |
1262 |
> |
if (base != loc) { |
1263 |
> |
// OldWorld ROMs contain an absolute branch |
1264 |
> |
D(bug(" patching absolute branch at %08x\n", (uint32)lp - ROM_BASE)); |
1265 |
> |
*lp = htonl(0x48000000 + 0xf000 - (((uint32)lp - ROM_BASE) & 0xffff)); // b DR_CACHE_BASE+0x1f000 |
1266 |
> |
lp = (uint32 *)(ROM_BASE + 0x37f000); |
1267 |
> |
*lp++ = htonl(0x3c000000 + ((ROM_BASE + base) >> 16)); // lis r0,xxx |
1268 |
> |
*lp++ = htonl(0x60000000 + ((ROM_BASE + base) & 0xffff)); // ori r0,r0,xxx |
1269 |
> |
*lp++ = htonl(0x7c0803a6); // mtlr r0 |
1270 |
> |
*lp = htonl(POWERPC_BLR); // blr |
1271 |
> |
} |
1272 |
|
return true; |
1273 |
|
} |
1274 |
|
|
1385 |
|
uint32 npc = (uint32)(lp + 1) - ROM_BASE; |
1386 |
|
|
1387 |
|
lp = (uint32 *)(ROM_BASE + 0x318000); |
1391 |
– |
#if EMULATED_PPC |
1392 |
– |
*lp++ = htonl(NativeOpcode(NATIVE_ENABLE_INTERRUPT)); |
1393 |
– |
*lp = htonl(0x48000000 + ((npc - 0x318004) & 0x03fffffc)); // b ROM_BASE+0x312c2c |
1394 |
– |
#else |
1388 |
|
*lp++ = htonl(0x81400000 + XLM_IRQ_NEST); // lwz r10,XLM_IRQ_NEST |
1389 |
|
*lp++ = htonl(0x394affff); // subi r10,r10,1 |
1390 |
|
*lp++ = htonl(0x91400000 + XLM_IRQ_NEST); // stw r10,XLM_IRQ_NEST |
1391 |
|
*lp = htonl(0x48000000 + ((npc - 0x31800c) & 0x03fffffc)); // b ROM_BASE+0x312c2c |
1399 |
– |
#endif |
1392 |
|
|
1393 |
|
/* |
1394 |
|
// Disable FE0A/FE06 opcodes |
1750 |
|
*wp++ = htons(0x1000); |
1751 |
|
*wp++ = htons(0x001e); |
1752 |
|
*wp++ = htons(0x157c); // move.b #PVR,$1d(a2) |
1753 |
< |
*wp++ = htons(PVR >> 16); |
1753 |
> |
*wp++ = htons(((PVR & 0x80000000) ? 0x10 : 0) | ((PVR >> 16) & 0xff)); |
1754 |
|
*wp++ = htons(0x001d); |
1755 |
|
*wp++ = htons(0x263c); // move.l #RAMSize,d3 |
1756 |
|
*wp++ = htons(RAMSize >> 16); |
2220 |
|
lp = (uint32 *)(ROM_BASE + ntohl(*lp)); |
2221 |
|
lp[0xa9fd & 0x3ff] = htonl(GET_SCRAP_PATCH_SPACE); |
2222 |
|
|
2231 |
– |
#if __BEOS__ |
2223 |
|
// Patch SynchIdleTime() |
2224 |
|
if (PrefsFindBool("idlewait")) { |
2225 |
|
wp = (uint16 *)(ROM_BASE + find_rom_trap(0xabf7) + 4); // SynchIdleTime() |
2226 |
|
D(bug("SynchIdleTime at %08lx\n", wp)); |
2227 |
< |
if (ntohs(*wp) == 0x2078) { |
2227 |
> |
if (ntohs(*wp) == 0x2078) { // movea.l ExpandMem,a0 |
2228 |
|
*wp++ = htons(M68K_EMUL_OP_IDLE_TIME); |
2229 |
|
*wp = htons(M68K_NOP); |
2230 |
< |
} else { |
2230 |
> |
} |
2231 |
> |
else if (ntohs(*wp) == 0x70fe) // moveq #-2,d0 |
2232 |
> |
*wp++ = htons(M68K_EMUL_OP_IDLE_TIME_2); |
2233 |
> |
else { |
2234 |
|
D(bug("SynchIdleTime patch not installed\n")); |
2235 |
|
} |
2236 |
|
} |
2243 |
– |
#endif |
2237 |
|
|
2238 |
|
// Construct list of all sifters used by sound components in ROM |
2239 |
|
D(bug("Searching for sound components with type sdev in ROM\n")); |