This commit is contained in:
red-prig 2022-11-28 20:05:52 +03:00
parent c52e0f2902
commit b0032177f2
4 changed files with 101 additions and 70 deletions

View File

@ -12,7 +12,8 @@ uses
type
p_pthread_condattr=^pthread_condattr_t;
pthread_condattr_t=bitpacked record
pthread_condattr_t=^pthread_condattr;
pthread_condattr=bitpacked record
_shared:0..1; //1
_clock:0..31; //5
_align:0..67108863; //26
@ -80,29 +81,39 @@ Uses
ps4_time;
function ps4_pthread_condattr_init(pAttr:p_pthread_condattr):Integer; SysV_ABI_CDecl;
var
attr:pthread_condattr_t;
begin
if (pAttr=nil) then Exit(EINVAL);
pAttr^:=Default(pthread_condattr_t);
attr:=AllocMem(SizeOf(pthread_condattr));
if (attr=nil) then Exit(ENOMEM);
pAttr^:=attr;
Result:=0;
end;
function ps4_pthread_condattr_destroy(pAttr:p_pthread_condattr):Integer; SysV_ABI_CDecl;
var
attr:pthread_condattr_t;
begin
if (pAttr=nil) then Exit(EINVAL);
pAttr^:=Default(pthread_condattr_t);
attr:=pAttr^;
if (attr=nil) then Exit(EINVAL);
FreeMem(attr);
Result:=0;
end;
function ps4_pthread_condattr_getclock(pAttr:p_pthread_condattr;t:PInteger):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) or (t=nil) then Exit(EINVAL);
t^:=pAttr^._clock;
if (pAttr^=nil) then Exit(EINVAL);
t^:=pAttr^^._clock;
Result:=0;
end;
function ps4_pthread_condattr_setclock(pAttr:p_pthread_condattr;t:Integer):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) then Exit(EINVAL);
if (pAttr^=nil) then Exit(EINVAL);
Case t of
CLOCK_REALTIME :;
CLOCK_VIRTUAL :;
@ -125,27 +136,29 @@ begin
else
Exit(EINVAL);
end;
pAttr^._clock:=t;
pAttr^^._clock:=t;
Result:=0;
end;
function ps4_pthread_condattr_getpshared(pAttr:p_pthread_condattr;t:PInteger):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) or (t=nil) then Exit(EINVAL);
t^:=pAttr^._shared;
if (pAttr^=nil) then Exit(EINVAL);
t^:=pAttr^^._shared;
Result:=0;
end;
function ps4_pthread_condattr_setpshared(pAttr:p_pthread_condattr;t:Integer):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) then Exit(EINVAL);
if (pAttr^=nil) then Exit(EINVAL);
Case t of
PTHREAD_PROCESS_PRIVATE:;
PTHREAD_PROCESS_SHARED :;
else
Exit(EINVAL);
end;
pAttr^._shared:=t;
pAttr^^._shared:=t;
Result:=0;
end;
@ -672,16 +685,12 @@ end;
function ps4_scePthreadCondattrInit(pAttr:p_pthread_condattr):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
pAttr^:=Default(pthread_condattr_t);
Result:=0;
Result:=px2sce(ps4_pthread_condattr_init(pAttr));
end;
function ps4_scePthreadCondattrDestroy(pAttr:p_pthread_condattr):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
pAttr^:=Default(pthread_condattr_t);
Result:=0;
Result:=px2sce(ps4_pthread_condattr_destroy(pAttr));
end;
function ps4_scePthreadCondInit(pCond:PScePthreadCond;pAttr:p_pthread_condattr;name:Pchar):Integer; SysV_ABI_CDecl;

View File

@ -230,19 +230,31 @@ begin
Result:=ps4_sceKernelGetModuleInfoForUnwind(addr,flags,info);
end;
function ps4_sceKernelGetLibkernelTextLocation(address:PPointer;size:PQWORD):Integer; SysV_ABI_CDecl;
var
elf:Telf_file;
begin
Result:=0;
elf:=Telf_file(ps4_program.ps4_app.prog);
if (elf=nil) then Exit(-1);
address^:=elf.ModuleInfo.segmentInfo[0].address;
size ^:=elf.ModuleInfo.segmentInfo[0].size;
end;
type
PInternalSegmentInfo=^TInternalSegmentInfo;
TInternalSegmentInfo=packed record
address:Pointer;
size:DWORD;
size:QWORD;
end;
function ps4_sceKernelInternalMemoryGetModuleSegmentInfo(pOut:PInternalSegmentInfo):Integer; SysV_ABI_CDecl;
begin
pOut^.address:=nil;
pOut^.size:=0;
Result:=0;
//sceKernelGetLibkernelTextLocation(pOut^.address,pOut^.size)
//pOut^.address:=nil;
//pOut^.size:=0;
//Result:=0;
Result:=ps4_sceKernelGetLibkernelTextLocation(@pOut^.address,@pOut^.size)
end;
function ps4_sceKernelGetProcParam:PSceProcParam; SysV_ABI_CDecl;
@ -668,7 +680,7 @@ begin
lib^.set_proc($F4960DA8DEA300A2,@ps4_sceKernelDebugOutText);
//signal
lib^.set_proc($0262749A7DA5E253,@ps4_sceKernelGetLibkernelTextLocation);
lib^.set_proc($FD84D6FAA5DCDC24,@ps4_sceKernelInternalMemoryGetModuleSegmentInfo);
lib^.set_proc($7FB28139A7F2B17A,@ps4_sceKernelGetModuleInfoFromAddr);
lib^.set_proc($914A60AD722BCFB4,@ps4_sceKernelGetModuleInfo);

