blob: 272289c2cd18e0b72e4d6b31cf8d1e8078e49b3c [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
20 with Refined_State => (Timer_State => null,
21 Abstract_Time => (Sinfo, Sched_Info))
22is
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
30 Address => System'To_Address (Sinfo_Base_Address);
31
32 Sched_Info : Muschedinfo.Scheduling_Info_Type
33 with
34 Volatile,
35 Async_Writers,
36 Address => System'To_Address (Sinfo_Base_Address + Sinfo_Page_Size);
37
38 function Raw_Value_Min return T
39 is
40 TSC_Schedule_Start : constant Interfaces.Unsigned_64
41 := Sched_Info.TSC_Schedule_Start;
42 begin
43 return T (TSC_Schedule_Start);
44 end Raw_Value_Min;
45
46 function Raw_Value_Max return T
47 is
48 TSC_Schedule_End : constant Interfaces.Unsigned_64
49 := Sched_Info.TSC_Schedule_End;
50 begin
51 return T (TSC_Schedule_End);
52 end Raw_Value_Max;
53
54 function Hz return T is
55 begin
56 return T (Sinfo.TSC_Khz) * 1000;
57 end Hz;
58
59end HW.Time.Timer;