blob: c683d6f68c4f086bf9c16a800f276f8614931335 [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
28 Sinfo : Musinfo.Subject_Info_Type
29 with
Nico Hubera6a49092018-05-18 15:04:12 +020030 Volatile,
31 Async_Writers,
Nico Huberb6641192017-02-13 15:27:30 +010032 Address => System'To_Address (Sinfo_Base_Address);
33
34 Sched_Info : Muschedinfo.Scheduling_Info_Type
35 with
36 Volatile,
37 Async_Writers,
38 Address => System'To_Address (Sinfo_Base_Address + Sinfo_Page_Size);
39
40 function Raw_Value_Min return T
41 is
42 TSC_Schedule_Start : constant Interfaces.Unsigned_64
43 := Sched_Info.TSC_Schedule_Start;
44 begin
45 return T (TSC_Schedule_Start);
46 end Raw_Value_Min;
47
48 function Raw_Value_Max return T
49 is
50 TSC_Schedule_End : constant Interfaces.Unsigned_64
51 := Sched_Info.TSC_Schedule_End;
52 begin
53 return T (TSC_Schedule_End);
54 end Raw_Value_Max;
55
Nico Hubera6a49092018-05-18 15:04:12 +020056 function Hz return T
57 is
58 Khz : constant T := T (Sinfo.TSC_Khz);
Nico Huberb6641192017-02-13 15:27:30 +010059 begin
Nico Hubera6a49092018-05-18 15:04:12 +020060 return Khz * 1000;
Nico Huberb6641192017-02-13 15:27:30 +010061 end Hz;
62
63end HW.Time.Timer;