[CPU] Use reserved form of sc for imports.
This commit is contained in:
parent
e2346ee539
commit
cc47704a6b
|
@ -423,8 +423,15 @@ int InstrEmit_mcrf(PPCHIRBuilder& f, const InstrData& i) {
|
|||
// System linkage (A-24)
|
||||
|
||||
int InstrEmit_sc(PPCHIRBuilder& f, const InstrData& i) {
|
||||
f.CallExtern(f.function());
|
||||
return 0;
|
||||
// Game code should only ever use LEV=0.
|
||||
// LEV=2 is to signify 'call import' from Xenia.
|
||||
// TODO(gibbed): syscalls!
|
||||
if (i.SC.LEV == 2) {
|
||||
f.CallExtern(f.function());
|
||||
return 0;
|
||||
}
|
||||
XEINSTRNOTIMPLEMENTED();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Trap (A-25)
|
||||
|
|
|
@ -1225,15 +1225,17 @@ bool XexModule::SetupLibraryImports(const char* name,
|
|||
// bctr
|
||||
// Real consoles rewrite this with some code that sets r11.
|
||||
// If we did that we'd still have to put a thunk somewhere and do the
|
||||
// dynamic lookup. Instead, we rewrite it to use syscalls, as they
|
||||
// aren't used on the 360. CPU backends can either take the syscall
|
||||
// or do something smarter.
|
||||
// sc
|
||||
// dynamic lookup. Instead, we rewrite it to use syscalls.
|
||||
// We use sc with a LEV operand of 2, which is reserved usage and
|
||||
// should never see actual usage outside of our rewrite.
|
||||
// CPU backends can either take the special form syscall or do
|
||||
// something smarter.
|
||||
// sc 2
|
||||
// blr
|
||||
// nop
|
||||
// nop
|
||||
uint8_t* p = memory()->TranslateVirtual(record_addr);
|
||||
xe::store_and_swap<uint32_t>(p + 0x0, 0x44000002);
|
||||
xe::store_and_swap<uint32_t>(p + 0x0, 0x44000042);
|
||||
xe::store_and_swap<uint32_t>(p + 0x4, 0x4E800020);
|
||||
xe::store_and_swap<uint32_t>(p + 0x8, 0x60000000);
|
||||
xe::store_and_swap<uint32_t>(p + 0xC, 0x60000000);
|
||||
|
|
Loading…
Reference in New Issue