vc4_control_list.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. /*
  2. VideoCore IV
  3. Control ID Codes
  4. */
  5. // we need these because we can't store words in odd addresses with pointer arithmetic, this will crash the device
  6. #define str16(buf,value) *(buf)=value&0xff; *(buf+1)=(value&0xff00)>>8;
  7. #define str32(buf,value) *(buf)=value&0xff; *(buf+1)=(value&0xff00)>>8; *(buf+2)=(value&0xffff00)>>16; *(buf+3)=(value&0xffffff00)>>24;
  8. #define vc4_halt_op 0x00
  9. #define vc4_nop_op 0x01
  10. #define vc4_reserved2_op 0x02 // MARKER
  11. #define vc4_reserved3_op 0x03 // RESET_MARKER_COUNT
  12. #define vc4_flush_op 0x04
  13. #define vc4_flush_all_state_op 0x05
  14. #define vc4_start_tile_binning_op 0x06
  15. #define vc4_increment_semaphore_op 0x07
  16. #define vc4_wait_on_semaphore_op 0x08
  17. #define vc4_repeat_start_marker_op 0x19
  18. #define vc4_repeat_from_start_marker_op 0x20
  19. #define vc4_branch_op 0x10 // followed by address
  20. #define vc4_branch_to_sublist_op 0x11 // followed by address
  21. int vc4_nop(uint8_t* buf){
  22. *((uint8_t*) (buf+0)) = vc4_nop_op;
  23. return 1;
  24. }
  25. int vc4_reserved2(uint8_t* buf){
  26. *((uint8_t*) (buf+0)) = vc4_reserved2_op;
  27. return 1;
  28. }
  29. int vc4_flush(uint8_t* buf){
  30. *((uint8_t*) (buf+0)) = vc4_flush_op;
  31. return 1;
  32. }
  33. int vc4_flush_all_state(uint8_t* buf){
  34. *((uint8_t*) (buf+0)) = vc4_flush_all_state_op;
  35. return 1;
  36. }
  37. int vc4_start_tile_binning(uint8_t* buf){
  38. *((uint8_t*) (buf+0)) = vc4_start_tile_binning_op;
  39. return 1;
  40. }
  41. int vc4_increment_semaphore(uint8_t* buf){
  42. *((uint8_t*) (buf+0)) = vc4_increment_semaphore_op;
  43. return 1;
  44. }
  45. int vc4_wait_on_semaphore(uint8_t* buf){
  46. *((uint8_t*) (buf+0)) = vc4_wait_on_semaphore_op;
  47. return 1;
  48. }
  49. int vc4_branch(uint8_t* buf, uint32_t addr){
  50. *((uint8_t*) (buf+0)) = vc4_branch_op;
  51. str32(buf+1,addr);
  52. return 5;
  53. }
  54. int vc4_branch_to_sublist(uint8_t* buf, uint32_t addr){
  55. *((uint8_t*) (buf+0)) = vc4_branch_to_sublist_op;
  56. str32(buf+1,addr);
  57. return 5;
  58. }
  59. #define vc4_return_from_sublist_op 0x12
  60. #define vc4_store_multi_sample_op 0x18
  61. #define vc4_store_multi_sample_end_op 0x19
  62. int vc4_store_multi_sample(uint8_t* buf){
  63. *((uint8_t*) (buf+0)) = vc4_store_multi_sample_op;
  64. return 1;
  65. }
  66. int vc4_store_multi_sample_end(uint8_t* buf){
  67. *((uint8_t*) (buf+0)) = vc4_store_multi_sample_end_op;
  68. return 1;
  69. }
  70. #define vc4_disable_color_buffer_write 0x01
  71. #define vc4_disable_z_stencil_buffer_write 0x02
  72. #define vc4_disable_clear_on_write 0x04
  73. #define vc4_last_tile_of_frame 0x08
  74. #define vc4_memory_base_address 0xfffffff0
  75. #define vc4_store_full_resolution 0x1a // followed by address + data control id data record word: memory address of tile (in multiples of 16 bytes) (bit 4..31), data record (bit 0..3)
  76. #define vc4_disable_color_buffer_read 0x01
  77. #define vc4_disable_z_stencil_buffer_read 0x02
  78. //#define Memory_Base_Address 0xFFFFFFF0
  79. #define vc4_re_load_full_resolution 0x1b // followed by address +data control id data record word: memory address of tile (in multiples of 16 bytes) (bit 4..31), data record (bit 0..3)
  80. // store_tile_buffer_general: store tile buffer general control id code data record description
  81. #define vc4_store_none 0x0000 // store_tile_buffer_general: buffer to store = none
  82. #define vc4_store_color 0x0001 // store_tile_buffer_general: buffer to store = color
  83. #define vc4_store_z_stencil 0x0002 // store_tile_buffer_general: buffer to store = z/stencil
  84. #define vc4_store_z_only 0x0003 // store_tile_buffer_general: buffer to store = z-only
  85. #define vc4_store_vg_mask 0x0004 // store_tile_buffer_general: buffer to store = vg-mask
  86. #define vc4_store_full_dump 0x0005 // store_tile_buffer_general: buffer to store = full dump
  87. #define vc4_format_raster 0x0000 // store_tile_buffer_general: format = raster format
  88. #define vc4_format_t 0x0010 // store_tile_buffer_general: format = t-format
  89. #define vc4_format_lt 0x0020 // store_tile_buffer_general: format = lt-format
  90. #define vc4_mode_sample 0x0000 // store_tile_buffer_general: mode = sample
  91. #define vc4_mode_decimate_4x 0x0040 // store_tile_buffer_general: mode = decimate 4x
  92. #define vc4_mode_decimate_16x 0x0080 // store_tile_buffer_general: mode = decimate 16x
  93. #define vc4_color_format_rgba8888 0x0000 // store_tile_buffer_general: pixel color format = rgba8888
  94. #define vc4_color_format_bgr565_dithered 0x0100 // store_tile_buffer_general: pixel color format = bgr565 dithered
  95. #define vc4_color_format_bgr565_no_dither 0x0200 // store_tile_buffer_general: pixel color format = bgr565 no dither
  96. #define vc4_disable_double_buffer_swap 0x1000 // store_tile_buffer_general: disable double-buffer swap in double buffer mode
  97. #define vc4_disable_color_buffer_clear 0x2000 // store_tile_buffer_general: disable color buffer clear on store/dump
  98. #define vc4_disable_z_stencil_buffer_clear 0x4000 // store_tile_buffer_general: disable z/stencil buffer clear on store/dump
  99. #define vc4_disable_vg_mask_buffer_clear 0x8000 // store_tile_buffer_general: disable vg-mask buffer clear on store/dump
  100. #define vc4_disable_color_buffer_dump 0x00000001 // store_tile_buffer_general: disable color buffer dump
  101. #define vc4_disable_z_stencil_buffer_dump 0x00000002 // store_tile_buffer_general: disable z/stencil buffer dump
  102. #define vc4_disable_vg_mask_buffer_dump 0x00000004 // store_tile_buffer_general: disable vg-mask buffer dump
  103. //#define last_tile_of_frame 0x00000008 // store_tile_buffer_general: last tile of frame
  104. //#define memory_base_address 0xfffffff0 // store_tile_buffer_general: memory base address of frame/tile dump buffer (in multiples of 16 bytes)
  105. /*
  106. #define Store_Tile_Buffer_General data16, data32, address { // Control ID Code: Store Tile Buffer General (R)
  107. db $1C // Control ID Code Byte: ID Code #28
  108. dh data16 // Control ID Data Record Short: (Bit 0..15)
  109. dw address + data32 // Control ID Data Record Word: Memory Base Address Of Frame/Tile Dump Buffer (In Multiples Of 16 Bytes) (Bit 20..47), Data Record (Bit 16..19)
  110. }
  111. */
  112. int vc4_store_tile_buffer_general(uint8_t* buf, uint16_t data16, uint32_t data32, uint32_t address){
  113. *((uint8_t*) (buf+0)) = 0x1c;
  114. str16(buf+1,data16);
  115. str32(buf+3,address+data32); // FIXME mask + or?
  116. return 7;
  117. }
  118. // Load_Tile_Buffer_General: Load Tile Buffer General Control ID Code Data Record Description
  119. #define vc4_load_none 0x0000 // load_tile_buffer_general: buffer to load = none
  120. #define vc4_load_color 0x0001 // load_tile_buffer_general: buffer to load = color
  121. #define vc4_load_z_stencil 0x0002 // load_tile_buffer_general: buffer to load = z/stencil
  122. #define vc4_load_na 0x0003 // load_tile_buffer_general: buffer to load = n/a
  123. #define vc4_load_vg_mask 0x0004 // load_tile_buffer_general: buffer to load = vg-mask
  124. #define vc4_load_full_reload 0x0005 // load_tile_buffer_general: buffer to load = full reload
  125. //#define color_format_rgba8888 0x0000 // load_tile_buffer_general: pixel color format = rgba8888
  126. //#define color_format_bgr565_dithered 0x0100 // load_tile_buffer_general: pixel color format = bgr565 dithered
  127. //#define color_format_bgr565_no_dither 0x0200 // load_tile_buffer_general: pixel color format = bgr565 no dither
  128. #define vc4_disable_color_buffer_load 0x00000001 // load_tile_buffer_general: disable color buffer load
  129. #define vc4_disable_z_stencil_buffer_load 0x00000002 // load_tile_buffer_general: disable z/stencil buffer load
  130. #define vc4_disable_vg_mask_buffer_load 0x00000004 // load_tile_buffer_general: disable VG-Mask Buffer Load
  131. //#define Memory_Base_Address 0xFFFFFFF0 // Load_Tile_Buffer_General: Memory Base Address Of Frame/Tile Dump Buffer (In multiples of 16 bytes)
  132. /*#define Load_Tile_Buffer_General data16, data32, address { // Control ID Code: Load Tile Buffer General (R)
  133. db $1D // Control ID Code Byte: ID Code #29
  134. dh data16 // Control ID Data Record Short: (Bit 0..15)
  135. dw address + data32 // Control ID Data Record Word: Memory Base Address Of Frame/Tile Dump Buffer (In Multiples Of 16 Bytes) (Bit 20..47), Data Record (Bit 16..19)
  136. }
  137. */
  138. int vc4_load_tile_buffer_general(uint8_t* buf, uint16_t data16, uint32_t data32, uint32_t address){
  139. *((uint8_t*) (buf+0)) = 0x1d;
  140. str16(buf+1,data16);
  141. str32(buf+3,address+data32); // FIXME mask + or?
  142. return 7;
  143. }
  144. /*// Indexed_Primitive_List: Indexed Primitive List (OpenGL) Control ID Code Data Record Description
  145. #define Mode_Points 0x00 // Indexed_Primitive_List: Primitive Mode = Points
  146. #define Mode_Lines 0x01 // Indexed_Primitive_List: Primitive Mode = Lines
  147. #define Mode_Line_Loop 0x02 // Indexed_Primitive_List: Primitive Mode = Line Loop
  148. #define Mode_Line_Strip 0x03 // Indexed_Primitive_List: Primitive Mode = Line Strip
  149. #define Mode_Triangles 0x04 // Indexed_Primitive_List: Primitive Mode = Triangles
  150. #define Mode_Triangle_Strip 0x05 // Indexed_Primitive_List: Primitive Mode = Triangle Strip
  151. #define Mode_Triangle_Fan 0x06 // Indexed_Primitive_List: Primitive Mode = Triangle Fan
  152. #define Index_Type_8 0x00 // Indexed_Primitive_List: Index Type = 8-Bit
  153. #define Index_Type_16 0x10 // Indexed_Primitive_List: Index Type = 16-Bit
  154. #define Indices_Length 0xFFFFFFFF // Indexed_Primitive_List: Length (Number Of Indices)
  155. #define Indices_List_Address 0xFFFFFFFF // Indexed_Primitive_List: Address Of Indices List
  156. #define Maximum_Index 0xFFFFFFFF // Indexed_Primitive_List: Maximum Index (Primitives Using A Greater Index Will Cause Error)
  157. */
  158. /*macro Indexed_Primitive_List data, length, address, maxindex { // Control ID Code: Indexed Primitive List (OpenGL)
  159. db $20 // Control ID Code Byte: ID Code #32
  160. db data // Control ID Data Record Byte: (Bit 0..7)
  161. dw length // Control ID Data Record Word: Length (Number Of Indices) (Bit 8..39)
  162. dw address // Control ID Data Record Word: Address Of Indices List (Bit 40..71)
  163. dw maxindex // Control ID Data Record Word: Maximum Index (Bit 72..103)
  164. }*/
  165. // Vertex_Array_Primitives: Vertex Array Primitives (OpenGL) Control ID Code Data Record Description
  166. #define Mode_Points 0x00 // Vertex_Array_Primitives: Primitives Mode = Points
  167. #define Mode_Lines 0x01 // Vertex_Array_Primitives: Primitives Mode = Lines
  168. #define Mode_Line_Loop 0x02 // Vertex_Array_Primitives: Primitives Mode = Line Loop
  169. #define Mode_Line_Strip 0x03 // Vertex_Array_Primitives: Primitives Mode = Line Strip
  170. #define vc4_mode_triangles 0x04 // Vertex_Array_Primitives: Primitives Mode = Triangles
  171. #define Mode_Triangle_Strip 0x05 // Vertex_Array_Primitives: Primitives Mode = Triangle Strip
  172. #define Mode_Triangle_Fan 0x06 // Vertex_Array_Primitives: Primitives Mode = Triangle Fan
  173. #define Vertices_Length 0xFFFFFFFF // Vertex_Array_Primitives: Length (Number Of Vertices)
  174. #define First_Vertex_Index 0xFFFFFFFF // Vertex_Array_Primitives: Index Of First Vertex
  175. /*macro Vertex_Array_Primitives data, length, index { // Control ID Code: Vertex Array Primitives (OpenGL)
  176. db $21 // Control ID Code Byte: ID Code #33
  177. db data // Control ID Data Record Byte: (Bit 0..7)
  178. dw length // Control ID Data Record Word: Length (Number Of Vertices) (Bit 8..39)
  179. dw index // Control ID Data Record Word: Index Of First Vertex (Bit 40..71)
  180. }*/
  181. int vc4_vertex_array_primitives(uint8_t* buf, uint8_t data, uint32_t len, uint32_t index){
  182. *((uint8_t*) (buf+0)) = 0x21;
  183. *((uint8_t*) (buf+1)) = data;
  184. str32(buf+2,len);
  185. str32(buf+6,index);
  186. return 10;
  187. }
  188. // VG_Coordinate_Array_Primitives: VG Coordinate Array Primitives (Only For Use In VG Shader Mode) Control ID Code Data Record Description
  189. #define Primitives_Type_RHT 0x01 // VG_Coordinate_Array_Primitives: Primitives Type = RHT
  190. #define Primitives_Type_RHT_Strip 0x03 // VG_Coordinate_Array_Primitives: Primitives Type = RHT Strip
  191. #define vc4_primitives_type_triangles 0x04 // VG_Coordinate_Array_Primitives: Primitives Type = Triangles
  192. #define Primitives_Type_Triangle_Strip 0x05 // VG_Coordinate_Array_Primitives: Primitives Type = Triangle Strip
  193. #define Primitives_Type_Triangle_Fan 0x06 // VG_Coordinate_Array_Primitives: Primitives Type = Triangle Fan
  194. #define Triangle_Fan_Continuation_List 0xF0 // VG_Coordinate_Array_Primitives: Continuation List (For Triangle Fans Only)
  195. #define Primitives_Length 0xFFFFFFFF // VG_Coordinate_Array_Primitives: Length (Number Of Primitives)
  196. #define Coordinate_Array_Address 0xFFFFFFFF // VG_Coordinate_Array_Primitives: Address Of Coordinate Array (32-Bit X,Y Screen Coordinates)
  197. /*macro VG_Coordinate_Array_Primitives data, length, address { // Control ID Code: VG Coordinate Array Primitives (Only For Use In VG Shader Mode)
  198. db $29 // Control ID Code Byte: ID Code #41
  199. db data // Control ID Data Record Byte: (Bit 0..7)
  200. dw length // Control ID Data Record Word: Length (Number Of Primitives) (Bit 8..39)
  201. dw address // Control ID Data Record Word: Address Of Coordinate Array (Bit 40..71)
  202. }*/
  203. int vc4_coordinate_array_primitives(uint8_t* buf, uint8_t data, uint32_t len, uint32_t addr){
  204. *((uint8_t*) (buf+0)) = 0x29;
  205. *((uint8_t*) (buf+1)) = data;
  206. str32(buf+2,len);
  207. str32(buf+6,addr);
  208. return 10;
  209. }
  210. // VG_Inline_Primitives: VG Inline Primitives (Only For Use In VG Shader Mode) Control ID Code Data Record Description
  211. #define Primitives_Type_RHT 0x01 // VG_Inline_Primitives: Primitives Type = RHT
  212. #define Primitives_Type_RHT_Strip 0x03 // VG_Inline_Primitives: Primitives Type = RHT Strip
  213. #define Primitives_Type_Triangles 0x04 // VG_Inline_Primitives: Primitives Type = Triangles
  214. #define Primitives_Type_Triangle_Strip 0x05 // VG_Inline_Primitives: Primitives Type = Triangle Strip
  215. #define Primitives_Type_Triangle_Fan 0x06 // VG_Inline_Primitives: Primitives Type = Triangle Fan
  216. #define Triangle_Fan_Continuation_List 0xF0 // VG_Inline_Primitives: Continuation List (For Triangle Fans Only)
  217. #define Escape_Terminated_Coordinate_List 0xFFFFFFFF // VG_Inline_Primitives: Escape Terminated Uncompressed 32-Bit X,Y Coordinate List
  218. /*macro VG_Inline_Primitives data { // Control ID Code: VG Inline Primitives (Only For Use In VG Shader Mode)
  219. db $2A // Control ID Code Byte: ID Code #42
  220. db data // Control ID Data Record Byte: (Bit 0..7)
  221. // Control ID Data Record Words: Escape Terminated Uncompressed 32-Bit X,Y Coordinate List (Bit 8..X)
  222. }
  223. */
  224. // Primitive_List_Format: Primitive List Format Control ID Code Data Record Description
  225. #define vc4_primitive_type_points 0x00 // primitive list format: primitive type = points
  226. #define vc4_primitive_type_lines 0x01 // primitive list format: primitive type = lines
  227. #define vc4_primitive_type_triangles 0x02 // primitive list format: primitive type = triangles
  228. #define vc4_primitive_type_rht 0x03 // primitive list format: primitive type = rht
  229. #define vc4_data_type_index_16 0x10 // primitive list format: data type = 16-bit index
  230. #define vc4_data_type_xy_32 0x30 // primitive list format: data type = 32-bit x/y
  231. /*macro Primitive_List_Format data { // Control ID Code: Primitive List Format (R)
  232. db $38 // Control ID Code Byte: ID Code #56
  233. db data // Control ID Data Record Byte: (Bit 0..7)
  234. }
  235. */
  236. // GL_Shader_State: GL Shader State Control ID Code Data Record Description
  237. #define Attribute_Arrays_0 0x00000000 // GL_Shader_State: Number Of Attribute Arrays = 0 (0 => All 8 Arrays) (Ignored For Extended Shader Record)
  238. #define Attribute_Arrays_1 0x00000001 // GL_Shader_State: Number Of Attribute Arrays = 1 (Ignored For Extended Shader Record)
  239. #define Attribute_Arrays_2 0x00000002 // GL_Shader_State: Number Of Attribute Arrays = 2 (Ignored For Extended Shader Record)
  240. #define Attribute_Arrays_3 0x00000003 // GL_Shader_State: Number Of Attribute Arrays = 3 (Ignored For Extended Shader Record)
  241. #define Attribute_Arrays_4 0x00000004 // GL_Shader_State: Number Of Attribute Arrays = 4 (Ignored For Extended Shader Record)
  242. #define Attribute_Arrays_5 0x00000005 // GL_Shader_State: Number Of Attribute Arrays = 5 (Ignored For Extended Shader Record)
  243. #define Attribute_Arrays_6 0x00000006 // GL_Shader_State: Number Of Attribute Arrays = 6 (Ignored For Extended Shader Record)
  244. #define Attribute_Arrays_7 0x00000007 // GL_Shader_State: Number Of Attribute Arrays = 7 (Ignored For Extended Shader Record)
  245. #define Extended_Shader_Record 0x00000008 // GL_Shader_State: Extended Shader Record (With 26-Bit Attribute Memory Stride)
  246. #define Memory_Base_Address 0xFFFFFFF0 // GL_Shader_State: Memory Base Address Of Shader Record (In Multiples Of 16 Bytes)
  247. /*macro GL_Shader_State data, address { // Control ID Code: GL Shader State
  248. db $40 // Control ID Code Byte: ID Code #64
  249. dw address + data // Control ID Data Record Word: Memory Address Of Shader Record (In Multiples Of 16 Bytes) (Bit 4..31), Data Record (Bit 0..3)
  250. }*/
  251. // NV_Shader_State: NV Shader State (No Vertex Shading) Control ID Code Data Record Description
  252. /*macro NV_Shader_State address { // Control ID Code: NV Shader State (No Vertex Shading)
  253. db $41 // Control ID Code Byte: ID Code #65
  254. dw address // Control ID Data Record Word: Memory Address Of Shader Record (16-Byte Aligned) (Bit 0..31)
  255. }*/
  256. // VG_Shader_State: VG Shader State Control ID Code Data Record Description
  257. /*macro VG_Shader_State address { // Control ID Code: VG Shader State
  258. db $42 // Control ID Code Byte: ID Code #66
  259. dw address // Control ID Data Record Word: Memory Address Of Shader Record (16-Byte Aligned) (Bit 0..31)
  260. }*/
  261. int vc4_nv_shader_state(uint8_t* buf, uint32_t addr) {
  262. *((uint8_t*) (buf+0)) = 0x41;
  263. str32(buf+1,addr);
  264. return 5;
  265. }
  266. int vc4_vg_shader_state(uint8_t* buf, uint32_t addr) {
  267. *((uint8_t*) (buf+0)) = 0x42;
  268. str32(buf+1,addr);
  269. return 5;
  270. }
  271. // VG_Inline_Shader_Record: VG Inline Shader Record Control ID Code Data Record Description
  272. #define Dual_Threaded_Fragment_Shader 0x00000000 // VG_Inline_Shader_Record: Dual Threaded Fragment Shader
  273. #define Single_Threaded_Fragment_Shader 0x00000001 // VG_Inline_Shader_Record: Single Threaded Fragment Shader
  274. #define Fragment_Shader_Code_Address 0xFFFFFFF8 // VG_Inline_Shader_Record: Fragment Shader Code Address (8-Byte Multiple)
  275. #define Fragment_Shader_Uniforms_Address 0xFFFFFFFF // VG_Inline_Shader_Record: Fragment Shader Uniforms Address (4-Byte Aligned)
  276. /*macro VG_Inline_Shader_Record data, addressc, addressu { // Control ID Code: VG Inline Shader Record
  277. db $43 // Control ID Code Byte: ID Code #67
  278. dw addressc + data // Control ID Data Record Word: Fragment Shader Code Address (8-Byte Multiple) (Bit 3..31), Data Record (Bit 0..2)
  279. dw addressu // Control ID Data Record Word: Fragment Shader Uniforms Address (4-Byte Aligned) (Bit 32..63)
  280. }
  281. */
  282. // Configuration data -------------------------------------
  283. // Configuration_bits: configuration bits control id code data record description
  284. #define vc4_enable_forward_facing_primitive 0x01 // configuration_bits: enable forward facing primitive
  285. #define vc4_enable_reverse_facing_primitive 0x02 // configuration_bits: enable reverse facing primitive
  286. #define vc4_clockwise_primitives 0x04 // configuration_bits: clockwise primitives
  287. #define vc4_enable_depth_offset 0x08 // configuration_bits: enable depth offset
  288. #define vc4_antialiased_points_lines 0x10 // configuration_bits: antialiased points & lines (not actually supported)
  289. #define vc4_coverage_read_type_level_4_8 0x00 // configuration_bits: coverage read type = 4*8-bit level
  290. #define vc4_coverage_read_type_mask_16 0x20 // configuration_bits: coverage read type = 16-bit mask
  291. #define vc4_rasteriser_oversample_mode_none 0x00 // configuration_bits: rasteriser oversample mode = none
  292. #define vc4_rasteriser_oversample_mode_4x 0x40 // configuration_bits: rasteriser oversample mode = 4x
  293. #define vc4_rasteriser_oversample_mode_16x 0x80 // configuration_bits: rasteriser oversample mode = 16x
  294. #define vc4_coverage_pipe_select 0x0001 // configuration_bits: coverage pipe select
  295. #define vc4_coverage_update_mode_non_zero 0x0000 // configuration_bits: coverage update mode = non zero
  296. #define vc4_coverage_update_mode_odd 0x0002 // configuration_bits: coverage update mode = odd
  297. #define vc4_coverage_update_mode_or 0x0004 // configuration_bits: coverage update mode = or
  298. #define vc4_coverage_update_mode_zero 0x0006 // configuration_bits: coverage update mode = zero
  299. #define vc4_coverage_read_mode_clear_on_read 0x0000 // configuration_bits: coverage read mode = clear on read
  300. #define vc4_coverage_read_mode_leave_on_read 0x0008 // configuration_bits: coverage read mode = leave on read
  301. #define vc4_depth_test_function_never 0x0000 // configuration_bits: depth-test function = never
  302. #define vc4_depth_test_function_lt 0x0010 // configuration_bits: depth-test function = less than (lt)
  303. #define vc4_depth_test_function_eq 0x0020 // configuration_bits: depth-test function = equal (eq)
  304. #define vc4_depth_test_function_le 0x0030 // configuration_bits: depth-test function = less equal (le)
  305. #define vc4_depth_test_function_gt 0x0040 // configuration_bits: depth-test function = greater than (gt)
  306. #define vc4_depth_test_function_ne 0x0050 // configuration_bits: depth-test function = not equal (ne)
  307. #define vc4_depth_test_function_ge 0x0060 // configuration_bits: depth-test function = greater equal (ge)
  308. #define vc4_depth_test_function_always 0x0070 // configuration_bits: depth-test function = always
  309. #define vc4_z_updates_enable 0x0080 // configuration_bits: z updates enable
  310. #define vc4_early_z_enable 0x0100 // configuration_bits: early z enable
  311. #define vc4_early_z_updates_enable 0x0200 // configuration_bits: early z updates enable
  312. /*macro Configuration_Bits data8, data16 { // Control ID Code: Configuration Bits
  313. db $60 // Control ID Code Byte: ID Code #96
  314. db data8 // Control ID Data Record Byte: (Bit 0..7)
  315. dh data16 // Control ID Data Record Short: (Bit 8..23)
  316. }*/
  317. int vc4_configuration_bits(uint8_t* buf, uint8_t data8, uint16_t data16) {
  318. *((uint8_t*) (buf+0)) = 0x60;
  319. *((uint8_t*) (buf+1)) = data8;
  320. *((uint16_t*)(buf+2)) = data16;
  321. return 4;
  322. }
  323. // Flat_Shade_Flags: Flat Shade Flags Control ID Code Data Record Description
  324. #define Flat_Shade_Flags 0xFFFFFFFF // Flat_Shade_Flags: Flat-Shading Flags (32 X 1-Bit)
  325. /*macro Flat_Shade_Flags flags { // Control ID Code: Flat Shade Flags
  326. db $61 // Control ID Code Byte: ID Code #97
  327. dw flags // Control ID Data Record Word: Flat-Shading Flags (32 x 1-Bit) (Bit 0..31)
  328. }*/
  329. // Point_Size: Points Size Control ID Code Data Record Description
  330. #define Points_Size 0xFFFFFFFF // Points_Size: Point Size (FLOAT32)
  331. /*macro Point_Size size { // Control ID Code: Points Size
  332. db $62 // Control ID Code Byte: ID Code #98
  333. dw size // Control ID Data Record Word: Point Size (FLOAT32) (Bit 0..31)
  334. }*/
  335. // Line_Width: Line Width Control ID Code Data Record Description
  336. #define Line_Width 0xFFFFFFFF // Line_Width: Line Width (FLOAT32)
  337. /*macro Line_Width width { // Control ID Code: Line Width
  338. db $63 // Control ID Code Byte: ID Code #99
  339. dw width // Control ID Data Record Word: Line Width (FLOAT32) (Bit 0..31)
  340. }*/
  341. // RHT_X_Boundary: RHT X Boundary Control ID Code Data Record Description
  342. #define RHT_Primitive_X_Boundary 0xFFFF // RHT_X_Boundary: RHT Primitive X Boundary (SINT16)
  343. /*macro RHT_X_Boundary boundary { // Control ID Code: RHT X Boundary
  344. db $64 // Control ID Code Byte: ID Code #100
  345. dh boundary // Control ID Data Record Short: RHT Primitive X Boundary (SINT16) (Bit 0..15)
  346. }*/
  347. // Depth_Offset: Depth Offset Control ID Code Data Record Description
  348. #define Depth_Offset_Factor 0xFFFF // Depth_Offset: Depth Offset Factor (FLOAT1-8-7)
  349. #define Depth_Offset_Units 0xFFFF // Depth_Offset: Depth Offset Units (FLOAT1-8-7)
  350. /*macro Depth_Offset factor, units { // Control ID Code: Depth Offset
  351. db $65 // Control ID Code Byte: ID Code #101
  352. dh factor // Control ID Data Record Short: Depth Offset Factor (FLOAT1-8-7) (Bit 0..15)
  353. dh units // Control ID Data Record Short: Depth Offset Units (FLOAT1-8-7) (Bit 16..31)
  354. }*/
  355. /*macro Clip_Window left, bottom, width, height { // Control ID Code: Clip Window
  356. db $66 // Control ID Code Byte: ID Code #102
  357. dh left // Control ID Data Record Short: Clip Window Left Pixel Coordinate (UINT16) (Bit 0..15)
  358. dh bottom // Control ID Data Record Short: Clip Window Bottom Pixel Coordinate (UINT16) (Bit 16..31)
  359. dh width // Control ID Data Record Short: Clip Window Width In Pixels (UINT16) (Bit 32..47)
  360. dh height // Control ID Data Record Short: Clip Window Height In Pixels (UINT16) (Bit 48..63)
  361. }*/
  362. int vc4_clip_window(uint8_t* buf, uint16_t left, uint16_t bottom, uint16_t w, uint16_t h) {
  363. *((uint8_t*) (buf+0)) = 0x66;
  364. str16(buf+1,left);
  365. str16(buf+3,bottom);
  366. str16(buf+5,w);
  367. str16(buf+7,h);
  368. return 9;
  369. }
  370. /*macro Viewport_Offset x, y { // Control ID Code: Viewport Offset
  371. db $67 // Control ID Code Byte: ID Code #103
  372. dh x // Control ID Data Record Short: Viewport Centre X-Coordinate (SINT16) (Bit 0..15)
  373. dh y // Control ID Data Record Short: Viewport Centre Y-Coordinate (SINT16) (Bit 16..31)
  374. }*/
  375. int vc4_viewport_offset(uint8_t* buf, uint16_t x, uint16_t y) {
  376. *((uint8_t*) (buf+0)) = 0x67;
  377. str16(buf+1,x);
  378. str16(buf+3,y);
  379. return 5;
  380. }
  381. // Z_Min_Max_Clipping_Planes: Z Min & Max Clipping Planes Control ID Code Data Record Description
  382. #define Minimum_ZW 0xFFFFFFFF // Z_Min_Max_Clipping_Planes: Minimum ZW (FLOAT32)
  383. #define Maximum_ZW 0xFFFFFFFF // Z_Min_Max_Clipping_Planes: Maximum ZW (FLOAT32)
  384. /*macro Z_Min_Max_Clipping_Planes min, max { // Control ID Code: Z Min & Max Clipping Planes
  385. db $68 // Control ID Code Byte: ID Code #104
  386. dw min // Control ID Data Record Word: Minimum ZW (FLOAT32) (Bit 0..31)
  387. dw max // Control ID Data Record Word: Maximum ZW (FLOAT32) (Bit 32..63)
  388. }*/
  389. // Clipper_XY_Scaling: Clipper XY Scaling Control ID Code Data Record Description
  390. #define Viewport_Half_Width 0xFFFFFFFF // Clipper_XY_Scaling: Viewport Half-Width In 1/16th Of Pixel (FLOAT32)
  391. #define Viewport_Half_Height 0xFFFFFFFF // Clipper_XY_Scaling: Viewport Half-Height In 1/16th Of pixel (FLOAT32)
  392. /*macro Clipper_XY_Scaling width, height { // Control ID Code: Clipper XY Scaling (B)
  393. db $69 // Control ID Code Byte: ID Code #105
  394. dw width // Control ID Data Record Word: Viewport Half-Width In 1/16th Of Pixel (FLOAT32) (Bit 0..31)
  395. dw height // Control ID Data Record Word: Viewport Half-Height In 1/16th Of pixel (FLOAT32) (Bit 32..63)
  396. }*/
  397. // Clipper_Z_Scale_Offset: Clipper Z Scale & Offset Control ID Code Data Record Description
  398. #define Viewport_Z_Scale 0xFFFFFFFF // Clipper_Z_Scale_Offset: Viewport Z Scale (ZC To ZS) (FLOAT32)
  399. #define Viewport_Z_Offset 0xFFFFFFFF // Clipper_Z_Scale_Offset: Viewport Z Offset (ZC To ZS) (FLOAT32)
  400. /*macro Clipper_Z_Scale_Offset scale, offset { // Control ID Code: Clipper Z Scale & Offset (B)
  401. db $6A // Control ID Code Byte: ID Code #106
  402. dw scale // Control ID Data Record Word: Viewport Z Scale (ZC To ZS) (FLOAT32) (Bit 0..31)
  403. dw offset // Control ID Data Record Word: Viewport Z Offset (ZC To ZS) (FLOAT32) (Bit 32..63)
  404. }*/
  405. // Tile_Binning_Mode_Configuration: Tile Binning Mode Configuration Control ID Code Data Record Description
  406. //#define Multisample_Mode_4X 0x01 // Tile_Binning_Mode_Configuration: Multisample Mode (4X)
  407. //#define Buffer_Color_Depth_64 0x02 // Tile_Binning_Mode_Configuration: Tile Buffer 64-Bit Color Depth
  408. #define vc4_auto_initialise_tile_state_data_array 0x04 // tile_binning_mode_configuration: auto-initialise tile state data array
  409. #define vc4_tile_allocation_initial_block_size_32 0x00 // tile_binning_mode_configuration: tile allocation initial block size = 32 bytes
  410. #define vc4_tile_allocation_initial_block_size_64 0x08 // tile_binning_mode_configuration: tile allocation initial block size = 64 bytes
  411. #define vc4_tile_allocation_initial_block_size_128 0x10 // tile_binning_mode_configuration: tile allocation initial block size = 128 bytes
  412. #define vc4_tile_allocation_initial_block_size_256 0x18 // tile_binning_mode_configuration: tile allocation initial block size = 256 bytes
  413. #define vc4_tile_allocation_block_size_32 0x00 // tile_binning_mode_configuration: tile allocation block size = 32 bytes
  414. #define vc4_tile_allocation_block_size_64 0x20 // tile_binning_mode_configuration: tile allocation block size = 64 bytes
  415. #define vc4_tile_allocation_block_size_128 0x40 // tile_binning_mode_configuration: tile allocation block size = 128 bytes
  416. #define vc4_tile_allocation_block_size_256 0x60 // tile_binning_mode_configuration: Tile Allocation Block Size = 256 Bytes
  417. //#define Double_Buffer_In_Non_MS_Mode 0x80 // Tile_Binning_Mode_Configuration: Double-Buffer In Non-MS Mode
  418. /*macro Tile_Binning_Mode_Configuration address, size, baseaddress, width, height, data { // Control ID Code: Tile Binning Mode Configuration (B)
  419. db $70 // Control ID Code Byte: ID Code #112
  420. dw address // Control ID Data Record Word: Tile Allocation Memory Address (Bit 0..31)
  421. dw size // Control ID Data Record Word: Tile Allocation Memory Size (Bytes) (Bit 32..63)
  422. dw baseaddress // Control ID Data Record Word: Tile State Data Array Base Address (16-Byte Aligned, Size Of 48 Bytes * Num Tiles) (Bit 64..95)
  423. db width // Control ID Data Record Byte: Width (In Tiles) (Bit 96..103)
  424. db height // Control ID Data Record Byte: Height (In Tiles) (Bit 104..111)
  425. db data // Control ID Data Record Byte: Data Record (Bit 112..119)
  426. }*/
  427. int vc4_tile_binning_mode_conf(uint8_t* buf, uint32_t addr, uint32_t size, uint32_t baseaddr, uint8_t w, uint8_t h, uint8_t data) {
  428. *((uint8_t*) (buf+0)) = 0x70;
  429. str32(buf+1,addr);
  430. str32(buf+5,size);
  431. str32(buf+9,baseaddr);
  432. *((uint8_t*) (buf+13)) = w;
  433. *((uint8_t*) (buf+14)) = h;
  434. *((uint8_t*) (buf+15)) = data;
  435. return 16;
  436. }
  437. // Tile_Rendering_Mode_Configuration: Tile Rendering Mode Configuration Control ID Code Data Record Description
  438. #define vc4_tile_rendering_memory_address 0xffffffff // tile_rendering_mode_configuration: memory address
  439. #define vc4_tile_rendering_width 0xffff // tile_rendering_mode_configuration: width (pixels) (uint16)
  440. #define vc4_tile_rendering_height 0xffff // tile_rendering_mode_configuration: height (pixels) (uint16)
  441. #define vc4_multisample_mode_4x 0x0001 // tile_rendering_mode_configuration: multisample mode (4x)
  442. #define vc4_buffer_color_depth_64 0x0002 // tile_rendering_mode_configuration: tile buffer 64-bit color depth (hdr mode)
  443. #define vc4_frame_buffer_color_format_bgr565_dithered 0x0000 // tile_rendering_mode_configuration: non-hdr frame buffer color format = bgr565 dithered
  444. #define vc4_frame_buffer_color_format_rgba8888 0x0004 // tile_rendering_mode_configuration: non-hdr frame buffer color format = rgba8888
  445. #define frame_buffer_color_format_bgr565_no_dither 0x0008 // tile_rendering_mode_configuration: non-hdr frame buffer color format = bgr565 no dither
  446. #define vc4_decimate_mode_1x 0x0000 // tile_rendering_mode_configuration: decimate mode = 1x
  447. #define vc4_decimate_mode_4x 0x0010 // tile_rendering_mode_configuration: decimate mode = 4x
  448. #define vc4_decimate_mode_16x 0x0020 // tile_rendering_mode_configuration: decimate mode = 16x
  449. #define vc4_memory_format_linear 0x0000 // tile_rendering_mode_configuration: memory format = linear
  450. #define vc4_memory_format_t_format 0x0040 // tile_rendering_mode_configuration: memory format = t-format
  451. #define vc4_memory_format_lt_format 0x0080 // tile_rendering_mode_configuration: memory format = lt-format
  452. #define vc4_enable_vg_mask_buffer 0x0100 // tile_rendering_mode_configuration: enable vg mask buffer
  453. #define vc4_select_coverage_mode 0x0200 // tile_rendering_mode_configuration: select coverage mode
  454. #define vc4_early_z_update_direction_lt_le 0x0000 // tile_rendering_mode_configuration: early-z update direction = lt/le
  455. #define vc4_early_z_update_direction_gt_ge 0x0400 // tile_rendering_mode_configuration: early-z update direction = gt/ge
  456. #define vc4_early_z_early_cov_disable 0x0800 // tile_rendering_mode_configuration: early-z/early-cov disable
  457. #define vc4_double_buffer_in_non_ms_mode 0x1000 // tile_rendering_mode_configuration: double-buffer in non-ms mode
  458. /*macro Tile_Rendering_Mode_Configuration address, width, height, data { // Control ID Code: Tile Rendering Mode Configuration (R)
  459. db $71 // Control ID Code Byte: ID Code #113
  460. dw address // Control ID Data Record Word: Memory Address (Bit 0..31)
  461. dh width // Control ID Data Record Short: Width (Pixels) (UINT16) (Bit 32..47)
  462. dh height // Control ID Data Record Short: Height (Pixels) (UINT16) (Bit 48..63)
  463. dh data // Control ID Data Record Short: Data Record (Bit 64..79)
  464. }*/
  465. int vc4_tile_rendering_mode_conf(uint8_t* buf, uint32_t addr, uint16_t w, uint16_t h, uint16_t data) {
  466. *((uint8_t*) (buf+0)) = 0x71;
  467. str32(buf+1,addr);
  468. str16(buf+5,w);
  469. str16(buf+7,h);
  470. str16(buf+9,data);
  471. return 11;
  472. }
  473. // Clear_Colors: Clear Colors Control ID Code Data Record Description
  474. #define Clear_Color 0xFFFFFFFFFFFFFFFF // Clear_Colors: Clear Color (2X RGBA8888 Or RGBA16161616)
  475. #define Clear_ZS 0x00FFFFFF // Clear_Colors: Clear ZS (UINT24)
  476. #define Clear_VG_Mask 0xFF000000 // Clear_Colors: Clear VG Mask (UINT8)
  477. #define Clear_Stencil 0xFF // Clear_Colors: Clear Stencil (UINT8)
  478. /*macro Clear_Colors clearcolor, clearzs, clearvgmask, clearstencil { // Control ID Code: Clear Colors (R)
  479. db $72 // Control ID Code Byte: ID Code #114
  480. dd clearcolor // Control ID Data Record Double: Clear Color (2X RGBA8888 Or RGBA16161616) (Bit 0..63)
  481. dw (clearvgmask * $1000000) + clearzs // Control ID Data Record Word: Clear VG Mask (UINT8) (Bit 80..95), Clear ZS (UINT24) (Bit 64..79)
  482. db clearstencil // Control ID Data Record Byte: Clear Stencil (UINT8) (Bit 96..103)
  483. }*/
  484. int vc4_clear_colors(uint8_t* buf, uint32_t cc1, uint32_t cc2, uint32_t clearzs, uint8_t clearvgmask, uint8_t clearstencil){
  485. *((uint8_t*) (buf+0)) = 0x72;
  486. str32(buf+1, cc1);
  487. str32(buf+5, cc2);
  488. str32(buf+9, (clearvgmask * 0x1000000) + clearzs);
  489. *((uint8_t*) (buf+13)) = clearstencil;
  490. return 14;
  491. }
  492. /*macro Tile_Coordinates column, row { // Control ID Code: Tile Coordinates (R)
  493. db $73 // Control ID Code Byte: ID Code #115
  494. db column // Control ID Data Record Byte: Tile Column Number (INT8) (Bit 0..7)
  495. db row // Control ID Data Record Byte: Tile Row Number (INT8) (Bit 8..15)
  496. }
  497. */
  498. int vc4_tile_coordinates(uint8_t* buf, uint8_t col, uint8_t row) {
  499. *((uint8_t*)(buf+0)) = 0x73;
  500. *((uint8_t*)(buf+1)) = col;
  501. *((uint8_t*)(buf+2)) = row;
  502. return 3;
  503. }
  504. int vc4_shader_state_record(uint8_t* buf, uint8_t* frag_shader_addr) {
  505. *((uint8_t*) (buf+0)) = 0; // flags (0 = single threaded)
  506. *((uint8_t*) (buf+1)) = 0; // not used
  507. *((uint8_t*) (buf+2)) = 0; // num uniforms (not used?)
  508. *((uint8_t*) (buf+3)) = 0; // num varyings
  509. *((uint32_t*)(buf+4)) = (uint32_t)frag_shader_addr;
  510. *((uint32_t*)(buf+8)) = 0; // uniforms address
  511. return 12;
  512. }
  513. /*
  514. align 16 ; 128-Bit Align
  515. NV_SHADER_STATE_RECORD:
  516. db 0 ; Flag Bits: 0 = Fragment Shader Is Single Threaded, 1 = Point Size Included In Shaded Vertex Data, 2 = Enable Clipping, 3 = Clip Coordinates Header Included In Shaded Vertex Data
  517. db 6 * 4 ; Shaded Vertex Data Stride
  518. db 0 ; Fragment Shader Number Of Uniforms (Not Used Currently)
  519. db 3 ; Fragment Shader Number Of Varyings
  520. dw FRAGMENT_SHADER_CODE ; Fragment Shader Code Address
  521. dw 0 ; Fragment Shader Uniforms Address
  522. dw VERTEX_DATA ; Shaded Vertex Data Address (128-Bit Aligned If Including Clip Coordinate Header)
  523. */
  524. int vc4_nv_shader_state_record(uint8_t* buf, uint8_t* frag_shader_addr, uint8_t num_varyings, uint8_t vertex_stride, uint8_t* vertex_addr) {
  525. *((uint8_t*) (buf+0)) = 0; // flags (0 = single threaded)
  526. *((uint8_t*) (buf+1)) = vertex_stride; // Shaded Vertex Data Stride
  527. *((uint8_t*) (buf+2)) = 0; // num uniforms (not used?)
  528. *((uint8_t*) (buf+3)) = num_varyings; // num varyings
  529. *((uint32_t*)(buf+4)) = (uint32_t)frag_shader_addr;
  530. *((uint32_t*)(buf+8)) = 0; // uniforms address (unused)
  531. *((uint32_t*)(buf+12)) = (uint32_t)vertex_addr;
  532. return 16;
  533. }
  534. int vc4_vertex(uint8_t* buf, uint16_t x, uint16_t y) {
  535. *((uint16_t*)(buf+0)) = x * 16;
  536. *((uint16_t*)(buf+2)) = y * 16;
  537. return 4;
  538. }
  539. int vc4_flat_shader(uint8_t* buf, uint32_t rgba) {
  540. *((uint32_t*)(buf+0)) = 0x009e7000;
  541. *((uint32_t*)(buf+4)) = 0x100009E7;
  542. *((uint32_t*)(buf+8)) = rgba;
  543. *((uint32_t*)(buf+12)) = 0xe0020ba7;
  544. *((uint32_t*)(buf+16)) = 0x009e7000;
  545. *((uint32_t*)(buf+20)) = 0x500009e7;
  546. *((uint32_t*)(buf+24)) = 0x009e7000;
  547. *((uint32_t*)(buf+28)) = 0x300009e7;
  548. *((uint32_t*)(buf+32)) = 0x009e7000;
  549. *((uint32_t*)(buf+36)) = 0x100009E7;
  550. *((uint32_t*)(buf+40)) = 0x009e7000;
  551. *((uint32_t*)(buf+44)) = 0x100009E7;
  552. return 12*4;
  553. }
  554. int vc4_gouraud_shader(uint8_t* buf) {
  555. *((uint32_t*)(buf+0)) = 0x958E0DBF;
  556. *((uint32_t*)(buf+4)) = 0xD1724823; // mov r0, vary// mov r3.8d, 1.0
  557. *((uint32_t*)(buf+8)) = 0x818E7176;
  558. *((uint32_t*)(buf+12)) = 0x40024821; // fadd r0, r0, r5// mov r1, vary
  559. *((uint32_t*)(buf+16)) = 0x818E7376;
  560. *((uint32_t*)(buf+20)) = 0x10024862; // fadd r1, r1, r5// mov r2, vary
  561. *((uint32_t*)(buf+24)) = 0x819E7540;
  562. *((uint32_t*)(buf+28)) = 0x114248A3; // fadd r2, r2, r5// mov r3.8a, r0
  563. *((uint32_t*)(buf+32)) = 0x809E7009;
  564. *((uint32_t*)(buf+36)) = 0x115049E3; // nop// mov r3.8b, r1
  565. *((uint32_t*)(buf+40)) = 0x809E7012;
  566. *((uint32_t*)(buf+44)) = 0x116049E3; // nop// mov r3.8c, r2
  567. *((uint32_t*)(buf+48)) = 0x159E76C0;
  568. *((uint32_t*)(buf+52)) = 0x30020BA7; // mov tlbc, r3// nop// thrend
  569. *((uint32_t*)(buf+56)) = 0x009E7000;
  570. *((uint32_t*)(buf+60)) = 0x100009E7; // nop// nop// nop
  571. *((uint32_t*)(buf+64)) = 0x009E7000;
  572. *((uint32_t*)(buf+68)) = 0x500009E7; // nop// nop// sbdone
  573. return 72;
  574. }