Add Null_TP constant
[libxhcidbg.git] / src / hw-dbc-transfer_rings.adb
index f5847d999d2d3cf88542a95424b78a9bf38dce4c..8f6f657feb24c1bee02b0c837085c9f9fd68f65d 100644 (file)
@@ -47,6 +47,13 @@ is
       Toggle   : TRBs.Ring_Range;
       Overrun  : Boolean;
    end record;
+   Null_TP : constant Transfer_Pointers
+     := (Enqueue => TRBs.Ring_Range'First,
+         Dequeue => TRBs.Ring_Range'First,
+         Full    => False,
+         Toggle  => TRBs.Ring_Range'First,
+         Overrun => False);
+
    type Transfer_Pointers_Array is array (Endpoint_Range) of Transfer_Pointers;
    Pointers : Transfer_Pointers_Array;
 
@@ -99,13 +106,8 @@ is
         (Physical => Physical (EP),
          Ring     => Rings (EP));
 
-      PCS (EP)       := 1;
-      Pointers (EP)  := Transfer_Pointers'
-        (Enqueue => TRBs.Ring_Range'First,
-         Dequeue => TRBs.Ring_Range'First,
-         Full    => False,
-         Toggle  => TRBs.Ring_Range'First,
-         Overrun => False);
+      PCS (EP)      := 1;
+      Pointers (EP) := Null_TP;
    end Initialize;
 
    ----------------------------------------------------------------------------
@@ -172,8 +174,8 @@ is
       Status            : Error;
       Remaining_Length  : Natural)
    is
-      use type TRBs.TRB_Types;
       use type TRBs.Ring_Range;
+
       Current : TRBs.Ring_Range;
       Invalid : Boolean;
    begin
@@ -203,17 +205,30 @@ is
          while Pointers (EP).Dequeue /= Current loop
             -- Finish transfers that have been skipped by the controller
             pragma Debug (Debug.Put_Line ("WARNING: Skipped TD."));
-            Transfer_Info.Finish
-              (DMA_Physical      => TRBs.Get_Parameter
-                                      (Rings (EP) (Pointers (EP).Dequeue)),
-               Status            => Controller_Error,
-               Remaining_Length  => Max_Bulk_Size);
+            declare
+               Cur_Address : Word64;
+            begin
+               TRBs.Get_Parameter
+                 (Data      => Rings (EP) (Pointers (EP).Dequeue),
+                  Parameter => Cur_Address);
+               Transfer_Info.Finish
+                 (DMA_Physical      => Cur_Address,
+                  Status            => Controller_Error,
+                  Remaining_Length  => Max_Bulk_Size);
+            end;
             Dequeue_TRB (EP);
          end loop;
-         Transfer_Info.Finish
-           (DMA_Physical      => TRBs.Get_Parameter (Rings (EP) (Current)),
-            Status            => Status,
-            Remaining_Length  => Remaining_Length);
+         declare
+            Cur_Address : Word64;
+         begin
+            TRBs.Get_Parameter
+              (Data      => Rings (EP) (Current),
+               Parameter => Cur_Address);
+            Transfer_Info.Finish
+              (DMA_Physical      => Cur_Address,
+               Status            => Status,
+               Remaining_Length  => Remaining_Length);
+         end;
          Dequeue_TRB (EP);
       end if;