hirtos_1.0.0_e7372ec1/hirtos_separation_kernel/src/porting_layer/cpu_architectures/armv8r_aarch32/hirtos_cpu_arch_interface-system_registers-hypervisor.adb

  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
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
--
--  Copyright (c) 2022-2023, German Rivera
--
--
--  SPDX-License-Identifier: Apache-2.0
--

--
--  @summary RTOS to target platform interface - ARMv8-R hypervisor registers
--

with System.Machine_Code;

package body HiRTOS_Cpu_Arch_Interface.System_Registers.Hypervisor
   with SPARK_Mode => On
is
   function Get_HCR return HCR_Type is
      HCR_Value : HCR_Type;
   begin
      System.Machine_Code.Asm (
         "mrc p15, 4, %0, c1, c1, 0",
         Outputs => HCR_Type'Asm_Output ("=r", HCR_Value), --  %0
         Volatile => True);

      return HCR_Value;
   end Get_HCR;

   procedure Set_HCR (HCR_Value : HCR_Type) is
   begin
      System.Machine_Code.Asm (
         "mcr p15, 4, %0, c1, c1, 0",
         Inputs => HCR_Type'Asm_Input ("r", HCR_Value), --  %0
         Volatile => True);
   end Set_HCR;

   function Get_HSR return HSR_Type is
      HSR_Value : HSR_Type;
   begin
      System.Machine_Code.Asm (
         "mrc p15, 4, %0, c5, c2, 0",
         Outputs => HSR_Type'Asm_Output ("=r", HSR_Value), --  %0
         Volatile => True);

      return HSR_Value;
   end Get_HSR;

   procedure Set_HSR (HSR_Value : HSR_Type) is
   begin
      System.Machine_Code.Asm (
         "mcr p15, 4, %0, c5, c2, 0",
         Inputs => HSR_Type'Asm_Input ("r", HSR_Value), --  %0
         Volatile => True);
   end Set_HSR;

   function Get_HSCTLR return HSCTLR_Type is
      HSCTLR_Value : HSCTLR_Type;
   begin
      System.Machine_Code.Asm (
         "mrc p15, 4, %0, c1, c0, 0",
         Outputs => HSCTLR_Type'Asm_Output ("=r", HSCTLR_Value), --  %0
         Volatile => True);

      return HSCTLR_Value;
   end Get_HSCTLR;

   procedure Set_HSCTLR (HSCTLR_Value : HSCTLR_Type) is
   begin
      System.Machine_Code.Asm (
         "mcr p15, 4, %0, c1, c0, 0",
         Inputs => HSCTLR_Type'Asm_Input ("r", HSCTLR_Value), --  %0
         Volatile => True);
   end Set_HSCTLR;

   function Get_VSCTLR return VSCTLR_Type is
      VSCTLR_Value : VSCTLR_Type;
   begin
      System.Machine_Code.Asm (
         "mrc p15, 4, %0, c2, c0, 0",
         Outputs => VSCTLR_Type'Asm_Output ("=r", VSCTLR_Value), --  %0
         Volatile => True);

      return VSCTLR_Value;
   end Get_VSCTLR;

   procedure Set_VSCTLR (VSCTLR_Value : VSCTLR_Type) is
   begin
      System.Machine_Code.Asm (
         "mcr p15, 4, %0, c2, c0, 0",
         Inputs => VSCTLR_Type'Asm_Input ("r", VSCTLR_Value), --  %0
         Volatile => True);
   end Set_VSCTLR;

   function Get_HVBAR return System.Address is
      HVBAR_Value : System.Address;
   begin
      System.Machine_Code.Asm (
         "mrc p15, 4, %0, c12, c0, 0",
         Outputs => System.Address'Asm_Output ("=r", HVBAR_Value), --  %0
         Volatile => True);

      return HVBAR_Value;
   end Get_HVBAR;

   procedure Set_HVBAR (HVBAR_Value : System.Address) is
   begin
      System.Machine_Code.Asm (
         "mcr p15, 4, %0, c12, c0, 0",
         Inputs => System.Address'Asm_Input ("r", HVBAR_Value), --  %0
         Volatile => True);
   end Set_HVBAR;

end HiRTOS_Cpu_Arch_Interface.System_Registers.Hypervisor;