blob: 8e9b497035af29fb56dcfb969a80d5c92c0b0d35 [file] [log] [blame]
Nico Huberb6641192017-02-13 15:27:30 +01001--
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
14with System;
15
16with Musinfo;
17with Muschedinfo;
18
19package body HW.Time.Timer
Nico Hubera6a49092018-05-18 15:04:12 +020020 with Refined_State => (Timer_State => (Sinfo),
21 Abstract_Time => (Sched_Info))
Nico Huberb6641192017-02-13 15:27:30 +010022is
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 Rueegsegger69e90862020-01-21 13:53:59 +010028 Sinfo : constant Musinfo.Subject_Info_Type
Nico Huberb6641192017-02-13 15:27:30 +010029 with
Adrian-Ken Rueegsegger69e90862020-01-21 13:53:59 +010030 Import,
Nico Huberb6641192017-02-13 15:27:30 +010031 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 Hubera6a49092018-05-18 15:04:12 +020055 function Hz return T
56 is
57 Khz : constant T := T (Sinfo.TSC_Khz);
Nico Huberb6641192017-02-13 15:27:30 +010058 begin
Nico Hubera6a49092018-05-18 15:04:12 +020059 return Khz * 1000;
Nico Huberb6641192017-02-13 15:27:30 +010060 end Hz;
61
62end HW.Time.Timer;