broadcom/clif: Move the CL printing part of CL dumps to a helper.
[mesa.git] / src / broadcom / clif / clif_dump.c
index 8e9e248c0e472b92288441daceac2a7fb0ab2c45..af72834e5dc56127a72d0e12d5ed5238ec70c4fc 100644 (file)
@@ -219,6 +219,37 @@ clif_dump_gl_shader_state_record(struct clif_dump *clif,
         }
 }
 
+static void
+clif_dump_cl(struct clif_dump *clif, uint32_t start, uint32_t end)
+{
+        void *start_vaddr;
+        if (!clif->lookup_vaddr(clif->data, start, &start_vaddr)) {
+                out(clif, "Failed to look up address 0x%08x\n",
+                    start);
+                return;
+        }
+
+        /* The end address is optional (for example, a BRANCH instruction
+         * won't set an end), but is used for BCL/RCL termination.
+         */
+        void *end_vaddr = NULL;
+        if (end && !clif->lookup_vaddr(clif->data, end, &end_vaddr)) {
+                out(clif, "Failed to look up address 0x%08x\n",
+                    end);
+                return;
+        }
+
+        uint32_t size;
+        uint8_t *cl = start_vaddr;
+        while (clif_dump_packet(clif, start, cl, &size)) {
+                cl += size;
+                start += size;
+
+                if (cl == end_vaddr)
+                        break;
+        }
+}
+
 static void
 clif_process_worklist(struct clif_dump *clif)
 {
@@ -245,23 +276,9 @@ clif_process_worklist(struct clif_dump *clif)
 }
 
 void
-clif_dump_add_cl(struct clif_dump *clif, uint32_t address)
+clif_dump_add_cl(struct clif_dump *clif, uint32_t start, uint32_t end)
 {
-        uint32_t size;
-
-        void *vaddr;
-        if (!clif->lookup_vaddr(clif->data, address, &vaddr)) {
-                out(clif, "Failed to look up address 0x%08x\n",
-                    address);
-                return;
-        }
-
-        uint8_t *cl = vaddr;
-        while (clif_dump_packet(clif, address, cl, &size)) {
-                cl += size;
-                address += size;
-        }
-
+        clif_dump_cl(clif, start, end);
         out(clif, "\n");
 
         clif_process_worklist(clif);