mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-12-23 12:03:11 +00:00
m1n1.agx: Timestamp stuff
Signed-off-by: Asahi Lina <lina@asahilina.net>
This commit is contained in:
parent
8c38ca2380
commit
7fe9544e90
7 changed files with 73 additions and 62 deletions
|
@ -77,13 +77,15 @@ class AGX:
|
|||
self.kgpurw = GPUAllocator(self, "kernel GPU RW",
|
||||
self.kern_va_base + 0x70000000, 0x1000000,
|
||||
AttrIndex=MemoryAttr.Shared, AP=0, UXN=1, PXN=1)
|
||||
self.ktimestamp = GPUAllocator(self, "ktimestamp",
|
||||
self.kern_va_base + 0x71000000, 0x4000000,
|
||||
AttrIndex=MemoryAttr.Shared, AP=1, guard_pages=1)
|
||||
|
||||
self.klow = GPUAllocator(self, "kernel_low",
|
||||
0x1500000000, 0x100000,
|
||||
AttrIndex=MemoryAttr.Shared, AP=0, UXN=1, PXN=1)
|
||||
self.klow.align_to_end = False
|
||||
|
||||
|
||||
self.io_allocator = Heap(self.kern_va_base + 0x68000000,
|
||||
self.kern_va_base + 0x70000000,
|
||||
block=self.PAGE_SIZE)
|
||||
|
|
|
@ -499,6 +499,7 @@ def build_initdata(agx):
|
|||
|
||||
# size: 0xb80, io stuff
|
||||
hwdata = agx.kobj.new(AGXHWDataB(sgx, chip_info), track=False)
|
||||
hwdata.timestamp_region_base = agx.ktimestamp.start
|
||||
hwdata.io_mappings = build_iomappings(agx, chosen.chip_id)
|
||||
|
||||
if chip_info.sram_base:
|
||||
|
|
|
@ -185,6 +185,8 @@ class GPUAllocator:
|
|||
self.agx = agx
|
||||
self.ctx = ctx
|
||||
self.name = name
|
||||
self.start = start
|
||||
self.size = size
|
||||
self.va = Heap(start, start + size, block=va_block)
|
||||
self.verbose = 0
|
||||
self.guard_pages = guard_pages
|
||||
|
|
|
@ -146,11 +146,6 @@ class GPURenderer:
|
|||
|
||||
##### Work Queues
|
||||
|
||||
self.ts3d_1 = agx.kshared.new(Int64ul, name="3D timestamp 1")
|
||||
self.ts3d_2 = agx.kshared.new(Int64ul, name="3D timestamp 2")
|
||||
self.tsta_1 = agx.kshared.new(Int64ul, name="TA timestamp 1")
|
||||
self.tsta_2 = agx.kshared.new(Int64ul, name="TA timestamp 2")
|
||||
|
||||
self.wq_3d = GPU3DWorkQueue(agx, ctx, self.job_list)
|
||||
self.wq_ta = GPUTAWorkQueue(agx, ctx, self.job_list)
|
||||
|
||||
|
@ -228,6 +223,23 @@ class GPURenderer:
|
|||
work = GPUWork(self)
|
||||
self.work.append(work)
|
||||
|
||||
def mktimestamp(alloc, name):
|
||||
ts = alloc.new(Int64ul, name=name)
|
||||
ts.val = 0
|
||||
ts.push()
|
||||
work.add(ts)
|
||||
return ts
|
||||
|
||||
work.ts3d_start = mktimestamp(self.agx.kshared, "3D timestamp start")
|
||||
work.ts3d_end = mktimestamp(self.agx.kshared, "3D timestamp end")
|
||||
work.tsta_start = mktimestamp(self.agx.kshared, "TA timestamp start")
|
||||
work.tsta_end = mktimestamp(self.agx.kshared, "TA timestamp end")
|
||||
|
||||
work.ns3d_start = mktimestamp(self.agx.ktimestamp, "3D user timestamp start")
|
||||
work.ns3d_end = mktimestamp(self.agx.ktimestamp, "3D user timestamp end")
|
||||
work.nsta_start = mktimestamp(self.agx.ktimestamp, "TA timestamp start")
|
||||
work.nsta_end = mktimestamp(self.agx.ktimestamp, "TA timestamp end")
|
||||
|
||||
self.buffer_mgr.increment()
|
||||
|
||||
aux_fb = self.ctx.uobj.new_buf(0x20000, "Aux FB thing", track=False)
|
||||
|
@ -503,16 +515,14 @@ class GPURenderer:
|
|||
wc_3d.unk_buf2.unk_8 = 0
|
||||
wc_3d.unk_buf2.unk_10 = 1
|
||||
wc_3d.ts1 = TimeStamp(0)
|
||||
wc_3d.ts2 = TimeStamp(self.ts3d_1._addr)
|
||||
wc_3d.ts3 = TimeStamp(self.ts3d_2._addr)
|
||||
wc_3d.unk_914 = 0
|
||||
wc_3d.unk_918 = 0
|
||||
wc_3d.unk_920 = 0
|
||||
wc_3d.ts_pointers = TimeStampPointers(work.ts3d_start._addr, work.ts3d_end._addr)
|
||||
wc_3d.user_ts_pointers = TimeStampPointers(work.ns3d_start._addr, work.ns3d_end._addr)
|
||||
wc_3d.client_sequence = 1
|
||||
# Ventura
|
||||
wc_3d.unk_928_0 = 0
|
||||
wc_3d.unk_928_4 = 0
|
||||
wc_3d.unk_ts = TimeStamp()
|
||||
wc_3d.unk_ts2 = TimeStamp()
|
||||
|
||||
use_registers = Ver.check("G >= G14X")
|
||||
|
||||
|
@ -843,10 +853,10 @@ class GPURenderer:
|
|||
ts1.unk_2 = 0x0
|
||||
ts1.unk_3 = 0x80
|
||||
ts1.ts0_addr = wc_3d.ts1._addr
|
||||
ts1.ts1_addr = wc_3d.ts2._addr
|
||||
ts1.ts2_addr = wc_3d.ts2._addr
|
||||
ts1.ts_pointers_addr = wc_3d.ts_pointers._addr
|
||||
ts1.unk_addr = 0xdeadbeef
|
||||
ts1.cmdqueue_ptr = self.wq_3d.info._addr
|
||||
ts1.unk_24 = 0x0
|
||||
ts1.user_ts_pointers_addr = wc_3d.user_ts_pointers._addr
|
||||
if Ver.check("V >= V13_0B4"):
|
||||
ts1.unk_ts_addr = wc_3d.unk_ts._addr
|
||||
ts1.uuid = uuid_3d
|
||||
|
@ -863,10 +873,10 @@ class GPURenderer:
|
|||
ts2.unk_2 = 0x0
|
||||
ts2.unk_3 = 0x0
|
||||
ts2.ts0_addr = wc_3d.ts1._addr
|
||||
ts2.ts1_addr = wc_3d.ts2._addr
|
||||
ts2.ts2_addr = wc_3d.ts3._addr
|
||||
ts2.ts_pointers_addr = wc_3d.ts_pointers._addr
|
||||
ts2.unk_addr = 0xdeadbeef
|
||||
ts2.cmdqueue_ptr = self.wq_3d.info._addr
|
||||
ts2.unk_24 = 0x0
|
||||
ts2.user_ts_pointers_addr = wc_3d.user_ts_pointers._addr
|
||||
if Ver.check("V >= V13_0B4"):
|
||||
ts2.unk_ts_addr = wc_3d.unk_ts._addr
|
||||
ts2.uuid = uuid_3d
|
||||
|
@ -962,17 +972,14 @@ class GPURenderer:
|
|||
wc_ta.unk_594 = WorkCommand0_UnkBuf()
|
||||
|
||||
wc_ta.ts1 = TimeStamp(0)
|
||||
wc_ta.ts2 = TimeStamp(self.tsta_1._addr)
|
||||
wc_ta.ts3 = TimeStamp(self.tsta_2._addr)
|
||||
wc_ta.unk_5c4 = 0
|
||||
wc_ta.unk_5c8 = 0
|
||||
wc_ta.unk_5cc = 0
|
||||
wc_ta.unk_5d0 = 0
|
||||
wc_ta.ts_pointers = TimeStampPointers(work.tsta_start._addr, work.tsta_end._addr)
|
||||
wc_ta.user_ts_pointers = TimeStampPointers(work.nsta_start._addr, work.nsta_end._addr)
|
||||
wc_ta.client_sequence = 1
|
||||
# Ventura
|
||||
wc_ta.unk_5d8_0 = 0
|
||||
wc_ta.unk_5d8_4 = 0
|
||||
wc_ta.unk_ts = TimeStamp()
|
||||
wc_ta.unk_ts2 = TimeStamp()
|
||||
|
||||
# Structures embedded in WorkCommandTA
|
||||
if not use_registers:
|
||||
|
@ -1195,10 +1202,10 @@ class GPURenderer:
|
|||
ts1.unk_2 = 0x0
|
||||
ts1.unk_3 = 0x80
|
||||
ts1.ts0_addr = wc_ta.ts1._addr
|
||||
ts1.ts1_addr = wc_ta.ts2._addr
|
||||
ts1.ts2_addr = wc_ta.ts2._addr
|
||||
ts1.ts_pointers_addr = wc_ta.ts_pointers._addr
|
||||
ts1.unk_addr = 0xdeadbeef
|
||||
ts1.cmdqueue_ptr = self.wq_ta.info._addr
|
||||
ts1.unk_24 = 0x0
|
||||
ts1.user_ts_pointers_addr = wc_ta.user_ts_pointers._addr
|
||||
if Ver.check("V >= V13_0B4"):
|
||||
ts1.unk_ts_addr = wc_ta.unk_ts._addr
|
||||
ts1.uuid = uuid_ta
|
||||
|
@ -1215,10 +1222,10 @@ class GPURenderer:
|
|||
ts2.unk_2 = 0x0
|
||||
ts2.unk_3 = 0x0
|
||||
ts2.ts0_addr = wc_ta.ts1._addr
|
||||
ts2.ts1_addr = wc_ta.ts2._addr
|
||||
ts2.ts2_addr = wc_ta.ts3._addr
|
||||
ts2.ts_pointers_addr = wc_ta.ts_pointers._addr
|
||||
ts2.unk_addr = 0xdeadbeef
|
||||
ts2.cmdqueue_ptr = self.wq_ta.info._addr
|
||||
ts2.unk_24 = 0x0
|
||||
ts2.user_ts_pointers_addr = wc_ta.user_ts_pointers._addr
|
||||
if Ver.check("V >= V13_0B4"):
|
||||
ts2.unk_ts_addr = wc_ta.unk_ts._addr
|
||||
ts2.uuid = uuid_ta
|
||||
|
|
|
@ -178,18 +178,15 @@ class WorkCommandCP(ConstructClass):
|
|||
"encoder_params" / EncoderParams,
|
||||
"job_meta" / JobMeta,
|
||||
"ts1" / TimeStamp,
|
||||
"ts2" / TimeStamp,
|
||||
"ts3" / TimeStamp,
|
||||
"unk_2c0" / Int32ul,
|
||||
"unk_2c4" / Int32ul,
|
||||
"unk_2c8" / Int32ul,
|
||||
"unk_2cc" / Int32ul,
|
||||
"ts_pointers" / TimeStampPointers,
|
||||
"user_ts_pointers" / TimeStampPointers, # This is a guess, but it makes sense
|
||||
"client_sequence" / Int8ul,
|
||||
"pad_2d1" / Default(HexDump(Bytes(0x3)), bytes(0x3)),
|
||||
"unk_2d4" / Int32ul,
|
||||
"unk_2d8" / Int8ul,
|
||||
Ver("V >= V13_0B4", "unk_ts" / TimeStamp),
|
||||
Ver("V >= V13_0B4", "unk_2e1" / Default(HexDump(Bytes(0x1c)), bytes(0x1c))),
|
||||
Ver("V >= V13_0B4", "unk_ts2" / TimeStamp),
|
||||
Ver("V >= V13_0B4", "unk_2e9" / Default(HexDump(Bytes(0x14)), bytes(0x14))),
|
||||
Ver("V >= V13_0B4", "unk_flag" / Flag),
|
||||
Ver("V >= V13_0B4", "unk_pad" / Default(HexDump(Bytes(0x10)), bytes(0x10))),
|
||||
"pad_2d9" / Default(HexDump(Bytes(0x7)), bytes(0x7)),
|
||||
|
@ -281,17 +278,15 @@ class WorkCommand3D(ConstructClass):
|
|||
"struct_7" / Start3DStruct7,
|
||||
"unk_buf2" / WorkCommand1_UnkBuf2,
|
||||
"ts1" / TimeStamp,
|
||||
"ts2" / TimeStamp,
|
||||
"ts3" / TimeStamp,
|
||||
"unk_914" / Int32ul,
|
||||
"unk_918" / Int64ul,
|
||||
"unk_920" / Int32ul,
|
||||
"ts_pointers" / TimeStampPointers,
|
||||
"user_ts_pointers" / TimeStampPointers, # This is a guess, but it makes sense
|
||||
"client_sequence" / Int8ul,
|
||||
"pad_925" / Default(HexDump(Bytes(0x3)), bytes(0x3)),
|
||||
Ver("V >= V13_0B4", "unk_928_0" / Int32ul),
|
||||
Ver("V >= V13_0B4", "unk_928_4" / Int8ul),
|
||||
Ver("V >= V13_0B4", "unk_ts" / TimeStamp),
|
||||
Ver("V >= V13_0B4", "unk_928_d" / Default(HexDump(Bytes(0x1b)), bytes(0x1b))),
|
||||
Ver("V >= V13_0B4", "unk_ts2" / TimeStamp),
|
||||
Ver("V >= V13_0B4", "unk_928_15" / Default(HexDump(Bytes(0x13)), bytes(0x13))),
|
||||
Ver("V == V13_3", "unk_pad2" / Default(HexDump(Bytes(0x3c)), bytes(0x3c))),
|
||||
)
|
||||
|
||||
|
@ -365,19 +360,16 @@ class WorkCommandTA(ConstructClass):
|
|||
"unk_594" / WorkCommand0_UnkBuf,
|
||||
|
||||
"ts1" / TimeStamp,
|
||||
"ts2" / TimeStamp,
|
||||
"ts3" / TimeStamp,
|
||||
"ts_pointers" / TimeStampPointers,
|
||||
"user_ts_pointers" / TimeStampPointers, # This is a guess, but it makes sense
|
||||
|
||||
"unk_5c4" / Int32ul,
|
||||
"unk_5c8" / Int32ul,
|
||||
"unk_5cc" / Int32ul,
|
||||
"unk_5d0" / Int32ul,
|
||||
"client_sequence" / Int8ul,
|
||||
"pad_5d5" / Default(HexDump(Bytes(0x3)), bytes(0x3)),
|
||||
Ver("V >= V13_0B4", "unk_5d8_0" / Int32ul),
|
||||
Ver("V >= V13_0B4", "unk_5d8_4" / Int8ul),
|
||||
Ver("V >= V13_0B4", "unk_ts" / TimeStamp),
|
||||
Ver("V >= V13_0B4", "unk_5d8_d" / Default(HexDump(Bytes(0x13)), bytes(0x13))),
|
||||
Ver("V >= V13_0B4", "unk_ts2" / TimeStamp),
|
||||
Ver("V >= V13_0B4", "unk_5d8_15" / Default(HexDump(Bytes(0xb)), bytes(0xb))),
|
||||
"pad_5d8" / Default(HexDump(Bytes(0x8)), bytes(0x8)),
|
||||
Ver("V >= V13_3", "unk_pad2" / Default(HexDump(Bytes(0xc)), bytes(0xc))),
|
||||
)
|
||||
|
@ -411,12 +403,8 @@ class WorkCommandBlit(ConstructClass):
|
|||
"encoder_params" / EncoderParams,
|
||||
"unk_618" / Int32ul,
|
||||
"ts1" / TimeStamp,
|
||||
"ts2" / TimeStamp,
|
||||
"ts3" / TimeStamp,
|
||||
"unk_634" / Int32ul,
|
||||
"unk_638" / Int32ul,
|
||||
"unk_63c" / Int32ul,
|
||||
"unk_640" / Int32ul,
|
||||
"ts_pointers" / TimeStampPointers,
|
||||
"user_ts_pointers" / TimeStampPointers,
|
||||
"client_sequence" / Int8ul,
|
||||
"pad_645" / Default(HexDump(Bytes(0x3)), bytes(0x3)),
|
||||
"unk_648" / Int32ul,
|
||||
|
|
|
@ -1059,7 +1059,7 @@ class AGXHWDataB(ConstructClass):
|
|||
"unk_20" / Int64ul,
|
||||
"unk_28" / Int64ul,
|
||||
"unk_30" / Int64ul,
|
||||
"unkptr_38" / Int64ul,
|
||||
"timestamp_region_base" / Int64ul,
|
||||
"pad_40" / HexDump(Bytes(0x20)),
|
||||
Ver("V < V13_0B4", "yuv_matrices" / Array(15, Array(3, Array(4, Int16sl)))),
|
||||
Ver("V >= V13_0B4", "yuv_matrices" / Array(63, Array(3, Array(4, Int16sl)))),
|
||||
|
@ -1217,7 +1217,7 @@ class AGXHWDataB(ConstructClass):
|
|||
self.unk_30 = 0x6f_ffff8000
|
||||
self.pad_40 = bytes(0x20)
|
||||
# unmapped?
|
||||
self.unkptr_38 = 0xffffffa0_11800000
|
||||
self.timestamp_region_base = 0
|
||||
self.pad_1c8 = bytes(8)
|
||||
|
||||
# Note: these are rounded poorly, need to recompute.
|
||||
|
|
|
@ -28,6 +28,17 @@ class TimeStamp(ConstructValueClass):
|
|||
def __init__(self, value=0):
|
||||
self.value = value
|
||||
|
||||
class TimeStampPointers(ConstructClass):
|
||||
subcon = Struct(
|
||||
"start_addr" / Int64ul,
|
||||
"end_addr" / Int64ul,
|
||||
)
|
||||
|
||||
def __init__(self, start_addr=0, end_addr=0):
|
||||
super().__init__()
|
||||
self.start_addr = start_addr
|
||||
self.end_addr = end_addr
|
||||
|
||||
class TsFlag(ConstructValueClass):
|
||||
subcon = Int8ul
|
||||
|
||||
|
@ -906,12 +917,12 @@ class TimestampCmd(ConstructClass):
|
|||
# all these pointers point to 0xfa0... addresses. Might be where the timestamp should be writen?
|
||||
"ts0_addr" / Int64ul,
|
||||
"ts0" / ROPointer(this.ts0_addr, TimeStamp),
|
||||
"ts1_addr" / Int64ul,
|
||||
"ts1" / ROPointer(this.ts1_addr, TimeStamp),
|
||||
"ts2_addr" / Int64ul,
|
||||
"ts2" / ROPointer(this.ts2_addr, TimeStamp),
|
||||
"ts_pointers_addr" / Int64ul,
|
||||
"ts_pointers" / ROPointer(this.ts_pointers_addr, TimeStampPointers),
|
||||
"unk_addr" / Int64ul,
|
||||
"cmdqueue_ptr" / Int64ul,
|
||||
"unk_24" / Int64ul,
|
||||
"user_ts_pointers_addr" / Int64ul,
|
||||
"ts_pointers" / ROPointer(this.user_ts_pointers_addr, TimeStampPointers),
|
||||
Ver("V >= V13_0B4", "unk_ts_addr" / Int64ul),
|
||||
"uuid" / Int32ul,
|
||||
"unk_30" / Int32ul,
|
||||
|
|
Loading…
Reference in a new issue