Add Null_TP constant
[libxhcidbg.git] / src / hw-dbc-contexts.adb
1 --
2 -- Copyright (C) 2016-2017 secunet Security Networks AG
3 --
4 -- This program is free software; you can redistribute it and/or modify
5 -- it under the terms of the GNU General Public License as published by
6 -- the Free Software Foundation; either version 2 of the License, or
7 -- (at your option) any later version.
8 --
9 -- This program is distributed in the hope that it will be useful,
10 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 -- GNU General Public License for more details.
13 --
14
15 with System.Storage_Elements;
16 with Ada.Unchecked_Conversion;
17
18 with HW.Debug;
19
20 package body HW.DbC.Contexts
21 with SPARK_Mode => Off
22 is
23
24    procedure Clear_DbC_Context (Context : out DbC_Context)
25    is
26
27       --  These constants must not be global, see [Q213-030].
28
29       Null_Info_Context : constant DbC_Info_Context := DbC_Info_Context'
30         (String_0_Address                 => 0,
31          Manufacturer_String_Address      => 0,
32          Product_String_Address           => 0,
33          Serial_Number_String_Address     => 0,
34          String_0_Length                  => 0,
35          Manufacturer_String_Length       => 0,
36          Product_String_Length            => 0,
37          Serial_Number_String_Length      => 0,
38          Reserved_Z                       => 0,
39          Reserved_Z_2                     => 0,
40          Reserved_Z_3                     => 0,
41          Reserved_Z_4                     => 0);
42
43       Null_Endpoint_Context : constant Endpoint_Context := Endpoint_Context'
44         (EP_State              => Disabled,
45          Reserved_Z            => 0,
46          Mult                  => 0,
47          Max_P_Streams         => 0,
48          Linear_Stream_Array   => 0,
49          Interval              => 0,
50          Reserved_Z_2          => 0,
51          Reserved_Z_3          => 0,
52          Error_Count           => 0,
53          EP_Type               => NA,
54          Reserved_Z_4          => 0,
55          Host_Initiate_Disable => 0,
56          Max_Burst_Size        => 0,
57          Max_Packet_Size       => 0,
58          Dequeue_Cycle_State   => 0,
59          Reserved_Z_5          => 0,
60          TR_Dequeue_Pointer_Lo => 0,
61          TR_Dequeue_Pointer_Hi => 0,
62          Average_TRB_Length    => 0,
63          Max_ESIT_Payload      => 0,
64          reserved1             => 0,
65          reserved2             => 0,
66          reserved3             => 0);
67    begin
68       Context := DbC_Context'
69         (DbC_Info => Null_Info_Context,
70          OUT_EP   => Null_Endpoint_Context,
71          IN_EP    => Null_Endpoint_Context);
72    end Clear_DbC_Context;
73
74    ----------------------------------------------------------------------------
75
76    procedure Dump_Endpoint_Context (EC : in Endpoint_Context)
77    is
78       function EP_State_To_Word is new Ada.Unchecked_Conversion (Endpoint_State, Word3);
79       function EP_Type_To_Word is new Ada.Unchecked_Conversion (Endpoint_Type, Word3);
80    begin
81       Debug.Put_Reg64 ("Endpoint Context", Word64 (System.Storage_Elements.To_Integer (EC'Address)));
82       Debug.Put_Reg8  ("EP_State             ", Word8  (EP_State_To_Word (EC.EP_State)));
83       Debug.Put_Reg8  ("RsvdZ                ", Word8  (EC.Reserved_Z));
84       Debug.Put_Reg8  ("Mult                 ", Word8  (EC.Mult));
85       Debug.Put_Reg8  ("Max_P_Streams        ", Word8  (EC.Max_P_Streams));
86       Debug.Put_Reg8  ("Linear_Stream_Array  ", Word8  (EC.Linear_Stream_Array));
87       Debug.Put_Reg8  ("Interval             ",         EC.Interval);
88       Debug.Put_Reg8  ("RsvdZ                ",         EC.Reserved_Z_2);
89       Debug.Put_Reg8  ("RsvdZ                ", Word8  (EC.Reserved_Z_3));
90       Debug.Put_Reg8  ("Error_Count          ", Word8  (EC.Error_Count));
91       Debug.Put_Reg8  ("EP_Type              ", Word8  (EP_Type_To_Word (EC.EP_Type)));
92       Debug.Put_Reg8  ("RsvdZ                ", Word8  (EC.Reserved_Z_4));
93       Debug.Put_Reg8  ("Host_Initiate_Disable", Word8  (EC.Host_Initiate_Disable));
94       Debug.Put_Reg8  ("Max_Burst_Size       ",         EC.Max_Burst_Size);
95       Debug.Put_Reg16 ("Max_Packet_Size      ",         EC.Max_Packet_Size);
96       Debug.Put_Reg8  ("Dequeue_Cycle_State  ", Word8  (EC.Dequeue_Cycle_State));
97       Debug.Put_Reg8  ("RsvdZ                ", Word8  (EC.Reserved_Z_5));
98       Debug.Put_Reg32 ("TR_Dequeue_Pointer_Lo", Word32 (EC.TR_Dequeue_Pointer_Lo));
99       Debug.Put_Reg32 ("TR_Dequeue_Pointer_Hi",         EC.TR_Dequeue_Pointer_Hi);
100       Debug.Put_Reg16 ("Average_TRB_Length   ",         EC.Average_TRB_Length);
101       Debug.Put_Reg16 ("Max_ESIT_Payload     ",         EC.Max_ESIT_Payload);
102       Debug.Put_Reg32 ("RsvdO                ",         EC.reserved1);
103       Debug.Put_Reg32 ("RsvdO                ",         EC.reserved2);
104       Debug.Put_Reg32 ("RsvdO                ",         EC.reserved3);
105    end Dump_Endpoint_Context;
106
107 end HW.DbC.Contexts;
108
109 --  vim: set ts=8 sts=3 sw=3 et: