mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
c07ace5319
commit
526f576514
|
@ -0,0 +1,27 @@
|
|||
unit kern_gpo;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
{$CALLING SysV_ABI_CDecl}
|
||||
|
||||
interface
|
||||
|
||||
function sys_get_gpo(pbits:PByte):Integer;
|
||||
function sys_set_gpo(uiBits:DWORD):Integer;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
errno;
|
||||
|
||||
function sys_get_gpo(pbits:PByte):Integer;
|
||||
begin
|
||||
Exit(EPERM); //sceSblACMgrIsSystemUcred
|
||||
end;
|
||||
|
||||
function sys_set_gpo(uiBits:DWORD):Integer;
|
||||
begin
|
||||
Exit(0);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
@ -33,6 +33,9 @@ function sys_thr_set_name(id:DWORD;pname:PChar):Integer;
|
|||
function sys_thr_get_name(id:DWORD;pname:PChar):Integer;
|
||||
|
||||
function sys_amd64_set_fsbase(base:Pointer):Integer;
|
||||
function sys_amd64_get_fsbase(base:PPointer):Integer;
|
||||
function sys_amd64_set_gsbase(base:Pointer):Integer;
|
||||
function sys_amd64_get_gsbase(base:PPointer):Integer;
|
||||
|
||||
procedure thread_inc_ref(td:p_kthread);
|
||||
procedure thread_dec_ref(td:p_kthread);
|
||||
|
@ -819,9 +822,39 @@ var
|
|||
begin
|
||||
Result:=0;
|
||||
td:=curkthread;
|
||||
if (td=nil) then Exit(EFAULT);
|
||||
if (td=nil) then Exit(-1);
|
||||
cpu_set_user_tls(td,base);
|
||||
end;
|
||||
|
||||
function sys_amd64_get_fsbase(base:PPointer):Integer;
|
||||
var
|
||||
td:p_kthread;
|
||||
begin
|
||||
Result:=0;
|
||||
td:=curkthread;
|
||||
if (td=nil) or (base=nil) then Exit(-1);
|
||||
base^:=td^.pcb_fsbase;
|
||||
end;
|
||||
|
||||
function sys_amd64_set_gsbase(base:Pointer):Integer;
|
||||
var
|
||||
td:p_kthread;
|
||||
begin
|
||||
Result:=0;
|
||||
td:=curkthread;
|
||||
if (td=nil) then Exit(-1);
|
||||
td^.pcb_gsbase:=base;
|
||||
end;
|
||||
|
||||
function sys_amd64_get_gsbase(base:PPointer):Integer;
|
||||
var
|
||||
td:p_kthread;
|
||||
begin
|
||||
Result:=0;
|
||||
td:=curkthread;
|
||||
if (td=nil) or (base=nil) then Exit(-1);
|
||||
base^:=td^.pcb_gsbase;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
unit kern_uuid;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
{$CALLING SysV_ABI_CDecl}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SysUtils;
|
||||
|
||||
type
|
||||
p_uuid=^t_uuid;
|
||||
t_uuid=TGuid;
|
||||
|
||||
function sys_uuidgen(store:p_uuid;count:Integer):Integer;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
errno,
|
||||
systm;
|
||||
|
||||
function kern_uuidgen(store:p_uuid;count:ptrint):p_uuid;
|
||||
var
|
||||
n:ptrint;
|
||||
begin
|
||||
Assert(SizeOf(t_uuid)=16);
|
||||
|
||||
For n:=0 to count-1 do
|
||||
begin
|
||||
CreateGUID(store[n]);
|
||||
end;
|
||||
|
||||
Exit(store);
|
||||
end;
|
||||
|
||||
function sys_uuidgen(store:p_uuid;count:Integer):Integer;
|
||||
var
|
||||
kstore:p_uuid;
|
||||
begin
|
||||
{
|
||||
* Limit the number of UUIDs that can be created at the same time
|
||||
* to some arbitrary number. This isn't really necessary, but I
|
||||
* like to have some sort of upper-bound that's less than 2G :-)
|
||||
* XXX probably needs to be tunable.
|
||||
}
|
||||
if (count < 1) or (count > 2048) then
|
||||
Exit(EINVAL);
|
||||
|
||||
kstore:=AllocMem(count * sizeof(t_uuid));
|
||||
|
||||
kern_uuidgen(store, count);
|
||||
|
||||
Result:=copyout(kstore, store, count * sizeof(t_uuid));
|
||||
|
||||
FreeMem(kstore);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
unit sys_machdep;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
{$CALLING SysV_ABI_CDecl}
|
||||
|
||||
interface
|
||||
|
||||
const
|
||||
I386_GET_IOPERM = 3;
|
||||
I386_SET_IOPERM = 4;
|
||||
I386_GET_FSBASE = 7;
|
||||
I386_SET_FSBASE = 8;
|
||||
I386_GET_GSBASE = 9;
|
||||
I386_SET_GSBASE = 10;
|
||||
|
||||
AMD64_GET_FSBASE =128;
|
||||
AMD64_SET_FSBASE =129;
|
||||
AMD64_GET_GSBASE =130;
|
||||
AMD64_SET_GSBASE =131;
|
||||
|
||||
type
|
||||
p_i386_ioperm_args=^t_i386_ioperm_args;
|
||||
t_i386_ioperm_args=packed record
|
||||
start :DWORD;
|
||||
length:DWORD;
|
||||
enable:Integer;
|
||||
end;
|
||||
|
||||
function sys_sysarch(op:Integer;parms:Pointer):Integer;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
errno,
|
||||
systm,
|
||||
vmparam,
|
||||
kern_thread;
|
||||
|
||||
function amd64_get_ioperm(uap:p_i386_ioperm_args):Integer;
|
||||
begin
|
||||
if (uap^.start >= (IOPAGES * PAGE_SIZE * NBBY)) then
|
||||
Exit(EINVAL);
|
||||
|
||||
uap^.length:=0;
|
||||
Exit(0);
|
||||
end;
|
||||
|
||||
function amd64_set_ioperm(uap:p_i386_ioperm_args):Integer;
|
||||
begin
|
||||
Exit(EPERM); //priv_check(td, PRIV_IO)
|
||||
end;
|
||||
|
||||
function sys_sysarch(op:Integer;parms:Pointer):Integer;
|
||||
var
|
||||
i386base:DWORD;
|
||||
a64base :QWORD;
|
||||
iargs :t_i386_ioperm_args;
|
||||
begin
|
||||
Result:=0;
|
||||
|
||||
//read
|
||||
case op of
|
||||
I386_GET_IOPERM,
|
||||
I386_SET_IOPERM:
|
||||
begin
|
||||
Result:=copyin(parms, @iargs, sizeof(t_i386_ioperm_args));
|
||||
end;
|
||||
I386_SET_FSBASE,
|
||||
I386_SET_GSBASE:
|
||||
begin
|
||||
Result:=copyin(parms, @i386base, sizeof(i386base));
|
||||
end;
|
||||
AMD64_SET_FSBASE,
|
||||
AMD64_SET_GSBASE:
|
||||
begin
|
||||
Result:=copyin(parms, @a64base, sizeof(a64base));
|
||||
end;
|
||||
else;
|
||||
end;
|
||||
|
||||
if (Result<>0) then Exit;
|
||||
|
||||
//operation
|
||||
case op of
|
||||
I386_GET_IOPERM:
|
||||
begin
|
||||
Result:=amd64_get_ioperm(@iargs);
|
||||
end;
|
||||
I386_SET_IOPERM:
|
||||
begin
|
||||
Result:=amd64_set_ioperm(@iargs);
|
||||
end;
|
||||
I386_GET_FSBASE:
|
||||
begin
|
||||
Result:=sys_amd64_get_fsbase(@a64base);
|
||||
i386base:=a64base;
|
||||
end;
|
||||
I386_SET_FSBASE:
|
||||
begin
|
||||
a64base:=i386base;
|
||||
Result:=sys_amd64_set_fsbase(Pointer(a64base));
|
||||
end;
|
||||
I386_GET_GSBASE:
|
||||
begin
|
||||
Result:=sys_amd64_get_gsbase(@a64base);
|
||||
i386base:=a64base;
|
||||
end;
|
||||
I386_SET_GSBASE:
|
||||
begin
|
||||
a64base:=i386base;
|
||||
Result:=sys_amd64_set_gsbase(Pointer(a64base));
|
||||
end;
|
||||
AMD64_GET_FSBASE:
|
||||
begin
|
||||
Result:=sys_amd64_get_fsbase(@a64base);
|
||||
end;
|
||||
AMD64_SET_FSBASE:
|
||||
begin
|
||||
Result:=sys_amd64_set_fsbase(Pointer(a64base));
|
||||
end;
|
||||
AMD64_GET_GSBASE:
|
||||
begin
|
||||
Result:=sys_amd64_get_gsbase(@a64base);
|
||||
end;
|
||||
AMD64_SET_GSBASE:
|
||||
begin
|
||||
Result:=sys_amd64_set_gsbase(Pointer(a64base));
|
||||
end;
|
||||
else
|
||||
Exit(EINVAL);
|
||||
end;
|
||||
|
||||
if (Result<>0) then Exit;
|
||||
|
||||
//write
|
||||
case op of
|
||||
I386_GET_IOPERM:
|
||||
begin
|
||||
Result:=copyout(@iargs, parms, sizeof(t_i386_ioperm_args));
|
||||
end;
|
||||
I386_GET_FSBASE,
|
||||
I386_GET_GSBASE:
|
||||
begin
|
||||
Result:=copyout(@i386base, parms, sizeof(i386base));
|
||||
end;
|
||||
AMD64_GET_FSBASE,
|
||||
AMD64_GET_GSBASE:
|
||||
begin
|
||||
Result:=copyout(@a64base, parms, sizeof(a64base));
|
||||
end;
|
||||
else;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
@ -533,6 +533,18 @@
|
|||
<Filename Value="..\kern\md_resource.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="..\kern\kern_uuid.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="..\kern\kern_gpo.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="..\sys_machdep.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
|
|
@ -78,7 +78,10 @@ uses
|
|||
_resource,
|
||||
kern_resource,
|
||||
md_proc,
|
||||
kern_ksched;
|
||||
kern_ksched,
|
||||
kern_uuid,
|
||||
kern_gpo,
|
||||
sys_machdep;
|
||||
|
||||
var
|
||||
mtx:umutex;
|
||||
|
|
|
@ -15,6 +15,9 @@ const
|
|||
NBPDR =$1fffff;
|
||||
PDRMASK=$1fffff;
|
||||
|
||||
MAXPAGESIZES=3; // maximum number of supported page sizes
|
||||
IOPAGES =2; // pages of i/o permission bitmap
|
||||
|
||||
//Virtual memory related constants, all in bytes
|
||||
MAXTSIZ =(128 *1024*1024); // max text size
|
||||
DFLDSIZ =(128 *1024*1024); // initial data size limit
|
||||
|
|
Loading…
Reference in New Issue