Guest User

Untitled

a guest
Jan 24th, 2023
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. --
  2. -- Copyright (C) 2013-2015 Reto Buerki <reet@codelabs.ch>
  3. -- Copyright (C) 2013-2015 Adrian-Ken Rueegsegger <ken@codelabs.ch>
  4. --
  5. -- This program is free software: you can redistribute it and/or modify
  6. -- it under the terms of the GNU General Public License as published by
  7. -- the Free Software Foundation, either version 3 of the License, or
  8. -- (at your option) any later version.
  9. --
  10. -- This program is distributed in the hope that it will be useful,
  11. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. -- GNU General Public License for more details.
  14. --
  15. -- You should have received a copy of the GNU General Public License
  16. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. --
  18.  
  19. with Interfaces;
  20.  
  21. with SK.CPU;
  22. with SK.Strings;
  23. with SK.Hypercall;
  24.  
  25. with Musinfo.Instance;
  26.  
  27. with Debuglog.Client;
  28.  
  29. with Log;
  30.  
  31. with Example_Component.Config;
  32. with Example_Component.Events;
  33.  
  34. with Mucontrol.Command.Instance;
  35. with Mucontrol.Status.Instance;
  36.  
  37. procedure Example
  38. is
  39. Cur_Epoch : constant Interfaces.Unsigned_64 := Mucontrol.Command.Instance.Get_Epoch;
  40. begin
  41.  
  42. -- Initialize debug log.
  43.  
  44. Debuglog.Client.Init (Epoch => Cur_Epoch);
  45.  
  46. -- Check sinfo validity.
  47.  
  48. if not Musinfo.Instance.Is_Valid then
  49. Debuglog.Client.Put_Line
  50. (Item => "Error: Muen subject info (sinfo) not valid -> HLT");
  51. SK.CPU.Stop;
  52. end if;
  53.  
  54. -- Say hello via dbglog.
  55.  
  56. Log.Put_Line (Item => Example_Component.Config.Greeter);
  57.  
  58. --D @Lst Configbegin
  59. pragma Debug (Example_Component.Config.Print_Serial,
  60. Log.Put_Line (Item => "Serial " & SK.Strings.Img
  61. (SK.Word64 (Example_Component.Config.Serial))));
  62. pragma Debug (Example_Component.Config.Print_Vcpu_Speed,
  63. Log.Put_Line (Item => "VCPU running with " & SK.Strings.Img
  64. (Musinfo.Instance.TSC_Khz) & " Khz"));
  65. --D @Lst Configend
  66.  
  67. Log.Put_Line (Item => "Current Status: " & SK.Strings.Img
  68. (Item => SK.Word64 (Mucontrol.Status.Instance.Get)));
  69. Log.Put_Line (Item => "Current Epoch : " & SK.Strings.Img
  70. (Item => Cur_Epoch));
  71.  
  72. -- Act as a service: process events from associated subject.
  73.  
  74. declare
  75. use type Interfaces.Unsigned_64;
  76.  
  77. --Minor_Start : SK.Word64;
  78. --Minor_End : SK.Word64;
  79. TSC_Value : Interfaces.Unsigned_64;
  80. TSC_Khz : constant Musinfo.TSC_Tick_Rate_Khz_Type := Musinfo.Instance.TSC_Khz;
  81. TSC_Mhz : constant Interfaces.Unsigned_64 := TSC_Khz / 1000;
  82. Activation_Delay : Interfaces.Unsigned_64;
  83. Old_Activation_Time : Interfaces.Unsigned_64;
  84. Microsecs_Boot : Interfaces.Unsigned_64;
  85. begin
  86. Old_Activation_Time := 0;
  87. loop
  88.  
  89. Log.Put_Line (Item => Example_Component.Config.Greeter);
  90.  
  91. -- Sleep until next period
  92. Log.Put_Line (Item => "Going to sleep");
  93. Log.Put_Line (Item => "------------------------------------------------------");
  94. SK.Hypercall.Trigger_Event (Number => Example_Component.Events.Yield_ID);
  95.  
  96. --Minor_Start := Musinfo.Instance.TSC_Schedule_Start;
  97. --Minor_End := Musinfo.Instance.TSC_Schedule_End;
  98. TSC_Value := SK.CPU.RDTSC;
  99. Microsecs_Boot := TSC_Value / TSC_Mhz;
  100. Activation_Delay := Microsecs_Boot - Old_Activation_Time;
  101. Log.Put_Line (Item => "Activation delay in microseconds: " & SK.Strings.Img_Dec (Activation_Delay));
  102. --Log.Put_Line (Item => "Wakeup in frame " & SK.Strings.Img_Dec (Minor_Start) & " .. " & SK.Strings.Img_Dec (Minor_End));
  103. Log.Put_Line (Item => "Microseconds since boot " & SK.Strings.Img_Dec (Microsecs_Boot));
  104. Old_Activation_Time := Microsecs_Boot;
  105. end loop;
  106. end;
  107. end Example;
Add Comment
Please, Sign In to add comment