File: /home/oboss/Users/gec/sources/PUS_Services/Memory_Management/memory_management_parser.ads

1     --% Compilation Unit: Memory_Management_Parser
2     --
3     --% Category: Generic Package Declaration
4     --
5     --% Release:  $Name:  $
6     --
7     --% Version:  $Revision: 2.2 $
8     --
9     --% Author:   $Author: gec $
10     --
11     --% Revision Log:
12     --    $Log: memory_management_parser.ads,v $
13     --    Revision 2.2  2003/11/13 14:57:49  gec
14     --    Merged ECSS Migration branch to main trunk.
15     --
16     --    Revision 2.1.4.1  2003/11/10 10:03:40  gec
17     --    Updated memory management service in accordance with ECSS-E-70-41A.
18     --
19     --    Revision 2.1  2003/10/21 08:44:50  gec
20     --    Merged STADY_Recommendations branch onto trunk.
21     --    Contains numerous updates resulting from STADY fault descriptions.
22     --
23     --    Revision 2.0.2.1  2003/10/09 13:54:24  gec
24     --    Added check for total required bit size for memory dumps.
25     --    A telecommand verification failure is generated if this exceeds the
26     --+    maximum available source data size.
27     --
28     --    Response to STADY fault description Fault 11.
29     --
30     --    Revision 2.0  2003/04/04 08:51:09  gec
31     --    Initial release of source files serving as baseline for OBOSS-III
32     --+    project.
33     --
34     --    Revision 1.1.1.1  2003/04/04 08:13:13  gec
35     --    Imported using TkCVS
36     --
37     --
38     --
39     --% Project: OBOSS
40     --
41     --% Copyright (C) 2003 by Terma A/S
42     --  Proprietary and intellectual rights of Terma A/S, Denmark,
43     --  are involved in the subject-matter of this material and
44     --  all manufacturing, reproduction, use, disclosure, and
45     --  sales rights pertaining to such subject-matter are
46     --  expressly reserved. This material is submitted for a
47     --  specific purpose as agreed, and the recipient by
48     --  accepting this material agrees that this material will
49     --  not be used, copied, or reproduced in whole or in part
50     --  nor its contents revealed in any manner or to any person,
51     --  except to meet the purpose for which it was submitted and
52     --  subject to the terms of the agreement.
53     --
54     --% Target Dependencies:
55     --    None
56     --% Compiler Dependencies:
57     --    None
58     
59     --~-----------------------------------------------------------------------------
60     
61     with Mission_Parameters;
62     with PUS;
63     with Memory_Management_Types;
64     with External_Memory_Management_Types;
65     with PUS_Data_Types;
66     with Basic_Types;
67     with ISO_Checksum;
68     with Verification_Types;
69     with Source_Data_Stream;
70     with Parser;
71     with System.Storage_Elements;
72     generic
73     
74        --% Generic Parameter Constraints:
75        -->   None
76     
77        -- Maximum number of elements in service requests containing lists
78        Max_List_Length : in     Positive;
79        -- Maximum length of a data block expressed in <SMALLEST_ADDRESSABLE_UNIT>
80        Max_Data_Length : in     Positive;
81     
82        -- Types and representations of memory identifications
83        type Memory_ID is (<>);
84        type Memory_ID_Rep is array (Memory_ID) of
85              External_Memory_Management_Types.Memory_ID;
86        Memory_ID_Rep_Vals : in     Memory_ID_Rep;
87     
88        Application_ID : in     Mission_Parameters.APID;
89     
90        -- Routine for writing data at a given memory block and a given start
91        --+    address within that block.
92        with procedure Write_Data
93              (Memory_Def       : in     Memory_ID;
94               Absolute_Address : in     Memory_Management_Types.Start_Address;
95               Data_Val         : in     Memory_Management_Types.Data);
96     
97        -- Routine for reading data at a given memory block and a given start
98        --+    address within that block and with a given length.
99        with procedure Read_Data
100              (Memory_Def       : in     Memory_ID;
101               Absolute_Address : in     Memory_Management_Types.Start_Address;
102               Data_Val         :    out Memory_Management_Types.Data);
103     
104        -- Routine for calculating the ISO checksum data at a given memory block and
105        --+    a given start address within that block and with a given length.
106        with function Calculate_ISO_Checksum
107              (Memory_Def       : in     Memory_ID;
108               Absolute_Address : in     Memory_Management_Types.Start_Address;
109               Length           : in     Memory_Management_Types.Data_Length)
110              return ISO_Checksum.Checksum_Type;
111     
112        -- Routine for depositing generated telemetry, should be instantiated with
113        --+    an   operation that ensures that telemetry packet counters are
114        --+    updated.
115        with function Optional_Deposit
116              (Packet : in     PUS.Optional_PUS_Packet)
117              return Boolean;
118     
119     package Memory_Management_Parser is
120     
121        --% Library Package:
122        --    Parsing of the source data part of TCs and unparsing of the source
123        --+    data part of TMs related to memory management
124        --% Active Tasks:
125        -->   None
126        --% Passive Tasks:
127        -->   None
128     
129        -- Indicates that unparsing of internal TM representation failed
130        Unparsing_Failed : exception;
131     
132        -- Indicates that report generation failed as report exceeded maximum source
133        --+    data size.
134        Max_Source_Data_Size_Exceeded : exception;
135     
136        type List_Length is new Memory_Management_Types.List_Length;
137     
138        -- Types related to internal representation of Telecommands
139     
140        type TC_Subservice is
141              (Load_Memory_Using_Absolute_Address,
142               Dump_Memory_Using_Absolute_Address,
143               Check_Memory_Using_Absolute_Address);
144     
145        type Address_And_Data is
146           record
147              Absolute_Address :
148                 Memory_Management_Types.Start_Address;
149              Data_Val_Length :
150                 Memory_Management_Types.Data_Length;
151              Data_Val :
152                 Memory_Management_Types.Data
153                    (1 .. Memory_Management_Types.Data_Length(Max_Data_Length));
154           end record;
155     
156        subtype Data_Block_Index is
157              List_Length range 1 .. List_Length(Max_List_Length);
158        type Absolute_Address_Blocks is array (Data_Block_Index) of
159              Address_And_Data;
160     
161        type Load_Memory_Absolute_Spec is
162           record
163              Memory_Def      : Memory_ID;
164              Number_Of_Elems : List_Length;
165              Address_Blocks  : Absolute_Address_Blocks;
166           end record;
167     
168        type Address_And_Length is
169           record
170              Absolute_Address : Memory_Management_Types.Start_Address;
171              Length           : Memory_Management_Types.Data_Length;
172           end record;
173     
174        type Absolute_Address_Specs is array (Data_Block_Index) of
175              Address_And_Length;
176     
177        type Memory_Absolute_Address_Specs is
178           record
179              Memory_Def      : Memory_ID;
180              Number_Of_Elems : List_Length;
181              Address_Specs   : Absolute_Address_Specs;
182           end record;
183     
184        --   type Internal_TC_Source_Data
185        --         (Subservice : TC_Subservice := TC_Subservice'First) is
186        --      record
187        --         case Subservice is
188        --            when Load_Memory_Using_Absolute_Address =>
189        --               Load_Absolute_Def : Load_Memory_Absolute_Spec;
190        --            when Dump_Memory_Using_Absolute_Address =>
191        --               Dump_Absolute_Def : Memory_Absolute_Address_Specs;
192        --            when Check_Memory_Using_Absolute_Address =>
193        --               Check_Absolute_Def : Memory_Absolute_Address_Specs;
194        --         end case;
195        --      end record;
196     
197        --% Subprogram:
198        --    Prepare for execution of new telecommand
199        --% Parameter Constraints:
200        -->   None
201        --% Exceptions Raised:
202        -->   None
203        procedure Start_New_TC_Interpretation;
204     
205        --% Subprogram:
206        --    Send verification telemetry for a given stage
207        --% Parameter Constraints:
208        -->   None
209        --% Exceptions Raised:
210        -->   None
211        procedure Verify_Stage
212              (TC     : in     PUS.PUS_Packet;
213               Stage  : in     PUS_Data_Types.Ack_Stages;
214               Status : in     Verification_Types.Verification_Status);
215        type Internal_TC_Source_Data is tagged null record;
216        --% Subprogram:
217        --    Interpret a memory management TC
218        --% Parameter Constraints:
219        -->   None
220        --% Exceptions Raised:
221        -->   Source_Data_Stream.No_Streams_Available  - Heap of source streams has
222        --+    been exhausted
223        -->   PUS_State.No_Packets_Available  - Heap of PUS packets has been
224        --+    exhausted
225        function Interpret_TC
226              (TC  :        PUS.PUS_Packet;
227               Cmd :        Internal_TC_Source_Data)
228              return Boolean;
229     
230        type Internal_TC_Source_Data_Load_Memory_Using_Absolute_Address is new
231              Internal_TC_Source_Data
232           with record
233              Load_Absolute_Def : Load_Memory_Absolute_Spec;
234           end record;
235     
236        --% Subprogram:
237        --    Interpret a memory management TC
238        --% Parameter Constraints:
239        -->   None
240        --% Exceptions Raised:
241        -->   Source_Data_Stream.No_Streams_Available  - Heap of source streams has
242        --+    been exhausted
243        -->   PUS_State.No_Packets_Available  - Heap of PUS packets has been
244        --+    exhausted
245        function Interpret_TC
246              (TC  :        PUS.PUS_Packet;
247               Cmd
248                   :        Internal_TC_Source_Data_Load_Memory_Using_Absolute_Address)
249              return Boolean;
250     
251        type Internal_TC_Source_Data_Dump_Memory_Using_Absolute_Address is new
252              Internal_TC_Source_Data
253           with record
254              Dump_Absolute_Def : Memory_Absolute_Address_Specs;
255           end record;
256     
257        --% Subprogram:
258        --    Interpret a memory management TC
259        --% Parameter Constraints:
260        -->   None
261        --% Exceptions Raised:
262        -->   Source_Data_Stream.No_Streams_Available  - Heap of source streams has
263        --+    been exhausted
264        -->   PUS_State.No_Packets_Available  - Heap of PUS packets has been
265        --+    exhausted
266        function Interpret_TC
267              (TC  :        PUS.PUS_Packet;
268               Cmd
269                   :        Internal_TC_Source_Data_Dump_Memory_Using_Absolute_Address)
270              return Boolean;
271     
272        type Internal_TC_Source_Data_Check_Memory_Using_Absolute_Address is new
273              Internal_TC_Source_Data
274           with record
275              Check_Absolute_Def : Memory_Absolute_Address_Specs;
276           end record;
277     
278        --% Subprogram:
279        --    Interpret a memory management TC
280        --% Parameter Constraints:
281        -->   None
282        --% Exceptions Raised:
283        -->   Source_Data_Stream.No_Streams_Available  - Heap of source streams has
284        --+    been exhausted
285        -->   PUS_State.No_Packets_Available  - Heap of PUS packets has been
286        --+    exhausted
287        function Interpret_TC
288              (TC  :        PUS.PUS_Packet;
289               Cmd
290                   :        Internal_TC_Source_Data_Check_Memory_Using_Absolute_Address)
291              return Boolean;
292     
293        type Interpretation_Result is
294              (Failed,
295               Passed);
296     
297        --% Subprogram:
298        --    Read the data part of a TC from from Src_Data and convert it into an
299        --+    internal representation
300        --% Parameter Constraints:
301        -->   None
302        --% Exceptions Raised:
303        -->   Source_Data_Is_Inconsistent  - When a valid memory management TC
304        --+    source data part cannot be read from Src_Data
305        -->   Source_Data_Stream.Read_Stream_Exhausted  - When Src_Data does not
306        --+    hold a sufficient number of bits.
307        function Parse_Source_Data
308              (Service_Subtype : in     PUS_Data_Types.Service_Subtype;
309               Src_Data        : in     Source_Data_Stream.Read_Stream)
310              return Internal_TC_Source_Data'Class;
311     
312        Memory_Management_Service_Type :
313           constant PUS_Data_Types.Service_Type :=
314                    PUS_Data_Types.Memory_Management;
315     
316        package The_Parser is new Parser
317                 (Service_Type            => Memory_Management_Service_Type,
318                  Internal_TC_Source_Data => Internal_TC_Source_Data,
319                  Parse_Source_Data       => Parse_Source_Data);
320     
321        subtype Internal_TC_Representation is
322              The_Parser.Internal_TC_Representation;
323     
324        subtype Internal_TC_Representation_Failed is
325              The_Parser.Internal_TC_Representation_Failed;
326     
327        subtype Internal_TC_Representation_Passed is
328              The_Parser.Internal_TC_Representation_Passed;
329     
330     
331        -- Types related to internal representation of telemetry
332     
333        type Memory_Dump_Using_Absolute_Address_Report is
334           record
335              Memory_Def      : Memory_ID;
336              Number_Of_Elems : List_Length             := 0;
337              Address_Blocks  : Absolute_Address_Blocks;
338           end record;
339     
340        type Absolute_Checksum_Elem is
341           record
342              Absolute_Address : Memory_Management_Types.Start_Address;
343              Length           : Memory_Management_Types.Data_Length;
344              Checksum         : ISO_Checksum.Checksum_Type;
345           end record;
346     
347        subtype Memory_Check_Absolute_Index is
348              List_Length range 1 .. List_Length(Max_List_Length);
349        type Memory_Check_Absolute is array (Memory_Check_Absolute_Index) of
350              Absolute_Checksum_Elem;
351     
352        type Memory_Check_Using_Absolute_Address_Report is
353           record
354              Memory_Def        : Memory_ID;
355              Number_Of_Elems   : List_Length           := 0;
356              Memory_Check_Info : Memory_Check_Absolute;
357           end record;
358     
359     
360        --% Subprogram:
361        --    Transform the source data part of a memory management TC into its
362        --+    internal representation
363        --% Parameter Constraints:
364        -->   None
365        --% Exceptions Raised:
366        -->   None
367     
368        function Parse_TC
369              (TC : in     PUS.PUS_Packet)
370              return Internal_TC_Representation'Class;
371     
372     
373        --% Subprogram:
374        --    Produce a telemetry packet with a given 'memory dump using absolute
375        --+    address report' as its source data
376        --% Parameter Constraints:
377        -->   None
378        --% Exceptions Raised:
379        -->   Unparsing_Failed  - When a Memory_Dump_Using_Absolute_Address_Report
380        --+    cannot be written to Src_Data
381        -->   Source_Data_Stream.Write_Stream_Exhausted  - When there is not
382        --+    sufficient space for the value on Src_Data
383        -->   Source_Data_Stream.No_Streams_Available  - Heap of source streams has
384        --+    been exhausted
385        -->   PUS_State.No_Packets_Available  - Heap of PUS packets has been
386        --+    exhausted
387     
388        function Unparse_Memory_Dump_Using_Absolute_Address_Report
389              (Appl_ID            : in     Mission_Parameters.APID;
390               Memory_Dump_Report
391                                  : in     Memory_Dump_Using_Absolute_Address_Report)
392              return PUS.PUS_Packet;
393     
394     
395        --% Subprogram:
396        --    Produce a telemetry packet with a given 'memory check using absolute
397        --+    address report' as its source data
398        --% Parameter Constraints:
399        -->   None
400        --% Exceptions Raised:
401        -->   Unparsing_Failed  - When a Memory_Check_Using_Absolute_Address_Report
402        --+    cannot be written to Src_Data
403        -->   Source_Data_Stream.Write_Stream_Exhausted  - When there is not
404        --+    sufficient space for the value on Src_Data
405        -->   Source_Data_Stream.No_Streams_Available  - Heap of source streams has
406        --+    been exhausted
407        -->   PUS_State.No_Packets_Available  - Heap of PUS packets has been
408        --+    exhausted
409     
410        function Unparse_Memory_Check_Using_Absolute_Address_Report
411              (Appl_ID             : in     Mission_Parameters.APID;
412               Memory_Check_Report
413                                   : in     Memory_Check_Using_Absolute_Address_Report)
414              return PUS.PUS_Packet;
415     
416        procedure Initialize;
417     
418     end Memory_Management_Parser;
419     
420     --~-----------------------------------------------------------------------------
421