mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-12 01:38:37 +12:00
Implemented LLE Modules Manager (draft)
Improved loader core. Implemented *_thread wrappers. Minor fixes. Temporary disabled ELF Compiler & DisAsm frame.
This commit is contained in:
parent
1d61484992
commit
598d929aba
57 changed files with 2844 additions and 2804 deletions
|
@ -1,11 +1,38 @@
|
|||
#include "stdafx.h"
|
||||
#include "Utilities/Log.h"
|
||||
#include "Loader.h"
|
||||
#include "ELF.h"
|
||||
#include "SELF.h"
|
||||
#include "PSF.h"
|
||||
#include "Emu/FS/vfsLocalFile.h"
|
||||
|
||||
namespace loader
|
||||
{
|
||||
bool loader::load(vfsStream& stream)
|
||||
{
|
||||
for (auto i : m_handlers)
|
||||
{
|
||||
if (i->init(stream) == handler::ok)
|
||||
{
|
||||
if (i->load() == handler::ok)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
stream.Seek(i->get_stream_offset());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
handler::error_code handler::init(vfsStream& stream)
|
||||
{
|
||||
m_stream_offset = stream.Tell();
|
||||
m_stream = &stream;
|
||||
|
||||
return ok;
|
||||
}
|
||||
};
|
||||
|
||||
static const u64 g_spu_offset = 0x10000;
|
||||
|
||||
const std::string Ehdr_DataToString(const u8 data)
|
||||
|
@ -13,7 +40,7 @@ const std::string Ehdr_DataToString(const u8 data)
|
|||
if(data > 1) return fmt::Format("%d's complement, big endian", data);
|
||||
if(data < 1) return "Data is not found";
|
||||
|
||||
return fmt::Format("%d's complement, small endian", data);
|
||||
return fmt::Format("%d's complement, little endian", data);
|
||||
}
|
||||
|
||||
const std::string Ehdr_TypeToString(const u16 type)
|
||||
|
@ -35,7 +62,7 @@ const std::string Ehdr_OS_ABIToString(const u8 os_abi)
|
|||
case 0x66: return "Cell OS LV-2";
|
||||
};
|
||||
|
||||
return fmt::Format("Unknown (0x%x)", os_abi);
|
||||
return fmt::Format("Unknown (%x)", os_abi);
|
||||
}
|
||||
|
||||
const std::string Ehdr_MachineToString(const u16 machine)
|
||||
|
@ -48,7 +75,7 @@ const std::string Ehdr_MachineToString(const u16 machine)
|
|||
case MACHINE_ARM: return "ARM";
|
||||
};
|
||||
|
||||
return fmt::Format("Unknown (0x%x)", machine);
|
||||
return fmt::Format("Unknown (%x)", machine);
|
||||
}
|
||||
|
||||
const std::string Phdr_FlagsToString(u32 flags)
|
||||
|
@ -73,7 +100,7 @@ const std::string Phdr_FlagsToString(u32 flags)
|
|||
flags &= ~spu << 0x14;
|
||||
flags &= ~rsx << 0x18;
|
||||
|
||||
if(flags != 0) return fmt::Format("Unknown %s PPU[0x%x] SPU[0x%x] RSX[0x%x]", ret.c_str(), ppu, spu, rsx);
|
||||
if(flags != 0) return fmt::Format("Unknown %s PPU[%x] SPU[%x] RSX[%x]", ret.c_str(), ppu, spu, rsx);
|
||||
|
||||
ret += "PPU[" + FLAGS_TO_STRING(ppu) + "] ";
|
||||
ret += "SPU[" + FLAGS_TO_STRING(spu) + "] ";
|
||||
|
@ -93,94 +120,5 @@ const std::string Phdr_TypeToString(const u32 type)
|
|||
case 0x60000002: return "LOOS+2";
|
||||
};
|
||||
|
||||
return fmt::Format("Unknown (0x%x)", type);
|
||||
}
|
||||
|
||||
Loader::Loader()
|
||||
: m_stream(nullptr)
|
||||
, m_loader(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Loader::Loader(vfsFileBase& stream)
|
||||
: m_stream(&stream)
|
||||
, m_loader(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Loader::~Loader()
|
||||
{
|
||||
delete m_loader;
|
||||
m_loader = nullptr;
|
||||
}
|
||||
|
||||
void Loader::Open(vfsFileBase& stream)
|
||||
{
|
||||
m_stream = &stream;
|
||||
}
|
||||
|
||||
LoaderBase* Loader::SearchLoader()
|
||||
{
|
||||
if(!m_stream)
|
||||
return nullptr;
|
||||
|
||||
LoaderBase* l = new ELFLoader(*m_stream);
|
||||
if(l->LoadInfo())
|
||||
return l;
|
||||
delete l;
|
||||
|
||||
l = new SELFLoader(*m_stream);
|
||||
if(l->LoadInfo())
|
||||
return l;
|
||||
delete l;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Loader::Analyze()
|
||||
{
|
||||
delete m_loader;
|
||||
|
||||
m_loader = SearchLoader();
|
||||
|
||||
if(!m_loader)
|
||||
{
|
||||
LOG_ERROR(LOADER, "Unknown file type");
|
||||
return false;
|
||||
}
|
||||
|
||||
machine = m_loader->GetMachine();
|
||||
entry = m_loader->GetMachine() == MACHINE_SPU ? m_loader->GetEntry() + g_spu_offset : m_loader->GetEntry();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Loader::Load()
|
||||
{
|
||||
if(!m_loader)
|
||||
return false;
|
||||
|
||||
if(!m_loader->LoadData(m_loader->GetMachine() == MACHINE_SPU ? g_spu_offset : 0))
|
||||
{
|
||||
LOG_ERROR(LOADER, "Broken file");
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
const std::string& root = fmt::ToUTF8(wxFileName(wxFileName(m_stream->GetPath()).GetPath()).GetPath());
|
||||
std::string ps3_path;
|
||||
const std::string& psf_path = root + "/" + "PARAM.SFO";
|
||||
vfsFile f(psf_path);
|
||||
if(f.IsOpened())
|
||||
{
|
||||
PSFLoader psf_l(f);
|
||||
if(psf_l.Load())
|
||||
{
|
||||
CurGameInfo = psf_l.m_info;
|
||||
CurGameInfo.root = root;
|
||||
psf_l.Close();
|
||||
}
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
return fmt::Format("Unknown (%x)", type);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue