Skip to content

Commit 817b48d

Browse files
committed
m1n1.fw.agx & co: Unbork a bunch of stuff on <G14X
Signed-off-by: Asahi Lina <[email protected]>
1 parent b270f2f commit 817b48d

5 files changed

Lines changed: 73 additions & 32 deletions

File tree

proxyclient/m1n1/agx/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ def check_fault(self):
283283
if not fault_info.FAULTED:
284284
return
285285

286-
fault_addr = getattr(self.sgx, "FAULT_ADDR", None).val
286+
fault_addr = getattr(self.sgx, "FAULT_ADDR", None)
287287
if fault_addr is not None:
288-
fault_addr <<= 6
288+
fault_addr = fault_addr.val << 6
289289
else:
290290
fault_addr = fault_info.ADDR << 6
291291

proxyclient/m1n1/agx/initdata.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ def iomap(phys, size, range_size, rw):
5959
iomap(0x27d050000, 0x4000, 0x4000, 0), # Streaming codec registers
6060
iomap(0x23b3d0000, 0x1000, 0x1000, 0), #
6161
iomap(0x23b3c0000, 0x1000, 0x1000, 0), #
62+
IOMapping(),
63+
IOMapping(),
64+
IOMapping(),
65+
IOMapping(),
66+
IOMapping(),
6267
]
6368
elif chip_id in (0x6000, 0x6001, 0x6002):
6469
mcc_cnt = {0x6002: 16, 0x6001: 8, 0x6000: 4}
@@ -111,6 +116,7 @@ def iomap(phys, size, range_size, rw):
111116
iomap(0x404eac000, 0x4000, 0x4000, 1),
112117
IOMapping(),
113118
IOMapping(),
119+
IOMapping(),
114120
]
115121

