hirtos_1.0.0_e7372ec1/src/generic_execution_stack.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--
--  Copyright (c) 2022-2023, German Rivera
--
--
--  SPDX-License-Identifier: Apache-2.0
--

with System.Storage_Elements;
with Interfaces;
with HiRTOS_Cpu_Arch_Parameters;

--
--  @summary Generic execution stack
--
generic
   Stack_Size_In_Bytes : Positive;
package Generic_Execution_Stack with
  SPARK_Mode => On
is

   type Stack_Overflow_Guard_Type is
     array
       (1 ..
            HiRTOS_Cpu_Arch_Parameters.Memory_Region_Alignment) of Interfaces
       .Unsigned_8 with
     Size =>
      HiRTOS_Cpu_Arch_Parameters.Memory_Region_Alignment * System.Storage_Unit,
     Alignment => HiRTOS_Cpu_Arch_Parameters.Memory_Region_Alignment;

   subtype Stack_Entry_Type is System.Storage_Elements.Integer_Address;

   type Stack_Entries_Type is
     array (1 ..
            Stack_Size_In_Bytes /
            (System.Storage_Elements.Integer_Address'Size / System.Storage_Unit)) of Stack_Entry_Type with
     Convention => C,
     Alignment  =>
      Stack_Entry_Type'Size / System.Storage_Unit;

   type Execution_Stack_Type is limited record
      Stack_Overflow_Guard : Stack_Overflow_Guard_Type;
      Stack_Entries        : Stack_Entries_Type;
   end record with
     Convention => C,
     Alignment  => HiRTOS_Cpu_Arch_Parameters.Memory_Region_Alignment;

end Generic_Execution_Stack;