diff --git a/sys/dev/dev_gc.pas b/sys/dev/dev_gc.pas index a7f92dbb..8f000348 100644 --- a/sys/dev/dev_gc.pas +++ b/sys/dev/dev_gc.pas @@ -79,6 +79,14 @@ begin PPointer(data)^:=@gc_AreSubmitsAllowed; 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 begin print_backtrace_td(stderr); diff --git a/sys/kern/kern_stub.pas b/sys/kern/kern_stub.pas index 170bac3e..6728de4a 100644 --- a/sys/kern/kern_stub.pas +++ b/sys/kern/kern_stub.pas @@ -8,6 +8,8 @@ interface uses mqueue; +{.$DEFINE chunk_alloc} + const m_header=WORD($C3C3); @@ -39,17 +41,21 @@ procedure p_dec_ref(chunk:p_stub_chunk); implementation uses + {$IFDEF chunk_alloc} hamt, + {$ENDIF} kern_rwlock, vm, vmparam, vm_map, vm_mmap, - vm_pmap, vm_object; var + {$IFDEF chunk_alloc} chunk_alloc:TSTUB_HAMT64; + {$ENDIF} + chunk_free :TAILQ_HEAD=(tqh_first:nil;tqh_last:@chunk_free.tqh_first); chunk_lock :Pointer=nil; @@ -118,7 +124,6 @@ begin vm_map_lock(map); 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); Result:=Pointer(start); @@ -328,7 +333,9 @@ begin chunk^.flags:=chunk^.flags and (not m_free__chunk); + {$IFDEF chunk_alloc} HAMT_insert64(@chunk_alloc,QWORD(chunk),chunk); + {$ENDIF} rw_wunlock(chunk_lock); @@ -375,7 +382,9 @@ begin chunk^.flags:=chunk^.flags and (not m_free__chunk); + {$IFDEF chunk_alloc} HAMT_insert64(@chunk_alloc,QWORD(chunk),chunk); + {$ENDIF} rw_wunlock(chunk_lock); @@ -390,6 +399,7 @@ begin rw_wlock(chunk_lock); + {$IFDEF chunk_alloc} if (HAMT_search64(@chunk_alloc,QWORD(chunk))=nil) then begin rw_wunlock(chunk_lock); @@ -398,6 +408,8 @@ begin HAMT_delete64(@chunk_alloc,QWORD(chunk),nil); + {$ENDIF} + chunk^.flags:=chunk^.flags or m_free__chunk; merge_chunk(chunk); diff --git a/sys/kern/trap.pas b/sys/kern/trap.pas index 29fa4e49..47b169cc 100644 --- a/sys/kern/trap.pas +++ b/sys/kern/trap.pas @@ -288,6 +288,8 @@ begin end; function CaptureBacktrace(td:p_kthread;rbp:PPointer;skipframes,count:sizeint;frames:PCodePointer):sizeint; +label + _next; var adr:Pointer; begin @@ -298,6 +300,8 @@ begin adr:=fuptr(rbp[1]); rbp:=fuptr(rbp[0]); + _next: + if (adr<>nil) then begin if (skipframes<>0) then @@ -321,6 +325,7 @@ begin begin adr:=Pointer(td^.td_frame.tf_rip); rbp:=Pointer(td^.td_frame.tf_rbp); + goto _next; end; end; @@ -495,7 +500,15 @@ begin Writeln(f,' offset $00X',HexStr(offset1,6),' ',info.source,':',info.func,'+$',HexStr(offset2,6)); end else 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 else if (BackTraceStrFunc<>nil) then @@ -503,7 +516,7 @@ begin Writeln(f,BackTraceStrFunc(frame)); end else begin - Writeln(f,' 0x',HexStr(frame)); + Writeln(f,' $',HexStr(frame)); end; end; diff --git a/sys/md/md_exception.pas b/sys/md/md_exception.pas index 85f8c75e..4880df43 100644 --- a/sys/md/md_exception.pas +++ b/sys/md/md_exception.pas @@ -254,7 +254,9 @@ begin write(stderr,msg); Writeln(stderr,' (',FName,', line ',LineNo,').'); print_backtrace(stderr,Get_pc_addr,get_frame,0); - DebugBreak; + asm + int3 + end; md_halt(217); end; diff --git a/sys/md/vm_pmap.pas b/sys/md/vm_pmap.pas index f81bc5c5..b0534d7d 100644 --- a/sys/md/vm_pmap.pas +++ b/sys/md/vm_pmap.pas @@ -12,6 +12,8 @@ uses vmparam, vm_object; +{$DEFINE GPU_REMAP} + const PAGE_MAP_COUNT =(QWORD(VM_MAXUSER_ADDRESS) shr PAGE_SHIFT); PAGE_MAP_MASK =PAGE_MAP_COUNT-1; @@ -401,6 +403,7 @@ begin base:=Pointer(trunc_page(start)); size:=trunc_page(__end-start); + {$IFDEF GPU_REMAP} if is_gpu(prot) then begin //shift @@ -408,6 +411,7 @@ begin 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)); end; + {$ENDIF} r:=NtAllocateVirtualMemory( NtCurrentProcess, @@ -527,6 +531,7 @@ begin size:=trunc_page(__end-start); old:=0; + {$IFDEF GPU_REMAP} if (is_gpu(new_prot)<>is_gpu(old_prot)) then begin //realloc @@ -546,21 +551,30 @@ begin pmap_move(pmap,start,vm_offset_t(base_old),vm_offset_t(base_new),size,new_prot); - end else - begin - r:=NtProtectVirtualMemory( - NtCurrentProcess, - @base_new, - @size, - wprots[new_prot and VM_RWX], - @old - ); + Exit; + end; + {$ENDIF} - if (r<>0) then - begin - Writeln('failed NtProtectVirtualMemory:',HexStr(r,8)); - Assert(false,'pmap_protect'); - end; + {$IFDEF GPU_REMAP} + if is_gpu(new_prot) then + begin + //shift + base_new:=base_new+VM_MIN_GPU_ADDRESS; + end; + {$ENDIF} + + r:=NtProtectVirtualMemory( + NtCurrentProcess, + @base_new, + @size, + wprots[new_prot and VM_RWX], + @old + ); + + if (r<>0) then + begin + Writeln('failed NtProtectVirtualMemory:',HexStr(r,8)); + Assert(false,'pmap_protect'); end; end; @@ -613,11 +627,13 @@ begin pmap_unmark(start,__end); + {$IFDEF GPU_REMAP} if is_gpu(prot) then begin //shift base:=base+VM_MIN_GPU_ADDRESS; end; + {$ENDIF} r:=NtFreeVirtualMemory( NtCurrentProcess, diff --git a/sys/test/project1.lpr b/sys/test/project1.lpr index f8c51ee4..928e1f8b 100644 --- a/sys/test/project1.lpr +++ b/sys/test/project1.lpr @@ -369,7 +369,7 @@ begin //readln; - argv0:='/app0/basic-sample_debug.elf'; + //argv0:='/app0/basic-sample_debug.elf'; argv0:='/app0/simple.elf'; //argv0:='/app0/videoout_basic.elf';