116122
CHIP_INFO = {
@@ -125,7 +131,9 @@ def iomap(phys, size, range_size, rw):
125131
unk_e48 = [[0] * 8] * 8,
126132
unk_e24 = 112,
127133
gpu_fast_die0_sensor_mask64 = 0x12,
134+
gpu_fast_die1_sensor_mask64 = 0,
128135
gpu_fast_die0_sensor_mask64_alt = 0x12,
136+
gpu_fast_die1_sensor_mask64_alt = 0,
129137
gpu_fast_die0_sensor_present = 0x01,
130138
shared1_tab = [
131139
-1, 0x7282, 0x50ea, 0x370a, 0x25be, 0x1c1f, 0x16fb
@@ -162,14 +170,17 @@ def iomap(phys, size, range_size, rw):
162170
]],
163171
unk_e24 = 125,
164172
gpu_fast_die0_sensor_mask64 = 0x80808080,
173+
gpu_fast_die1_sensor_mask64 = 0,
165174
gpu_fast_die0_sensor_mask64_alt = 0x90909090,
175+
gpu_fast_die1_sensor_mask64_alt = 0,
166176
gpu_fast_die0_sensor_present = 0x0f,
167177
shared1_tab = [0xffff] * 16,
168178
shared1_a4 = 0xffff,
169179
shared2_tab = [-1, -1, -1, -1, 0x2aa, 0xaaa, -1, -1, 0, 0],
170180
shared2_unk_508 = 0xcc00001,
171181
unk_3cf4 = [1314.0, 1330.0, 1314.0, 1288.0, 0, 0, 0, 0],
172182
unk_3d14 = [21.0, 21.0, 22.0, 21.0, 0, 0, 0, 0],
183+
unk_3d34_0 = [0, 0, 0, 0, 0, 0, 0, 0],
173184
unk_118ec = [
174185
0, 1, 2,
175186
1, 1, 90, 75, 1, 1,
@@ -203,7 +214,9 @@ def iomap(phys, size, range_size, rw):
203214
]],
204215
unk_e24 = 125,
205216
gpu_fast_die0_sensor_mask64 = 0x8080808080808080,
217+
gpu_fast_die1_sensor_mask64 = 0,
206218
gpu_fast_die0_sensor_mask64_alt = 0x9090909090909090,
219+
gpu_fast_die1_sensor_mask64_alt = 0,
207220
gpu_fast_die0_sensor_present = 0xff,
208221
shared1_tab = [0xffff] * 16,
209222
shared1_a4 = 0xffff,
@@ -212,6 +225,7 @@ def iomap(phys, size, range_size, rw):
212225
unk_3cf4 = [1244.0, 1260.0, 1242.0, 1214.0,
213226
1072.0, 1066.0, 1044.0, 1042.0],
214227
unk_3d14 = [18.0, 18.0, 18.0, 17.0, 15.0, 15.0, 15.0, 14.0],
228+
unk_3d34_0 = [0, 0, 0, 0, 0, 0, 0, 0],
215229
unk_8924 = 0,
216230
unk_118ec = [
217231
0, 1, 2,
@@ -238,22 +252,25 @@ def iomap(phys, size, range_size, rw):
238252
unk_8cc = 11000,
239253
unk_924 = [[
240254
0.0, 0.0, 0.0, 0.0,
241-
5.3, 0.0, 5.3, 6.6,
255+
5.3, 0.0, 5.3, 5.3,
242256
]] + ([[0] * 8] * 7),
243257
unk_e48 = [[
244258
0.0, 0.0, 0.0, 0.0,
245-
5.3, 0.0, 5.3, 6.6,
259+
5.3, 0.0, 5.3, 5.3,
246260
]] + ([[0] * 8] * 7),
247261
unk_e24 = 125,
248262
gpu_fast_die0_sensor_mask64 = 0x6800,
263+
gpu_fast_die1_sensor_mask64 = 0,
249264
gpu_fast_die0_sensor_mask64_alt = 0x6800,
265+
gpu_fast_die1_sensor_mask64_alt = 0,
250266
gpu_fast_die0_sensor_present = 0x02,
251267
shared1_tab = [0xffff] * 16,
252268
shared1_a4 = 0,
253269
shared2_tab = [-1, -1, -1, -1, -1, -1, -1, -1, 0xaa5aa, 0],
254270
shared2_unk_508 = 0xc00000,
255271
unk_3cf4 = [1920.0, 0, 0, 0, 0, 0, 0, 0],
256272
unk_3d14 = [74.0, 0, 0, 0, 0, 0, 0, 0],
273+
unk_3d34_0 = [0, 0, 0, 0, 0, 0, 0, 0],
257274
unk_118ec = None,
258275
hwdb_4e0 = 4,
259276
hwdb_534 = 0,
@@ -271,8 +288,8 @@ def iomap(phys, size, range_size, rw):
271288
unk_hws2_0 = 0,
272289
unk_hws2_4 = [0] * 8,
273290
unk_hws2_24 = 0,
274-
sram_base = 0x404d60000,
275-
sram_size = 0x20000,
291+
sram_base = 0,
292+
sram_size = 0,
276293
shared3_unk = 5,
277294
shared3_tab = [
278295
10700, 10700, 10700, 10700,
@@ -354,9 +371,9 @@ def build_initdata(agx):
354371

355372
initdata = agx.kshared.new(InitData)
356373

357-
if Ver.check("V == V13_3 && G == G14X"):
374+
if Ver.check("V >= V13_3 && G == G14X"):
358375
initdata.ver_info = (0xb390, 0x70f8, 0x601, 0xb0)
359-
elif Ver.check("V == V13_3 && G == G14"):
376+
elif Ver.check("V >= V13_3 && G == G14"):
360377
initdata.ver_info = (0x6ba0, 0x1f28, 0x601, 0xb0)
361378
else:
362379
initdata.ver_info = (1, 1, 16, 1)
@@ -394,6 +411,8 @@ def build_initdata(agx):
394411
hwdata.sgx_sram_ptr = virt
395412
agx.uat.iomap_at(0, virt, chip_info.sram_base, chip_info.sram_size,
396413
AttrIndex=MemoryAttr.Shared)
414+
else:
415+
hwdata.sgx_sram_ptr = 0
397416

398417
k = 1.02 #?
399418
count = sgx.perf_state_count
@@ -426,6 +445,11 @@ def build_initdata(agx):
426445
hwdata.cs_voltages = [[(ps.volt // 1000), 0]
427446
for ps in cs_pstates.states] + [[0, 0]] * (16 - cs_pstates.count)
428447
hwdata.cs_voltages_sram = [[max(i[0], cs_pstates.min_sram_volt // 1000) if i[0] else 0, 0] for i in hwdata.cs_voltages]
448+
else:
449+
hwdata.cs_max_pstate = 0
450+
hwdata.cs_frequencies = [0] * 16
451+
hwdata.cs_voltages = [[0, 0]] * 16
452+
hwdata.cs_voltages_sram = [[0, 0]] * 16
429453

430454
afr_pstates = sgx.getprop("afr-perf-states", None)
431455
if afr_pstates:
@@ -435,6 +459,11 @@ def build_initdata(agx):
435459
hwdata.afr_voltages = [[(ps.volt // 1000), 0]
436460
for ps in afr_pstates.states] + [[0, 0]] * (8 - afr_pstates.count)
437461
hwdata.afr_voltages_sram = [[max(i[0], afr_pstates.min_sram_volt // 1000) if i[0] else 0, 0] for i in hwdata.afr_voltages]
462+
else:
463+
hwdata.afr_max_pstate = 0
464+
hwdata.afr_frequencies = [0] * 8
465+
hwdata.afr_voltages = [[0, 0]] * 8
466+
hwdata.afr_voltages_sram = [[0, 0]] * 8
438467

439468
regionB.hwdata_a.push()
440469

proxyclient/m1n1/agx/render.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def submit(self, cmdbuf, wait_for=None):
541541
wc_3d.struct_1.unk_38 = 0x0
542542
wc_3d.struct_1.unk_3c = 0x1
543543
wc_3d.struct_1.unk_40 = 0
544-
wc_3d.struct_1.unk_44_padding = bytes(0xac)
544+
wc_3d.struct_1.unk_44_padding = bytes(0x9c)
545545

546546
if not use_registers:
547547
wc_3d.struct_2 = Start3DStruct2()
@@ -551,9 +551,9 @@ def submit(self, cmdbuf, wait_for=None):
551551
wc_3d.struct_2.unk_18 = ppp_multisamplectl
552552
wc_3d.struct_2.scissor_array = cmdbuf.scissor_array
553553
wc_3d.struct_2.depth_bias_array = cmdbuf.depth_bias_array
554-
wc_3d.struct_2.aux_fb = wc_3d.struct_1.aux_fb
554+
wc_3d.struct_2.aux_fb = AuxFBInfo(iogpu_unk_214, 0, width, height)
555555
# ISP_ZLS_PIXELS
556-
wc_3d.struct_2.depth_dimensions = wc_3d.struct_1.depth_dimensions
556+
wc_3d.struct_2.depth_dimensions = (width - 1) | ((height - 1) << 15)
557557
wc_3d.struct_2.visibility_result_buffer = 0x0
558558
# ISP_ZLSCTL
559559
wc_3d.struct_2.depth_flags = cmdbuf.ds_flags
@@ -686,9 +686,14 @@ def fui(v):
686686

687687
if True:
688688
wc_3d.struct_3 = Start3DStruct3()
689-
wc_3d.struct_3.registers_addr = wc_3d.registers[0]._addr
690-
wc_3d.struct_3.register_count = reg_count
691-
wc_3d.struct_3.registers_length = reg_count * 12
689+
if use_registers:
690+
wc_3d.struct_3.registers_addr = wc_3d.registers[0]._addr
691+
wc_3d.struct_3.register_count = reg_count
692+
wc_3d.struct_3.registers_length = reg_count * 12
693+
else:
694+
wc_3d.struct_3.registers_addr = 0
695+
wc_3d.struct_3.register_count = 0
696+
wc_3d.struct_3.registers_length = 0
692697
wc_3d.struct_3.unk_d8 = 0
693698
wc_3d.struct_3.depth_bias_array = Start3DArrayAddr(cmdbuf.depth_bias_array)
694699
wc_3d.struct_3.scissor_array = Start3DArrayAddr(cmdbuf.scissor_array)
@@ -704,7 +709,7 @@ def fui(v):
704709
wc_3d.struct_3.reload_pipeline = Start3DClearPipelineBinding(
705710
cmdbuf.partial_reload_pipeline_bind, cmdbuf.partial_reload_pipeline | 4)
706711
wc_3d.struct_3.depth_flags = cmdbuf.ds_flags | 0x44
707-
wc_3d.struct_3.unk_290 = 0x0
712+
wc_3d.struct_3.unk_290 = 0x4040404
708713
wc_3d.struct_3.depth_buffer_ptr1 = cmdbuf.depth_buffer
709714
wc_3d.struct_3.unk_2a0 = 0x0
710715
wc_3d.struct_3.unk_2a8 = 0x0
@@ -721,7 +726,10 @@ def fui(v):
721726
wc_3d.struct_3.aux_fb_unk0 = tib_blocks
722727
wc_3d.struct_3.unk_30c = 0x0
723728
wc_3d.struct_3.aux_fb = AuxFBInfo(iogpu_unk_214, 0, width, height)
724-
wc_3d.struct_3.s2_unk_f8 = tile_config
729+
if use_registers:
730+
wc_3d.struct_3.s2_unk_f8 = tile_config
731+
else:
732+
wc_3d.struct_3.s2_unk_f8 = 0
725733
wc_3d.struct_3.unk_324_padding = bytes(0xc)
726734
wc_3d.struct_3.unk_partial_store_pipeline = Start3DStorePipelineBinding(
727735
cmdbuf.partial_store_pipeline_bind, cmdbuf.partial_store_pipeline | 4)
@@ -948,7 +956,7 @@ def fui(v):
948956
wc_ta.unk_emptybuf_addr = wc_3d.unk_emptybuf_addr
949957
wc_ta.unk_34 = 0x0
950958

951-
wc_ta.unk_3e8 = bytes(0x74)
959+
wc_ta.unk_3e8 = bytes(0x64)
952960
wc_ta.unk_594 = WorkCommand0_UnkBuf()
953961

954962
wc_ta.ts1 = TimeStamp(0)
@@ -1194,7 +1202,7 @@ def fui(v):
11941202
if Ver.check("G >= G14X"):
11951203
ms.append(Wait2Cmd())
11961204
else:
1197-
ms.append(WaitForInterruptCmd(0, 1, 0))
1205+
ms.append(WaitForInterruptCmd(1, 0, 0))
11981206

11991207
ts2 = TimestampCmd()
12001208
ts2.unk_1 = 0x0

proxyclient/m1n1/fw/agx/cmdqueue.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class WorkCommand3D(ConstructClass):
274274
Ver("V >= V13_0B4", "unk_928_4" / Int8ul),
275275
Ver("V >= V13_0B4", "unk_ts" / TimeStamp),
276276
Ver("V >= V13_0B4", "unk_928_d" / Default(HexDump(Bytes(0x1b)), bytes(0x1b))),
277-
Ver("V >= V13_3", "unk_pad2" / Default(HexDump(Bytes(0x3c)), bytes(0x3c))),
277+
Ver("V == V13_3", "unk_pad2" / Default(HexDump(Bytes(0x3c)), bytes(0x3c))),
278278
)
279279

280280
class WorkCommand0_UnkBuf(ConstructValueClass):
@@ -549,6 +549,7 @@ def __init__(self):
549549
self.unk_58 = 0x0
550550
self.busy = 0x0
551551
self.blocked_on_barrier = 0x0
552+
self.unk_80 = 0
552553
self.unk_88 = 0
553554
self.unk_8c = 0
554555
self.unk_90 = 0

proxyclient/m1n1/fw/agx/initdata.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class AGXHWDataT81xx(ConstructClass):
286286
"unk_dcc" / Int32ul,
287287
)
288288
def __init__(self, sgx, chip_info):
289-
if chip_info.chip_id in (0x8103, 0x8112):
289+
if chip_info.chip_id in (0x8103, 0x8112) and Ver.check("V < V13_3"):
290290
self.unk_d8c = 0x80000000
291291
self.unk_d90 = 4
292292
self.unk_d94 = 0
@@ -979,7 +979,10 @@ def __init__(self, sgx, chip_info):
979979
self.unk_3644 = 0
980980
self.hws1 = AGXHWDataShared1(chip_info)
981981
self.hws2 = AGXHWDataShared2(sgx, chip_info)
982-
self.unk_hws2 = [0 if i == 0xffff else i // 2 for i in self.hws2.unk_38.curve2.t1]
982+
if Ver.check("G >= G14X"):
983+
self.unk_hws2 = [0 if i == 0xffff else i // 2 for i in self.hws2.unk_38.curve2.t1]
984+
else:
985+
self.unk_hws2 = [0] * 16
983986
self.unk_3c00 = 0
984987
self.unk_3c04 = 0
985988
self.hws3 = AGXHWDataShared3(chip_info)
@@ -1197,8 +1200,8 @@ class AGXHWDataB(ConstructClass):
11971200
"unk_b68" / Int32ul,
11981201
Ver("V >= V13_0B4", "unk_b6c" / HexDump(Bytes(0xd0))),
11991202
Ver("G >= G14X", "unk_c3c_0" / Default(HexDump(Bytes(0x8)), bytes(0x8))),
1200-
Ver("G >= G14X && V < V13_3", "unk_c3c_8" / Default(HexDump(Bytes(0x30)), bytes(0x30))),
1201-
Ver("G >= G14X && V >= V13_5B4", "unk_c3c_8" / Default(HexDump(Bytes(0x20)), bytes(0x20))),
1203+
Ver("G < G14X && V >= V13_5B4", "unk_c3c_8" / Default(HexDump(Bytes(0x10)), bytes(0x10))),
1204+
Ver("V >= V13_5B4", "unk_c3c_10" / Default(HexDump(Bytes(0x20)), bytes(0x20))),
12021205
Ver("V >= V13_0B4", "unk_c3c" / Int32ul),
12031206
)
12041207

@@ -1461,20 +1464,20 @@ def __init__(self):
14611464
class InitData_GPUStatsTA(ConstructClass):
14621465
subcon = Struct(
14631466
"unk_4" / Int32ul,
1464-
Ver("V < V13_0B4", "queues" / Array(4, InitData_GPUQueueStatsTA)),
1465-
Ver("V >= V13_0B4", "queues" / Array(8, InitData_GPUQueueStatsTA)),
1467+
Ver("G < G14X", "queues" / Array(4, InitData_GPUQueueStatsTA)),
1468+
Ver("G >= G14X", "queues" / Array(8, InitData_GPUQueueStatsTA)),
14661469
"unk_68" / Bytes(0x8),
14671470
"unk_70" / Int32ul,
14681471
"unk_74" / Int32ul,
14691472
Ver("V >= V13_0B4", "unk_c0" / HexDump(Bytes(0x558))),
14701473
"unk_timestamp" / Array(16, Int64ul),
14711474
"unk_80" / HexDump(Bytes(0x40)),
1472-
Ver("V >= V13_3", "unk_684" / HexDump(Bytes(0x800))),
1475+
Ver("G >= G14X", "unk_684" / HexDump(Bytes(0x800))),
14731476
)
14741477

14751478
def __init__(self):
14761479
self.unk_4 = 0
1477-
if Ver.check("V >= V13_0B4"):
1480+
if Ver.check("G >= G14X"):
14781481
self.queues = [InitData_GPUQueueStatsTA() for i in range(8)]
14791482
else:
14801483
self.queues = [InitData_GPUQueueStatsTA() for i in range(4)]
@@ -1507,8 +1510,8 @@ class InitData_GPUStats3D(ConstructClass):
15071510
subcon = Struct(
15081511
"unk_0" / Bytes(0x18),
15091512
Ver("G >= G14X", "unk_d0_0" / Default(HexDump(Bytes(0x50)), bytes(0x50))),
1510-
Ver("V < V13_0B4", "queues" / Array(4, InitData_GPUQueueStats3D)),
1511-
Ver("V >= V13_0B4", "queues" / Array(8, InitData_GPUQueueStats3D)),
1513+
Ver("G < G14X", "queues" / Array(4, InitData_GPUQueueStats3D)),
1514+
Ver("G >= G14X", "queues" / Array(8, InitData_GPUQueueStats3D)),
15121515
Ver("G >= G14X", "unk_d0_0" / Default(HexDump(Bytes(0x820)), bytes(0x820))),
15131516
"unk_d0" / HexDump(Bytes(0x38)),
15141517
"tvb_overflows_1" / Int32ul,
@@ -1530,7 +1533,7 @@ class InitData_GPUStats3D(ConstructClass):
15301533

15311534
def __init__(self):
15321535
self.unk_0 = bytes(0x18)
1533-
if Ver.check("V >= V13_0B4"):
1536+
if Ver.check("G >= G14X"):
15341537
self.queues = [InitData_GPUQueueStats3D() for i in range(8)]
15351538
else:
15361539
self.queues = [InitData_GPUQueueStats3D() for i in range(4)]
@@ -1856,7 +1859,7 @@ def __init__(self, sgx, chip_info):
18561859
self.debug = 0
18571860
self.unk_28_4 = 0
18581861
self.unk_28 = 1
1859-
if Ver.check("V >= V13_3"):
1862+
if Ver.check("G >= G14X"):
18601863
self.unk_2c_0 = 1
18611864
else:
18621865
self.unk_2c_0 = 0
@@ -1966,7 +1969,7 @@ def __init__(self, sgx, chip_info):
19661969
self.idle_to_off_delay_ms = sgx.getprop("gpu-idle-off-delay-ms", 2)
19671970
self.fender_idle_to_off_delay_ms = sgx.getprop("gpu-fender-idle-off-delay-ms", 40)
19681971
self.fw_early_wake_timeout_ms = sgx.getprop("gpu-fw-early-wake-timeout-ms", 5)
1969-
self.pending_stamps = [InitData_PendingStamp() for i in range(0x110)]
1972+
self.pending_stamps = [InitData_PendingStamp() for i in range(0x100)]
19701973
self.unk_117bc = 0
19711974
self.fault_info = InitData_FaultInfo()
19721975
self.counter = 0

0 commit comments

Comments
 (0)