View File

@ -94,6 +94,16 @@ begin
Result:=0;
end;
procedure ps4__ZNSt8ios_base4InitC1Ev(this:Pointer); //void __thiscall std::ios_base::Init::Init(Init *this)
begin
//
end;
procedure ps4__ZNSt6_WinitC1Ev(this:Pointer); //void __thiscall std::_Winit::_Winit(_Winit *this)
begin
//
end;
Const
Need_sceLibcInternal:QWORD=1;
@ -190,6 +200,9 @@ begin
//lib^.set_proc($B6CBC49A77A7CF8F,@ps4___cxa_atexit);
lib^.set_proc($B2A5B2B678587448,@ps4__ZNSt8ios_base4InitC1Ev);
lib^.set_proc($FC197DFD26769E87,@ps4__ZNSt6_WinitC1Ev);
//mspace
lib^.set_proc($DB4714934A97F73A,@ps4_malloc_init_lv2);

View File

@ -11,7 +11,8 @@ uses
type
p_pthread_mutex_attr=^pthread_mutex_attr_t;
pthread_mutex_attr_t=bitpacked record
pthread_mutex_attr_t=^pthread_mutex_attr;
pthread_mutex_attr=bitpacked record
_type:0..7; //3
_shared:0..1; //1
_protocol:0..3; //2
@ -104,29 +105,41 @@ Uses
ps4_time;
function ps4_pthread_mutexattr_init(pAttr:p_pthread_mutex_attr):Integer; SysV_ABI_CDecl;
var
attr:pthread_mutex_attr_t;
begin
if (pAttr=nil) then Exit(EINVAL);
pAttr^:=Default(pthread_mutex_attr_t);
pAttr^._type:=PTHREAD_MUTEX_DEFAULT;
attr:=AllocMem(SizeOf(pthread_mutex_attr));
if (attr=nil) then Exit(ENOMEM);
attr^:=Default(pthread_mutex_attr);
attr^._type:=PTHREAD_MUTEX_DEFAULT;
pAttr^:=attr;
Result:=0;
end;
function ps4_pthread_mutexattr_destroy(pAttr:p_pthread_mutex_attr):Integer; SysV_ABI_CDecl;
var
attr:pthread_mutex_attr_t;
begin
if (pAttr=nil) then Exit(EINVAL);
attr:=pAttr^;
if (attr=nil) then Exit(EINVAL);
FreeMem(attr);
Result:=0;
end;
function ps4_pthread_mutexattr_gettype(pAttr:p_pthread_mutex_attr;t:PInteger):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) or (t=nil) then Exit(EINVAL);
t^:=pAttr^._type;
if (pAttr^=nil) then Exit(EINVAL);
t^:=pAttr^^._type;
Result:=0;
end;
function ps4_pthread_mutexattr_settype(pAttr:p_pthread_mutex_attr;t:Integer):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) then Exit(EINVAL);
if (pAttr^=nil) then Exit(EINVAL);
Case t of
PTHREAD_MUTEX_ERRORCHECK:;
PTHREAD_MUTEX_RECURSIVE :;
@ -135,40 +148,44 @@ begin
else
Exit(EINVAL);
end;
pAttr^._type:=t;
pAttr^^._type:=t;
Result:=0;
end;
function ps4_pthread_mutexattr_getpshared(pAttr:p_pthread_mutex_attr;t:PInteger):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) or (t=nil) then Exit(EINVAL);
t^:=pAttr^._shared;
if (pAttr^=nil) then Exit(EINVAL);
t^:=pAttr^^._shared;
Result:=0;
end;
function ps4_pthread_mutexattr_setpshared(pAttr:p_pthread_mutex_attr;t:Integer):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) then Exit(EINVAL);
if (pAttr^=nil) then Exit(EINVAL);
Case t of
PTHREAD_PROCESS_PRIVATE:;
PTHREAD_PROCESS_SHARED :;
else
Exit(EINVAL);
end;
pAttr^._shared:=t;
pAttr^^._shared:=t;
Result:=0;
end;
function ps4_pthread_mutexattr_getprotocol(pAttr:p_pthread_mutex_attr;t:PInteger):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) or (t=nil) then Exit(EINVAL);
t^:=pAttr^._protocol;
if (pAttr^=nil) then Exit(EINVAL);
t^:=pAttr^^._protocol;
Result:=0;
end;
function ps4_pthread_mutexattr_setprotocol(pAttr:p_pthread_mutex_attr;t:Integer):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) then Exit(EINVAL);
if (pAttr^=nil) then Exit(EINVAL);
Case t of
PTHREAD_PRIO_NONE :;
PTHREAD_PRIO_INHERIT:;
@ -176,21 +193,23 @@ begin
else
Exit(EINVAL);
end;
pAttr^._protocol:=t;
pAttr^^._protocol:=t;
Result:=0;
end;
function ps4_pthread_mutexattr_getprioceiling(pAttr:p_pthread_mutex_attr;t:PInteger):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) or (t=nil) then Exit(EINVAL);
t^:=pAttr^._prioceiling;
if (pAttr^=nil) then Exit(EINVAL);
t^:=pAttr^^._prioceiling;
Result:=0;
end;
function ps4_pthread_mutexattr_setprioceiling(pAttr:p_pthread_mutex_attr;t:Integer):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) then Exit(EINVAL);
pAttr^._prioceiling:=t;
if (pAttr^=nil) then Exit(EINVAL);
pAttr^^._prioceiling:=t;
Result:=0;
end;
@ -401,12 +420,20 @@ end;
function pthread_mutex_init(m:p_pthread_mutex;a:p_pthread_mutex_attr;str:PChar;default:Integer):Integer;
var
mi:pthread_mutex;
attr:pthread_mutex_attr_t;
begin
if (m=nil) then Exit(EINVAL);
mi:=m^;
attr:=nil;
if (a<>nil) then
begin
mi:=mutex_impl_init(m,mi,a^._type);
attr:=a^;
end;
if (attr<>nil) then
begin
mi:=mutex_impl_init(m,mi,attr^._type);
end else
begin
mi:=mutex_impl_init(m,mi,default);
@ -454,73 +481,43 @@ end;
function ps4_scePthreadMutexattrInit(pAttr:p_pthread_mutex_attr):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
pAttr^:=Default(pthread_mutex_attr_t);
pAttr^._type:=SCE_PTHREAD_MUTEX_DEFAULT;
Result:=0;
Result:=px2sce(ps4_pthread_mutexattr_init(pAttr));
end;
function ps4_scePthreadMutexattrDestroy(pAttr:p_pthread_mutex_attr):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
Result:=0;
Result:=px2sce(ps4_pthread_mutexattr_destroy(pAttr));
end;
function ps4_scePthreadMutexattrGettype(pAttr:p_pthread_mutex_attr;t:PInteger):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) or (t=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
t^:=pAttr^._type;
Result:=0;
Result:=px2sce(ps4_pthread_mutexattr_gettype(pAttr,t));
end;
function ps4_scePthreadMutexattrSettype(pAttr:p_pthread_mutex_attr;t:Integer):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
Case t of
SCE_PTHREAD_MUTEX_ERRORCHECK:;
SCE_PTHREAD_MUTEX_RECURSIVE :;
SCE_PTHREAD_MUTEX_NORMAL :;
SCE_PTHREAD_MUTEX_ADAPTIVE :;
else
Exit(SCE_KERNEL_ERROR_EINVAL);
end;
pAttr^._type:=t;
Result:=0;
Result:=px2sce(ps4_pthread_mutexattr_settype(pAttr,t));
end;
function ps4_scePthreadMutexattrGetprotocol(pAttr:p_pthread_mutex_attr;t:PInteger):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) or (t=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
t^:=pAttr^._protocol;
Result:=0;
Result:=px2sce(ps4_pthread_mutexattr_getprotocol(pAttr,t));
end;
function ps4_scePthreadMutexattrSetprotocol(pAttr:p_pthread_mutex_attr;t:Integer):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
Case t of
PTHREAD_PRIO_NONE :;
PTHREAD_PRIO_INHERIT:;
PTHREAD_PRIO_PROTECT:;
else
Exit(SCE_KERNEL_ERROR_EINVAL);
end;
pAttr^._protocol:=t;
Result:=0;
Result:=px2sce(ps4_pthread_mutexattr_setprotocol(pAttr,t));
end;
function ps4_scePthreadMutexattrGetprioceiling(pAttr:p_pthread_mutex_attr;t:PInteger):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) or (t=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
t^:=pAttr^._prioceiling;
Result:=0;
Result:=px2sce(ps4_pthread_mutexattr_getprioceiling(pAttr,t));
end;
function ps4_scePthreadMutexattrSetprioceiling(pAttr:p_pthread_mutex_attr;t:Integer):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
pAttr^._prioceiling:=t;
Result:=0;
Result:=px2sce(ps4_pthread_mutexattr_setprioceiling(pAttr,t));
end;
//////////////