we can now execute code (reaches init_env() function )
This commit is contained in:
parent
cc596083f5
commit
d641f7b6c4
|
@ -27,7 +27,7 @@ int scePthreadAttrInit(ScePthreadAttr* attr) {
|
||||||
SceKernelSchedParam param{};
|
SceKernelSchedParam param{};
|
||||||
param.sched_priority = 700;
|
param.sched_priority = 700;
|
||||||
|
|
||||||
result = (result == 0 ? scePthreadAttrSetinheritsched(attr, PTHREAD_INHERIT_SCHED) : result);
|
result = (result == 0 ? scePthreadAttrSetinheritsched(attr, 4) : result);
|
||||||
result = (result == 0 ? scePthreadAttrSetschedparam(attr, ¶m) : result);
|
result = (result == 0 ? scePthreadAttrSetschedparam(attr, ¶m) : result);
|
||||||
result = (result == 0 ? scePthreadAttrSetschedpolicy(attr, SCHED_OTHER) : result);
|
result = (result == 0 ? scePthreadAttrSetschedpolicy(attr, SCHED_OTHER) : result);
|
||||||
result = (result == 0 ? scePthreadAttrSetdetachstate(attr, PTHREAD_CREATE_JOINABLE) : result);
|
result = (result == 0 ? scePthreadAttrSetdetachstate(attr, PTHREAD_CREATE_JOINABLE) : result);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#define _TIMESPEC_DEFINED
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include "../../../../types.h"
|
#include "../../../../types.h"
|
||||||
|
@ -28,6 +30,8 @@ struct PthreadAttrInternal {
|
||||||
|
|
||||||
class PThreadCxt {};
|
class PThreadCxt {};
|
||||||
|
|
||||||
|
void Pthread_Init_Self_MainThread();
|
||||||
|
|
||||||
//HLE FUNCTIONS
|
//HLE FUNCTIONS
|
||||||
int scePthreadAttrInit(ScePthreadAttr* attr);
|
int scePthreadAttrInit(ScePthreadAttr* attr);
|
||||||
int scePthreadAttrSetdetachstate(ScePthreadAttr* attr, int detachstate);
|
int scePthreadAttrSetdetachstate(ScePthreadAttr* attr, int detachstate);
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace HLE::Libs::LibC {
|
||||||
static void init_env() //every game/demo should probably
|
static void init_env() //every game/demo should probably
|
||||||
{
|
{
|
||||||
for(;;) {
|
for(;;) {
|
||||||
printf("__debugbreak\n");
|
printf("life is a bitch but it did reach here\n");
|
||||||
}
|
}
|
||||||
//__debugbreak();//if we reach here it will be a great progress :D
|
//__debugbreak();//if we reach here it will be a great progress :D
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "../../Util/StringUtil.h"
|
#include "../../Util/StringUtil.h"
|
||||||
#include "Util/aerolib.h"
|
#include "Util/aerolib.h"
|
||||||
#include "Loader/SymbolsResolver.h"
|
#include "Loader/SymbolsResolver.h"
|
||||||
|
#include "HLE/Kernel/ThreadManagement.h"
|
||||||
|
|
||||||
|
|
||||||
constexpr bool debug_loader = true;
|
constexpr bool debug_loader = true;
|
||||||
|
@ -629,3 +630,26 @@ void Linker::Resolve(const std::string& name, int Symtype, Module* m, SymbolReco
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using exit_func_t = void (*)();
|
||||||
|
using entry_func_t = void (*)(EntryParams* params, exit_func_t atexit_func);
|
||||||
|
|
||||||
|
static void ProgramExitFunc() {
|
||||||
|
|
||||||
|
printf("exit function called\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void run_main_entry(u64 addr, EntryParams* params, exit_func_t exit_func) {
|
||||||
|
reinterpret_cast<entry_func_t>(addr)(params, exit_func);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Linker::Execute()
|
||||||
|
{
|
||||||
|
HLE::Libs::LibKernel::ThreadManagement::Pthread_Init_Self_MainThread();
|
||||||
|
EntryParams p{};
|
||||||
|
p.argc = 1;
|
||||||
|
p.argv[0] = "eboot.bin"; //hmm should be ok?
|
||||||
|
|
||||||
|
run_main_entry(m_modules.at(0)->elf->GetElfEntry()+m_modules.at(0)->base_virtual_addr, &p, ProgramExitFunc);
|
||||||
|
|
||||||
|
}
|
|
@ -7,6 +7,12 @@
|
||||||
struct DynamicModuleInfo;
|
struct DynamicModuleInfo;
|
||||||
class Linker;
|
class Linker;
|
||||||
|
|
||||||
|
struct EntryParams {
|
||||||
|
int argc;
|
||||||
|
u32 padding;
|
||||||
|
const char* argv[3];
|
||||||
|
};
|
||||||
|
|
||||||
/*this struct keeps neccesary info about loaded modules.Main executeable is included too as well*/
|
/*this struct keeps neccesary info about loaded modules.Main executeable is included too as well*/
|
||||||
struct Module
|
struct Module
|
||||||
{
|
{
|
||||||
|
@ -115,6 +121,7 @@ public:
|
||||||
SymbolsResolver* getHLESymbols() { return m_HLEsymbols; }
|
SymbolsResolver* getHLESymbols() { return m_HLEsymbols; }
|
||||||
void Relocate(Module* m);
|
void Relocate(Module* m);
|
||||||
void Resolve(const std::string& name, int Symtype, Module* m, SymbolRecord* return_info);
|
void Resolve(const std::string& name, int Symtype, Module* m, SymbolRecord* return_info);
|
||||||
|
void Execute();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ModuleInfo* FindModule(const Module& m, const std::string& id);
|
const ModuleInfo* FindModule(const Module& m, const std::string& id);
|
||||||
|
|
|
@ -33,10 +33,10 @@
|
||||||
// Main code
|
// Main code
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if (argc == 1) {
|
/* if (argc == 1) {
|
||||||
printf("Usage: %s <elf or eboot.bin path>\n", argv[0]);
|
printf("Usage: %s <elf or eboot.bin path>\n", argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
logging::init(true);//init logging
|
logging::init(true);//init logging
|
||||||
const char* const path = argv[1]; // argument 1 is the path of self file to boot
|
const char* const path = argv[1]; // argument 1 is the path of self file to boot
|
||||||
|
@ -44,6 +44,7 @@ int main(int argc, char* argv[])
|
||||||
HLE::Libs::Init_HLE_Libs(linker->getHLESymbols());
|
HLE::Libs::Init_HLE_Libs(linker->getHLESymbols());
|
||||||
auto *module =linker->LoadModule(path);//load main executable
|
auto *module =linker->LoadModule(path);//load main executable
|
||||||
|
|
||||||
|
linker->Execute();
|
||||||
#if 0
|
#if 0
|
||||||
// Setup SDL
|
// Setup SDL
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMEPAD) != 0)
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMEPAD) != 0)
|
||||||
|
|
Loading…
Reference in New Issue