diff --git a/sys/kern/kern_gpo.pas b/sys/kern/kern_gpo.pas new file mode 100644 index 00000000..2e01b0e5 --- /dev/null +++ b/sys/kern/kern_gpo.pas @@ -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. + diff --git a/sys/kern/kern_thread.pas b/sys/kern/kern_thread.pas index 5190f746..f2be81d9 100644 --- a/sys/kern/kern_thread.pas +++ b/sys/kern/kern_thread.pas @@ -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. diff --git a/sys/kern/kern_uuid.pas b/sys/kern/kern_uuid.pas new file mode 100644 index 00000000..02282dfe --- /dev/null +++ b/sys/kern/kern_uuid.pas @@ -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. + diff --git a/sys/sys_machdep.pas b/sys/sys_machdep.pas new file mode 100644 index 00000000..baa634cc --- /dev/null +++ b/sys/sys_machdep.pas @@ -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. + diff --git a/sys/test/project1.lpi b/sys/test/project1.lpi index da3a1b34..1a05cfd5 100644 --- a/sys/test/project1.lpi +++ b/sys/test/project1.lpi @@ -533,6 +533,18 @@ + + + + + + + + + + + + diff --git a/sys/test/project1.lpr b/sys/test/project1.lpr index 9b4413ef..6c3c9c23 100644 --- a/sys/test/project1.lpr +++ b/sys/test/project1.lpr @@ -78,7 +78,10 @@ uses _resource, kern_resource, md_proc, - kern_ksched; + kern_ksched, + kern_uuid, + kern_gpo, + sys_machdep; var mtx:umutex; diff --git a/sys/vm/vmparam.pas b/sys/vm/vmparam.pas index 7d24c40b..15de5c6a 100644 --- a/sys/vm/vmparam.pas +++ b/sys/vm/vmparam.pas @@ -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