Hook up SIGSEGV handling in the Linux port.(and correct a few misspellings)

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@538 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
arcum42 2009-01-02 03:18:18 +00:00 committed by Gregory Hainaut
parent 8c806870fa
commit dc017cd99a
8 changed files with 30 additions and 13 deletions

View File

@ -6,14 +6,14 @@
# Uncomment if building by itself, rather then with all the plugins
#Normal
#export PCSX2OPTIONS="--enable-sse3 --enable-sse4 --prefix `pwd`"
export PCSX2OPTIONS="--enable-sse3 --enable-sse4 --prefix `pwd`"
#Optimized, but a devbuild
#export PCSX2OPTIONS="--enable-sse3 --enable-sse4 --enable-devbuild --prefix `pwd`"
#Debug / Devbuild version
export PCSX2OPTIONS="--enable-debug --enable-devbuild --enable-sse3 --prefix `pwd`"
#export PCSX2OPTIONS="--enable-debug --enable-devbuild --enable-sse3 --prefix `pwd`"
option=$@
export PCSX2PLUGINS="`pwd`/bin/plugins"

View File

@ -139,6 +139,7 @@ void ExecuteCpu()
void RunExecute( const char* elf_file, bool use_bios )
{
// (air notes:)
// If you want to use the new to-memory savestate feature, take a look at the new
// RunExecute in WinMain.c, and secondly the CpuDlg.c or AdvancedDlg.cpp. The
@ -385,7 +386,7 @@ void States_Load(const char* file, int num = -1 )
return;
}
Cpu->Execute();
ExecuteCpu();
}
void States_Load(int num) {

View File

@ -80,7 +80,8 @@ extern MemoryAlloc<u8>* g_RecoveryState;
extern bool g_GameInProgress;
extern void SysRestorableReset();
extern void SysDetect();
void RunExecute( const char* elf_file, bool use_bios = false);
extern void RunExecute( const char* elf_file, bool use_bios = false);
extern void ExecuteCpu();
typedef struct {
char lang[g_MaxPath];

View File

@ -204,7 +204,7 @@ int main(int argc, char *argv[]) {
if( GSsetGameCRC != NULL )
GSsetGameCRC(ElfCRC, g_ZeroGSOptions);
Cpu->Execute();
ExecuteCpu();
return 0;
}

View File

@ -466,11 +466,11 @@ uptr *memLUT = NULL;
int memInit()
{
int i;
int i;
LPVOID pExtraMem = NULL;
// release the previous reserved mem
munmap(PS2MEM_BASE, 0x40000000);
munmap(PS2MEM_BASE, 0x40000000);
// allocate all virtual memory
PHYSICAL_ALLOC(PS2MEM_BASE, Ps2MemSize::Base, s_psM);
@ -2596,8 +2596,15 @@ static u8* m_psAllMem = NULL;
int memInit()
{
if (!vtlb_Init())
return -1;
#ifdef __LINUX__
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = &SysPageFaultExceptionFilter;
sigaction(SIGSEGV, &sa, NULL);
#endif
if (!vtlb_Init()) return -1;
tlb_fallback_0=vtlb_RegisterHandlerTempl1(_ext_mem,0);
tlb_fallback_1=vtlb_RegisterHandlerTempl1(_ext_mem,1);
@ -2615,7 +2622,7 @@ int memInit()
#ifdef __LINUX__
// For Linux we need to use the system virtual memory mapper so that we
// can coherse an allocation below the 2GB line.
// can coerce an allocation below the 2GB line.
// just try an arbitrary address first...
// maybe there's a better one to pick?
@ -2926,8 +2933,9 @@ int SysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps)
// Linux implementation of SIGSEGV handler. Bind it using sigaction().
// This is my shot in the dark. Probably needs some work. Good luck! (air)
void SysPageFaultExceptionFilter( int signal, struct __siginfo *info, void * )
__forceinline void __fastcall SysPageFaultExceptionFilter( int signal, siginfo_t *info, void * )
{
//Console::Error("SysPageFaultExceptionFilter!");
// get bad virtual address
u32 offset = (u8*)info->si_addr - psM;

View File

@ -23,6 +23,10 @@
#ifndef __MEMORY_H__
#define __MEMORY_H__
#ifdef __LINUX__
#include <signal.h>
#endif
//#define ENABLECACHE
namespace Ps2MemSize
@ -230,6 +234,9 @@ void memSetUserMode();
void memSetPageAddr(u32 vaddr, u32 paddr);
void memClearPageAddr(u32 vaddr);
void memShutdown();
#ifdef __LINUX__
void SysPageFaultExceptionFilter( int signal, siginfo_t *info, void * );
#endif
#ifdef _WIN32
int SysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps);

View File

@ -100,7 +100,7 @@ void SysDetect()
WriteLn( "x86Init:" );
MsgLn(
"\tCPU vender name = %s\n"
"\tCPU vendor name = %s\n"
"\tFamilyID = %x\n"
"\tx86Family = %s\n"
"\tCPU speed = %d.%03d Ghz\n"

View File

@ -1329,7 +1329,7 @@ int recInit( void )
cpudetectSSE3(recMem);
SysPrintf( "x86Init: \n" );
SysPrintf( "\tCPU vender name = %s\n", cpuinfo.x86ID );
SysPrintf( "\tCPU vendor name = %s\n", cpuinfo.x86ID );
SysPrintf( "\tFamilyID = %x\n", cpuinfo.x86StepID );
SysPrintf( "\tx86Family = %s\n", cpuinfo.x86Fam );
SysPrintf( "\tCPU speed = %d.%03d Ghz\n", cpuinfo.cpuspeed / 1000, cpuinfo.cpuspeed%1000);