Exemple #1
0
 internal static void SwitchToHpetClock(Hpet hpet)
 {
     DebugStub.WriteLine("Switching to HPET clock");
     halClock.SwitchToHpetClock(
         new HpetClock(hpet, (ulong)halClock.GetKernelTicks() + 1000u)
         );
 }
Exemple #2
0
        public static uint UpdateFrequency(Hpet hpet)
        {
            // Compute RTC clock frequency (2^n Hz) to avoid a
            // wrap between clock interrupts.
            ulong wrapPeriodUs =
                ((ulong)0xffffffffu * hpet.PeriodFs) / (1000000 * 1000);
            uint wrapFrequency =
                1 + (uint)((long)1000000 / (1 + wrapPeriodUs));
            uint updateFrequency = 2;   // Min freq of RTC

            while (updateFrequency < 4 * wrapFrequency)
            {
                updateFrequency *= 2;
            }
            return(updateFrequency);
        }
Exemple #3
0
        internal static IDevice CreateDevice(IoConfig config, string name)
        {
            PnpConfig pnpConfig = config as PnpConfig;

            if (pnpConfig == null)
            {
                return(null);
            }

            IoMemoryRange imr = config.DynamicRanges[0] as IoMemoryRange;

            if (imr == null)
            {
                return(null);
            }

            int imrBytes = (int)imr.Length.ToUInt32();

            if (imrBytes < Hpet.MinRegionBytes)
            {
                DebugStub.Write(
                    "HPET failed as region too small ({0} bytes).\n",
                    __arglist(imrBytes));
                return(null);
            }

            Hpet hpet = new Hpet(pnpConfig);

            if (hpet.MainCounterWorks())
            {
                HalDevicesApic.SwitchToHpetClock(hpet);
            }
            else
            {
                DebugStub.Print("WARNING: HPET main counter does not work!\n");
            }

            return(hpet);
        }
Exemple #4
0
 internal HpetClock(Hpet timer, ulong initialKernelTicks)
 {
     this.hpet                   = timer;
     this.hpetLastUpdate         = hpet.MainCounterValue32;
     this.kernelTicksAccumulated = initialKernelTicks;
 }