Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- Copyright (C) 2013-2015 Reto Buerki <reet@codelabs.ch>
- -- Copyright (C) 2013-2015 Adrian-Ken Rueegsegger <ken@codelabs.ch>
- --
- -- This program is free software: you can redistribute it and/or modify
- -- it under the terms of the GNU General Public License as published by
- -- the Free Software Foundation, either version 3 of the License, or
- -- (at your option) any later version.
- --
- -- This program is distributed in the hope that it will be useful,
- -- but WITHOUT ANY WARRANTY; without even the implied warranty of
- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- -- GNU General Public License for more details.
- --
- -- You should have received a copy of the GNU General Public License
- -- along with this program. If not, see <http://www.gnu.org/licenses/>.
- --
- with Interfaces;
- with SK.CPU;
- with SK.Strings;
- with SK.Hypercall;
- with Musinfo.Instance;
- with Debuglog.Client;
- with Log;
- with Example_Component.Config;
- with Example_Component.Events;
- with Mucontrol.Command.Instance;
- with Mucontrol.Status.Instance;
- procedure Example
- is
- Cur_Epoch : constant Interfaces.Unsigned_64 := Mucontrol.Command.Instance.Get_Epoch;
- begin
- -- Initialize debug log.
- Debuglog.Client.Init (Epoch => Cur_Epoch);
- -- Check sinfo validity.
- if not Musinfo.Instance.Is_Valid then
- Debuglog.Client.Put_Line
- (Item => "Error: Muen subject info (sinfo) not valid -> HLT");
- SK.CPU.Stop;
- end if;
- -- Say hello via dbglog.
- Log.Put_Line (Item => Example_Component.Config.Greeter);
- --D @Lst Configbegin
- pragma Debug (Example_Component.Config.Print_Serial,
- Log.Put_Line (Item => "Serial " & SK.Strings.Img
- (SK.Word64 (Example_Component.Config.Serial))));
- pragma Debug (Example_Component.Config.Print_Vcpu_Speed,
- Log.Put_Line (Item => "VCPU running with " & SK.Strings.Img
- (Musinfo.Instance.TSC_Khz) & " Khz"));
- --D @Lst Configend
- Log.Put_Line (Item => "Current Status: " & SK.Strings.Img
- (Item => SK.Word64 (Mucontrol.Status.Instance.Get)));
- Log.Put_Line (Item => "Current Epoch : " & SK.Strings.Img
- (Item => Cur_Epoch));
- -- Act as a service: process events from associated subject.
- declare
- use type Interfaces.Unsigned_64;
- --Minor_Start : SK.Word64;
- --Minor_End : SK.Word64;
- TSC_Value : Interfaces.Unsigned_64;
- TSC_Khz : constant Musinfo.TSC_Tick_Rate_Khz_Type := Musinfo.Instance.TSC_Khz;
- TSC_Mhz : constant Interfaces.Unsigned_64 := TSC_Khz / 1000;
- Activation_Delay : Interfaces.Unsigned_64;
- Old_Activation_Time : Interfaces.Unsigned_64;
- Microsecs_Boot : Interfaces.Unsigned_64;
- begin
- Old_Activation_Time := 0;
- loop
- Log.Put_Line (Item => Example_Component.Config.Greeter);
- -- Sleep until next period
- Log.Put_Line (Item => "Going to sleep");
- Log.Put_Line (Item => "------------------------------------------------------");
- SK.Hypercall.Trigger_Event (Number => Example_Component.Events.Yield_ID);
- --Minor_Start := Musinfo.Instance.TSC_Schedule_Start;
- --Minor_End := Musinfo.Instance.TSC_Schedule_End;
- TSC_Value := SK.CPU.RDTSC;
- Microsecs_Boot := TSC_Value / TSC_Mhz;
- Activation_Delay := Microsecs_Boot - Old_Activation_Time;
- Log.Put_Line (Item => "Activation delay in microseconds: " & SK.Strings.Img_Dec (Activation_Delay));
- --Log.Put_Line (Item => "Wakeup in frame " & SK.Strings.Img_Dec (Minor_Start) & " .. " & SK.Strings.Img_Dec (Minor_End));
- Log.Put_Line (Item => "Microseconds since boot " & SK.Strings.Img_Dec (Microsecs_Boot));
- Old_Activation_Time := Microsecs_Boot;
- end loop;
- end;
- end Example;
Add Comment
Please, Sign In to add comment