mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-02 06:44:45 +00:00
Make previous code cleaner
This commit is contained in:
parent
c2851467e5
commit
e4ce0592c1
@ -271,7 +271,6 @@ bool ElfReader::LoadInto(u32 loadAddress)
|
||||
}
|
||||
|
||||
DEBUG_LOG(LOADER,"Relocations:");
|
||||
bool oldRelocs = false;
|
||||
|
||||
// Second pass: Do necessary relocations
|
||||
for (int i=0; i<GetNumSections(); i++)
|
||||
@ -300,20 +299,23 @@ bool ElfReader::LoadInto(u32 loadAddress)
|
||||
else if (s->sh_type == SHT_REL)
|
||||
{
|
||||
DEBUG_LOG(LOADER, "Traditional relocation section found.");
|
||||
if (bRelocate)
|
||||
if (!bRelocate)
|
||||
{
|
||||
DEBUG_LOG(LOADER, "Binary is prerelocated. Skipping relocations.");
|
||||
}
|
||||
else
|
||||
{
|
||||
oldRelocs = true;
|
||||
//We have a relocation table!
|
||||
int sectionToModify = s->sh_info;
|
||||
if (!(sections[sectionToModify].sh_flags & SHF_ALLOC))
|
||||
{
|
||||
ERROR_LOG(LOADER,"Trying to relocate non-loaded section %s, ignoring",GetSectionName(sectionToModify));
|
||||
continue;
|
||||
}
|
||||
ERROR_LOG(LOADER,"Traditional relocations unsupported.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (oldRelocs)
|
||||
{
|
||||
INFO_LOG(LOADER, "Game uses old relocations (often for debugging, should be harmless)");
|
||||
}
|
||||
|
||||
// Segment relocations (a few games use them)
|
||||
if (GetNumSections() == 0)
|
||||
|
@ -120,6 +120,43 @@ struct dirent {
|
||||
};
|
||||
#endif
|
||||
|
||||
class FileNode : public KernelObject {
|
||||
public:
|
||||
FileNode() : callbackID(0), callbackArg(0), asyncResult(0), pendingAsyncResult(false), sectorBlockMode(false) {}
|
||||
~FileNode() {
|
||||
pspFileSystem.CloseFile(handle);
|
||||
}
|
||||
const char *GetName() {return fullpath.c_str();}
|
||||
const char *GetTypeName() {return "OpenFile";}
|
||||
void GetQuickInfo(char *ptr, int size) {
|
||||
sprintf(ptr, "Seekpos: %08x", (u32)pspFileSystem.GetSeekPos(handle));
|
||||
}
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_BADF; }
|
||||
int GetIDType() const { return PPSSPP_KERNEL_TMID_File; }
|
||||
|
||||
virtual void DoState(PointerWrap &p) {
|
||||
p.Do(fullpath);
|
||||
p.Do(handle);
|
||||
p.Do(callbackID);
|
||||
p.Do(callbackArg);
|
||||
p.Do(asyncResult);
|
||||
p.Do(pendingAsyncResult);
|
||||
p.Do(sectorBlockMode);
|
||||
p.DoMarker("File");
|
||||
}
|
||||
|
||||
std::string fullpath;
|
||||
u32 handle;
|
||||
|
||||
u32 callbackID;
|
||||
u32 callbackArg;
|
||||
|
||||
u32 asyncResult;
|
||||
|
||||
bool pendingAsyncResult;
|
||||
bool sectorBlockMode;
|
||||
};
|
||||
|
||||
void __IoInit() {
|
||||
INFO_LOG(HLE, "Starting up I/O...");
|
||||
|
||||
@ -175,6 +212,15 @@ void __IoShutdown() {
|
||||
defParam = 0;
|
||||
}
|
||||
|
||||
u32 __IoGetFileHandleFromId(u32 id, u32 &outError)
|
||||
{
|
||||
FileNode *f = kernelObjects.Get < FileNode > (id, outError);
|
||||
if (!f) {
|
||||
return -1;
|
||||
}
|
||||
return f->handle;
|
||||
}
|
||||
|
||||
u32 sceIoAssign(const char *aliasname, const char *physname, const char *devname, u32 flag) {
|
||||
ERROR_LOG(HLE, "UNIMPL sceIoAssign(%s, %s, %s, %08x, ...)", aliasname,
|
||||
physname, devname, flag);
|
||||
|
@ -23,46 +23,10 @@
|
||||
#include "HLE.h"
|
||||
#include "sceKernel.h"
|
||||
|
||||
class FileNode : public KernelObject {
|
||||
public:
|
||||
FileNode() : callbackID(0), callbackArg(0), asyncResult(0), pendingAsyncResult(false), sectorBlockMode(false) {}
|
||||
~FileNode() {
|
||||
pspFileSystem.CloseFile(handle);
|
||||
}
|
||||
const char *GetName() {return fullpath.c_str();}
|
||||
const char *GetTypeName() {return "OpenFile";}
|
||||
void GetQuickInfo(char *ptr, int size) {
|
||||
sprintf(ptr, "Seekpos: %08x", (u32)pspFileSystem.GetSeekPos(handle));
|
||||
}
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_BADF; }
|
||||
int GetIDType() const { return PPSSPP_KERNEL_TMID_File; }
|
||||
|
||||
virtual void DoState(PointerWrap &p) {
|
||||
p.Do(fullpath);
|
||||
p.Do(handle);
|
||||
p.Do(callbackID);
|
||||
p.Do(callbackArg);
|
||||
p.Do(asyncResult);
|
||||
p.Do(pendingAsyncResult);
|
||||
p.Do(sectorBlockMode);
|
||||
p.DoMarker("File");
|
||||
}
|
||||
|
||||
std::string fullpath;
|
||||
u32 handle;
|
||||
|
||||
u32 callbackID;
|
||||
u32 callbackArg;
|
||||
|
||||
u32 asyncResult;
|
||||
|
||||
bool pendingAsyncResult;
|
||||
bool sectorBlockMode;
|
||||
};
|
||||
|
||||
void __IoInit();
|
||||
void __IoDoState(PointerWrap &p);
|
||||
void __IoShutdown();
|
||||
u32 __IoGetFileHandleFromId(u32 id, u32 &outError);
|
||||
KernelObject *__KernelFileNodeObject();
|
||||
KernelObject *__KernelDirListingObject();
|
||||
|
||||
|
@ -794,8 +794,8 @@ void sceKernelFindModuleByName()
|
||||
u32 sceKernelLoadModuleByID(u32 id, u32 flags, u32 lmoptionPtr)
|
||||
{
|
||||
u32 error;
|
||||
FileNode *f = kernelObjects.Get < FileNode > (id, error);
|
||||
if (!f) {
|
||||
u32 handle = __IoGetFileHandleFromId(id, error);
|
||||
if (handle < 0) {
|
||||
ERROR_LOG(HLE,"sceKernelLoadModuleByID(%08x, %08x, %08x): could not open file id",id,flags,lmoptionPtr);
|
||||
return error;
|
||||
}
|
||||
@ -803,13 +803,13 @@ u32 sceKernelLoadModuleByID(u32 id, u32 flags, u32 lmoptionPtr)
|
||||
if (lmoptionPtr) {
|
||||
lmoption = (SceKernelLMOption *)Memory::GetPointer(lmoptionPtr);
|
||||
}
|
||||
u32 pos = pspFileSystem.SeekFile(f->handle, 0, FILEMOVE_CURRENT);
|
||||
u32 size = pspFileSystem.SeekFile(f->handle, 0, FILEMOVE_END);
|
||||
u32 pos = pspFileSystem.SeekFile(handle, 0, FILEMOVE_CURRENT);
|
||||
u32 size = pspFileSystem.SeekFile(handle, 0, FILEMOVE_END);
|
||||
std::string error_string;
|
||||
pspFileSystem.SeekFile(f->handle, pos, FILEMOVE_BEGIN);
|
||||
pspFileSystem.SeekFile(handle, pos, FILEMOVE_BEGIN);
|
||||
Module *module = 0;
|
||||
u8 *temp = new u8[size];
|
||||
pspFileSystem.ReadFile(f->handle, temp, size);
|
||||
pspFileSystem.ReadFile(handle, temp, size);
|
||||
module = __KernelLoadELFFromPtr(temp, 0, &error_string);
|
||||
delete [] temp;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user