This commit is contained in:
Pavel 2023-08-31 14:05:13 +03:00
parent 1477aa61e7
commit 250f7f52a0
6 changed files with 71 additions and 20 deletions

View File

@ -79,6 +79,14 @@ begin
PPointer(data)^:=@gc_AreSubmitsAllowed; PPointer(data)^:=@gc_AreSubmitsAllowed;
end; end;
$C010810B: //get cu mask
begin
PInteger(data)[0]:=$10; //& 0x3ff GC SE0 Redundant CU: 0x10
PInteger(data)[1]:=$10; //& 0x3ff GC SE1 Redundant CU: 0x10
PInteger(data)[2]:=$00; //& 0x3ff GC SE2 Redundant CU: 0x00
PInteger(data)[3]:=$00; //& 0x3ff GC SE3 Redundant CU: 0x00
end;
else else
begin begin
print_backtrace_td(stderr); print_backtrace_td(stderr);

View File

@ -8,6 +8,8 @@ interface
uses uses
mqueue; mqueue;
{.$DEFINE chunk_alloc}
const const
m_header=WORD($C3C3); m_header=WORD($C3C3);
@ -39,17 +41,21 @@ procedure p_dec_ref(chunk:p_stub_chunk);
implementation implementation
uses uses
{$IFDEF chunk_alloc}
hamt, hamt,
{$ENDIF}
kern_rwlock, kern_rwlock,
vm, vm,
vmparam, vmparam,
vm_map, vm_map,
vm_mmap, vm_mmap,
vm_pmap,
vm_object; vm_object;
var var
{$IFDEF chunk_alloc}
chunk_alloc:TSTUB_HAMT64; chunk_alloc:TSTUB_HAMT64;
{$ENDIF}
chunk_free :TAILQ_HEAD=(tqh_first:nil;tqh_last:@chunk_free.tqh_first); chunk_free :TAILQ_HEAD=(tqh_first:nil;tqh_last:@chunk_free.tqh_first);
chunk_lock :Pointer=nil; chunk_lock :Pointer=nil;
@ -118,7 +124,6 @@ begin
vm_map_lock(map); vm_map_lock(map);
vm_map_set_name_locked(map,start,start+size,'#patch',VM_INHERIT_PATCH); vm_map_set_name_locked(map,start,start+size,'#patch',VM_INHERIT_PATCH);
//pmap_mark_flags(start,start+size,PAGE_PATCH_FLAG);
vm_map_unlock(map); vm_map_unlock(map);
Result:=Pointer(start); Result:=Pointer(start);
@ -328,7 +333,9 @@ begin
chunk^.flags:=chunk^.flags and (not m_free__chunk); chunk^.flags:=chunk^.flags and (not m_free__chunk);
{$IFDEF chunk_alloc}
HAMT_insert64(@chunk_alloc,QWORD(chunk),chunk); HAMT_insert64(@chunk_alloc,QWORD(chunk),chunk);
{$ENDIF}
rw_wunlock(chunk_lock); rw_wunlock(chunk_lock);
@ -375,7 +382,9 @@ begin
chunk^.flags:=chunk^.flags and (not m_free__chunk); chunk^.flags:=chunk^.flags and (not m_free__chunk);
{$IFDEF chunk_alloc}
HAMT_insert64(@chunk_alloc,QWORD(chunk),chunk); HAMT_insert64(@chunk_alloc,QWORD(chunk),chunk);
{$ENDIF}
rw_wunlock(chunk_lock); rw_wunlock(chunk_lock);
@ -390,6 +399,7 @@ begin
rw_wlock(chunk_lock); rw_wlock(chunk_lock);
{$IFDEF chunk_alloc}
if (HAMT_search64(@chunk_alloc,QWORD(chunk))=nil) then if (HAMT_search64(@chunk_alloc,QWORD(chunk))=nil) then
begin begin
rw_wunlock(chunk_lock); rw_wunlock(chunk_lock);
@ -398,6 +408,8 @@ begin
HAMT_delete64(@chunk_alloc,QWORD(chunk),nil); HAMT_delete64(@chunk_alloc,QWORD(chunk),nil);
{$ENDIF}
chunk^.flags:=chunk^.flags or m_free__chunk; chunk^.flags:=chunk^.flags or m_free__chunk;
merge_chunk(chunk); merge_chunk(chunk);

View File

@ -288,6 +288,8 @@ begin
end; end;
function CaptureBacktrace(td:p_kthread;rbp:PPointer;skipframes,count:sizeint;frames:PCodePointer):sizeint; function CaptureBacktrace(td:p_kthread;rbp:PPointer;skipframes,count:sizeint;frames:PCodePointer):sizeint;
label
_next;
var var
adr:Pointer; adr:Pointer;
begin begin
@ -298,6 +300,8 @@ begin
adr:=fuptr(rbp[1]); adr:=fuptr(rbp[1]);
rbp:=fuptr(rbp[0]); rbp:=fuptr(rbp[0]);
_next:
if (adr<>nil) then if (adr<>nil) then
begin begin
if (skipframes<>0) then if (skipframes<>0) then
@ -321,6 +325,7 @@ begin
begin begin
adr:=Pointer(td^.td_frame.tf_rip); adr:=Pointer(td^.td_frame.tf_rip);
rbp:=Pointer(td^.td_frame.tf_rbp); rbp:=Pointer(td^.td_frame.tf_rbp);
goto _next;
end; end;
end; end;
@ -495,7 +500,15 @@ begin
Writeln(f,' offset $00X',HexStr(offset1,6),' ',info.source,':',info.func,'+$',HexStr(offset2,6)); Writeln(f,' offset $00X',HexStr(offset1,6),' ',info.source,':',info.func,'+$',HexStr(offset2,6));
end else end else
begin begin
Writeln(f,' 0x',HexStr(frame),' ',info.source); if (info.base_addr<>0) then
begin
offset1:=QWORD(frame)-QWORD(info.base_addr);
Writeln(f,' offset $00X',HexStr(offset1,6),' ',info.source);
end else
begin
Writeln(f,' $',HexStr(frame),' ',info.source);
end;
end; end;
end else end else
if (BackTraceStrFunc<>nil) then if (BackTraceStrFunc<>nil) then
@ -503,7 +516,7 @@ begin
Writeln(f,BackTraceStrFunc(frame)); Writeln(f,BackTraceStrFunc(frame));
end else end else
begin begin
Writeln(f,' 0x',HexStr(frame)); Writeln(f,' $',HexStr(frame));
end; end;
end; end;

