| Nico Huber | b664119 | 2017-02-13 15:27:30 +0100 | [diff] [blame] | 1 | -- |
| 2 | -- Copyright (C) 2015-2016 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; version 2 of the License. |
| 7 | -- |
| 8 | -- This program is distributed in the hope that it will be useful, |
| 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | -- GNU General Public License for more details. |
| 12 | -- |
| 13 | |
| 14 | with System; |
| 15 | |
| 16 | with Musinfo; |
| 17 | with Muschedinfo; |
| 18 | |
| 19 | package body HW.Time.Timer |
| Nico Huber | a6a4909 | 2018-05-18 15:04:12 +0200 | [diff] [blame] | 20 | with Refined_State => (Timer_State => (Sinfo), |
| 21 | Abstract_Time => (Sched_Info)) |
| Nico Huber | b664119 | 2017-02-13 15:27:30 +0100 | [diff] [blame] | 22 | is |
| 23 | Sinfo_Base_Address : constant := 16#000e_0000_0000#; |
| 24 | Sinfo_Page_Size : constant |
| 25 | := ((Musinfo.Subject_Info_Type_Size + (16#1000# - 1)) |
| 26 | / 16#1000#) * 16#1000#; |
| 27 | |
| Adrian-Ken Rueegsegger | 69e9086 | 2020-01-21 13:53:59 +0100 | [diff] [blame] | 28 | Sinfo : constant Musinfo.Subject_Info_Type |
| Nico Huber | b664119 | 2017-02-13 15:27:30 +0100 | [diff] [blame] | 29 | with |
| Adrian-Ken Rueegsegger | 69e9086 | 2020-01-21 13:53:59 +0100 | [diff] [blame] | 30 | Import, |
| Nico Huber | b664119 | 2017-02-13 15:27:30 +0100 | [diff] [blame] | 31 | Address => System'To_Address (Sinfo_Base_Address); |
| 32 | |
| 33 | Sched_Info : Muschedinfo.Scheduling_Info_Type |
| 34 | with |
| 35 | Volatile, |
| 36 | Async_Writers, |
| 37 | Address => System'To_Address (Sinfo_Base_Address + Sinfo_Page_Size); |
| 38 | |
| 39 | function Raw_Value_Min return T |
| 40 | is |
| 41 | TSC_Schedule_Start : constant Interfaces.Unsigned_64 |
| 42 | := Sched_Info.TSC_Schedule_Start; |
| 43 | begin |
| 44 | return T (TSC_Schedule_Start); |
| 45 | end Raw_Value_Min; |
| 46 | |
| 47 | function Raw_Value_Max return T |
| 48 | is |
| 49 | TSC_Schedule_End : constant Interfaces.Unsigned_64 |
| 50 | := Sched_Info.TSC_Schedule_End; |
| 51 | begin |
| 52 | return T (TSC_Schedule_End); |
| 53 | end Raw_Value_Max; |
| 54 | |
| Nico Huber | a6a4909 | 2018-05-18 15:04:12 +0200 | [diff] [blame] | 55 | function Hz return T |
| 56 | is |
| 57 | Khz : constant T := T (Sinfo.TSC_Khz); |
| Nico Huber | b664119 | 2017-02-13 15:27:30 +0100 | [diff] [blame] | 58 | begin |
| Nico Huber | a6a4909 | 2018-05-18 15:04:12 +0200 | [diff] [blame] | 59 | return Khz * 1000; |
| Nico Huber | b664119 | 2017-02-13 15:27:30 +0100 | [diff] [blame] | 60 | end Hz; |
| 61 | |
| 62 | end HW.Time.Timer; |