; a7xx microcode
; Version: 01730001

[01730001]
[#jumptbl]
mov $01, 0x830	; CP_SQE_INSTR_BASE
mov $02, 0x2
cwrite $01, [$00 + @REG_READ_ADDR]
cwrite $02, [$00 + @REG_READ_DWORDS]
mov $01, $regdata
mov $02, $regdata
add $01, $01, 0x4
addhi $02, $02, 0x0
mov $03, 0x1
cwrite $01, [$00 + @MEM_READ_ADDR]
cwrite $02, [$00 + @MEM_READ_ADDR+0x1]
cwrite $03, [$00 + @MEM_READ_DWORDS]
rot $04, $memdata, 0x8
ushr $04, $04, 0x6
sub $04, $04, 0x4
add $01, $01, $04
addhi $02, $02, 0x0
mov $rem, 0x80
cwrite $01, [$00 + @MEM_READ_ADDR]
cwrite $02, [$00 + @MEM_READ_ADDR+0x1]
cwrite $02, [$00 + @LOAD_STORE_HI]
cwrite $rem, [$00 + @MEM_READ_DWORDS]
cwrite $00, [$00 + @PACKET_TABLE_WRITE_ADDR]
(rep)cwrite $memdata, [$00 + @PACKET_TABLE_WRITE]
add $01, $01, 0x200
addhi $02, $02, 0x0
cwrite $01, [$00 + @BV_INSTR_BASE]
cwrite $02, [$00 + @BV_INSTR_BASE+0x1]
cwrite $03, [$00 + @BV_CNTL]
add $01, $01, 0x4
addhi $02, $02, 0x0
cwrite $01, [$00 + @MEM_READ_ADDR]
cwrite $02, [$00 + @MEM_READ_ADDR+0x1]
cwrite $03, [$00 + @MEM_READ_DWORDS]
rot $04, $memdata, 0x8
ushr $04, $04, 0x6
sub $04, $04, 0x4
add $01, $01, $04
addhi $02, $02, 0x0
add $01, $01, 0x200
addhi $02, $02, 0x0
cwrite $01, [$00 + @LPAC_INSTR_BASE]
cwrite $02, [$00 + @LPAC_INSTR_BASE+0x1]
cwrite $03, [$00 + @LPAC_CNTL]
mov $02, 0x883	; CP_SCRATCH[0].REG
mov $03, 0xbeef
mov $04, 0xdead << 16
or $03, $03, $04
cwrite $02, [$00 + @REG_WRITE_ADDR]
cwrite $03, [$00 + @REG_WRITE]
waitin
mov $01, $data

CP_ME_INIT:
mov $02, 0x2
waitin
mov $01, $data

CP_MEM_WRITE:
mov $addr, 0xa0 << 24	; |NRT_ADDR
mov $02, 0x4
(xmov1)add $data, $02, $data
mov $addr, 0xa204 << 16	; |NRT_DATA
(rep)(xmov3)mov $data, $data
waitin
mov $01, $data

CP_SCRATCH_WRITE:
mov $02, 0xff
(rep)cwrite $data, [$02 + 0x1]!
waitin
mov $01, $data

CP_SET_DRAW_STATE:
(rep)(sds2)cwrite $data, [$00 + @DRAW_STATE_SET_HDR]
waitin
mov $01, $data

CP_SET_BIN_DATA5:
sread $02, [$00 + %SP]
swrite $02, [$00 + %SP]
mov $02, 0x7
(rep)swrite $data, [$02 + 0x1]!
waitin
mov $01, $data

CP_SET_SECURE_MODE:
mov $02, $data
setsecure $02, #l81

fxn79:
l79:
jump #l79
nop
l81:
waitin
mov $01, $data

fxn83:
l83:
cmp $04, $02, $03
breq $04, b0, #l90
brne $04, b1, #l88
breq $04, b2, #l83
sub $03, $03, $02
l88:
jump #l83
sub $02, $02, $03
l90:
ret
nop

CP_REG_RMW:
cwrite $data, [$00 + @REG_READ_ADDR]
add $02, $regdata, 0x42
addhi $03, $00, $regdata
sub $02, $02, $regdata
call #fxn83
subhi $03, $03, $regdata
and $02, $02, $regdata
or $02, $02, 0x1
xor $02, $02, 0x1
not $02, $02
shl $02, $02, $regdata
ushr $02, $02, $regdata
ishr $02, $02, $regdata
rot $02, $02, $regdata
min $02, $02, $regdata
max $02, $02, $regdata
mul8 $02, $02, $regdata
bic $02, $02, $regdata
msb $02, $02
bfi $02, $03, b1, b2
setbit $02, $02, b3
clrbit $02, $02, b4
setbit $02, $02, $03
ubfx $03, $02, b5, b6
mov $usraddr, $data
mov $data, $02
(peek)mov $00, $data
waitin
mov $01, $data

CP_MEMCPY:
mov $02, $data
mov $03, $data
mov $04, $data
mov $05, $data
mov $06, $data
l126:
breq $06, 0x0, #l132
cwrite $03, [$00 + @LOAD_STORE_HI]
load $07, [$02 + 0x4]!
cwrite $05, [$00 + @LOAD_STORE_HI]
jump #l126
store $07, [$04 + 0x4]!
l132:
waitin
mov $01, $data

CP_MEM_TO_MEM:
cwrite $data, [$00 + @MEM_READ_ADDR]
cwrite $data, [$00 + @MEM_READ_ADDR+0x1]
mov $02, $data
cwrite $data, [$00 + @LOAD_STORE_HI]
mov $rem, $data
cwrite $rem, [$00 + @MEM_READ_DWORDS]
(rep)store $memdata, [$02 + 0x4]!
waitin
mov $01, $data

IN_PREEMPT:
cread $02, [$00 + 0x101]
brne $02, 0x1, #l152
nop
bl #fxn79
nop
nop
nop
waitin
mov $01, $data
l152:
iret
nop

CP_BLIT:
CP_BOOTSTRAP_UCODE:
CP_BV_BR_COUNT_OPS:
CP_CCHE_INVALIDATE:
CP_COND_EXEC:
CP_COND_REG_EXEC:
CP_COND_WRITE5:
CP_CONTEXT_REG_BUNCH:
CP_CONTEXT_SWITCH_YIELD:
CP_CONTEXT_UPDATE:
CP_DRAW_AUTO:
CP_DRAW_INDIRECT:
CP_DRAW_INDIRECT_MULTI:
CP_DRAW_INDX:
CP_DRAW_INDX_INDIRECT:
CP_DRAW_INDX_OFFSET:
CP_DRAW_PRED_ENABLE_GLOBAL:
CP_DRAW_PRED_ENABLE_LOCAL:
CP_DRAW_PRED_SET:
CP_END_BIN:
CP_EVENT_WRITE7:
CP_EXEC_CS:
CP_EXEC_CS_INDIRECT:
CP_FIXED_STRIDE_DRAW_TABLE:
CP_GLOBAL_TIMESTAMP:
CP_INDIRECT_BUFFER:
CP_INDIRECT_BUFFER_CHAIN:
CP_INDIRECT_BUFFER_PFD:
CP_INTERRUPT:
CP_INVALIDATE_STATE:
CP_LOAD_STATE6:
CP_LOAD_STATE6_FRAG:
CP_LOAD_STATE6_GEOM:
CP_LOCAL_TIMESTAMP:
CP_MEM_TO_REG:
CP_MEM_TO_SCRATCH_MEM:
CP_MEM_WRITE_CNTR:
CP_MODIFY_TIMESTAMP:
CP_NON_CONTEXT_REG_BUNCH:
CP_NOP:
CP_RECORD_PFP_TIMESTAMP:
CP_REG_TEST:
CP_REG_TO_MEM:
CP_REG_TO_MEM_OFFSET_MEM:
CP_REG_TO_MEM_OFFSET_REG:
CP_REG_TO_SCRATCH:
CP_REG_WR_NO_CTXT:
CP_RESET_CONTEXT_STATE:
CP_RESOURCE_LIST:
CP_RUN_OPENCL:
CP_SCOPE_CNTL:
CP_SCRATCH_TO_REG:
CP_SET_AMBLE:
CP_SET_BIN_DATA5_OFFSET:
CP_SET_DRAW_INIT_FLAGS:
CP_SET_MARKER:
CP_SET_MODE:
CP_SET_PROTECTED_MODE:
CP_SET_PSEUDO_REG:
CP_SET_STATE:
CP_SET_SUBDRAW_SIZE:
CP_SET_UNK_BIN_DATA:
CP_SET_VISIBILITY_OVERRIDE:
CP_SKIP_IB2_ENABLE_GLOBAL:
CP_SKIP_IB2_ENABLE_LOCAL:
CP_SKIP_IB_MODE:
CP_SMMU_TABLE_UPDATE:
CP_START_BIN:
CP_TEST_TWO_MEMS:
CP_THREAD_CONTROL:
CP_WAIT_FOR_IDLE:
CP_WAIT_FOR_ME:
CP_WAIT_MEM_WRITES:
CP_WAIT_REG_EQ:
CP_WAIT_REG_MEM:
CP_WAIT_TIMESTAMP:
CP_WHERE_AM_I:
IN_GMU_INTERRUPT:
IN_IB_END:
PKT4:
UNKN0:
UNKN1:
UNKN103:
UNKN104:
UNKN105:
UNKN106:
UNKN109:
UNKN110:
UNKN112:
UNKN118:
UNKN119:
UNKN12:
UNKN121:
UNKN122:
UNKN123:
UNKN124:
UNKN125:
UNKN126:
UNKN13:
UNKN14:
UNKN2:
UNKN3:
UNKN30:
UNKN32:
UNKN43:
UNKN48:
UNKN5:
UNKN6:
UNKN7:
UNKN8:
UNKN84:
UNKN88:
UNKN89:
UNKN9:
UNKN90:
UNKN91:
UNKN96:
UNKN97:
waitin
mov $01, $data
nop
nop
nop
nop
.align 32
jumptbl:
.jumptbl

.section BV
;
; BV microcode:
;
[01000001]
[#jumptbl]
cread $01, [$00 + @BV_INSTR_BASE]
cread $02, [$00 + @BV_INSTR_BASE+0x1]
add $01, $01, 0x4
addhi $02, $02, 0x0
mov $03, 0x1
cwrite $01, [$00 + @MEM_READ_ADDR]
cwrite $02, [$00 + @MEM_READ_ADDR+0x1]
cwrite $03, [$00 + @MEM_READ_DWORDS]
rot $04, $memdata, 0x8
ushr $04, $04, 0x6
sub $04, $04, 0x4
add $01, $01, $04
addhi $02, $02, 0x0
mov $rem, 0x80
cwrite $01, [$00 + @MEM_READ_ADDR]
cwrite $02, [$00 + @MEM_READ_ADDR+0x1]
cwrite $02, [$00 + @LOAD_STORE_HI]
cwrite $rem, [$00 + @MEM_READ_DWORDS]
cwrite $00, [$00 + @PACKET_TABLE_WRITE_ADDR]
(rep)cwrite $memdata, [$00 + @PACKET_TABLE_WRITE]
add $01, $01, 0x200
addhi $02, $02, 0x0
cwrite $01, [$00 + @LPAC_INSTR_BASE]
cwrite $02, [$00 + @LPAC_INSTR_BASE+0x1]
waitin
mov $01, $data

CP_BLIT:
CP_BOOTSTRAP_UCODE:
CP_BV_BR_COUNT_OPS:
CP_CCHE_INVALIDATE:
CP_COND_EXEC:
CP_COND_REG_EXEC:
CP_COND_WRITE5:
CP_CONTEXT_REG_BUNCH:
CP_CONTEXT_SWITCH_YIELD:
CP_CONTEXT_UPDATE:
CP_DRAW_AUTO:
CP_DRAW_INDIRECT:
CP_DRAW_INDIRECT_MULTI:
CP_DRAW_INDX:
CP_DRAW_INDX_INDIRECT:
CP_DRAW_INDX_OFFSET:
CP_DRAW_PRED_ENABLE_GLOBAL:
CP_DRAW_PRED_ENABLE_LOCAL:
CP_DRAW_PRED_SET:
CP_END_BIN:
CP_EVENT_WRITE7:
CP_EXEC_CS:
CP_EXEC_CS_INDIRECT:
CP_FIXED_STRIDE_DRAW_TABLE:
CP_GLOBAL_TIMESTAMP:
CP_INDIRECT_BUFFER:
CP_INDIRECT_BUFFER_CHAIN:
CP_INDIRECT_BUFFER_PFD:
CP_INTERRUPT:
CP_INVALIDATE_STATE:
CP_LOAD_STATE6:
CP_LOAD_STATE6_FRAG:
CP_LOAD_STATE6_GEOM:
CP_LOCAL_TIMESTAMP:
CP_MEMCPY:
CP_MEM_TO_MEM:
CP_MEM_TO_REG:
CP_MEM_TO_SCRATCH_MEM:
CP_MEM_WRITE:
CP_MEM_WRITE_CNTR:
CP_ME_INIT:
CP_MODIFY_TIMESTAMP:
CP_NON_CONTEXT_REG_BUNCH:
CP_NOP:
CP_RECORD_PFP_TIMESTAMP:
CP_REG_RMW:
CP_REG_TEST:
CP_REG_TO_MEM:
CP_REG_TO_MEM_OFFSET_MEM:
CP_REG_TO_MEM_OFFSET_REG:
CP_REG_TO_SCRATCH:
CP_REG_WR_NO_CTXT:
CP_RESET_CONTEXT_STATE:
CP_RESOURCE_LIST:
CP_RUN_OPENCL:
CP_SCOPE_CNTL:
CP_SCRATCH_TO_REG:
CP_SCRATCH_WRITE:
CP_SET_AMBLE:
CP_SET_BIN_DATA5:
CP_SET_BIN_DATA5_OFFSET:
CP_SET_DRAW_INIT_FLAGS:
CP_SET_DRAW_STATE:
CP_SET_MARKER:
CP_SET_MODE:
CP_SET_PROTECTED_MODE:
CP_SET_PSEUDO_REG:
CP_SET_SECURE_MODE:
CP_SET_STATE:
CP_SET_SUBDRAW_SIZE:
CP_SET_UNK_BIN_DATA:
CP_SET_VISIBILITY_OVERRIDE:
CP_SKIP_IB2_ENABLE_GLOBAL:
CP_SKIP_IB2_ENABLE_LOCAL:
CP_SKIP_IB_MODE:
CP_SMMU_TABLE_UPDATE:
CP_START_BIN:
CP_TEST_TWO_MEMS:
CP_THREAD_CONTROL:
CP_WAIT_FOR_IDLE:
CP_WAIT_FOR_ME:
CP_WAIT_MEM_WRITES:
CP_WAIT_REG_EQ:
CP_WAIT_REG_MEM:
CP_WAIT_TIMESTAMP:
CP_WHERE_AM_I:
IN_GMU_INTERRUPT:
IN_IB_END:
IN_PREEMPT:
PKT4:
UNKN0:
UNKN1:
UNKN103:
UNKN104:
UNKN105:
UNKN106:
UNKN109:
UNKN110:
UNKN112:
UNKN118:
UNKN119:
UNKN12:
UNKN121:
UNKN122:
UNKN123:
UNKN124:
UNKN125:
UNKN126:
UNKN13:
UNKN14:
UNKN2:
UNKN3:
UNKN30:
UNKN32:
UNKN43:
UNKN48:
UNKN5:
UNKN6:
UNKN7:
UNKN8:
UNKN84:
UNKN88:
UNKN89:
UNKN9:
UNKN90:
UNKN91:
UNKN96:
UNKN97:
waitin
mov $01, $data
nop
nop
.align 32
jumptbl:
.jumptbl

.section LPAC
;
; LPAC microcode:
;
[01000001]
[#jumptbl]
cread $01, [$00 + @LPAC_INSTR_BASE]
cread $02, [$00 + @LPAC_INSTR_BASE+0x1]
add $01, $01, 0x4
addhi $02, $02, 0x0
mov $03, 0x1
cwrite $01, [$00 + @MEM_READ_ADDR]
cwrite $02, [$00 + @MEM_READ_ADDR+0x1]
cwrite $03, [$00 + @MEM_READ_DWORDS]
rot $04, $memdata, 0x8
ushr $04, $04, 0x6
sub $04, $04, 0x4
add $01, $01, $04
addhi $02, $02, 0x0
mov $rem, 0x80
cwrite $01, [$00 + @MEM_READ_ADDR]
cwrite $02, [$00 + @MEM_READ_ADDR+0x1]
cwrite $02, [$00 + @LOAD_STORE_HI]
cwrite $rem, [$00 + @MEM_READ_DWORDS]
cwrite $00, [$00 + @PACKET_TABLE_WRITE_ADDR]
(rep)cwrite $memdata, [$00 + @PACKET_TABLE_WRITE]

CP_BLIT:
CP_BOOTSTRAP_UCODE:
CP_BV_BR_COUNT_OPS:
CP_CCHE_INVALIDATE:
CP_COND_EXEC:
CP_COND_REG_EXEC:
CP_COND_WRITE5:
CP_CONTEXT_REG_BUNCH:
CP_CONTEXT_SWITCH_YIELD:
CP_CONTEXT_UPDATE:
CP_DRAW_AUTO:
CP_DRAW_INDIRECT:
CP_DRAW_INDIRECT_MULTI:
CP_DRAW_INDX:
CP_DRAW_INDX_INDIRECT:
CP_DRAW_INDX_OFFSET:
CP_DRAW_PRED_ENABLE_GLOBAL:
CP_DRAW_PRED_ENABLE_LOCAL:
CP_DRAW_PRED_SET:
CP_END_BIN:
CP_EVENT_WRITE7:
CP_EXEC_CS:
CP_EXEC_CS_INDIRECT:
CP_FIXED_STRIDE_DRAW_TABLE:
CP_GLOBAL_TIMESTAMP:
CP_INDIRECT_BUFFER:
CP_INDIRECT_BUFFER_CHAIN:
CP_INDIRECT_BUFFER_PFD:
CP_INTERRUPT:
CP_INVALIDATE_STATE:
CP_LOAD_STATE6:
CP_LOAD_STATE6_FRAG:
CP_LOAD_STATE6_GEOM:
CP_LOCAL_TIMESTAMP:
CP_MEMCPY:
CP_MEM_TO_MEM:
CP_MEM_TO_REG:
CP_MEM_TO_SCRATCH_MEM:
CP_MEM_WRITE:
CP_MEM_WRITE_CNTR:
CP_ME_INIT:
CP_MODIFY_TIMESTAMP:
CP_NON_CONTEXT_REG_BUNCH:
CP_NOP:
CP_RECORD_PFP_TIMESTAMP:
CP_REG_RMW:
CP_REG_TEST:
CP_REG_TO_MEM:
CP_REG_TO_MEM_OFFSET_MEM:
CP_REG_TO_MEM_OFFSET_REG:
CP_REG_TO_SCRATCH:
CP_REG_WR_NO_CTXT:
CP_RESET_CONTEXT_STATE:
CP_RESOURCE_LIST:
CP_RUN_OPENCL:
CP_SCOPE_CNTL:
CP_SCRATCH_TO_REG:
CP_SCRATCH_WRITE:
CP_SET_AMBLE:
CP_SET_BIN_DATA5:
CP_SET_BIN_DATA5_OFFSET:
CP_SET_DRAW_INIT_FLAGS:
CP_SET_DRAW_STATE:
CP_SET_MARKER:
CP_SET_MODE:
CP_SET_PROTECTED_MODE:
CP_SET_PSEUDO_REG:
CP_SET_SECURE_MODE:
CP_SET_STATE:
CP_SET_SUBDRAW_SIZE:
CP_SET_UNK_BIN_DATA:
CP_SET_VISIBILITY_OVERRIDE:
CP_SKIP_IB2_ENABLE_GLOBAL:
CP_SKIP_IB2_ENABLE_LOCAL:
CP_SKIP_IB_MODE:
CP_SMMU_TABLE_UPDATE:
CP_START_BIN:
CP_TEST_TWO_MEMS:
CP_THREAD_CONTROL:
CP_WAIT_FOR_IDLE:
CP_WAIT_FOR_ME:
CP_WAIT_MEM_WRITES:
CP_WAIT_REG_EQ:
CP_WAIT_REG_MEM:
CP_WAIT_TIMESTAMP:
CP_WHERE_AM_I:
IN_GMU_INTERRUPT:
IN_IB_END:
IN_PREEMPT:
PKT4:
UNKN0:
UNKN1:
UNKN103:
UNKN104:
UNKN105:
UNKN106:
UNKN109:
UNKN110:
UNKN112:
UNKN118:
UNKN119:
UNKN12:
UNKN121:
UNKN122:
UNKN123:
UNKN124:
UNKN125:
UNKN126:
UNKN13:
UNKN14:
UNKN2:
UNKN3:
UNKN30:
UNKN32:
UNKN43:
UNKN48:
UNKN5:
UNKN6:
UNKN7:
UNKN8:
UNKN84:
UNKN88:
UNKN89:
UNKN9:
UNKN90:
UNKN91:
UNKN96:
UNKN97:
waitin
mov $01, $data
jumptbl:
.jumptbl
[0100beef]
