679 |
|
|
680 |
|
|
681 |
|
/* |
682 |
+ |
* Copy PowerPC code to ROM image and reverse bytes if necessary |
683 |
+ |
*/ |
684 |
+ |
|
685 |
+ |
static inline void memcpy_powerpc_code(void *dst, const void *src, size_t len) |
686 |
+ |
{ |
687 |
+ |
#ifdef WORDS_BIGENDIAN |
688 |
+ |
(void)memcpy(dst, src, len); |
689 |
+ |
#else |
690 |
+ |
uint32 *d = (uint32 *)dst; |
691 |
+ |
uint32 *s = (uint32 *)src; |
692 |
+ |
for (int i = 0; i < len/4; i++) |
693 |
+ |
d[i] = htonl(s[i]); |
694 |
+ |
#endif |
695 |
+ |
} |
696 |
+ |
|
697 |
+ |
|
698 |
+ |
/* |
699 |
|
* Install ROM patches (RAMBase and KernelDataAddr must be set) |
700 |
|
*/ |
701 |
|
|
1096 |
|
// Extra routine for 68k emulator start |
1097 |
|
lp = (uint32 *)(ROM_BASE + 0x36f900); |
1098 |
|
*lp++ = htonl(0x7c2903a6); // mtctr r1 |
1099 |
+ |
#if EMULATED_PPC |
1100 |
+ |
*lp++ = POWERPC_NATIVE_OP(NATIVE_DISABLE_INTERRUPT); |
1101 |
+ |
#else |
1102 |
|
*lp++ = htonl(0x80200000 + XLM_IRQ_NEST); // lwz r1,XLM_IRQ_NEST |
1103 |
|
*lp++ = htonl(0x38210001); // addi r1,r1,1 |
1104 |
|
*lp++ = htonl(0x90200000 + XLM_IRQ_NEST); // stw r1,XLM_IRQ_NEST |
1105 |
+ |
#endif |
1106 |
|
*lp++ = htonl(0x80200000 + XLM_KERNEL_DATA);// lwz r1,XLM_KERNEL_DATA |
1107 |
|
*lp++ = htonl(0x90c10018); // stw r6,0x18(r1) |
1108 |
|
*lp++ = htonl(0x7cc902a6); // mfctr r6 |
1130 |
|
// Extra routine for Mixed Mode |
1131 |
|
lp = (uint32 *)(ROM_BASE + 0x36fa00); |
1132 |
|
*lp++ = htonl(0x7c2903a6); // mtctr r1 |
1133 |
+ |
#if EMULATED_PPC |
1134 |
+ |
*lp++ = POWERPC_NATIVE_OP(NATIVE_DISABLE_INTERRUPT); |
1135 |
+ |
#else |
1136 |
|
*lp++ = htonl(0x80200000 + XLM_IRQ_NEST); // lwz r1,XLM_IRQ_NEST |
1137 |
|
*lp++ = htonl(0x38210001); // addi r1,r1,1 |
1138 |
|
*lp++ = htonl(0x90200000 + XLM_IRQ_NEST); // stw r1,XLM_IRQ_NEST |
1139 |
+ |
#endif |
1140 |
|
*lp++ = htonl(0x80200000 + XLM_KERNEL_DATA);// lwz r1,XLM_KERNEL_DATA |
1141 |
|
*lp++ = htonl(0x90c10018); // stw r6,0x18(r1) |
1142 |
|
*lp++ = htonl(0x7cc902a6); // mfctr r6 |
1164 |
|
// Extra routine for Reset/FC1E opcode |
1165 |
|
lp = (uint32 *)(ROM_BASE + 0x36fb00); |
1166 |
|
*lp++ = htonl(0x7c2903a6); // mtctr r1 |
1167 |
+ |
#if EMULATED_PPC |
1168 |
+ |
*lp++ = POWERPC_NATIVE_OP(NATIVE_DISABLE_INTERRUPT); |
1169 |
+ |
#else |
1170 |
|
*lp++ = htonl(0x80200000 + XLM_IRQ_NEST); // lwz r1,XLM_IRQ_NEST |
1171 |
|
*lp++ = htonl(0x38210001); // addi r1,r1,1 |
1172 |
|
*lp++ = htonl(0x90200000 + XLM_IRQ_NEST); // stw r1,XLM_IRQ_NEST |
1173 |
+ |
#endif |
1174 |
|
*lp++ = htonl(0x80200000 + XLM_KERNEL_DATA);// lwz r1,XLM_KERNEL_DATA |
1175 |
|
*lp++ = htonl(0x90c10018); // stw r6,0x18(r1) |
1176 |
|
*lp++ = htonl(0x7cc902a6); // mfctr r6 |
1198 |
|
// Extra routine for FE0A opcode (QuickDraw 3D needs this) |
1199 |
|
lp = (uint32 *)(ROM_BASE + 0x36fc00); |
1200 |
|
*lp++ = htonl(0x7c2903a6); // mtctr r1 |
1201 |
+ |
#if EMULATED_PPC |
1202 |
+ |
*lp++ = POWERPC_NATIVE_OP(NATIVE_DISABLE_INTERRUPT); |
1203 |
+ |
#else |
1204 |
|
*lp++ = htonl(0x80200000 + XLM_IRQ_NEST); // lwz r1,XLM_IRQ_NEST |
1205 |
|
*lp++ = htonl(0x38210001); // addi r1,r1,1 |
1206 |
|
*lp++ = htonl(0x90200000 + XLM_IRQ_NEST); // stw r1,XLM_IRQ_NEST |
1207 |
+ |
#endif |
1208 |
|
*lp++ = htonl(0x80200000 + XLM_KERNEL_DATA);// lwz r1,XLM_KERNEL_DATA |
1209 |
|
*lp++ = htonl(0x90c10018); // stw r6,0x18(r1) |
1210 |
|
*lp++ = htonl(0x7cc902a6); // mfctr r6 |
1339 |
|
*lp = htonl(POWERPC_BCTR); |
1340 |
|
|
1341 |
|
lp = (uint32 *)(ROM_BASE + 0x318000); |
1342 |
+ |
#if EMULATED_PPC |
1343 |
+ |
*lp++ = POWERPC_NATIVE_OP(NATIVE_ENABLE_INTERRUPT); |
1344 |
+ |
*lp = htonl(0x48000000 + ((xlp - 0x8004) & 0x03fffffc)); // b ROM_BASE+0x312c2c |
1345 |
+ |
#else |
1346 |
|
*lp++ = htonl(0x81400000 + XLM_IRQ_NEST); // lwz r10,XLM_IRQ_NEST |
1347 |
|
*lp++ = htonl(0x394affff); // subi r10,r10,1 |
1348 |
|
*lp++ = htonl(0x91400000 + XLM_IRQ_NEST); // stw r10,XLM_IRQ_NEST |
1349 |
|
*lp = htonl(0x48000000 + ((xlp - 0x800c) & 0x03fffffc)); // b ROM_BASE+0x312c2c |
1350 |
+ |
#endif |
1351 |
+ |
|
1352 |
|
/* |
1353 |
|
// Disable FE0A/FE06 opcodes |
1354 |
|
lp = (uint32 *)(ROM_BASE + 0x3144ac); |
1983 |
|
memcpy((void *)(ROM_BASE + sony_offset + 0x200), cdrom_driver, sizeof(cdrom_driver)); |
1984 |
|
|
1985 |
|
// Install serial drivers |
1986 |
< |
memcpy((void *)(ROM_BASE + sony_offset + 0x300), ain_driver, sizeof(ain_driver)); |
1987 |
< |
memcpy((void *)(ROM_BASE + sony_offset + 0x400), aout_driver, sizeof(aout_driver)); |
1988 |
< |
memcpy((void *)(ROM_BASE + sony_offset + 0x500), bin_driver, sizeof(bin_driver)); |
1989 |
< |
memcpy((void *)(ROM_BASE + sony_offset + 0x600), bout_driver, sizeof(bout_driver)); |
1986 |
> |
memcpy_powerpc_code((void *)(ROM_BASE + sony_offset + 0x300), ain_driver, sizeof(ain_driver)); |
1987 |
> |
memcpy_powerpc_code((void *)(ROM_BASE + sony_offset + 0x400), aout_driver, sizeof(aout_driver)); |
1988 |
> |
memcpy_powerpc_code((void *)(ROM_BASE + sony_offset + 0x500), bin_driver, sizeof(bin_driver)); |
1989 |
> |
memcpy_powerpc_code((void *)(ROM_BASE + sony_offset + 0x600), bout_driver, sizeof(bout_driver)); |
1990 |
|
|
1991 |
|
// Copy icons to ROM |
1992 |
|
SonyDiskIconAddr = ROM_BASE + sony_offset + 0x800; |
2190 |
|
M68kRegisters r; |
2191 |
|
uint8 pb[SIZEOF_IOParam]; |
2192 |
|
|
2154 |
– |
#if DISABLE_SCSI && 0 |
2155 |
– |
// Fake SCSIGlobals |
2156 |
– |
static const uint8 fake_scsi_globals[32] = {0,}; |
2157 |
– |
WriteMacInt32(0xc0c, (uint32)fake_scsi_globals); |
2158 |
– |
#endif |
2159 |
– |
|
2193 |
|
// Install floppy driver |
2194 |
|
if (ROMType == ROMTYPE_NEWWORLD) { |
2195 |
|
|
2204 |
|
WriteMacInt16(dce + dCtlFlags, SonyDriverFlags); |
2205 |
|
} |
2206 |
|
|
2207 |
+ |
#if DISABLE_SCSI && 0 |
2208 |
+ |
// Fake SCSIGlobals |
2209 |
+ |
static const uint8 fake_scsi_globals[32] = {0,}; |
2210 |
+ |
WriteMacInt32(0xc0c, (uint32)fake_scsi_globals); |
2211 |
+ |
#endif |
2212 |
+ |
|
2213 |
|
// Open .Sony driver |
2214 |
|
WriteMacInt8((uint32)pb + ioPermssn, 0); |
2215 |
|
WriteMacInt32((uint32)pb + ioNamePtr, (uint32)"\005.Sony"); |