View File

@ -254,7 +254,9 @@ begin
write(stderr,msg); write(stderr,msg);
Writeln(stderr,' (',FName,', line ',LineNo,').'); Writeln(stderr,' (',FName,', line ',LineNo,').');
print_backtrace(stderr,Get_pc_addr,get_frame,0); print_backtrace(stderr,Get_pc_addr,get_frame,0);
DebugBreak; asm
int3
end;
md_halt(217); md_halt(217);
end; end;

View File

@ -12,6 +12,8 @@ uses
vmparam, vmparam,
vm_object; vm_object;
{$DEFINE GPU_REMAP}
const const
PAGE_MAP_COUNT =(QWORD(VM_MAXUSER_ADDRESS) shr PAGE_SHIFT); PAGE_MAP_COUNT =(QWORD(VM_MAXUSER_ADDRESS) shr PAGE_SHIFT);
PAGE_MAP_MASK =PAGE_MAP_COUNT-1; PAGE_MAP_MASK =PAGE_MAP_COUNT-1;
@ -401,6 +403,7 @@ begin
base:=Pointer(trunc_page(start)); base:=Pointer(trunc_page(start));
size:=trunc_page(__end-start); size:=trunc_page(__end-start);
{$IFDEF GPU_REMAP}
if is_gpu(prot) then if is_gpu(prot) then
begin begin
//shift //shift
@ -408,6 +411,7 @@ begin
prot:=prot or ((prot and VM_PROT_GPU_ALL) shr 4); prot:=prot or ((prot and VM_PROT_GPU_ALL) shr 4);
Writeln('pmap_enter_gpuobj:',HexStr(QWORD(base),11),':',HexStr(QWORD(base)+(__end-start),11),':',HexStr(prot,2)); Writeln('pmap_enter_gpuobj:',HexStr(QWORD(base),11),':',HexStr(QWORD(base)+(__end-start),11),':',HexStr(prot,2));
end; end;
{$ENDIF}
r:=NtAllocateVirtualMemory( r:=NtAllocateVirtualMemory(
NtCurrentProcess, NtCurrentProcess,
@ -527,6 +531,7 @@ begin
size:=trunc_page(__end-start); size:=trunc_page(__end-start);
old:=0; old:=0;
{$IFDEF GPU_REMAP}
if (is_gpu(new_prot)<>is_gpu(old_prot)) then if (is_gpu(new_prot)<>is_gpu(old_prot)) then
begin begin
//realloc //realloc
@ -546,8 +551,18 @@ begin
pmap_move(pmap,start,vm_offset_t(base_old),vm_offset_t(base_new),size,new_prot); pmap_move(pmap,start,vm_offset_t(base_old),vm_offset_t(base_new),size,new_prot);
end else Exit;
end;
{$ENDIF}
{$IFDEF GPU_REMAP}
if is_gpu(new_prot) then
begin begin
//shift
base_new:=base_new+VM_MIN_GPU_ADDRESS;
end;
{$ENDIF}
r:=NtProtectVirtualMemory( r:=NtProtectVirtualMemory(
NtCurrentProcess, NtCurrentProcess,
@base_new, @base_new,
@ -561,7 +576,6 @@ begin
Writeln('failed NtProtectVirtualMemory:',HexStr(r,8)); Writeln('failed NtProtectVirtualMemory:',HexStr(r,8));
Assert(false,'pmap_protect'); Assert(false,'pmap_protect');
end; end;
end;
end; end;
procedure pmap_madv_free(pmap :pmap_t; procedure pmap_madv_free(pmap :pmap_t;
@ -613,11 +627,13 @@ begin
pmap_unmark(start,__end); pmap_unmark(start,__end);
{$IFDEF GPU_REMAP}
if is_gpu(prot) then if is_gpu(prot) then
begin begin
//shift //shift
base:=base+VM_MIN_GPU_ADDRESS; base:=base+VM_MIN_GPU_ADDRESS;
end; end;
{$ENDIF}
r:=NtFreeVirtualMemory( r:=NtFreeVirtualMemory(
NtCurrentProcess, NtCurrentProcess,

View File

@ -369,7 +369,7 @@ begin
//readln; //readln;
argv0:='/app0/basic-sample_debug.elf'; //argv0:='/app0/basic-sample_debug.elf';
argv0:='/app0/simple.elf'; argv0:='/app0/simple.elf';
//argv0:='/app0/videoout_basic.elf'; //argv0:='/app0/videoout_basic.elf';