mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
89f8c9d053
commit
98eb9cc37b
|
@ -21,7 +21,7 @@ uses
|
|||
systm,
|
||||
trap,
|
||||
vm,
|
||||
vm_object,
|
||||
sys_vm_object,
|
||||
vm_pager,
|
||||
kern_event,
|
||||
kern_mtx,
|
||||
|
@ -712,8 +712,8 @@ begin
|
|||
begin
|
||||
knlist_remove(@g_video_out_event_flip,kn,0)
|
||||
end;
|
||||
//$0051:Result:=8;
|
||||
//$0058:Result:=12;
|
||||
// $0051:Result:=8;
|
||||
// $0058:Result:=12;
|
||||
else;
|
||||
end;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ uses
|
|||
vm,
|
||||
dmem_map,
|
||||
kern_dmem,
|
||||
vm_object,
|
||||
sys_vm_object,
|
||||
trap;
|
||||
|
||||
type
|
||||
|
|
|
@ -46,8 +46,7 @@ uses
|
|||
kern_sx,
|
||||
vfs_vnops,
|
||||
vfs_subr,
|
||||
vnode_if,
|
||||
devfs_vnops;
|
||||
vnode_if;
|
||||
|
||||
var
|
||||
devfs_desc:t_id_desc=(free:nil;refs:0);
|
||||
|
|
|
@ -467,8 +467,6 @@ begin
|
|||
vap^.va_size :=0;
|
||||
vap^.va_rdev :=makedev(0, vap^.va_fileid);
|
||||
end;
|
||||
else
|
||||
Assert(False,'fdesc_getattr');
|
||||
end;
|
||||
|
||||
vp^.v_type:=vap^.va_type;
|
||||
|
|
|
@ -6,7 +6,7 @@ unit kern_dmem;
|
|||
interface
|
||||
|
||||
uses
|
||||
vm_object,
|
||||
sys_vm_object,
|
||||
dmem_map,
|
||||
rmem_map;
|
||||
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
|
||||
|
||||
procedure knote(list:p_knlist;hint:QWORD;lockflags:Integer); external;
|
||||
|
||||
procedure KNOTE_LOCKED(list:p_knlist;hint:QWORD); inline;
|
||||
begin
|
||||
knote(list, hint, KNF_LISTLOCKED);
|
||||
end;
|
||||
|
||||
procedure KNOTE_UNLOCKED(list:p_knlist;hint:QWORD); inline;
|
||||
begin
|
||||
knote(list, hint, 0);
|
||||
end;
|
||||
|
||||
procedure knlist_add (knl:p_knlist;kn:p_knote;islocked:Integer); external;
|
||||
procedure knlist_remove(knl:p_knlist;kn:p_knote;islocked:Integer); external;
|
||||
|
||||
procedure knlist_destroy (knl:p_knlist); external;
|
||||
procedure knlist_cleardel(knl:p_knlist;islocked,killkn:Integer); external;
|
||||
|
||||
procedure knlist_clear(knl:p_knlist;islocked:Integer); inline;
|
||||
begin
|
||||
knlist_cleardel(knl, islocked, 0)
|
||||
end;
|
||||
|
||||
procedure knlist_init(knl:p_knlist;lock,kl_lock,kl_unlock,kl_assert_locked,kl_assert_unlocked:Pointer); external;
|
||||
procedure knlist_init_mtx(knl:p_knlist;lock:p_mtx); external;
|
||||
|
||||
function M_KNLIST_EMPTY(list:p_knlist):Boolean; inline;
|
||||
begin
|
||||
Result:=SLIST_EMPTY(@list^.kl_list);
|
||||
end;
|
||||
|
||||
|
|
@ -24,8 +24,7 @@ uses
|
|||
vcapability,
|
||||
vselinfo,
|
||||
vpoll,
|
||||
vstat,
|
||||
trap;
|
||||
vstat;
|
||||
|
||||
//TASKQUEUE_DEFINE_THREAD(kqueue);
|
||||
|
||||
|
@ -121,7 +120,6 @@ uses
|
|||
kern_proc,
|
||||
kern_callout,
|
||||
kern_timeout,
|
||||
kern_named_id,
|
||||
kern_namedobj;
|
||||
|
||||
//static MALLOC_DEFINE(M_KQUEUE, 'kqueue', 'memory for kqueue system');
|
||||
|
@ -2519,7 +2517,7 @@ end;
|
|||
* lock. This prevents a race where a new fd comes along and occupies the
|
||||
* entry and we attach a knote to the fd.
|
||||
}
|
||||
procedure knote_fdclose(fd:Integer);
|
||||
procedure knote_fdclose(fd:Integer); public;
|
||||
label
|
||||
again;
|
||||
var
|
||||
|
|
|
@ -40,7 +40,7 @@ uses
|
|||
vmparam,
|
||||
vm_map,
|
||||
vm_mmap,
|
||||
vm_object,
|
||||
sys_vm_object,
|
||||
vm_pager,
|
||||
vnamei,
|
||||
vfs_lookup,
|
||||
|
@ -53,7 +53,7 @@ uses
|
|||
kern_descrip,
|
||||
vfs_cache,
|
||||
vnode_if,
|
||||
_resource,
|
||||
sys_resource,
|
||||
kern_resource,
|
||||
sys_event,
|
||||
kern_event,
|
||||
|
@ -856,9 +856,6 @@ end;
|
|||
function dynlib_proc_initialize_step2(imgp:p_image_params):Integer;
|
||||
var
|
||||
obj,tail:p_lib_info;
|
||||
|
||||
init_proc_addr:Pointer;
|
||||
fini_proc_addr:Pointer;
|
||||
begin
|
||||
Result:=0;
|
||||
|
||||
|
@ -887,9 +884,6 @@ begin
|
|||
dynlibs_info.sym_zero.st_shndx:=SHN_UNDEF;
|
||||
dynlibs_info.sym_zero.st_value:=-Int64(obj^.relocbase);
|
||||
|
||||
init_proc_addr:=obj^.init_proc_addr;
|
||||
fini_proc_addr:=obj^.fini_proc_addr;
|
||||
|
||||
obj^.fini_proc_addr:=nil;
|
||||
obj^.init_proc_addr:=nil;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ unit kern_exit;
|
|||
interface
|
||||
|
||||
uses
|
||||
_resource;
|
||||
sys_resource;
|
||||
|
||||
const
|
||||
WCOREFLAG=&0200;
|
||||
|
|
|
@ -40,7 +40,6 @@ uses
|
|||
errno,
|
||||
systm,
|
||||
kern_thr,
|
||||
kern_rtprio,
|
||||
kern_proc,
|
||||
md_proc;
|
||||
|
||||
|
|
|
@ -80,10 +80,6 @@ uses
|
|||
|
||||
//
|
||||
|
||||
procedure knlist_init_mtx(knl:p_knlist;lock:p_mtx); external;
|
||||
|
||||
//
|
||||
|
||||
function pargs_alloc(len:Integer):p_pargs;
|
||||
begin
|
||||
Result:=AllocMem(sizeof(t_pargs) + len);
|
||||
|
|
|
@ -8,7 +8,7 @@ interface
|
|||
uses
|
||||
vmparam,
|
||||
kern_param,
|
||||
_resource;
|
||||
sys_resource;
|
||||
|
||||
function lim_max(which:Integer):QWORD;
|
||||
function lim_cur(which:Integer):QWORD;
|
||||
|
|
|
@ -10,7 +10,7 @@ uses
|
|||
kern_param,
|
||||
kern_thr,
|
||||
vnode,
|
||||
vm_object,
|
||||
sys_vm_object,
|
||||
vuio,
|
||||
elf64,
|
||||
kern_authinfo;
|
||||
|
|
|
@ -63,7 +63,7 @@ begin
|
|||
thread_unlock(td);
|
||||
end;
|
||||
|
||||
procedure pri_to_rtp(td:p_kthread;rtp:p_rtprio);
|
||||
procedure pri_to_rtp(td:p_kthread;rtp:p_rtprio); public;
|
||||
begin
|
||||
thread_lock(td);
|
||||
|
||||
|
|
|
@ -132,12 +132,6 @@ uses
|
|||
sched_ule,
|
||||
subr_sleepqueue;
|
||||
|
||||
//
|
||||
|
||||
{$I kern_event.inc}
|
||||
|
||||
//
|
||||
|
||||
const
|
||||
max_pending_per_proc=128;
|
||||
|
||||
|
@ -490,7 +484,7 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
Function sigonstack(sp:size_t):Integer;
|
||||
Function sigonstack(sp:size_t):Integer; public;
|
||||
var
|
||||
td:p_kthread;
|
||||
begin
|
||||
|
@ -685,7 +679,7 @@ Function kern_sigprocmask(td:p_kthread;
|
|||
_set:p_sigset_t;
|
||||
oset:p_sigset_t;
|
||||
flags:Integer
|
||||
):Integer;
|
||||
):Integer; public;
|
||||
label
|
||||
_out;
|
||||
var
|
||||
|
@ -867,10 +861,7 @@ begin
|
|||
tv:=0;
|
||||
end;
|
||||
|
||||
//PROC_UNLOCK; //
|
||||
Result:=msleep(@p_sigacts,@p_proc.p_mtx,PPAUSE or PCATCH,'sigwait',tvtohz(tv));
|
||||
//Result:=msleep_td(tvtohz(tv));
|
||||
//PROC_LOCK; //
|
||||
|
||||
if (timeout<>nil) then
|
||||
begin
|
||||
|
@ -1472,7 +1463,7 @@ begin
|
|||
tdsigwakeup(td,sig,action,intrval);
|
||||
end;
|
||||
|
||||
procedure tdsignal(td:p_kthread;sig:Integer);
|
||||
procedure tdsignal(td:p_kthread;sig:Integer); public;
|
||||
var
|
||||
ksi:ksiginfo_t;
|
||||
begin
|
||||
|
@ -1603,7 +1594,7 @@ begin
|
|||
reschedule_signals(unblocked,0);
|
||||
end;
|
||||
|
||||
function sigdeferstop:Integer;
|
||||
function sigdeferstop:Integer; public;
|
||||
var
|
||||
td:p_kthread;
|
||||
begin
|
||||
|
@ -1615,7 +1606,7 @@ begin
|
|||
Result:=1;
|
||||
end;
|
||||
|
||||
procedure sigallowstop;
|
||||
procedure sigallowstop; public;
|
||||
var
|
||||
td:p_kthread;
|
||||
begin
|
||||
|
@ -1739,7 +1730,7 @@ begin
|
|||
Result:=1;
|
||||
end;
|
||||
|
||||
procedure sigexit(td:p_kthread;sig:Integer);
|
||||
procedure sigexit(td:p_kthread;sig:Integer); public;
|
||||
begin
|
||||
exit1(W_EXITCODE(0,sig));
|
||||
// NOTREACHED
|
||||
|
@ -1747,7 +1738,7 @@ end;
|
|||
|
||||
//
|
||||
|
||||
procedure ast;
|
||||
procedure ast; public;
|
||||
var
|
||||
td:p_kthread;
|
||||
flags,sig:Integer;
|
||||
|
|
|
@ -49,7 +49,7 @@ uses
|
|||
vmparam,
|
||||
vm_map,
|
||||
vm_mmap,
|
||||
vm_object;
|
||||
sys_vm_object;
|
||||
|
||||
var
|
||||
{$IFDEF chunk_alloc}
|
||||
|
|
|
@ -140,7 +140,7 @@ begin
|
|||
Result:=(tsleep(@pause_wchan, 0, wmesg, timo));
|
||||
end;
|
||||
|
||||
procedure wakeup(ident:Pointer);
|
||||
procedure wakeup(ident:Pointer); public;
|
||||
begin
|
||||
sleepq_lock(ident);
|
||||
sleepq_broadcast(ident,SLEEPQ_SLEEP,0,0);
|
||||
|
|
|
@ -252,6 +252,23 @@ type
|
|||
function curkthread:p_kthread;
|
||||
procedure set_curkthread(td:p_kthread);
|
||||
|
||||
const
|
||||
SIG_ALTERABLE=$80000000;
|
||||
SIG_STI_LOCK =$40000000;
|
||||
|
||||
NOT_PCB_FULL_IRET=not PCB_FULL_IRET;
|
||||
NOT_SIG_ALTERABLE=not SIG_ALTERABLE;
|
||||
NOT_SIG_STI_LOCK =not SIG_STI_LOCK;
|
||||
|
||||
TDF_AST=TDF_ASTPENDING or TDF_NEEDRESCHED;
|
||||
|
||||
procedure sig_sta; assembler;
|
||||
procedure sig_cla; assembler;
|
||||
procedure sig_sti; assembler;
|
||||
procedure sig_cli; assembler;
|
||||
|
||||
procedure set_pcb_flags(td:p_kthread;f:Integer);
|
||||
|
||||
function TD_IS_SLEEPING(td:p_kthread):Boolean;
|
||||
function TD_ON_SLEEPQ(td:p_kthread):Boolean;
|
||||
function TD_IS_SUSPENDED(td:p_kthread):Boolean;
|
||||
|
@ -288,6 +305,9 @@ function curthread_pflags_set(flags:Integer):Integer;
|
|||
procedure curthread_pflags_restore(save:Integer);
|
||||
procedure curthread_set_pcb_onfault(v:Pointer);
|
||||
|
||||
procedure thread_lock(td:p_kthread); external;
|
||||
procedure thread_unlock(td:p_kthread); external;
|
||||
|
||||
implementation
|
||||
|
||||
function curkthread:p_kthread; assembler; nostackframe;
|
||||
|
@ -300,6 +320,31 @@ asm
|
|||
movqq td,%gs:teb.thread
|
||||
end;
|
||||
|
||||
procedure sig_sta; assembler; nostackframe;
|
||||
asm
|
||||
lock orl SIG_ALTERABLE,%gs:teb.iflag
|
||||
end;
|
||||
|
||||
procedure sig_cla; assembler; nostackframe;
|
||||
asm
|
||||
lock andl NOT_SIG_ALTERABLE,%gs:teb.iflag
|
||||
end;
|
||||
|
||||
procedure sig_sti; assembler; nostackframe;
|
||||
asm
|
||||
lock orl SIG_STI_LOCK,%gs:teb.iflag
|
||||
end;
|
||||
|
||||
procedure sig_cli; assembler; nostackframe;
|
||||
asm
|
||||
lock andl NOT_SIG_STI_LOCK,%gs:teb.iflag
|
||||
end;
|
||||
|
||||
procedure set_pcb_flags(td:p_kthread;f:Integer);
|
||||
begin
|
||||
td^.pcb_flags:=f or (td^.pcb_flags and PCB_IS_JIT);
|
||||
end;
|
||||
|
||||
function TD_IS_SLEEPING(td:p_kthread):Boolean;
|
||||
begin
|
||||
Result:=(td^.td_inhibitors and TDI_SLEEPING)<>0;
|
||||
|
|
|
@ -84,11 +84,9 @@ procedure umtx_thread_fini(td:p_kthread); external;
|
|||
function kern_umtx_wake(td:p_kthread;umtx:Pointer;n_wake,priv:Integer):Integer; external;
|
||||
function umtx_copyin_timeout(addr:Pointer;tsp:p_timespec):Integer; external;
|
||||
|
||||
function sleepq_alloc:Pointer; external;
|
||||
function sleepq_alloc:Pointer; external;
|
||||
procedure sleepq_free(sq:Pointer); external;
|
||||
|
||||
function rtp_to_pri(rtp:p_rtprio;td:p_kthread):Integer; external;
|
||||
|
||||
procedure switch_to_jit(td:p_kthread); external;
|
||||
|
||||
function msleep(ident :Pointer;
|
||||
|
|
|
@ -94,6 +94,9 @@ uses
|
|||
kern_thread,
|
||||
sched_ule;
|
||||
|
||||
var
|
||||
size_of_umtx_q:Integer=SizeOf(umtx_q); public;
|
||||
|
||||
type
|
||||
p_umtxq_hamt=^umtxq_hamt;
|
||||
umtxq_hamt=packed record
|
||||
|
|
|
@ -53,7 +53,6 @@ uses
|
|||
errno,
|
||||
systm,
|
||||
kern_psl,
|
||||
kern_sig,
|
||||
trap,
|
||||
md_context;
|
||||
|
||||
|
|
|
@ -361,7 +361,7 @@ uses
|
|||
vmparam,
|
||||
vm_map,
|
||||
vm_mmap,
|
||||
vm_object,
|
||||
sys_vm_object,
|
||||
vm_pager,
|
||||
vuio,
|
||||
vstat,
|
||||
|
|
|
@ -70,21 +70,15 @@ implementation
|
|||
|
||||
uses
|
||||
errno,
|
||||
signal,
|
||||
signalvar,
|
||||
kern_proc,
|
||||
sched_ule;
|
||||
|
||||
//
|
||||
|
||||
procedure ps_mtx_lock; external;
|
||||
procedure ps_mtx_unlock; external;
|
||||
Function cursig(td:p_kthread;stop_allowed:Integer):Integer; external;
|
||||
|
||||
function mi_switch(flags:Integer):Integer; external;
|
||||
|
||||
procedure thread_lock(td:p_kthread); external;
|
||||
procedure thread_unlock(td:p_kthread); external;
|
||||
|
||||
//
|
||||
|
||||
var
|
||||
|
|
|
@ -5,9 +5,6 @@ unit systm;
|
|||
|
||||
interface
|
||||
|
||||
uses
|
||||
kern_param;
|
||||
|
||||
function copystr(from,_to:pchar;maxlen:ptruint;lencopied:pptruint):Integer;
|
||||
function copyin(udaddr,kaddr:Pointer;len:ptruint):Integer;
|
||||
function copyin_nofault(udaddr,kaddr:Pointer;len:ptruint):Integer;
|
||||
|
|
|
@ -89,23 +89,12 @@ const
|
|||
'DTrace pid return trap' // 32 T_DTRACE_RET
|
||||
);
|
||||
|
||||
SIG_ALTERABLE=$80000000;
|
||||
SIG_STI_LOCK =$40000000;
|
||||
|
||||
procedure set_pcb_flags(td:p_kthread;f:Integer);
|
||||
|
||||
procedure _sig_lock;
|
||||
procedure _sig_unlock;
|
||||
|
||||
procedure sig_lock;
|
||||
procedure sig_unlock;
|
||||
|
||||
procedure sig_sta;
|
||||
procedure sig_cla;
|
||||
|
||||
procedure sig_sti;
|
||||
procedure sig_cli;
|
||||
|
||||
procedure print_backtrace(var f:text;rip,rbp:Pointer;skipframes:sizeint);
|
||||
procedure print_backtrace_td(var f:text);
|
||||
|
||||
|
@ -120,12 +109,6 @@ function IS_TRAP_FUNC(rip:qword):Boolean;
|
|||
function trap(frame:p_trapframe):Integer;
|
||||
function trap_pfault(frame:p_trapframe;usermode:Boolean):Integer;
|
||||
|
||||
const
|
||||
NOT_PCB_FULL_IRET=not PCB_FULL_IRET;
|
||||
NOT_SIG_ALTERABLE=not SIG_ALTERABLE;
|
||||
NOT_SIG_STI_LOCK =not SIG_STI_LOCK;
|
||||
TDF_AST=TDF_ASTPENDING or TDF_NEEDRESCHED;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
|
@ -139,7 +122,6 @@ uses
|
|||
md_context,
|
||||
md_thread,
|
||||
signal,
|
||||
kern_sig,
|
||||
kern_proc,
|
||||
kern_named_id,
|
||||
subr_dynlib,
|
||||
|
@ -222,31 +204,6 @@ asm
|
|||
popq %rbp
|
||||
end;
|
||||
|
||||
procedure sig_sta; assembler; nostackframe;
|
||||
asm
|
||||
lock orl SIG_ALTERABLE,%gs:teb.iflag
|
||||
end;
|
||||
|
||||
procedure sig_cla; assembler; nostackframe;
|
||||
asm
|
||||
lock andl NOT_SIG_ALTERABLE,%gs:teb.iflag
|
||||
end;
|
||||
|
||||
procedure sig_sti; assembler; nostackframe;
|
||||
asm
|
||||
lock orl SIG_STI_LOCK,%gs:teb.iflag
|
||||
end;
|
||||
|
||||
procedure sig_cli; assembler; nostackframe;
|
||||
asm
|
||||
lock andl NOT_SIG_STI_LOCK,%gs:teb.iflag
|
||||
end;
|
||||
|
||||
procedure set_pcb_flags(td:p_kthread;f:Integer);
|
||||
begin
|
||||
td^.pcb_flags:=f or (td^.pcb_flags and PCB_IS_JIT);
|
||||
end;
|
||||
|
||||
function fuptr(var base:Pointer):Pointer;
|
||||
begin
|
||||
Result:=nil;
|
||||
|
|
|
@ -106,23 +106,6 @@ uses
|
|||
|
||||
//
|
||||
|
||||
Function sigonstack(sp:size_t):Integer;
|
||||
var
|
||||
td:p_kthread;
|
||||
begin
|
||||
Result:=0;
|
||||
|
||||
td:=curkthread;
|
||||
if (td=nil) then Exit;
|
||||
|
||||
if ((td^.td_pflags and TDP_ALTSTACK)<>0) then
|
||||
begin
|
||||
Result:=ord((sp-size_t(td^.td_sigstk.ss_sp))<td^.td_sigstk.ss_size);
|
||||
end;
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
const
|
||||
_ucodesel=(8 shl 3) or 3;
|
||||
_udatasel=(7 shl 3) or 3;
|
||||
|
|
|
@ -6,7 +6,7 @@ unit md_resource;
|
|||
interface
|
||||
|
||||
uses
|
||||
_resource;
|
||||
sys_resource;
|
||||
|
||||
function kern_getrusage(who:Integer;rup:p_rusage):Integer;
|
||||
|
||||
|
|
|
@ -22,8 +22,7 @@ procedure md_yield;
|
|||
implementation
|
||||
|
||||
uses
|
||||
errno,
|
||||
trap;
|
||||
errno;
|
||||
|
||||
function ntw2px(n:Integer):Integer; inline;
|
||||
begin
|
||||
|
|
|
@ -36,8 +36,12 @@ procedure seh_wrapper(td:p_kthread);
|
|||
|
||||
implementation
|
||||
|
||||
uses
|
||||
kern_umtx;
|
||||
//
|
||||
|
||||
var
|
||||
size_of_umtx_q:Integer; external;
|
||||
|
||||
//
|
||||
|
||||
function cpu_thread_alloc():p_kthread;
|
||||
var
|
||||
|
@ -62,7 +66,7 @@ begin
|
|||
if (R<>0) then Exit;
|
||||
|
||||
//header
|
||||
size:=SizeOf(kthread)+SizeOf(umtx_q);
|
||||
size:=SizeOf(kthread)+size_of_umtx_q;
|
||||
size:=System.Align(size,4*1024);
|
||||
|
||||
R:=NtAllocateVirtualMemory(
|
||||
|
|
|
@ -2255,18 +2255,16 @@ begin
|
|||
td:=curkthread;
|
||||
if (td=nil) then Exit(-1);
|
||||
|
||||
ioin:=nil;
|
||||
case uio^.uio_rw of
|
||||
UIO_READ :ioin:=@td^.td_ru.ru_inblock;
|
||||
UIO_WRITE:ioin:=@td^.td_ru.ru_oublock;
|
||||
else
|
||||
Exit(EINVAL);
|
||||
end;
|
||||
|
||||
iocb:=nil;
|
||||
case uio^.uio_rw of
|
||||
UIO_READ :iocb:=@NtReadFile;
|
||||
UIO_WRITE:iocb:=@NtWriteFile;
|
||||
else
|
||||
Exit(EINVAL);
|
||||
end;
|
||||
|
||||
append:=(uio^.uio_rw=UIO_WRITE) and ((ioflag and IO_APPEND)<>0);
|
||||
|
|
|
@ -10,7 +10,7 @@ uses
|
|||
windows,
|
||||
vm,
|
||||
vmparam,
|
||||
vm_object;
|
||||
sys_vm_object;
|
||||
|
||||
{$DEFINE GPU_REMAP}
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@ unit rtprio;
|
|||
|
||||
interface
|
||||
|
||||
uses
|
||||
kern_thr;
|
||||
|
||||
const
|
||||
PRI_ITHD =1; // Interrupt thread.
|
||||
PRI_REALTIME =2; // Real time process.
|
||||
|
@ -46,6 +49,9 @@ type
|
|||
function PRI_BASE(P:Word):Word;
|
||||
function RTP_PRIO_BASE(P:Word):Word;
|
||||
|
||||
function rtp_to_pri(rtp:p_rtprio;td:p_kthread):Integer; external;
|
||||
procedure pri_to_rtp(td:p_kthread;rtp:p_rtprio); external;
|
||||
|
||||
implementation
|
||||
|
||||
function PRI_BASE(P:Word):Word;
|
||||
|
|
|
@ -232,6 +232,26 @@ function _SIG_VALID_32(sig:Integer):Boolean; inline;
|
|||
function _SIG_WORD(sig:Integer):DWORD; inline;
|
||||
function _SIG_BIT(sig:Integer):DWORD; inline;
|
||||
|
||||
procedure ps_mtx_lock; external;
|
||||
procedure ps_mtx_unlock; external;
|
||||
|
||||
function sigdeferstop:Integer; external;
|
||||
procedure sigallowstop; external;
|
||||
|
||||
Function sigonstack(sp:size_t):Integer; external;
|
||||
Function cursig(td:Pointer;stop_allowed:Integer):Integer; external;
|
||||
procedure tdsignal(td:Pointer;sig:Integer); external;
|
||||
procedure sigexit(td:Pointer;sig:Integer); external;
|
||||
|
||||
procedure ast; external;
|
||||
|
||||
Function kern_sigprocmask(td:Pointer;
|
||||
how:Integer;
|
||||
_set:p_sigset_t;
|
||||
oset:p_sigset_t;
|
||||
flags:Integer
|
||||
):Integer; external;
|
||||
|
||||
function _get_sig_str(signum:Integer):RawByteString;
|
||||
|
||||
implementation
|
||||
|
|
|
@ -227,11 +227,55 @@ type
|
|||
end;
|
||||
{$IF sizeof(t_kevent_copyops)<>24}{$STOP sizeof(t_kevent_copyops)<>24}{$ENDIF}
|
||||
|
||||
procedure knote(list:p_knlist;hint:QWORD;lockflags:Integer); external;
|
||||
|
||||
procedure knlist_add (knl:p_knlist;kn:p_knote;islocked:Integer); external;
|
||||
procedure knlist_remove(knl:p_knlist;kn:p_knote;islocked:Integer); external;
|
||||
|
||||
procedure knote_fdclose(fd:Integer); external;
|
||||
|
||||
procedure knlist_init(knl:p_knlist;lock,kl_lock,kl_unlock,kl_assert_locked,kl_assert_unlocked:Pointer); external;
|
||||
procedure knlist_init_mtx(knl:p_knlist;lock:Pointer); external;
|
||||
|
||||
procedure knlist_destroy (knl:p_knlist); external;
|
||||
procedure knlist_cleardel(knl:p_knlist;islocked,killkn:Integer); external;
|
||||
|
||||
//
|
||||
|
||||
procedure KNOTE_LOCKED (list:p_knlist;hint:QWORD);
|
||||
procedure KNOTE_UNLOCKED(list:p_knlist;hint:QWORD);
|
||||
|
||||
procedure knlist_clear(knl:p_knlist;islocked:Integer);
|
||||
|
||||
function M_KNLIST_EMPTY(list:p_knlist):Boolean;
|
||||
|
||||
//
|
||||
|
||||
procedure EV_SET(kevp:p_kevent;a:PtrUint;b:SmallInt;c:Word;d:DWORD;e:Ptrint;f:Pointer);
|
||||
function EVFILT_NAME(i:Integer):RawByteString;
|
||||
|
||||
implementation
|
||||
|
||||
procedure KNOTE_LOCKED(list:p_knlist;hint:QWORD);
|
||||
begin
|
||||
knote(list, hint, KNF_LISTLOCKED);
|
||||
end;
|
||||
|
||||
procedure KNOTE_UNLOCKED(list:p_knlist;hint:QWORD);
|
||||
begin
|
||||
knote(list, hint, 0);
|
||||
end;
|
||||
|
||||
procedure knlist_clear(knl:p_knlist;islocked:Integer);
|
||||
begin
|
||||
knlist_cleardel(knl, islocked, 0)
|
||||
end;
|
||||
|
||||
function M_KNLIST_EMPTY(list:p_knlist):Boolean;
|
||||
begin
|
||||
Result:=SLIST_EMPTY(@list^.kl_list);
|
||||
end;
|
||||
|
||||
procedure EV_SET(kevp:p_kevent;a:PtrUint;b:SmallInt;c:Word;d:DWORD;e:Ptrint;f:Pointer);
|
||||
begin
|
||||
(kevp)^.ident :=(a);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
unit _resource;
|
||||
unit sys_resource;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
{$CALLING SysV_ABI_CDecl}
|
|
@ -25,7 +25,6 @@ implementation
|
|||
uses
|
||||
errno,
|
||||
syscalls,
|
||||
kern_umtx,
|
||||
trap;
|
||||
|
||||
procedure umtx_init(var umtx:umtx); inline;
|
||||
|
@ -86,7 +85,7 @@ end;
|
|||
|
||||
function _umtx_op_err(obj:Pointer;op:Integer;val:QWORD;uaddr1,uaddr2:Pointer):Integer; assembler; nostackframe;
|
||||
asm
|
||||
movq sys__umtx_op,%rax
|
||||
movq $454,%rax
|
||||
call fast_syscall
|
||||
end;
|
||||
|
||||
|
|
|
@ -126,8 +126,7 @@ implementation
|
|||
uses
|
||||
sysutils,
|
||||
vmparam,
|
||||
vm_pmap,
|
||||
trap;
|
||||
vm_pmap;
|
||||
|
||||
//
|
||||
|
||||
|
@ -204,11 +203,11 @@ label
|
|||
var
|
||||
node:t_jit_dynamic.p_entry_point;
|
||||
jctx:p_jctx;
|
||||
jit_state:Boolean;
|
||||
//jit_state:Boolean;
|
||||
begin
|
||||
if (td=nil) then Exit;
|
||||
|
||||
jit_state:=((td^.pcb_flags and PCB_IS_JIT)<>0);
|
||||
//jit_state:=((td^.pcb_flags and PCB_IS_JIT)<>0);
|
||||
|
||||
if not is_guest_addr(td^.td_frame.tf_rip) then
|
||||
begin
|
||||
|
@ -506,7 +505,7 @@ var
|
|||
curr:Pointer;
|
||||
next:Pointer;
|
||||
|
||||
F:THandle;
|
||||
//F:THandle;
|
||||
begin
|
||||
if (ctx.builder.GetMemSize=0) then Exit;
|
||||
|
||||
|
|
|
@ -478,10 +478,6 @@
|
|||
<Filename Value="..\kern\kern_ksched.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="..\_resource.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="..\kern\kern_uuid.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
|
@ -763,10 +759,6 @@
|
|||
<Filename Value="kern_jit2_test.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="..\kern\kern_event.inc"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="..\kern\kern_param.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
|
@ -783,6 +775,18 @@
|
|||
<Filename Value="elf_machdep.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="..\init_sysent.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="..\sys_resource.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="..\vm\sys_vm_object.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@ -792,7 +796,7 @@
|
|||
<Filename Value="project1"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir);..;..\kern"/>
|
||||
<IncludeFiles Value="$(ProjOutDir);.."/>
|
||||
<OtherUnitFiles Value="..;..\..\rtl;..\..\kernel\libthr;..\kern;..\vm;..\vfs;..\fs\deadfs;..\fs\devfs;..\fs\fdescfs;..\fs\nullfs;..\fs\ufs;..\md;..\dev;..\.."/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
|
|
|
@ -74,7 +74,7 @@ uses
|
|||
ufs,
|
||||
vmount,
|
||||
kern_prot,
|
||||
_resource,
|
||||
sys_resource,
|
||||
kern_resource,
|
||||
md_proc,
|
||||
kern_ksched,
|
||||
|
|
|
@ -15,7 +15,7 @@ uses
|
|||
vnode,
|
||||
time,
|
||||
vm,
|
||||
vm_object,
|
||||
sys_vm_object,
|
||||
kern_mtx;
|
||||
|
||||
const
|
||||
|
@ -344,7 +344,9 @@ begin
|
|||
end;
|
||||
dev_unlock();
|
||||
if (flag<>0) then
|
||||
begin
|
||||
devfs_free(dev);
|
||||
end;
|
||||
end;
|
||||
|
||||
function dev_refthread(dev:p_cdev;ref:PInteger):p_cdevsw;
|
||||
|
|
|
@ -132,15 +132,20 @@ uses
|
|||
errno,
|
||||
systm,
|
||||
vfiledesc,
|
||||
sys_capability,
|
||||
vfs_subr,
|
||||
vfs_vnops,
|
||||
vnode_if,
|
||||
_resource,
|
||||
sys_resource,
|
||||
kern_resource,
|
||||
kern_mtx,
|
||||
kern_conf,
|
||||
kern_event;
|
||||
kern_conf;
|
||||
|
||||
//
|
||||
|
||||
function cap_funwrap(fp_cap:p_file;rights:cap_rights_t;fpp:pp_file):Integer; external;
|
||||
function cap_rights(fp_cap:p_file):cap_rights_t; external;
|
||||
function cap_funwrap_mmap(fp_cap:p_file;rights:cap_rights_t;maxprotp:PByte;fpp:pp_file):Integer; external;
|
||||
|
||||
//
|
||||
|
||||
function badfo_readwrite(fp:p_file;uio:p_uio;flags:Integer):Integer;
|
||||
begin
|
||||
|
|
|
@ -94,7 +94,6 @@ begin
|
|||
Move(iov^.iov_base^, cp^, cnt);
|
||||
end;
|
||||
UIO_NOCOPY:;
|
||||
else;
|
||||
end;
|
||||
|
||||
Inc(iov^.iov_base ,cnt);
|
||||
|
|
|
@ -112,7 +112,9 @@ end;
|
|||
function cap_check(c:p_capability;rights:cap_rights_t):Integer;
|
||||
begin
|
||||
if ((c^.cap_rights or rights)<>c^.cap_rights) then
|
||||
begin
|
||||
Exit(ENOTCAPABLE);
|
||||
end;
|
||||
Exit(0);
|
||||
end;
|
||||
|
||||
|
@ -121,7 +123,7 @@ end;
|
|||
* any other way, as we want to keep all capability permission evaluation in
|
||||
* this one file.
|
||||
}
|
||||
function cap_rights(fp_cap:p_file):cap_rights_t;
|
||||
function cap_rights(fp_cap:p_file):cap_rights_t; public;
|
||||
var
|
||||
c:p_capability;
|
||||
begin
|
||||
|
@ -131,7 +133,7 @@ begin
|
|||
Exit(c^.cap_rights);
|
||||
end;
|
||||
|
||||
function cap_funwrap(fp_cap:p_file;rights:cap_rights_t;fpp:pp_file):Integer;
|
||||
function cap_funwrap(fp_cap:p_file;rights:cap_rights_t;fpp:pp_file):Integer; public;
|
||||
var
|
||||
c:p_capability;
|
||||
error:Integer;
|
||||
|
@ -145,7 +147,9 @@ begin
|
|||
c:=fp_cap^.f_data;
|
||||
error:=cap_check(c, rights);
|
||||
if (error<>0) then
|
||||
begin
|
||||
Exit(error);
|
||||
end;
|
||||
fpp^:=c^.cap_object;
|
||||
Exit(0);
|
||||
end;
|
||||
|
@ -155,7 +159,7 @@ end;
|
|||
* capability and check CAP_MMAP, but also Exita bitmask representing the
|
||||
* maximum mapping rights the capability allows on the object.
|
||||
}
|
||||
function cap_funwrap_mmap(fp_cap:p_file;rights:cap_rights_t;maxprotp:PByte;fpp:pp_file):Integer;
|
||||
function cap_funwrap_mmap(fp_cap:p_file;rights:cap_rights_t;maxprotp:PByte;fpp:pp_file):Integer; public;
|
||||
var
|
||||
c:p_capability;
|
||||
maxprot:Byte;
|
||||
|
@ -174,11 +178,17 @@ begin
|
|||
fpp^:=c^.cap_object;
|
||||
maxprot:=0;
|
||||
if (c^.cap_rights and CAP_READ)<>0 then
|
||||
begin
|
||||
maxprot:=maxprot or VM_PROT_READ;
|
||||
end;
|
||||
if (c^.cap_rights and CAP_WRITE)<>0 then
|
||||
begin
|
||||
maxprot:=maxprot or VM_PROT_WRITE;
|
||||
end;
|
||||
if (c^.cap_rights and CAP_MAPEXEC)<>0 then
|
||||
begin
|
||||
maxprot:=maxprot or VM_PROT_EXECUTE;
|
||||
end;
|
||||
maxprotp^:=maxprot;
|
||||
Exit(0);
|
||||
end;
|
||||
|
@ -193,7 +203,9 @@ var
|
|||
error:Integer;
|
||||
begin
|
||||
if ((rights or CAP_MASK_VALID)<>CAP_MASK_VALID) then
|
||||
begin
|
||||
Exit(EINVAL);
|
||||
end;
|
||||
|
||||
{
|
||||
* If a new capability is being derived from an existing capability,
|
||||
|
@ -204,7 +216,9 @@ begin
|
|||
begin
|
||||
cp_old:=fp^.f_data;
|
||||
if ((cp_old^.cap_rights or rights)<>cp_old^.cap_rights) then
|
||||
begin
|
||||
Exit(ENOTCAPABLE);
|
||||
end;
|
||||
end;
|
||||
|
||||
{
|
||||
|
@ -212,7 +226,9 @@ begin
|
|||
}
|
||||
error:=falloc(@fcapp, capfdp, fp^.f_flag);
|
||||
if (error<>0) then
|
||||
begin
|
||||
Exit(error);
|
||||
end;
|
||||
|
||||
{
|
||||
* Rather than nesting capabilities, directly reference the object an
|
||||
|
@ -225,6 +241,7 @@ begin
|
|||
fp_object:=p_capability(fp^.f_data)^.cap_object
|
||||
else
|
||||
fp_object:=fp;
|
||||
|
||||
fhold(fp_object);
|
||||
cp:=AllocMem(SizeOf(t_capability));
|
||||
cp^.cap_rights:=rights;
|
||||
|
|
|
@ -11,7 +11,6 @@ uses
|
|||
systm,
|
||||
vcapability,
|
||||
vuio,
|
||||
vfile,
|
||||
vfiledesc,
|
||||
vfcntl,
|
||||
vnode,
|
||||
|
@ -33,8 +32,14 @@ implementation
|
|||
uses
|
||||
errno,
|
||||
vfs_subr,
|
||||
vfs_vnops,
|
||||
dead_vnops;
|
||||
vfs_vnops;
|
||||
|
||||
//
|
||||
|
||||
var
|
||||
dead_vnodeops:vop_vector; external;
|
||||
|
||||
//
|
||||
|
||||
var
|
||||
vp_crossmp:p_vnode;
|
||||
|
|
|
@ -13,7 +13,6 @@ uses
|
|||
vuio,
|
||||
vnamei,
|
||||
kern_mtx,
|
||||
kern_synch,
|
||||
kern_thr,
|
||||
vnode,
|
||||
vfs_init,
|
||||
|
@ -118,6 +117,18 @@ uses
|
|||
vfs_subr,
|
||||
vfs_cache;
|
||||
|
||||
//
|
||||
|
||||
function msleep(ident :Pointer;
|
||||
lock :Pointer;
|
||||
priority:Integer;
|
||||
wmesg :PChar;
|
||||
timo :Int64):Integer; external;
|
||||
|
||||
procedure wakeup(ident:Pointer); external;
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
* ---------------------------------------------------------------------
|
||||
* Functions for building and sanitizing the mount options
|
||||
|
|
|
@ -190,15 +190,13 @@ uses
|
|||
errno,
|
||||
vfs_vnops,
|
||||
subr_uio,
|
||||
vm_object,
|
||||
sys_vm_object,
|
||||
vsys_generic,
|
||||
rtprio,
|
||||
kern_conf;
|
||||
|
||||
//
|
||||
|
||||
{$I kern_event.inc}
|
||||
|
||||
var
|
||||
dead_vnodeops:vop_vector; external;
|
||||
|
||||
|
@ -348,7 +346,7 @@ begin
|
|||
Exit(nil);
|
||||
end;
|
||||
|
||||
function makedev(x,y:Integer):Integer;
|
||||
function makedev(x,y:Integer):Integer; inline;
|
||||
begin
|
||||
Result:=(x shl 8) or y;
|
||||
end;
|
||||
|
@ -710,7 +708,9 @@ begin
|
|||
Inc(td^.td_vp_reserv,count);
|
||||
Exit;
|
||||
end else
|
||||
begin
|
||||
System.InterlockedExchangeAdd64(numvnodes, -count);
|
||||
end;
|
||||
|
||||
mtx_lock(vnode_free_list_mtx);
|
||||
while (count > 0) do
|
||||
|
@ -822,7 +822,9 @@ begin
|
|||
begin
|
||||
//bo^.bo_bsize:=mp^.mnt_stat.f_iosize;
|
||||
if ((mp^.mnt_kern_flag and MNTK_NOKNOTE)<>0) then
|
||||
begin
|
||||
vp^.v_vflag:=vp^.v_vflag or VV_NOKNOTE;
|
||||
end;
|
||||
end;
|
||||
//rangelock_init(@vp^.v_rl);
|
||||
|
||||
|
@ -1969,7 +1971,9 @@ begin
|
|||
end;
|
||||
|
||||
if ((vp^.v_iflag and VI_DOOMED)<>0) and ((flags and LK_RETRY)=0) then
|
||||
begin
|
||||
Assert(false,'vget: vn_lock failed to Exit ENOENT');
|
||||
end;
|
||||
|
||||
VI_LOCK(vp);
|
||||
{ Upgrade our holdcnt to a usecount. }
|
||||
|
@ -1997,7 +2001,7 @@ end;
|
|||
{
|
||||
* Increase the reference count of a vnode.
|
||||
}
|
||||
procedure vref(vp:p_vnode);
|
||||
procedure vref(vp:p_vnode); public;
|
||||
begin
|
||||
VI_LOCK(vp);
|
||||
v_incr_usecount(vp);
|
||||
|
@ -2720,7 +2724,9 @@ var
|
|||
vi:p_vpollinfo;
|
||||
begin
|
||||
if (vp^.v_pollinfo<>nil) then
|
||||
begin
|
||||
Exit;
|
||||
end;
|
||||
vi:=AllocMem(SizeOf(vpollinfo));
|
||||
mtx_init(vi^.vpi_lock,'vnode pollinfo');
|
||||
knlist_init(@vi^.vpi_selinfo.si_note, vp, @vfs_knllock, @vfs_knlunlock, @vfs_knl_assert_locked, @vfs_knl_assert_unlocked);
|
||||
|
@ -2961,14 +2967,17 @@ begin
|
|||
error:=ENXIO
|
||||
else
|
||||
if (p_cdev(vp^.v_rdev)^.si_devsw=nil) then
|
||||
begin
|
||||
error:=ENXIO
|
||||
else{
|
||||
end{ else
|
||||
if ((p_cdev(vp^.v_rdev)^.si_devsw^.d_flags and D_DISK)=0) then
|
||||
error:=ENOTBLK};
|
||||
dev_unlock();
|
||||
error:=ENOTBLK;
|
||||
if (errp<>nil) then
|
||||
begin
|
||||
errp^:=error;
|
||||
end;
|
||||
Exit(error=0);
|
||||
end;
|
||||
|
||||
|
@ -3172,7 +3181,7 @@ begin
|
|||
vfs_badlock('is not exclusive locked but should be', str, vp);
|
||||
end;
|
||||
|
||||
function VOP_WRITE_PRE(ap:p_vop_write_args;var osize,ooffset:Int64):Integer;
|
||||
function VOP_WRITE_PRE(ap:p_vop_write_args;var osize,ooffset:Int64):Integer; public;
|
||||
var
|
||||
va:t_vattr;
|
||||
error:Integer;
|
||||
|
@ -3189,7 +3198,7 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure VOP_WRITE_POST(ap:p_vop_write_args;ret:Integer;var osize,ooffset:Int64);
|
||||
procedure VOP_WRITE_POST(ap:p_vop_write_args;ret:Integer;var osize,ooffset:Int64); public;
|
||||
var
|
||||
noffset:Int64;
|
||||
begin
|
||||
|
@ -3220,7 +3229,7 @@ begin
|
|||
vrele(ap^.a_fvp);
|
||||
end;
|
||||
|
||||
procedure vop_rename_pre(ap:p_vop_rename_args);
|
||||
procedure vop_rename_pre(ap:p_vop_rename_args); public;
|
||||
begin
|
||||
if (ap^.a_tdvp<>ap^.a_fdvp) then
|
||||
vhold(ap^.a_fdvp);
|
||||
|
@ -3234,7 +3243,7 @@ begin
|
|||
vhold(ap^.a_tvp);
|
||||
end;
|
||||
|
||||
procedure vop_create_post(ap:p_vop_create_args;rc:Integer);
|
||||
procedure vop_create_post(ap:p_vop_create_args;rc:Integer); public;
|
||||
begin
|
||||
if (rc=0) then
|
||||
begin
|
||||
|
@ -3242,16 +3251,16 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure vop_link_post(ap:p_vop_link_args;rc:Integer);
|
||||
procedure vop_link_post(ap:p_vop_link_args;rc:Integer); public;
|
||||
begin
|
||||
if (rc=0) then
|
||||
begin
|
||||
VFS_KNOTE_LOCKED(ap^.a_vp, NOTE_LINK);
|
||||
VFS_KNOTE_LOCKED(ap^.a_vp , NOTE_LINK);
|
||||
VFS_KNOTE_LOCKED(ap^.a_tdvp, NOTE_WRITE);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure vop_mkdir_post(ap:p_vop_mkdir_args;rc:Integer);
|
||||
procedure vop_mkdir_post(ap:p_vop_mkdir_args;rc:Integer); public;
|
||||
begin
|
||||
if (rc=0) then
|
||||
begin
|
||||
|
@ -3259,7 +3268,7 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure vop_mknod_post(ap:p_vop_mknod_args;rc:Integer);
|
||||
procedure vop_mknod_post(ap:p_vop_mknod_args;rc:Integer); public;
|
||||
begin
|
||||
if (rc=0) then
|
||||
begin
|
||||
|
@ -3267,22 +3276,22 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure vop_remove_post(ap:p_vop_remove_args;rc:Integer);
|
||||
procedure vop_remove_post(ap:p_vop_remove_args;rc:Integer); public;
|
||||
begin
|
||||
if (rc=0) then
|
||||
begin
|
||||
VFS_KNOTE_LOCKED(ap^.a_dvp, NOTE_WRITE);
|
||||
VFS_KNOTE_LOCKED(ap^.a_vp, NOTE_DELETE);
|
||||
VFS_KNOTE_LOCKED(ap^.a_vp , NOTE_DELETE);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure vop_rename_post(ap:p_vop_rename_args;rc:Integer);
|
||||
procedure vop_rename_post(ap:p_vop_rename_args;rc:Integer); public;
|
||||
begin
|
||||
if (rc=0) then
|
||||
begin
|
||||
VFS_KNOTE_UNLOCKED(ap^.a_fdvp, NOTE_WRITE);
|
||||
VFS_KNOTE_UNLOCKED(ap^.a_tdvp, NOTE_WRITE);
|
||||
VFS_KNOTE_UNLOCKED(ap^.a_fvp, NOTE_RENAME);
|
||||
VFS_KNOTE_UNLOCKED(ap^.a_fvp , NOTE_RENAME);
|
||||
if (ap^.a_tvp<>nil) then
|
||||
begin
|
||||
VFS_KNOTE_UNLOCKED(ap^.a_tvp, NOTE_DELETE);
|
||||
|
@ -3303,16 +3312,16 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure vop_rmdir_post(ap:p_vop_rmdir_args;rc:Integer);
|
||||
procedure vop_rmdir_post(ap:p_vop_rmdir_args;rc:Integer); public;
|
||||
begin
|
||||
if (rc=0) then
|
||||
begin
|
||||
VFS_KNOTE_LOCKED(ap^.a_dvp, NOTE_WRITE or NOTE_LINK);
|
||||
VFS_KNOTE_LOCKED(ap^.a_vp, NOTE_DELETE);
|
||||
VFS_KNOTE_LOCKED(ap^.a_vp , NOTE_DELETE);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure vop_setattr_post(ap:p_vop_setattr_args;rc:Integer);
|
||||
procedure vop_setattr_post(ap:p_vop_setattr_args;rc:Integer); public;
|
||||
begin
|
||||
if (rc=0) then
|
||||
begin
|
||||
|
@ -3320,7 +3329,7 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure vop_symlink_post(ap:p_vop_symlink_args;rc:Integer);
|
||||
procedure vop_symlink_post(ap:p_vop_symlink_args;rc:Integer); public;
|
||||
begin
|
||||
if (rc=0) then
|
||||
begin
|
||||
|
@ -3460,12 +3469,9 @@ begin
|
|||
kn:=ap^.a_kn;
|
||||
|
||||
case (kn^.kn_filter) of
|
||||
EVFILT_READ:
|
||||
kn^.kn_fop:=@vfsread_filtops;
|
||||
EVFILT_WRITE:
|
||||
kn^.kn_fop:=@vfswrite_filtops;
|
||||
EVFILT_VNODE:
|
||||
kn^.kn_fop:=@vfsvnode_filtops;
|
||||
EVFILT_READ :kn^.kn_fop:=@vfsread_filtops;
|
||||
EVFILT_WRITE:kn^.kn_fop:=@vfswrite_filtops;
|
||||
EVFILT_VNODE:kn^.kn_fop:=@vfsvnode_filtops;
|
||||
else
|
||||
Exit(EINVAL);
|
||||
end;
|
||||
|
@ -3473,8 +3479,11 @@ begin
|
|||
kn^.kn_hook:=vp;
|
||||
|
||||
v_addpollinfo(vp);
|
||||
|
||||
if (vp^.v_pollinfo=nil) then
|
||||
begin
|
||||
Exit(ENOMEM);
|
||||
end;
|
||||
|
||||
knl:=@vp^.v_pollinfo^.vpi_selinfo.si_note;
|
||||
vhold(vp);
|
||||
|
@ -3663,7 +3672,9 @@ begin
|
|||
* on the containing directory instead.
|
||||
}
|
||||
if ((accmode^ and (VDELETE_CHILD or VDELETE))<>0) then
|
||||
begin
|
||||
Exit(EPERM);
|
||||
end;
|
||||
|
||||
if ((accmode^ and VADMIN_PERMS)<>0) then
|
||||
begin
|
||||
|
@ -3862,8 +3873,7 @@ end;
|
|||
|
||||
procedure __mnt_vnode_markerfree_active(mvp:pp_vnode;mp:p_mount);
|
||||
begin
|
||||
if (mvp^=nil) then
|
||||
Exit;
|
||||
if (mvp^=nil) then Exit;
|
||||
|
||||
mtx_lock(vnode_free_list_mtx);
|
||||
TAILQ_REMOVE(@mp^.mnt_activevnodelist,mvp^,@mvp^^.v_actfreelist);
|
||||
|
|
|
@ -143,11 +143,11 @@ uses
|
|||
errno,
|
||||
kern_mtx,
|
||||
kern_thr,
|
||||
kern_synch,
|
||||
kern_descrip,
|
||||
vnode_if,
|
||||
sys_capability,
|
||||
vmparam,
|
||||
sys_vm_object,
|
||||
vm_object;
|
||||
|
||||
{
|
||||
|
|
|
@ -67,6 +67,12 @@ procedure foffset_unlock(fp:p_file;val:Int64;flags:Integer);
|
|||
procedure foffset_lock_uio(fp:p_file;uio:p_uio;flags:Integer);
|
||||
procedure foffset_unlock_uio(fp:p_file;uio:p_uio;flags:Integer);
|
||||
|
||||
//
|
||||
|
||||
procedure vref(vp:p_vnode); external;
|
||||
|
||||
//
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
|
|
|
@ -11,8 +11,8 @@ uses
|
|||
time,
|
||||
sys_event,
|
||||
kern_mtx,
|
||||
kern_synch,
|
||||
kern_sig,
|
||||
//kern_synch,
|
||||
signal,
|
||||
vnode;
|
||||
|
||||
const
|
||||
|
@ -418,6 +418,12 @@ procedure vmountinit; //SYSINIT
|
|||
|
||||
implementation
|
||||
|
||||
//
|
||||
|
||||
procedure wakeup(ident:Pointer); external;
|
||||
|
||||
//
|
||||
|
||||
function MNT_SHARED_WRITES(mp:p_mount):Boolean; inline;
|
||||
begin
|
||||
if (mp<>nil) then
|
||||
|
@ -473,7 +479,7 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function VFS_LOCK_GIANT(mp:p_mount):Integer;
|
||||
function VFS_LOCK_GIANT(mp:p_mount):Integer; public;
|
||||
begin
|
||||
if VFS_NEEDSGIANT(mp) then
|
||||
begin
|
||||
|
|
|
@ -321,8 +321,6 @@ uses
|
|||
|
||||
//
|
||||
|
||||
{$I kern_event.inc}
|
||||
|
||||
function VFS_PROLOGUE(mp:Pointer):Boolean; external;
|
||||
procedure VFS_EPILOGUE(_enable_stops:Boolean); external;
|
||||
|
||||
|
|
|
@ -949,9 +949,6 @@ const
|
|||
|
||||
implementation
|
||||
|
||||
uses
|
||||
vfs_subr;
|
||||
|
||||
function get_vp_cb(vp:p_vnode;offset:Pointer):Pointer; inline;
|
||||
var
|
||||
v:p_vop_vector;
|
||||
|
@ -1008,6 +1005,8 @@ begin
|
|||
VFS_EPILOGUE(s);
|
||||
end;
|
||||
|
||||
procedure vop_create_post(ap:p_vop_create_args;rc:Integer); external;
|
||||
|
||||
function VOP_CREATE(dvp:p_vnode;vpp:pp_vnode;cnp:p_componentname;vap:p_vattr):Integer;
|
||||
var
|
||||
c:Pointer;
|
||||
|
@ -1044,6 +1043,8 @@ begin
|
|||
VFS_EPILOGUE(s);
|
||||
end;
|
||||
|
||||
procedure vop_mknod_post(ap:p_vop_mknod_args;rc:Integer); external;
|
||||
|
||||
function VOP_MKNOD(dvp:p_vnode;vpp:pp_vnode;cnp:p_componentname;vap:p_vattr):Integer;
|
||||
var
|
||||
c:Pointer;
|
||||
|
@ -1144,6 +1145,8 @@ begin
|
|||
VFS_EPILOGUE(s);
|
||||
end;
|
||||
|
||||
procedure vop_setattr_post(ap:p_vop_setattr_args;rc:Integer); external;
|
||||
|
||||
function VOP_SETATTR(vp:p_vnode;vap:p_vattr):Integer;
|
||||
var
|
||||
c:Pointer;
|
||||
|
@ -1193,6 +1196,9 @@ begin
|
|||
VFS_EPILOGUE(s);
|
||||
end;
|
||||
|
||||
function VOP_WRITE_PRE(ap:p_vop_write_args;var osize,ooffset:Int64):Integer; external;
|
||||
procedure VOP_WRITE_POST(ap:p_vop_write_args;ret:Integer;var osize,ooffset:Int64); external;
|
||||
|
||||
function VOP_WRITE(vp:p_vnode;uio:p_uio;ioflag:Integer):Integer;
|
||||
var
|
||||
osize,ooffset:Int64;
|
||||
|
@ -1297,6 +1303,8 @@ begin
|
|||
VFS_EPILOGUE(s);
|
||||
end;
|
||||
|
||||
procedure vop_remove_post(ap:p_vop_remove_args;rc:Integer); external;
|
||||
|
||||
function VOP_REMOVE(dvp:p_vnode;vp:p_vnode;cnp:p_componentname):Integer;
|
||||
var
|
||||
c:Pointer;
|
||||
|
@ -1315,6 +1323,8 @@ begin
|
|||
vop_remove_post(@a,Result);
|
||||
end;
|
||||
|
||||
procedure vop_link_post(ap:p_vop_link_args;rc:Integer); external;
|
||||
|
||||
function VOP_LINK(tdvp:p_vnode;vp:p_vnode;cnp:p_componentname):Integer;
|
||||
var
|
||||
c:Pointer;
|
||||
|
@ -1333,6 +1343,9 @@ begin
|
|||
vop_link_post(@a,Result);
|
||||
end;
|
||||
|
||||
procedure vop_rename_pre (ap:p_vop_rename_args); external;
|
||||
procedure vop_rename_post(ap:p_vop_rename_args;rc:Integer); external;
|
||||
|
||||
function VOP_RENAME(fdvp:p_vnode;fvp:p_vnode;fcnp:p_componentname;tdvp:p_vnode;tvp:p_vnode;tcnp:p_componentname):Integer;
|
||||
var
|
||||
c:Pointer;
|
||||
|
@ -1355,6 +1368,8 @@ begin
|
|||
vop_rename_post(@a,Result);
|
||||
end;
|
||||
|
||||
procedure vop_mkdir_post(ap:p_vop_mkdir_args;rc:Integer); external;
|
||||
|
||||
function VOP_MKDIR(dvp:p_vnode;vpp:pp_vnode;cnp:p_componentname;vap:p_vattr):Integer;
|
||||
var
|
||||
c:Pointer;
|
||||
|
@ -1374,6 +1389,8 @@ begin
|
|||
vop_mkdir_post(@a,Result);
|
||||
end;
|
||||
|
||||
procedure vop_rmdir_post(ap:p_vop_rmdir_args;rc:Integer); external;
|
||||
|
||||
function VOP_RMDIR(dvp:p_vnode;vp:p_vnode;cnp:p_componentname):Integer;
|
||||
var
|
||||
c:Pointer;
|
||||
|
@ -1392,6 +1409,8 @@ begin
|
|||
vop_rmdir_post(@a,Result);
|
||||
end;
|
||||
|
||||
procedure vop_symlink_post(ap:p_vop_symlink_args;rc:Integer); external;
|
||||
|
||||
function VOP_SYMLINK(dvp:p_vnode;vpp:pp_vnode;cnp:p_componentname;vap:p_vattr;target:PChar):Integer;
|
||||
var
|
||||
c:Pointer;
|
||||
|
|
|
@ -5,10 +5,6 @@ unit vselect;
|
|||
|
||||
interface
|
||||
|
||||
uses
|
||||
signal,
|
||||
time;
|
||||
|
||||
type
|
||||
pp_fd_mask=^p_fd_mask;
|
||||
p_fd_mask=^fd_mask;
|
||||
|
|
|
@ -8,8 +8,6 @@ interface
|
|||
uses
|
||||
mqueue,
|
||||
vfile,
|
||||
vselinfo,
|
||||
vsocket,
|
||||
vsockstate,
|
||||
vsockbuf,
|
||||
kern_mtx;
|
||||
|
|
|
@ -112,7 +112,6 @@ uses
|
|||
errno,
|
||||
kern_descrip,
|
||||
subr_uio,
|
||||
kern_sig,
|
||||
kern_thread,
|
||||
kern_proc,
|
||||
md_time,
|
||||
|
|
|
@ -7,7 +7,7 @@ interface
|
|||
|
||||
uses
|
||||
vm,
|
||||
vm_object;
|
||||
sys_vm_object;
|
||||
|
||||
function dev_pager_alloc(
|
||||
handle:Pointer;
|
||||
|
|
|
@ -7,7 +7,7 @@ interface
|
|||
|
||||
uses
|
||||
vmparam,
|
||||
vm_object,
|
||||
sys_vm_object,
|
||||
kern_mtx;
|
||||
|
||||
Const
|
||||
|
|
|
@ -0,0 +1,210 @@
|
|||
unit sys_vm_object;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
{$CALLING SysV_ABI_CDecl}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
mqueue,
|
||||
vm,
|
||||
kern_mtx;
|
||||
|
||||
type
|
||||
obj_type=(
|
||||
OBJT_DEFAULT ,//0
|
||||
OBJT_SWAP ,//1
|
||||
OBJT_VNODE ,//2
|
||||
OBJT_DEVICE ,//3
|
||||
OBJT_PHYS ,//4
|
||||
OBJT_DEAD ,//5
|
||||
OBJT_SG ,//6
|
||||
OBJT_JITSHM ,//7
|
||||
OBJT_SELF ,//8
|
||||
OBJT_TRCMEM ,//9
|
||||
OBJT_PHYSHM ,//10
|
||||
OBJT_BLOCKPOOL //11
|
||||
);
|
||||
|
||||
objtype_t=obj_type;
|
||||
|
||||
p_vm_object_t=^vm_object_t;
|
||||
vm_object_t=^t_vm_object;
|
||||
t_vm_object=packed record
|
||||
mtx :mtx;
|
||||
memq :TAILQ_HEAD; // list of resident pages
|
||||
patchq :TAILQ_HEAD; // list of patches
|
||||
root :Pointer; // root of the resident page splay tree
|
||||
size :vm_pindex_t; // Object size
|
||||
generation :Integer; // generation ID
|
||||
ref_count :Integer; // How many refs??
|
||||
otype :objtype_t; // type of pager
|
||||
pg_color :Word;
|
||||
flags :Word; // see below
|
||||
handle :Pointer;
|
||||
paging_in_progress:Integer;
|
||||
un_pager:packed record
|
||||
vnp:packed record
|
||||
vnp_size:QWORD;
|
||||
writemappings:vm_ooffset_t;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
const
|
||||
//Flags
|
||||
OBJ_ACTIVE =$0004; // active objects
|
||||
OBJ_DEAD =$0008; // dead objects (during rundown)
|
||||
OBJ_NOSPLIT =$0010; // dont split this object
|
||||
OBJ_PIPWNT =$0040; // paging in progress wanted
|
||||
OBJ_MIGHTBEDIRTY =$0100; // object might be dirty, only for vnode
|
||||
OBJ_COLORED =$1000; // pg_color is defined
|
||||
OBJ_ONEMAPPING =$2000; // One USE (a single, non-forked) mapping flag
|
||||
OBJ_DISCONNECTWNT=$4000; // disconnect from vnode wanted
|
||||
OBJ_DMEM_EXT =$8000;
|
||||
|
||||
OBJPC_SYNC =$1; // sync I/O
|
||||
OBJPC_INVAL =$2; // invalidate
|
||||
OBJPC_NOSYNC=$4; // skip if PG_NOSYNC
|
||||
|
||||
//The following options are supported by vm_object_page_remove().
|
||||
OBJPR_CLEANONLY=$1; // Don't remove dirty pages.
|
||||
OBJPR_NOTMAPPED=$2; // Don't unmap pages.
|
||||
OBJPR_NOTWIRED =$4; // Don't remove wired pages.
|
||||
|
||||
function VM_OBJECT_MTX(obj:vm_object_t):p_mtx;
|
||||
procedure VM_OBJECT_LOCK(obj:vm_object_t);
|
||||
function VM_OBJECT_TRYLOCK(obj:vm_object_t):Boolean;
|
||||
procedure VM_OBJECT_UNLOCK(obj:vm_object_t);
|
||||
function VM_OBJECT_LOCKED(obj:vm_object_t):Boolean;
|
||||
procedure VM_OBJECT_LOCK_ASSERT(obj:vm_object_t);
|
||||
|
||||
procedure vm_object_set_flag(obj:vm_object_t;bits:Word);
|
||||
procedure vm_object_clear_flag(obj:vm_object_t;bits:Word);
|
||||
|
||||
function vm_object_allocate(t:objtype_t;size:vm_pindex_t):vm_object_t;
|
||||
procedure vm_object_destroy(obj:vm_object_t);
|
||||
procedure vm_object_reference(obj:vm_object_t);
|
||||
|
||||
procedure vm_object_pip_add(obj:vm_object_t;i:word);
|
||||
procedure vm_object_pip_subtract(obj:vm_object_t;i:word);
|
||||
|
||||
procedure vm_object_patch_remove(_obj:Pointer;start,__end:DWORD); external;
|
||||
|
||||
procedure vm_object_deallocate(obj:vm_object_t); external;
|
||||
|
||||
procedure vm_object_collapse(obj:vm_object_t); external;
|
||||
|
||||
function vm_object_coalesce(prev_object:vm_object_t;
|
||||
prev_offset:vm_ooffset_t;
|
||||
prev_size :vm_ooffset_t;
|
||||
next_size :vm_ooffset_t;
|
||||
reserved :Boolean):Boolean; external;
|
||||
|
||||
procedure vm_object_page_remove(obj:vm_object_t;
|
||||
start:vm_pindex_t;
|
||||
__end:vm_pindex_t;
|
||||
options:Integer); external;
|
||||
|
||||
function vm_object_page_clean(obj:vm_object_t;
|
||||
start,__end:vm_ooffset_t;
|
||||
flags:Integer):Boolean; external;
|
||||
|
||||
implementation
|
||||
|
||||
function VM_OBJECT_MTX(obj:vm_object_t):p_mtx;
|
||||
begin
|
||||
Result:=@obj^.mtx;
|
||||
end;
|
||||
|
||||
procedure VM_OBJECT_LOCK(obj:vm_object_t);
|
||||
begin
|
||||
mtx_lock(obj^.mtx);
|
||||
end;
|
||||
|
||||
function VM_OBJECT_TRYLOCK(obj:vm_object_t):Boolean;
|
||||
begin
|
||||
Result:=mtx_trylock(obj^.mtx);
|
||||
end;
|
||||
|
||||
procedure VM_OBJECT_UNLOCK(obj:vm_object_t);
|
||||
begin
|
||||
mtx_unlock(obj^.mtx);
|
||||
end;
|
||||
|
||||
function VM_OBJECT_LOCKED(obj:vm_object_t):Boolean;
|
||||
begin
|
||||
Result:=(mtx_owned(obj^.mtx));
|
||||
end;
|
||||
|
||||
procedure VM_OBJECT_LOCK_ASSERT(obj:vm_object_t);
|
||||
begin
|
||||
Assert(mtx_owned(obj^.mtx));
|
||||
end;
|
||||
|
||||
procedure vm_object_set_flag(obj:vm_object_t;bits:Word);
|
||||
begin
|
||||
VM_OBJECT_LOCK_ASSERT(obj);
|
||||
obj^.flags:=obj^.flags or bits;
|
||||
end;
|
||||
|
||||
procedure vm_object_clear_flag(obj:vm_object_t;bits:Word);
|
||||
begin
|
||||
VM_OBJECT_LOCK_ASSERT(obj);
|
||||
obj^.flags:=obj^.flags and (not bits);
|
||||
end;
|
||||
|
||||
function vm_object_allocate(t:objtype_t;size:vm_pindex_t):vm_object_t;
|
||||
begin
|
||||
Result:=AllocMem(SizeOf(t_vm_object));
|
||||
|
||||
mtx_init(Result^.mtx,'vm_object');
|
||||
|
||||
TAILQ_INIT(@Result^.memq);
|
||||
TAILQ_INIT(@Result^.patchq);
|
||||
|
||||
Result^.otype :=t;
|
||||
Result^.size :=size;
|
||||
Result^.generation:=1;
|
||||
Result^.ref_count :=1;
|
||||
|
||||
if (t=OBJT_DEFAULT) then
|
||||
begin
|
||||
Result^.flags:=OBJ_ONEMAPPING;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure vm_object_destroy(obj:vm_object_t);
|
||||
begin
|
||||
mtx_destroy(obj^.mtx);
|
||||
FreeMem(obj);
|
||||
end;
|
||||
|
||||
procedure vm_object_reference(obj:vm_object_t);
|
||||
begin
|
||||
if (obj=nil) then Exit;
|
||||
|
||||
System.InterlockedIncrement(obj^.ref_count);
|
||||
end;
|
||||
|
||||
procedure vm_object_pip_add(obj:vm_object_t;i:word);
|
||||
begin
|
||||
if (obj=nil) then Exit;
|
||||
|
||||
VM_OBJECT_LOCK_ASSERT(obj);
|
||||
obj^.paging_in_progress:=obj^.paging_in_progress+i;
|
||||
end;
|
||||
|
||||
procedure vm_object_pip_subtract(obj:vm_object_t;i:word);
|
||||
begin
|
||||
if (obj=nil) then Exit;
|
||||
|
||||
VM_OBJECT_LOCK_ASSERT(obj);
|
||||
obj^.paging_in_progress:=obj^.paging_in_progress-i;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ uses
|
|||
vmparam,
|
||||
vm_map,
|
||||
vm_pmap,
|
||||
vm_object;
|
||||
sys_vm_object;
|
||||
|
||||
function vm_fault(map :vm_map_t;
|
||||
mem_addr :vm_offset_t;
|
||||
|
@ -43,16 +43,6 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
type
|
||||
p_jmp32_trampoline=^t_jmp32_trampoline;
|
||||
t_jmp32_trampoline=packed record
|
||||
inst:Byte; //E9
|
||||
addr:Integer;
|
||||
end;
|
||||
|
||||
const
|
||||
c_jmpl32_trampoline:t_jmp32_trampoline=(inst:$E9;addr:0);
|
||||
|
||||
function AlignUp(addr:PtrUInt;alignment:PtrUInt):PtrUInt; inline;
|
||||
var
|
||||
tmp:PtrUInt;
|
||||
|
|
|
@ -9,10 +9,11 @@ uses
|
|||
vm,
|
||||
vmparam,
|
||||
vm_pmap,
|
||||
sys_vm_object,
|
||||
vm_object,
|
||||
kern_mtx,
|
||||
kern_thr,
|
||||
_resource,
|
||||
sys_resource,
|
||||
kern_resource;
|
||||
|
||||
type
|
||||
|
@ -918,7 +919,9 @@ begin
|
|||
inheritance:=VM_INHERIT_DEFAULT;
|
||||
|
||||
if ((cow and (MAP_ACC_NO_CHARGE or MAP_NOFAULT))<>0) then
|
||||
begin
|
||||
goto charged;
|
||||
end;
|
||||
|
||||
if ((cow and MAP_ACC_CHARGED)<>0) or (((prot and VM_PROT_WRITE)<>0) and
|
||||
(((protoeflags and MAP_ENTRY_NEEDS_COPY)<>0) or (vm_obj=nil))) then
|
||||
|
@ -926,7 +929,9 @@ begin
|
|||
Assert((vm_obj=nil) or
|
||||
((protoeflags and MAP_ENTRY_NEEDS_COPY)<>0),'OVERCOMMIT: vm_map_insert o %p", object');
|
||||
if (vm_obj=nil) and ((protoeflags and MAP_ENTRY_NEEDS_COPY)=0) then
|
||||
begin
|
||||
charge_prev_obj:=TRUE;
|
||||
end;
|
||||
end;
|
||||
|
||||
charged:
|
||||
|
|
|
@ -8,7 +8,7 @@ interface
|
|||
uses
|
||||
vm,
|
||||
vm_map,
|
||||
vm_object;
|
||||
sys_vm_object;
|
||||
|
||||
type
|
||||
p_query_memory_prot=^t_query_memory_prot;
|
||||
|
@ -54,7 +54,7 @@ uses
|
|||
kern_thr,
|
||||
kern_proc,
|
||||
vmparam,
|
||||
_resource,
|
||||
sys_resource,
|
||||
kern_resource,
|
||||
kern_mtx,
|
||||
kern_descrip,
|
||||
|
|
|
@ -6,83 +6,12 @@ unit vm_object;
|
|||
interface
|
||||
|
||||
uses
|
||||
mqueue,
|
||||
vm,
|
||||
kern_param,
|
||||
kern_mtx,
|
||||
kern_synch;
|
||||
sys_vm_object,
|
||||
kern_param;
|
||||
|
||||
type
|
||||
obj_type=(
|
||||
OBJT_DEFAULT ,//0
|
||||
OBJT_SWAP ,//1
|
||||
OBJT_VNODE ,//2
|
||||
OBJT_DEVICE ,//3
|
||||
OBJT_PHYS ,//4
|
||||
OBJT_DEAD ,//5
|
||||
OBJT_SG ,//6
|
||||
OBJT_JITSHM ,//7
|
||||
OBJT_SELF ,//8
|
||||
OBJT_TRCMEM ,//9
|
||||
OBJT_PHYSHM ,//10
|
||||
OBJT_BLOCKPOOL //11
|
||||
);
|
||||
|
||||
objtype_t=obj_type;
|
||||
|
||||
p_vm_object_t=^vm_object_t;
|
||||
vm_object_t=^_vm_object;
|
||||
_vm_object=packed record
|
||||
mtx :mtx;
|
||||
memq :TAILQ_HEAD; // list of resident pages
|
||||
patchq :TAILQ_HEAD; // list of patches
|
||||
root :Pointer; // root of the resident page splay tree
|
||||
size :vm_pindex_t; // Object size
|
||||
generation :Integer; // generation ID
|
||||
ref_count :Integer; // How many refs??
|
||||
otype :objtype_t; // type of pager
|
||||
pg_color :Word;
|
||||
flags :Word; // see below
|
||||
handle :Pointer;
|
||||
paging_in_progress:Integer;
|
||||
un_pager:packed record
|
||||
vnp:packed record
|
||||
vnp_size:QWORD;
|
||||
writemappings:vm_ooffset_t;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
const
|
||||
//Flags
|
||||
OBJ_ACTIVE =$0004; // active objects
|
||||
OBJ_DEAD =$0008; // dead objects (during rundown)
|
||||
OBJ_NOSPLIT =$0010; // dont split this object
|
||||
OBJ_PIPWNT =$0040; // paging in progress wanted
|
||||
OBJ_MIGHTBEDIRTY =$0100; // object might be dirty, only for vnode
|
||||
OBJ_COLORED =$1000; // pg_color is defined
|
||||
OBJ_ONEMAPPING =$2000; // One USE (a single, non-forked) mapping flag
|
||||
OBJ_DISCONNECTWNT=$4000; // disconnect from vnode wanted
|
||||
OBJ_DMEM_EXT =$8000;
|
||||
|
||||
OBJPC_SYNC =$1; // sync I/O
|
||||
OBJPC_INVAL =$2; // invalidate
|
||||
OBJPC_NOSYNC=$4; // skip if PG_NOSYNC
|
||||
|
||||
//The following options are supported by vm_object_page_remove().
|
||||
OBJPR_CLEANONLY=$1; // Don't remove dirty pages.
|
||||
OBJPR_NOTMAPPED=$2; // Don't unmap pages.
|
||||
OBJPR_NOTWIRED =$4; // Don't remove wired pages.
|
||||
|
||||
procedure vm_object_reference (obj:vm_object_t);
|
||||
function vm_object_allocate (t:objtype_t;size:vm_pindex_t):vm_object_t;
|
||||
procedure vm_object_deallocate (obj:vm_object_t);
|
||||
|
||||
procedure vm_object_set_flag (obj:vm_object_t;bits:Word);
|
||||
procedure vm_object_clear_flag (obj:vm_object_t;bits:Word);
|
||||
|
||||
procedure vm_object_pip_add (obj:vm_object_t;i:word);
|
||||
procedure vm_object_pip_subtract(obj:vm_object_t;i:word);
|
||||
procedure vm_object_pip_wakeup (obj:vm_object_t);
|
||||
procedure vm_object_pip_wakeupn (obj:vm_object_t;i:word);
|
||||
procedure vm_object_pip_wait (obj:vm_object_t;waitid:pchar);
|
||||
|
@ -98,16 +27,6 @@ procedure vm_object_page_remove(obj:vm_object_t;
|
|||
|
||||
procedure vm_object_collapse (obj:vm_object_t);
|
||||
|
||||
function VM_OBJECT_MTX (obj:vm_object_t):p_mtx;
|
||||
procedure VM_OBJECT_LOCK (obj:vm_object_t);
|
||||
function VM_OBJECT_TRYLOCK (obj:vm_object_t):Boolean;
|
||||
procedure VM_OBJECT_UNLOCK (obj:vm_object_t);
|
||||
function VM_OBJECT_LOCKED (obj:vm_object_t):Boolean;
|
||||
procedure VM_OBJECT_LOCK_ASSERT(obj:vm_object_t);
|
||||
|
||||
function IDX_TO_OFF(x:DWORD):QWORD; inline;
|
||||
function OFF_TO_IDX(x:QWORD):DWORD; inline;
|
||||
|
||||
function vm_object_coalesce(prev_object:vm_object_t;
|
||||
prev_offset:vm_ooffset_t;
|
||||
prev_size :vm_ooffset_t;
|
||||
|
@ -123,10 +42,16 @@ uses
|
|||
|
||||
//
|
||||
|
||||
procedure vm_object_patch_remove(_obj:Pointer;start,__end:DWORD); external;
|
||||
|
||||
procedure vm_pager_deallocate(obj:vm_object_t); external;
|
||||
|
||||
function msleep(ident :Pointer;
|
||||
lock :Pointer;
|
||||
priority:Integer;
|
||||
wmesg :PChar;
|
||||
timo :Int64):Integer; external;
|
||||
|
||||
procedure wakeup(ident:Pointer); external;
|
||||
|
||||
//
|
||||
|
||||
function IDX_TO_OFF(x:DWORD):QWORD; inline;
|
||||
|
@ -139,81 +64,6 @@ begin
|
|||
Result:=QWORD(x) shr PAGE_SHIFT;
|
||||
end;
|
||||
|
||||
function VM_OBJECT_MTX(obj:vm_object_t):p_mtx;
|
||||
begin
|
||||
Result:=@obj^.mtx;
|
||||
end;
|
||||
|
||||
procedure VM_OBJECT_LOCK(obj:vm_object_t);
|
||||
begin
|
||||
mtx_lock(obj^.mtx);
|
||||
end;
|
||||
|
||||
function VM_OBJECT_TRYLOCK(obj:vm_object_t):Boolean;
|
||||
begin
|
||||
Result:=mtx_trylock(obj^.mtx);
|
||||
end;
|
||||
|
||||
procedure VM_OBJECT_UNLOCK(obj:vm_object_t);
|
||||
begin
|
||||
mtx_unlock(obj^.mtx);
|
||||
end;
|
||||
|
||||
function VM_OBJECT_LOCKED(obj:vm_object_t):Boolean;
|
||||
begin
|
||||
Result:=(mtx_owned(obj^.mtx));
|
||||
end;
|
||||
|
||||
procedure VM_OBJECT_LOCK_ASSERT(obj:vm_object_t);
|
||||
begin
|
||||
Assert(mtx_owned(obj^.mtx));
|
||||
end;
|
||||
|
||||
procedure vm_object_set_flag(obj:vm_object_t;bits:Word);
|
||||
begin
|
||||
VM_OBJECT_LOCK_ASSERT(obj);
|
||||
obj^.flags:=obj^.flags or bits;
|
||||
end;
|
||||
|
||||
procedure vm_object_clear_flag(obj:vm_object_t;bits:Word);
|
||||
begin
|
||||
VM_OBJECT_LOCK_ASSERT(obj);
|
||||
obj^.flags:=obj^.flags and (not bits);
|
||||
end;
|
||||
|
||||
function vm_object_allocate(t:objtype_t;size:vm_pindex_t):vm_object_t;
|
||||
begin
|
||||
Result:=AllocMem(SizeOf(_vm_object));
|
||||
|
||||
mtx_init(Result^.mtx,'vm_object');
|
||||
|
||||
TAILQ_INIT(@Result^.memq);
|
||||
TAILQ_INIT(@Result^.patchq);
|
||||
|
||||
Result^.otype :=t;
|
||||
Result^.size :=size;
|
||||
Result^.generation:=1;
|
||||
Result^.ref_count :=1;
|
||||
|
||||
if (t=OBJT_DEFAULT) then
|
||||
begin
|
||||
Result^.flags:=OBJ_ONEMAPPING;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure vm_object_destroy(obj:vm_object_t);
|
||||
begin
|
||||
mtx_destroy(obj^.mtx);
|
||||
FreeMem(obj);
|
||||
end;
|
||||
|
||||
procedure vm_object_reference(obj:vm_object_t);
|
||||
begin
|
||||
if (obj=nil) then Exit;
|
||||
|
||||
System.InterlockedIncrement(obj^.ref_count);
|
||||
end;
|
||||
|
||||
{
|
||||
vm_object_terminate actually destroys the specified object, freeing
|
||||
up all previously used resources.
|
||||
|
@ -268,7 +118,7 @@ begin
|
|||
vm_object_destroy(obj);
|
||||
end;
|
||||
|
||||
procedure vm_object_deallocate(obj:vm_object_t);
|
||||
procedure vm_object_deallocate(obj:vm_object_t); public;
|
||||
var
|
||||
ref:Integer;
|
||||
begin
|
||||
|
@ -290,22 +140,6 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure vm_object_pip_add(obj:vm_object_t;i:word);
|
||||
begin
|
||||
if (obj=nil) then Exit;
|
||||
|
||||
VM_OBJECT_LOCK_ASSERT(obj);
|
||||
obj^.paging_in_progress:=obj^.paging_in_progress+i;
|
||||
end;
|
||||
|
||||
procedure vm_object_pip_subtract(obj:vm_object_t;i:word);
|
||||
begin
|
||||
if (obj=nil) then Exit;
|
||||
|
||||
VM_OBJECT_LOCK_ASSERT(obj);
|
||||
obj^.paging_in_progress:=obj^.paging_in_progress-i;
|
||||
end;
|
||||
|
||||
procedure vm_object_pip_wakeup(obj:vm_object_t);
|
||||
begin
|
||||
if (obj=nil) then Exit;
|
||||
|
@ -365,7 +199,7 @@ end;
|
|||
|
||||
function vm_object_page_clean(obj:vm_object_t;
|
||||
start,__end:vm_ooffset_t;
|
||||
flags:Integer):Boolean;
|
||||
flags:Integer):Boolean; public;
|
||||
begin
|
||||
Result:=True;
|
||||
end;
|
||||
|
@ -400,7 +234,7 @@ end;
|
|||
procedure vm_object_page_remove(obj:vm_object_t;
|
||||
start:vm_pindex_t;
|
||||
__end:vm_pindex_t;
|
||||
options:Integer);
|
||||
options:Integer); public;
|
||||
begin
|
||||
vm_object_patch_remove(obj,start,__end);
|
||||
end;
|
||||
|
@ -413,7 +247,7 @@ end;
|
|||
parent, and the backing object is deallocated.
|
||||
}
|
||||
|
||||
procedure vm_object_collapse(obj:vm_object_t);
|
||||
procedure vm_object_collapse(obj:vm_object_t); public;
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
@ -444,7 +278,7 @@ function vm_object_coalesce(prev_object:vm_object_t;
|
|||
prev_offset:vm_ooffset_t;
|
||||
prev_size :vm_ooffset_t;
|
||||
next_size :vm_ooffset_t;
|
||||
reserved :Boolean):Boolean;
|
||||
reserved :Boolean):Boolean; public;
|
||||
var
|
||||
next_pindex:vm_pindex_t;
|
||||
begin
|
||||
|
|
|
@ -7,7 +7,7 @@ interface
|
|||
|
||||
uses
|
||||
vm,
|
||||
vm_object;
|
||||
sys_vm_object;
|
||||
|
||||
function vm_pager_allocate(otype:objtype_t;
|
||||
handle:Pointer;
|
||||
|
@ -75,7 +75,6 @@ begin
|
|||
OBJT_TRCMEM :;
|
||||
OBJT_PHYSHM :;
|
||||
OBJT_BLOCKPOOL:;
|
||||
else;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ uses
|
|||
hamt,
|
||||
kern_rwlock,
|
||||
vmparam,
|
||||
vm_object;
|
||||
sys_vm_object;
|
||||
|
||||
type
|
||||
p_patch_page=^t_patch_page;
|
||||
|
|
Loading…
Reference in New Issue