public override void ReleaseResources() { clock.ReleaseResources(); clock = null; timer.ReleaseResources(); timer = null; pic.ReleaseResources(); pic = null; }
public override void Initialize(Processor rootProcessor) { DebugStub.Print("HalDevices.Initialize() - Legacy\n"); pmTimer = AcpiTables.GetPMTimer(); // PIC PnpConfig picConfig = (PnpConfig)IoSystem.YieldResources("/pnp/PNP0000", typeof(Pic)); pic = new Pic(picConfig); pic.Initialize(); // Timer PnpConfig timerConfig = (PnpConfig)IoSystem.YieldResources("/pnp/PNP0100", typeof(Timer8254LegacyPC)); timer = new Timer8254LegacyPC(timerConfig, pic); byte timerInterrupt = timer.Initialize(); // Real-time clock PnpConfig clockConfig = (PnpConfig)IoSystem.YieldResources("/pnp/PNP0B00", typeof(RTClockLegacyPC)); clock = new RTClockLegacyPC(clockConfig, pic, timer); byte clockInterrupt = clock.Initialize(); bool noisyTimer = false; if (pmTimer != null) { noisyTimer = CalibrateTimers.Run(pmTimer, timer); } else { CalibrateTimers.Run(clock, timer); } clock.SetNoisyTimer(noisyTimer); clock.Start(); SystemClock.Initialize(clock, TimeSpan.FromHours(8).Ticks); rootProcessor.AddPic(pic); rootProcessor.AddTimer(timerInterrupt, timer); rootProcessor.AddClock(clockInterrupt, clock); // ---------------------------------------------------------- // Add Srat tables to the Processor halMemory = new HalMemorySrat(AcpiTables.GetSrat()); Processor.AddMemory(halMemory); timer.Start(); // Get the screen resources. Since we have metadata above to // declare all fixed resources used by the screen, // YieldResources("") will keep the resource tracking correct: halScreen = new HalScreenDirect(IoSystem.YieldResources("", typeof(HalScreen))); Console.Screen = (HalScreen)halScreen; }
internal static void Run(RTClockLegacyPC rtc, Timer8254LegacyPC i8254) { // This test uses the RTC's update-in-progress bit, UIP, as // a measure of 1 second of time. The UIP set period is // around 240us which means we can safely read the // i8254 in a loop without worrying about missing the // bit being set / cleared because of i/o operations. // // This test fails horribly on VPC. It has problems with the // update-in-progress bit in the RTC. Fortunately we should // not get here on VPC. // // NB This routine does not try to be as rigorous as // the PM Timer version as each calibration run // takes much longer. const int testRuns = 2; int i8254Last = 0; int i8254Now = 0; int i8254Accum = 0; int [] i8254Hz = new int [testRuns]; ulong tscLast = 0; ulong tscNow = 0; ulong [] tscHz = new ulong[testRuns]; i8254.Timer2Start(); do { tscLast = Processor.CycleCount; i8254Last = i8254.Timer2Read(); } while (rtc.UpdateInProgress() == false); for (int i = 0; i < testRuns; i++) { while (rtc.UpdateInProgress() == true) { ; } do { tscNow = Processor.CycleCount; i8254Now = i8254.Timer2Read(); i8254Accum += (0x10000 + i8254Last - i8254Now) & 0xffff; i8254Last = i8254Now; }while (rtc.UpdateInProgress() == false); tscHz[i] = (tscNow + 0x1000000000000 - tscLast) & 0xffffffffffff; tscLast = tscNow; i8254Hz[i] = i8254Accum; i8254Accum = 0; } DisplayResults(tscHz[testRuns - 1], i8254Hz[testRuns - 1]); Processor.CyclesPerSecond = tscHz[testRuns - 1]; i8254.SetTicksPerSecond(i8254Hz[testRuns - 1]); }