From 79757846dc0a94febdb3b6fa6d9c880270e6cc6d Mon Sep 17 00:00:00 2001 From: Pavel <68122101+red-prig@users.noreply.github.com> Date: Thu, 28 Mar 2024 17:19:15 +0300 Subject: [PATCH] + --- chip/pm4_pfp.pas | 2 +- chip/pm4_ring.pas | 3 +-- chip/pm4defs.pas | 6 ++---- rtl/bittype.pas | 1 + sys/dev/dev_gc.pas | 4 ++-- sys/md/md_proc.pas | 21 +++++++++++++++++++++ sys/md/md_thread.pas | 21 +++++++++++++++++++++ 7 files changed, 49 insertions(+), 9 deletions(-) diff --git a/chip/pm4_pfp.pas b/chip/pm4_pfp.pas index 7a2c4370..1865bbbc 100644 --- a/chip/pm4_pfp.pas +++ b/chip/pm4_pfp.pas @@ -71,7 +71,7 @@ var begin Result:=False; - ib_base:=QWORD(buf^.ibBaseLo) or (QWORD(buf^.ibBaseHi) shl 32); + ib_base:=QWORD(buf^.ibBase); ib_size:=QWORD(buf^.ibSize)*sizeof(DWORD); addr:=nil; diff --git a/chip/pm4_ring.pas b/chip/pm4_ring.pas index c1eee06d..c7c7a993 100644 --- a/chip/pm4_ring.pas +++ b/chip/pm4_ring.pas @@ -18,8 +18,7 @@ type PPM4CMDINDIRECTBUFFER=^PM4CMDINDIRECTBUFFER; PM4CMDINDIRECTBUFFER=bitpacked record header :DWORD; // PM4_TYPE_3_HEADER - ibBaseLo :DWORD; // Indirect buffer base address, must be 4 byte aligned - ibBaseHi :bit8; + ibBase :bit40; // Indirect buffer base address, must be 4 byte aligned reserved0:bit24; // ibSize :bit20; // Indirect buffer size diff --git a/chip/pm4defs.pas b/chip/pm4defs.pas index b4b8739d..3b9567ef 100644 --- a/chip/pm4defs.pas +++ b/chip/pm4defs.pas @@ -315,8 +315,7 @@ type header :PM4_TYPE_3_HEADER; baseIndex:bit4; // < base index selector reserved1:bit28; - addressLo:bit32; // < base address Lo of buffer, must be 8 byte aligned - addressHi:bit16; // < base address Hi of buffer + address :bit48; // < base address of buffer, must be 8 byte aligned end; const @@ -329,8 +328,7 @@ type PPM4CMDSETPREDICATION=^PM4CMDSETPREDICATION; PM4CMDSETPREDICATION=bitpacked record header :PM4_TYPE_3_HEADER; - startAddressLo :bit32; // < start address low - startAddrHi :bit8; // < start address hi + startAddress :bit40; // < start address predicationBoolean:bit1; // < predication boolean reserved1 :bit3; hint :bit1; // < hint diff --git a/rtl/bittype.pas b/rtl/bittype.pas index 4213e2f7..5b20ce1f 100644 --- a/rtl/bittype.pas +++ b/rtl/bittype.pas @@ -38,6 +38,7 @@ type bit31=0..2147483647; bit32=DWORD; bit38=0..274877906943; + bit40=0..1099511627775; bit43=0..8796093022207; bit44=0..17592186044415; bit48=0..281474976710655; diff --git a/sys/dev/dev_gc.pas b/sys/dev/dev_gc.pas index b075066c..355c3674 100644 --- a/sys/dev/dev_gc.pas +++ b/sys/dev/dev_gc.pas @@ -187,7 +187,7 @@ procedure onSetBase(Body:PPM4CMDDRAWSETBASE); var addr:QWORD; begin - addr:=QWORD(Body^.addressLo) or (QWORD(Body^.addressHi) shl 32); + addr:=QWORD(Body^.address); Writeln(' baseIndex=0x',HexStr(Body^.baseIndex,4)); Writeln(' address =0x',HexStr(addr,16)); @@ -197,7 +197,7 @@ procedure onSetPredication(Body:PPM4CMDSETPREDICATION); var addr:QWORD; begin - addr:=QWORD(Body^.startAddressLo) or (QWORD(Body^.startAddrHi) shl 32); + addr:=QWORD(Body^.startAddress); Writeln(' startAddress=0x',HexStr(addr,16)); Writeln(' pred =',Body^.predicationBoolean); diff --git a/sys/md/md_proc.pas b/sys/md/md_proc.pas index 5857d595..74a5da5c 100644 --- a/sys/md/md_proc.pas +++ b/sys/md/md_proc.pas @@ -23,7 +23,28 @@ uses kern_proc; function cpuset_setproc(new:Ptruint):Integer; +var + info:SYSTEM_INFO; + i,m,t,n:Integer; begin + new:=new and $FF; + + info.dwNumberOfProcessors:=1; + GetSystemInfo(info); + + if (info.dwNumberOfProcessors<8) then + begin + //remap + m:=0; + for i:=0 to 7 do + begin + t:=(new shr i) and 1; + n:=(i mod info.dwNumberOfProcessors); + m:=m or (t shl n); + end; + new:=m; + end; + Result:=NtSetInformationProcess(NtCurrentProcess, ProcessAffinityMask, @new, diff --git a/sys/md/md_thread.pas b/sys/md/md_thread.pas index d815a4f8..ada6a1aa 100644 --- a/sys/md/md_thread.pas +++ b/sys/md/md_thread.pas @@ -310,10 +310,31 @@ begin end; function cpuset_setaffinity(td:p_kthread;new:Ptruint):Integer; +var + info:SYSTEM_INFO; + i,m,t,n:Integer; begin if (td=nil) then Exit; if (td^.td_handle=0) or (td^.td_handle=THandle(-1)) then Exit(-1); + new:=new and $FF; + + info.dwNumberOfProcessors:=1; + GetSystemInfo(info); + + if (info.dwNumberOfProcessors<8) then + begin + //remap + m:=0; + for i:=0 to 7 do + begin + t:=(new shr i) and 1; + n:=(i mod info.dwNumberOfProcessors); + m:=m or (t shl n); + end; + new:=m; + end; + td^.td_cpuset:=new; Result:=NtSetInformationThread(td^.td_handle,ThreadAffinityMask,@new,SizeOf(Ptruint)); end;