Skip Bios hack works in EE interpreters now.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2343 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-12-14 14:36:13 +00:00
parent 1fc2fd2736
commit f60ed711cc
6 changed files with 76 additions and 63 deletions

View File

@ -121,7 +121,8 @@ static __forceinline void cpuRcntSet()
if( nextCounter < 0 ) nextCounter = 0;
}
void rcntInit() {
void rcntInit()
{
int i;
memzero(counters);
@ -140,7 +141,8 @@ void rcntInit() {
vsyncCounter.Mode = MODE_VRENDER;
vsyncCounter.sCycle = cpuRegs.cycle;
UpdateVSyncRate();
// Set the video mode to user's default request:
gsSetRegionMode( (GS_RegionMode)EmuConfig.GS.DefaultRegionMode );
for (i=0; i<4; i++) rcntReset(i);
cpuRcntSet();

View File

@ -388,6 +388,30 @@ static void intExecute()
} catch( Exception::ExitCpuExecute& ) { }
}
static void intExecuteBiosStub()
{
Console.WriteLn( Color_StrongGreen, "(R5900-Interp) Executing Bios Stub..." );
while( (cpuRegs.pc != 0x00200008) && (cpuRegs.pc != 0x00100008) ) {
execI();
}
// ... some maual bios injection hack from a century ago, me thinks. Leaving the
// code intact for posterity. --air
// {
// FILE* f = fopen("eebios.bin", "wb");
// fwrite(PSM(0x80000000), 0x100000, 1, f);
// fclose(f);
// exit(0);
// f = fopen("iopbios.bin", "wb");
// fwrite(PS2MEM_PSX, 0x80000, 1, f);
// fclose(f);
// }
Console.WriteLn( Color_StrongGreen, "(R5900-Interp) Execute Bios Stub Complete");
}
static void intCheckExecutionState()
{
if( GetCoreThread().HasPendingStateChangeRequest() )
@ -415,6 +439,7 @@ R5900cpu intCpu =
intReset,
intStep,
intExecute,
intExecuteBiosStub,
intCheckExecutionState,
intClear,

View File

@ -59,12 +59,12 @@ void cpuReset()
memzero(fpuRegs);
memzero(tlb);
cpuRegs.pc = 0xbfc00000; ///set pc reg to stack
cpuRegs.CP0.n.Config = 0x440;
cpuRegs.CP0.n.Status.val = 0x70400004; //0x10900000 <-- wrong; // COP0 enabled | BEV = 1 | TS = 1
cpuRegs.CP0.n.PRid = 0x00002e20; // PRevID = Revision ID, same as R5900
fpuRegs.fprc[0] = 0x00002e00; // fpu Revision..
fpuRegs.fprc[31] = 0x01000001; // fpu Status/Control
cpuRegs.pc = 0xbfc00000; //set pc reg to stack
cpuRegs.CP0.n.Config = 0x440;
cpuRegs.CP0.n.Status.val= 0x70400004; //0x10900000 <-- wrong; // COP0 enabled | BEV = 1 | TS = 1
cpuRegs.CP0.n.PRid = 0x00002e20; // PRevID = Revision ID, same as R5900
fpuRegs.fprc[0] = 0x00002e00; // fpu Revision..
fpuRegs.fprc[31] = 0x01000001; // fpu Status/Control
g_nextBranchCycle = cpuRegs.cycle + 4;
EEsCycle = 0;
@ -533,54 +533,6 @@ __forceinline void cpuTestHwInts() {
cpuTestTIMRInts();
}
// This function performs a "hackish" execution of the BIOS stub, which initializes EE
// memory and hardware. It forcefully breaks execution when the stub is finished, prior
// to the PS2 logos being displayed. This allows us to "shortcut" right into a game
// without having to wait through the logos or endure game/bios localization checks.
//
// Use of this function must be followed by the proper injection of the elf header's code
// execution entry point into cpuRegs.pc. Failure to modify cpuRegs.pc will result in the
// bios continuing its normal unimpeeded splashscreen execution.
//
void cpuExecuteBios()
{
// Set the video mode to user's default request:
gsSetRegionMode( (GS_RegionMode)EmuConfig.GS.DefaultRegionMode );
Console.WriteLn( "Executing Bios Stub..." );
g_ExecBiosHack = true;
while( cpuRegs.pc != 0x00200008 &&
cpuRegs.pc != 0x00100008 )
{
Cpu->Execute();
}
g_ExecBiosHack = false;
// {
// FILE* f = fopen("eebios.bin", "wb");
// fwrite(PSM(0x80000000), 0x100000, 1, f);
// fclose(f);
// exit(0);
// f = fopen("iopbios.bin", "wb");
// fwrite(PS2MEM_PSX, 0x80000, 1, f);
// fclose(f);
// }
// REC_CLEARM(0x00200008);
// REC_CLEARM(0x00100008);
// REC_CLEARM(cpuRegs.pc);
// Reset the EErecs here, because the bios generates "slow" blocks that have
// g_ExecBiosHack checks in them. This deletes them so that the recs replace them
// with new faster versions:
Cpu->Reset();
Console.Warning("Execute Bios Stub Complete");
//GSprintf(5, "PCSX2 " PCSX2_VERSION "\nExecuteBios Complete\n");
}
__forceinline void CPU_INT( u32 n, s32 ecycle)
{
if( n != 2 && cpuRegs.interrupt & (1<<n) ){ //2 is Gif, and every path 3 masking game triggers this :/

View File

@ -319,6 +319,20 @@ struct R5900cpu
//
void (*Execute)();
// This function performs a "hackish" execution of the BIOS stub, which initializes
// EE memory and hardware. It forcefully breaks execution when the stub is finished,
// prior to the PS2 logos being displayed. This allows us to "shortcut" right into
// a game without having to wait through the logos or endure game/bios localization
// checks.
//
// Use of this function must be followed by the proper injection of the elf header's
// code execution entry point into cpuRegs.pc. Failure to modify cpuRegs.pc will
// result in the bios continuing its normal unimpeded splash screen execution.
//
// Exception Throws: [TODO] (possible execution-related throws to be added)
//
void (*ExecuteBiosStub)();
// Checks for execution suspension or cancellation. In pthreads terms this provides
// a "cancellation point." Execution state checks are typically performed at Vsyncs
// by the generic VM event handlers in R5900.cpp/Counters.cpp (applies to both recs
@ -361,7 +375,6 @@ extern R5900cpu recCpu;
extern void cpuInit();
extern void cpuReset(); // can throw Exception::FileNotFound.
extern void cpuExecuteBios();
extern void cpuException(u32 code, u32 bd);
extern void cpuTlbMissR(u32 addr, u32 bd);
extern void cpuTlbMissW(u32 addr, u32 bd);

View File

@ -313,7 +313,7 @@ void SysCoreThread::CpuInitializeMess()
// effects).
SetCPUState( EmuConfig.Cpu.sseMXCSR, EmuConfig.Cpu.sseVUMXCSR );
cpuExecuteBios();
Cpu->ExecuteBiosStub();
loadElfFile( elf_file );
}

View File

@ -28,8 +28,8 @@
#include "System/SysThreads.h"
#include "GS.h"
#ifdef __LINUX__
#include <csetjmp>
#if !PCSX2_SEH
# include <csetjmp>
#endif
using namespace x86Emitter;
@ -38,8 +38,8 @@ using namespace R5900;
#define PC_GETBLOCK(x) PC_GETBLOCK_(x, recLUT)
u32 maxrecmem = 0;
static uptr recLUT[0x10000];
static uptr hwLUT[0x10000];
static __aligned16 uptr recLUT[0x10000];
static __aligned16 uptr hwLUT[0x10000];
#define HWADDR(mem) (hwLUT[mem >> 16] + (mem))
@ -731,6 +731,26 @@ static void recExecute()
#endif
}
static void recExecuteBiosStub()
{
Console.WriteLn( Color_StrongGreen, "(R5900-32) Executing Bios Stub..." );
g_ExecBiosHack = true;
recExecute();
pxAssertDev( cpuRegs.pc == 0x00200008 || cpuRegs.pc == 0x00100008,
"Bios stub execution terminated on an abnormal address."
);
g_ExecBiosHack = false;
Console.WriteLn( Color_StrongGreen, "(R5900-32) Execute Bios Stub Complete");
// Reset the EErecs here, because the bios generates "slow" blocks that have
// g_ExecBiosHack checks in them. This deletes them so that the recs replace them
// with new faster versions:
recResetEE();
}
////////////////////////////////////////////////////
void R5900::Dynarec::OpcodeImpl::recSYSCALL( void )
{
@ -1721,6 +1741,7 @@ R5900cpu recCpu =
recResetEE,
recStep,
recExecute,
recExecuteBiosStub,
recCheckExecutionState,
recClear,