Linux: Bring in changes from various patches, and get it compiling again.

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@665 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
arcum42 2009-01-30 23:04:51 +00:00 committed by Gregory Hainaut
parent e41d18164e
commit 30554896ec
18 changed files with 96 additions and 110 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`"
# Make sure we have plugins, and bring the normal plugins in.
sh fetch.sh

View File

@ -25,7 +25,7 @@
#include "iR5900.h"
#include "Counters.h"
#include "Vifdma.h"
#include "VifDma.h"
using namespace Threading;
using namespace std;

View File

@ -19,12 +19,7 @@
#include "ConfigDlg.h"
using namespace std;
// these namespace directives globalize the new namespaces and make the code behave basically
// like it used to (with cpuReset() and other cpu* vars and functions global).
using namespace R5900;
//using namespace Dynarec;
//using namespace Dynarec::R5900;
static void FindComboText(GtkWidget *combo, char plist[255][255], GList *list, char *conf)
{

View File

@ -171,9 +171,11 @@ void RunExecute( const char* elf_file, bool use_bios )
return;
}
if( elf_file == 0 )
SysResetExecutionState() ;
if (elf_file == 0 )
{
if(g_RecoveryState != NULL)
if (g_RecoveryState != NULL)
{
try
{
@ -950,4 +952,4 @@ void on_Advanced_OK(GtkButton *button, gpointer user_data)
gtk_widget_destroy(AdvDlg);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
}

View File

@ -21,15 +21,7 @@
#include "LnxMain.h"
// these namespace directives globalize the new namespaces and make the code behave basically
// like it used to (with cpuReset() and other cpu* vars and functions global).
// Not sure if the Dynarec ones are needed, so uncomment them if you get unresolved external
// link errors. Should solve some of them (maybe not all...) - (air)
// Definitely not all. Most of them are coming from assembly files. :(
using namespace R5900;
//using namespace Dynarec;
DIR *dir;
@ -475,10 +467,16 @@ void SysRunGui() {
RunGui();
}
void *SysMmap(uptr base, u32 size) {
return mmap((uptr*)base, size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
void *SysMmap(uptr base, u32 size)
{
u8 *Mem;
Mem = mmap((uptr*)base, size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
if (Mem == MAP_FAILED) Console::Notice("Mmap Failed!");
return Mem;
}
void SysMunmap(uptr base, u32 size) {
void SysMunmap(uptr base, u32 size)
{
munmap((uptr*)base, size);
}

View File

@ -4,19 +4,20 @@ noinst_LIBRARIES = libpcsx2.a
libpcsx2_a_SOURCES = \
CDVD.cpp CDVDiso.cpp CDVDisodrv.cpp COP0.cpp COP2.cpp Cache.cpp CdRom.cpp Console.cpp \
Counters.cpp Decode_XA.cpp Elfheader.cpp FPU.cpp FPU2.cpp FiFo.cpp GS.cpp Hw.cpp Interpreter.cpp \
Counters.cpp Decode_XA.cpp Elfheader.cpp FPU.cpp FPU2.cpp FiFo.cpp Gif.cpp GS.cpp Hw.cpp Interpreter.cpp \
IopBios.cpp IopCounters.cpp IopDma.cpp IopHw.cpp IopMem.cpp IopSio2.cpp MMI.cpp MTGS.cpp \
Memory.cpp Misc.cpp Patch.cpp PathUtils.cpp Plugins.cpp PrecompiledHeader.cpp R3000A.cpp \
R3000AInterpreter.cpp R3000AOpcodeTables.cpp R5900.cpp R5900OpcodeImpl.cpp R5900OpcodeTables.cpp \
SPR.cpp SaveState.cpp Sif.cpp Sio.cpp SourceLog.cpp Stats.cpp System.cpp ThreadTools.cpp \
VU0.cpp VU0micro.cpp VU0microInterp.cpp VU1micro.cpp VU1microInterp.cpp VUflags.cpp VUmicroMem.cpp VUops.cpp \
Vif.cpp VifDma.cpp vssprintf.cpp vtlb.cpp xmlpatchloader.cpp
Vif.cpp VifDma.cpp vssprintf.cpp vtlb.cpp xmlpatchloader.cpp AlignedMalloc.cpp
libpcsx2_a_SOURCES += \
CDVD.h CDVDiso.h CDVDisodrv.h CDVDlib.h COP0.h Cache.h CdRom.h Common.h Counters.h Decode_XA.h EEregs.h \
Elfheader.h Exceptions.h GS.h Hw.h IopBios.h IopBios2.h IopCounters.h IopDma.h IopHw.h IopMem.h IopSio2.h \
Elfheader.h Exceptions.h GS.h Hw.h IopBios.h IopBios2.h IopCounters.h IopDma.h IopHw.h IopMem.h IopSio2.h Memcpyfast.h \
Memory.h Misc.h Patch.h Paths.h Plugins.h PrecompiledHeader.h PsxCommon.h R3000A.h R5900.h R5900OpcodeTables.h \
SPR.h SamplProf.h SaveState.h Sif.h Sifcmd.h Sio.h Stats.h StringUtils.h System.h Threading.h \
SPR.h SamplProf.h SaveState.h Sif.h Sifcmd.h Sio.h SafeArray.h Stats.h StringUtils.h System.h Threading.h \
VU.h VUflags.h VUmicro.h VUops.h Vif.h VifDma.h cheatscpp.h vtlb.h
SUBDIRS = x86 . DebugTools IPU RDebug tinyxml Linux
SUBDIRS = x86 . DebugTools IPU RDebug tinyxml Linux

View File

@ -19,6 +19,8 @@
#ifndef __MEMCPY_FAST_H__
#define __MEMCPY_FAST_H__
//#include "Misc.h"
void _memset16_unaligned( void* dest, u16 data, size_t size );
#if defined(_WIN32) && !defined(__x86_64__)

View File

@ -29,6 +29,7 @@ extern void pcsx2_aligned_free(void* pmem);
#if !defined(_MSC_VER) && !defined(HAVE_ALIGNED_MALLOC)
# define _aligned_malloc pcsx2_aligned_malloc
# define _aligned_free pcsx2_aligned_free
# define _aligned_realloc pcsx2_aligned_realloc
#endif
//////////////////////////////////////////////////////////////
@ -208,8 +209,7 @@ class SafeAlignedArray : public MemoryAlloc<T>
protected:
T* _virtual_realloc( int newsize )
{
// TODO : aligned_realloc will need a linux implementation now. -_-
return (T*)_aligned_realloc( m_ptr, newsize * sizeof(T), Alignment );
return (T*)_aligned_realloc( this->m_ptr, newsize * sizeof(T), Alignment );
}
// Appends "(align: xx)" to the name of the allocation in devel builds.
@ -225,17 +225,17 @@ protected:
public:
virtual ~SafeAlignedArray()
{
safe_aligned_free( m_ptr );
safe_aligned_free( this->m_ptr );
// mptr is set to null, so the parent class's destructor won't re-free it.
}
explicit SafeAlignedArray( const std::string& name="Unnamed" ) :
MemoryAlloc( name )
MemoryAlloc<T>::MemoryAlloc( name )
{
}
explicit SafeAlignedArray( int initialSize, const std::string& name="Unnamed" ) :
MemoryAlloc(
MemoryAlloc<T>::MemoryAlloc(
_getName(name),
(T*)_aligned_malloc( initialSize * sizeof(T), Alignment ),
initialSize
@ -245,8 +245,8 @@ public:
virtual SafeAlignedArray<T,Alignment>* Clone() const
{
SafeAlignedArray<T,Alignment>* retval = new SafeAlignedArray<T,Alignment>( m_size );
memcpy_fast( retval->GetPtr(), m_ptr, sizeof(T) * m_size );
SafeAlignedArray<T,Alignment>* retval = new SafeAlignedArray<T,Alignment>( this->m_size );
memcpy_fast( retval->GetPtr(), this->m_ptr, sizeof(T) * this->m_size );
return retval;
}
};

View File

@ -35,13 +35,13 @@ using namespace R5900;
FILE *emuLog;
#ifdef PCSX2_DEVBUILD
//#ifdef PCSX2_DEVBUILD
u32 varLog;
// these used by the depreciated _old_Log only
u16 logProtocol;
u8 logSource;
#endif
//#endif
int connected=0;
@ -70,7 +70,8 @@ void __Log( const char* fmt, ... )
{
Console::Write(tmp);
} else if( emuLog != NULL ) // manually write to the logfile.
}
else if( emuLog != NULL ) // manually write to the logfile.
{
fputs( tmp, emuLog );
//fputs( "\r\n", emuLog );

View File

@ -233,4 +233,33 @@ int SysMapUserPhysicalPages(void* Addr, uptr NumPages, uptr* pblock, int pageoff
#endif
static __forceinline u8 *SysBoundedMmap(uptr base, u32 size, u32 bounds, char *caller)
{
u8 *Mem = NULL;
// For Linux we need to use the system virtual memory mapper so that we
// can coerce an allocation below the 2GB line.
// just try an arbitrary address first...
// maybe there's a better one to pick?
Mem = (u8*)SysMmap( base, size );
if( (Mem == NULL) || ((uptr)Mem + size) > bounds )
{
DevCon::Error("Problem allocating in %s.", params caller);
// memory allocation *must* have the top bit clear, so let's try again
// with NULL (let the OS pick something for us).
if( Mem != NULL ) SysMunmap( base, size );
Mem = (u8*)SysMmap( NULL, size );
if( (uptr)Mem > bounds )
{
DevCon::Error("Continuing problems allocating in %s.", params caller);
SysMunmap( Mem, size );
Mem = NULL; // let the os-independent code below handle the error
}
}
return Mem;
}
#endif /* __SYSTEM_H__ */

View File

@ -99,7 +99,9 @@ namespace Threading
void Semaphore::Post( int multiple )
{
#if defined(_MSC_VER)
sem_post_multiple( &sema, multiple );
#endif
}
void Semaphore::Wait()

View File

@ -18,7 +18,7 @@
#
#Normal
export PCSX2OPTIONS="--enable-debug --enable-devbuild --enable-sse3 --enable-sse4 --prefix `pwd`"
#export PCSX2OPTIONS="--enable-debug --enable-devbuild --enable-sse3 --enable-sse4 --prefix `pwd`"
echo ---------------
echo Building Pcsx2

View File

@ -6,12 +6,12 @@ noinst_LIBRARIES = libx86recomp.a
archfiles = ix86-32/iR5900-32.cpp ix86-32/iR5900AritImm.cpp ix86-32/iR5900Jump.cpp \
ix86-32/iR5900Move.cpp ix86-32/iR5900Shift.cpp ix86-32/iR5900Arit.cpp ix86-32/iR5900Branch.cpp \
ix86-32/iR5900LoadStore.cpp ix86-32/iR5900MultDiv.cpp ix86-32/iCore-32.cpp ix86-32/aR5900-32.S \
ix86-32/iR5900Templates.cpp
ix86-32/iR5900Templates.cpp ix86-32/recVTLB.cpp
libx86recomp_a_SOURCES = \
BaseblockEx.cpp iCOP0.cpp iCOP2.cpp iCore.cpp iFPU.cpp iGS.cpp iHw.cpp iIPU.cpp iMMI.cpp iPsxHw.cpp iPsxMem.cpp \
iR3000A.cpp iR3000Atables.cpp iR5900Misc.cpp iVU0micro.cpp iVU1micro.cpp iVUmicro.cpp iVUmicroLower.cpp iVUmicroUpper.cpp \
iVUzerorec.cpp iVif.cpp ir5900tables.cpp fast_routines.S aR3000A.S aVUzerorec.S aVif.S $(archfiles)
iR3000A.cpp iR3000Atables.cpp iR5900CoissuedLoadStore.cpp iR5900Misc.cpp iVU0micro.cpp iVU1micro.cpp iVUmicro.cpp \
iVUmicroLower.cpp iVUmicroUpper.cpp iVUzerorec.cpp iVif.cpp ir5900tables.cpp fast_routines.S aR3000A.S aVUzerorec.S aVif.S $(archfiles)
libx86recomp_a_SOURCES += \
BaseblockEx.h iCOP0.h iCore.h iFPU.h iMMI.h iR3000A.h iR5900.h iR5900Arit.h iR5900AritImm.h iR5900Branch.h iR5900Jump.h \

View File

@ -556,23 +556,7 @@ static void recAlloc()
// ... we can't? (air)
if( recMem == NULL )
{
recMem = (u8*)SysMmap(0x0f000000, RECMEM_SIZE);
if( recMem == NULL || (uptr)recMem > 0xf0000000 )
{
// Allocation failed, so let's try a generic address...
if( recMem != NULL )
SysMunmap(recMem, RECMEM_SIZE);
recMem = (u8*)SysMmap(NULL, RECMEM_SIZE);
if( (uptr)recMem > 0xf0000000 )
{
SysMunmap(recMem, RECMEM_SIZE); // failed...
recMem = NULL;
}
}
}
recMem = (u8*)SysBoundedMmap(0x0f000000, RECMEM_SIZE, 0xf0000000, "recAlloc(3000)");
if( recMem == NULL )
throw Exception::OutOfMemory( "R3000a Init > failed to allocate memory for the recompiler." );

View File

@ -324,27 +324,12 @@ void SuperVUAlloc(int vuindex)
// The old -1 crap has been depreciated on this function. Please
// specify either 0 or 1, thanks.
jASSUME( vuindex >= 0 );
// upper 4 bits must be zero!
if( s_recVUMem == NULL )
{
// upper 4 bits must be zero!
s_recVUMem = (u8*)SysMmap( 0x0c000000, VU_EXESIZE);
if( s_recVUMem == NULL || ((uptr)s_recVUMem > 0x80000000) )
{
// Allocation failed? Well then let's just try an operating-system-assigned
// location, by specifying NULL as the address "hint."
if( s_recVUMem != NULL )
SysMunmap( s_recVUMem, VU_EXESIZE );
s_recVUMem = (u8*)SysMmap( NULL, VU_EXESIZE);
if( (uptr)s_recVUMem > 0x80000000 )
{
SysMunmap( s_recVUMem, VU_EXESIZE ); // failed...
s_recVUMem = NULL;
}
}
s_recVUMem = SysBoundedMmap(0x0c000000, VU_EXESIZE, 0x80000000, "SuperVUAlloc");
if( s_recVUMem == NULL )
{
@ -355,8 +340,7 @@ void SuperVUAlloc(int vuindex)
ProfilerRegisterSource( "VURec", s_recVUMem, VU_EXESIZE);
if( recVUStack == NULL )
recVUStack = new u8[SUPERVU_STACKSIZE * 4];
if( recVUStack == NULL ) recVUStack = new u8[SUPERVU_STACKSIZE * 4];
}
if( vuindex >= 0 )

View File

@ -33,11 +33,11 @@ Dispatcher:
mov %eax,dword ptr [cpuRegs+PCOFFSET]
mov %ecx,%eax
mov REG_PC,%eax
shr %eax,10h
and %ecx,0FFFFh
shr %eax,0x10
and %ecx,0xFFFF
mov %edx,dword ptr [recLUT]
mov %eax,dword ptr [edx+eax*4]
lea %ecx,[eax+ecx*2]
mov %eax,dword ptr [%edx+%eax*4]
lea %ecx,[%eax+%ecx*2]
// check if startpc == cpuRegs.pc
//and %ecx, 0x5fffffff // remove higher bits
@ -137,16 +137,16 @@ DispatcherReg:
mov %eax,dword ptr [cpuRegs+PCOFFSET]
mov %ecx,%eax
mov REG_PC,%eax
shr %eax,10h
and %ecx,0FFFFh
shr %eax,0x10
and %ecx,0xFFFF
mov %edx,dword ptr [recLUT]
mov %eax,dword ptr [edx+eax*4]
lea %ecx,[eax+ecx*2]
mov %eax,dword ptr [%edx+%eax*4]
lea %ecx,[%eax+%ecx*2]
// check if startpc == cpuRegs.pc
//and %ecx, 0x5fffffff // remove higher bits
cmp REG_PC, dword ptr [%ecx+BLOCKTYPE_STARTPC]
je Dispatcher_CheckPtr
je DispatcherReg_CheckPtr
// recompile
push %ecx
@ -154,16 +154,16 @@ DispatcherReg:
call recRecompile
add %esp, 4
pop %ecx
Dispatcher_CheckPtr:
DispatcherReg_CheckPtr:
mov %eax, dword ptr [%ecx]
#ifdef _DEBUG
test %eax, %eax
jnz Dispatcher_CallFn
jnz DispatcherReg_CallFn
// throw an exception
int 10
Dispatcher_CallFn:
DispatcherReg_CallFn:
#endif
and %eax, 0x0fffffff
jmp %eax

View File

@ -92,7 +92,7 @@ static u32 s_nInstCacheSize = 0;
static BASEBLOCK* s_pCurBlock = NULL;
static BASEBLOCKEX* s_pCurBlockEx = NULL;
static const BASEBLOCK* s_pDispatchBlock = NULL;
const BASEBLOCK* s_pDispatchBlock = NULL;
static u32 s_nEndBlock = 0; // what pc the current block ends
static u32 s_nHasDelay = 0;
@ -502,26 +502,14 @@ static void recAlloc()
const uint cachememsize = REC_CACHEMEM+0x1000;
// try an arbitrary address first, and if it doesn't work, try NULL.
recMem = (u8*)SysMmap(0x0d000000, cachememsize );
if( recMem == NULL || ((uptr)recMem > 0x80000000) )
{
SysMunmap( recMem, cachememsize );
recMem = (u8*)SysMmap( NULL, REC_CACHEMEM+0x1000 );
if( recMem == NULL || ((uptr)recMem > 0x80000000) )
{
SysMunmap( recMem, cachememsize );
throw Exception::OutOfMemory( "R5900-32 > failed to allocate recompiler memory." );
}
}
recMem = (u8*)SysBoundedMmap(0x0d000000, cachememsize, 0x80000000, "recAlloc(5900)");
}
// Goal: Allocate BASEBLOCKs for every possible branch target in PS2 memory.
// Any 4-byte aligned address makes a valid branch target as per MIPS design (all instructions are
// always 4 bytes long).
if( m_recBlockAlloc == NULL )
m_recBlockAlloc = (u8*) _aligned_malloc( m_recBlockAllocSize, 4096 );
if( m_recBlockAlloc == NULL )
m_recBlockAlloc = (u8*) _aligned_malloc( m_recBlockAllocSize, 4096 );
if( m_recBlockAlloc == NULL )
throw Exception::OutOfMemory( "R5900-32 Init > Failed to allocate memory for BASEBLOCK tables." );
@ -664,7 +652,7 @@ static __forceinline bool recEventTest()
////////////////////////////////////////////////////
static u32 g_lastpc = 0;
static u32 g_EEDispatchTemp;
u32 g_EEDispatchTemp;
#ifdef _MSC_VER
@ -840,7 +828,7 @@ __forceinline void recExecute()
// Manually pushing is faster, especially on Core2's and such. :)
do {
g_EEFreezeRegs = true;
__asm
__asm__
(
".intel_syntax\n"
"push %ebx\n"
@ -864,7 +852,7 @@ __forceinline void recExecute()
static void recExecuteBlock()
{
g_EEFreezeRegs = true;
__asm
__asm__
(
".intel_syntax\n"
"push %ebx\n"

View File

@ -12,7 +12,7 @@ then
aclocal
automake -a
autoconf
./configure --enable-debug-build --prefix=${PCSX2PLUGINS}
./configure --prefix=${PCSX2PLUGINS}
make clean
make install