mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
aefe6edb7f
commit
4f16ea357e
|
@ -10,14 +10,23 @@ type
|
|||
cpuset_t =array[0..1] of QWORD;
|
||||
|
||||
const
|
||||
CPU_LEVEL_WHICH =3; // Actual mask/id for which.
|
||||
CPU_LEVEL_ROOT =1; // All system cpus.
|
||||
CPU_LEVEL_CPUSET =2; // Available cpus for which.
|
||||
CPU_LEVEL_WHICH =3; // Actual mask/id for which.
|
||||
|
||||
CPU_WHICH_TID =1; // Specifies a thread id.
|
||||
CPU_WHICH_PID =2; // Specifies a process id.
|
||||
CPU_WHICH_CPUSET=3; // Specifies a set id.
|
||||
CPU_WHICH_IRQ =4; // Specifies an irq #.
|
||||
CPU_WHICH_JAIL =5; // Specifies a jail id.
|
||||
|
||||
function sys_cpuset_getaffinity(level,which,id:Integer;cpusetsize:QWORD;mask:p_cpuset_t):Integer;
|
||||
function sys_cpuset_setaffinity(level,which,id:Integer;cpusetsize:QWORD;mask:p_cpuset_t):Integer;
|
||||
|
||||
function sys_cpuset(setid:PInteger):Integer;
|
||||
function sys_cpuset_setid(which,id,setid:Integer):Integer;
|
||||
function sys_cpuset_getid(level,which,id:Integer;setid:PInteger):Integer;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
|
@ -35,7 +44,13 @@ var
|
|||
begin
|
||||
if (cpusetsize<SizeOf(cpuset_t)) then Exit(ERANGE);
|
||||
|
||||
if (level<>CPU_LEVEL_WHICH) then Exit(EINVAL);
|
||||
case level of
|
||||
CPU_LEVEL_ROOT :;
|
||||
CPU_LEVEL_CPUSET:;
|
||||
CPU_LEVEL_WHICH :;
|
||||
else
|
||||
Exit(EINVAL);
|
||||
end;
|
||||
|
||||
Case which of
|
||||
CPU_WHICH_TID:
|
||||
|
@ -66,6 +81,22 @@ begin
|
|||
Exit(ESRCH);
|
||||
end;
|
||||
end;
|
||||
CPU_WHICH_CPUSET,
|
||||
CPU_WHICH_JAIL:
|
||||
begin
|
||||
if (id=-1) or (id=0) then
|
||||
begin
|
||||
td:=curkthread;
|
||||
old:=td^.td_cpuset;
|
||||
end else
|
||||
begin
|
||||
Exit(ESRCH);
|
||||
end;
|
||||
end;
|
||||
CPU_WHICH_IRQ:
|
||||
begin
|
||||
Exit(ESRCH);
|
||||
end
|
||||
else
|
||||
Exit(EINVAL);
|
||||
end;
|
||||
|
@ -80,7 +111,13 @@ var
|
|||
begin
|
||||
if (cpusetsize<SizeOf(cpuset_t)) then Exit(ERANGE);
|
||||
|
||||
if (level<>CPU_LEVEL_WHICH) then Exit(EINVAL);
|
||||
case level of
|
||||
CPU_LEVEL_ROOT :;
|
||||
CPU_LEVEL_CPUSET:;
|
||||
CPU_LEVEL_WHICH :;
|
||||
else
|
||||
Exit(EINVAL);
|
||||
end;
|
||||
|
||||
Result:=copyin(mask,@new,SizeOf(QWORD));
|
||||
if (Result<>0) then Exit;
|
||||
|
@ -99,7 +136,10 @@ begin
|
|||
|
||||
if (td=nil) then Exit(ESRCH);
|
||||
|
||||
thread_lock(td);
|
||||
Result:=cpuset_setaffinity(td,new);
|
||||
thread_unlock(td);
|
||||
|
||||
if (Result<>0) then Result:=ESRCH;
|
||||
|
||||
thread_dec_ref(td);
|
||||
|
@ -116,6 +156,27 @@ begin
|
|||
Exit(ESRCH);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
CPU_WHICH_CPUSET,
|
||||
CPU_WHICH_JAIL:
|
||||
begin
|
||||
if (id=-1) or (id=0) then
|
||||
begin
|
||||
td:=curkthread;
|
||||
|
||||
thread_lock(td);
|
||||
Result:=cpuset_setaffinity(td,new);
|
||||
thread_unlock(td);
|
||||
|
||||
if (Result<>0) then Result:=ESRCH;
|
||||
end else
|
||||
begin
|
||||
Exit(ESRCH);
|
||||
end;
|
||||
end;
|
||||
CPU_WHICH_IRQ:
|
||||
begin
|
||||
Exit(ESRCH);
|
||||
end
|
||||
else
|
||||
Exit(EINVAL);
|
||||
|
@ -123,5 +184,78 @@ begin
|
|||
|
||||
end;
|
||||
|
||||
function sys_cpuset(setid:PInteger):Integer;
|
||||
begin
|
||||
Exit(EPERM); //sceSblACMgrIsSystemUcred
|
||||
end;
|
||||
|
||||
function sys_cpuset_setid(which,id,setid:Integer):Integer;
|
||||
begin
|
||||
Exit(EPERM); //sceSblACMgrIsSystemUcred
|
||||
end;
|
||||
|
||||
function sys_cpuset_getid(level,which,id:Integer;setid:PInteger):Integer;
|
||||
var
|
||||
td:p_kthread;
|
||||
begin
|
||||
if (level=CPU_LEVEL_WHICH) and (which<>CPU_WHICH_CPUSET) then
|
||||
Exit(EINVAL);
|
||||
|
||||
case level of
|
||||
CPU_LEVEL_ROOT :;
|
||||
CPU_LEVEL_CPUSET:;
|
||||
CPU_LEVEL_WHICH :;
|
||||
else
|
||||
Exit(EINVAL);
|
||||
end;
|
||||
|
||||
Case which of
|
||||
CPU_WHICH_TID:
|
||||
begin
|
||||
if (id=-1) then
|
||||
begin
|
||||
td:=curkthread;
|
||||
thread_inc_ref(td);
|
||||
end else
|
||||
begin
|
||||
td:=tdfind(id);
|
||||
end;
|
||||
|
||||
if (td=nil) then Exit(ESRCH);
|
||||
|
||||
thread_dec_ref(td);
|
||||
end;
|
||||
CPU_WHICH_PID:
|
||||
begin
|
||||
if (id=-1) or (id=g_pid) then
|
||||
begin
|
||||
//
|
||||
end else
|
||||
begin
|
||||
Exit(ESRCH);
|
||||
end;
|
||||
end;
|
||||
CPU_WHICH_CPUSET,
|
||||
CPU_WHICH_JAIL:
|
||||
begin
|
||||
if (id=-1) or (id=0) then
|
||||
begin
|
||||
//
|
||||
end else
|
||||
begin
|
||||
Exit(ESRCH);
|
||||
end;
|
||||
end;
|
||||
else
|
||||
Exit(EINVAL);
|
||||
end;
|
||||
|
||||
id:=0; //psevdo cpuset id
|
||||
Result:=copyout(@id, setid, sizeof(id));
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
|
|
@ -25,9 +25,25 @@ const
|
|||
RLIMIT_AS =RLIMIT_VMEM; // standard name for RLIMIT_VMEM
|
||||
RLIMIT_NPTS =11; // pseudo-terminals
|
||||
RLIMIT_SWAP =12; // swap used
|
||||
RLIM_NLIMITS =13; // number of resource limits
|
||||
|
||||
function lim_max(which:Integer):QWORD;
|
||||
function lim_cur(which:Integer):QWORD;
|
||||
RLIM_INFINITY =(QWORD(1) shl 63)-1;
|
||||
|
||||
maxprocperuid =4*1024;
|
||||
|
||||
type
|
||||
p_rlimit=^t_rlimit;
|
||||
t_rlimit=packed record
|
||||
rlim_cur:QWORD; //current (soft) limit
|
||||
rlim_max:QWORD; //maximum value for rlim_cur
|
||||
end;
|
||||
|
||||
function lim_max(which:Integer):QWORD;
|
||||
function lim_cur(which:Integer):QWORD;
|
||||
procedure lim_rlimit(which:Integer;rlp:p_rlimit);
|
||||
|
||||
function sys_getrlimit(which:Integer;rlp:p_rlimit):Integer;
|
||||
function sys_setrlimit(which:Integer;rlp:p_rlimit):Integer;
|
||||
|
||||
const
|
||||
RUSAGE_SELF = 0;
|
||||
|
@ -71,17 +87,19 @@ implementation
|
|||
|
||||
uses
|
||||
errno,
|
||||
systm,
|
||||
kern_thr,
|
||||
md_proc;
|
||||
|
||||
function lim_max(which:Integer):QWORD;
|
||||
begin
|
||||
Result:=0;
|
||||
Result:=RLIM_INFINITY;
|
||||
Case which of
|
||||
RLIMIT_DATA :Result:=MAXDSIZ;
|
||||
RLIMIT_STACK :Result:=MAXSSIZ;
|
||||
RLIMIT_MEMLOCK:Result:=pageablemem;
|
||||
RLIMIT_VMEM :Result:=pageablemem;
|
||||
RLIMIT_NPROC :Result:=maxprocperuid;
|
||||
RLIMIT_NOFILE :Result:=maxfilesperproc;
|
||||
else;
|
||||
end;
|
||||
|
@ -89,17 +107,47 @@ end;
|
|||
|
||||
function lim_cur(which:Integer):QWORD;
|
||||
begin
|
||||
Result:=0;
|
||||
Result:=RLIM_INFINITY;
|
||||
Case which of
|
||||
RLIMIT_DATA :Result:=MAXDSIZ;
|
||||
RLIMIT_STACK :Result:=MAXSSIZ;
|
||||
RLIMIT_MEMLOCK:Result:=pageablemem;
|
||||
RLIMIT_VMEM :Result:=pageablemem;
|
||||
RLIMIT_NPROC :Result:=maxprocperuid;
|
||||
RLIMIT_NOFILE :Result:=maxfilesperproc;
|
||||
else;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure lim_rlimit(which:Integer;rlp:p_rlimit);
|
||||
begin
|
||||
rlp^.rlim_cur:=lim_max(which);
|
||||
rlp^.rlim_max:=lim_cur(which);
|
||||
end;
|
||||
|
||||
function sys_getrlimit(which:Integer;rlp:p_rlimit):Integer;
|
||||
var
|
||||
rlim:t_rlimit;
|
||||
begin
|
||||
if (which >= RLIM_NLIMITS) then
|
||||
Exit(EINVAL);
|
||||
|
||||
lim_rlimit(which, @rlim);
|
||||
|
||||
Result:=copyout(@rlim, rlp, sizeof(t_rlimit));
|
||||
end;
|
||||
|
||||
function sys_setrlimit(which:Integer;rlp:p_rlimit):Integer;
|
||||
var
|
||||
alim:t_rlimit;
|
||||
begin
|
||||
Result:=copyin(rlp, @alim, sizeof(t_rlimit));
|
||||
if (Result<>0) then Exit;
|
||||
|
||||
//error:=kern_setrlimit(td, uap^.which, @alim);
|
||||
Exit(0);
|
||||
end;
|
||||
|
||||
function cur_proc_get_nice():Integer; inline;
|
||||
begin
|
||||
Result:=get_proc_prio;
|
||||
|
|
|
@ -72,6 +72,7 @@ Function sys_sigsuspend(sigmask:p_sigset_t):Integer;
|
|||
Function sys_sigaltstack(ss:p_stack_t;oss:p_stack_t):Integer;
|
||||
|
||||
function sys_kill(pid,signum:Integer):Integer;
|
||||
function sys_sigqueue(pid,signum:Integer;value:Pointer):Integer;
|
||||
|
||||
Function sigonstack(sp:size_t):Integer;
|
||||
procedure sigqueue_init(list:p_sigqueue);
|
||||
|
@ -1208,6 +1209,50 @@ begin
|
|||
{ NOTREACHED }
|
||||
end;
|
||||
|
||||
function sys_sigqueue(pid,signum:Integer;value:Pointer):Integer;
|
||||
var
|
||||
ksi:ksiginfo_t;
|
||||
error:Integer;
|
||||
begin
|
||||
if (signum > _SIG_MAXSIG) then
|
||||
Exit(EINVAL);
|
||||
|
||||
{
|
||||
* Specification says sigqueue can only send signal to
|
||||
* single process.
|
||||
}
|
||||
if (pid <= 0) then
|
||||
begin
|
||||
Exit(EINVAL);
|
||||
end;
|
||||
|
||||
if (pid<>0) and (pid<>g_pid) then
|
||||
begin
|
||||
Exit(ESRCH);
|
||||
end;
|
||||
|
||||
error:=p_cansignal(signum);
|
||||
|
||||
if (error=0) and (signum<>0) then
|
||||
begin
|
||||
ksiginfo_init(@ksi);
|
||||
ksi.ksi_flags:=KSI_SIGQ;
|
||||
ksi.ksi_info.si_signo:=signum;
|
||||
ksi.ksi_info.si_code :=SI_QUEUE;
|
||||
ksi.ksi_info.si_pid :=g_pid;
|
||||
ksi.ksi_info.si_value.sival_ptr:=value;
|
||||
|
||||
PROC_LOCK();
|
||||
error:=pksignal(signum, @ksi);
|
||||
PROC_UNLOCK();
|
||||
end;
|
||||
|
||||
Exit(error);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
procedure postsig_done(sig:Integer;td:p_kthread);
|
||||
var
|
||||
mask:sigset_t;
|
||||
|
@ -1239,10 +1284,9 @@ function tdsendsignal(td:p_kthread;sig:Integer;ksi:p_ksiginfo):Integer; forward;
|
|||
|
||||
procedure trapsignal(td:p_kthread;ksi:p_ksiginfo);
|
||||
var
|
||||
sig,code:Integer;
|
||||
sig:Integer;
|
||||
begin
|
||||
sig :=ksi^.ksi_info.si_signo;
|
||||
code:=ksi^.ksi_info.si_code;
|
||||
|
||||
Assert(_SIG_VALID(sig),'invalid signal');
|
||||
|
||||
|
@ -1335,6 +1379,7 @@ begin
|
|||
ksiginfo_init(@ksi);
|
||||
ksi.ksi_info.si_signo:=sig;
|
||||
ksi.ksi_info.si_code :=SI_KERNEL;
|
||||
ksi.ksi_info.si_pid :=g_pid;
|
||||
tdsendsignal(nil,sig,@ksi);
|
||||
end;
|
||||
|
||||
|
@ -1419,6 +1464,7 @@ begin
|
|||
ksiginfo_init(@ksi);
|
||||
ksi.ksi_info.si_signo:=sig;
|
||||
ksi.ksi_info.si_code :=SI_KERNEL;
|
||||
ksi.ksi_info.si_pid :=g_pid;
|
||||
tdsendsignal(td,sig,@ksi);
|
||||
end;
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@ procedure thread_free(td:p_kthread);
|
|||
function sys_thr_new(_param:p_thr_param;_size:Integer):Integer;
|
||||
function sys_thr_self(id:PDWORD):Integer;
|
||||
procedure sys_thr_exit(state:PQWORD);
|
||||
function sys_thr_kill(id:DWORD;sig:Integer):Integer;
|
||||
function sys_thr_kill(id,sig:Integer):Integer;
|
||||
function sys_thr_kill2(pid,id,sig:Integer):Integer;
|
||||
function sys_thr_suspend(timeout:ptimespec):Integer;
|
||||
function sys_thr_wake(id:DWORD):Integer;
|
||||
function sys_thr_set_name(id:DWORD;pname:PChar):Integer;
|
||||
|
@ -70,6 +71,7 @@ uses
|
|||
errno,
|
||||
systm,
|
||||
vm_machdep,
|
||||
md_proc,
|
||||
md_thread,
|
||||
kern_rwlock,
|
||||
kern_mtx,
|
||||
|
@ -584,7 +586,7 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function sys_thr_kill(id:DWORD;sig:Integer):Integer;
|
||||
function sys_thr_kill(id,sig:Integer):Integer;
|
||||
var
|
||||
data:_t_stk;
|
||||
begin
|
||||
|
@ -593,8 +595,9 @@ begin
|
|||
ksiginfo_init(@data.ksi);
|
||||
data.ksi.ksi_info.si_signo:=sig;
|
||||
data.ksi.ksi_info.si_code :=SI_LWP;
|
||||
data.ksi.ksi_info.si_pid :=g_pid;
|
||||
|
||||
if (Integer(id)=-1) then
|
||||
if (id=-1) then //all
|
||||
begin
|
||||
if (sig<>0) and (not _SIG_VALID(sig)) then
|
||||
begin
|
||||
|
@ -628,6 +631,16 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function sys_thr_kill2(pid,id,sig:Integer):Integer;
|
||||
begin
|
||||
if (pid<>0) and (pid<>g_pid) then
|
||||
begin
|
||||
Exit(ESRCH);
|
||||
end;
|
||||
|
||||
Result:=sys_thr_kill(id,sig);
|
||||
end;
|
||||
|
||||
function kern_thr_suspend(td:p_kthread;tsp:ptimespec):Integer;
|
||||
var
|
||||
tv:Int64;
|
||||
|
|
Loading…
Reference in New Issue