freedreno/afuc: fw patch compiler
Just a braindump of an idea..
Implement support for generating fw patch. Rough idea is per-sqe fw (ie. a630_sqe.fw), have a fw-patch src file that consists of multiple patch-points, plus an epilogue section appended to the end of the loaded fw after the jmptbl. Patch points consist of either:
- Replacement: pm4 packet-id plus replacement label (pointing to instructions in the epilogue)
- Patch: sequence of instructions to pattern match, plus optional offset offset to start searching for (ie. pm4 packet id)
In either case, there should be some optional tags to restrict the patch to certain fw versions (should we go just by version # we extract from the fw.. or md5sum of fw.. or??)
I think in both cases, at patch time we want to be able to resolve jumps/branches into the epilogue, and in latter case I think we want to be able to jump/branch back from the epilogue to the patch point.
; complete replacement of existing pm4 packet handler, which just patches jmptbl: @replace CP_SET_BIN_DATA5_OFFSET _cp_set_bin_data5_offset @patch CP_ME_INIT ; if no pm4 pkt offset, specified start searching from start of fw ; src pattern to match and replace with branch to code in epilogue, needs to ; be at least two instructions waitin mov $01, $data @replace ; replacement pattern, must be same # of instructions jump _cp_me_init_append nop @endpatch @epilogue _cp_set_bin_data5_offset: mov $06, $data mov $07, $data mov $04, $data mov $0f, $data mov $0a, VSC_DRAW_STRM_ADDRESS cwrite $0a, [$00 + @REG_READ_ADDR], 0x0 ... waitin mov $01, $data _cp_me_init_append: ... waitin mov $01, $data
rough idea (waves hands) is that this would compile into C src with tables that is built into kernel to implement the fw patching