// Constructor internal RTClockApic(PnpConfig config, Apic apic) { int cpuId; Microsoft.Singularity.Hal.Platform p = Microsoft.Singularity.Hal.Platform.ThePlatform; cpuId = p.ApicId; DebugStub.Print("RTClock: create\n"); // /pnp/08/03/01/PNP0B00 0003 cfg dis : ISA RTC Controller : AT RTC // IRQ mask=0100 type=47 // I/O Port inf=01 min=0070 max=0070 aln=01 len=02 0070..0071 this.config = config; this.irq = ((IoIrqRange)config.DynamicRanges[1]).Irq; this.apic = apic; this.rtcSpinLock = new SpinLock(SpinLock.Types.RTClock); rtcadd = ((IoPortRange)config.DynamicRanges[0]) .PortAtOffset(0, 1, Access.ReadWrite); rtcdat = ((IoPortRange)config.DynamicRanges[0]) .PortAtOffset(1, 1, Access.ReadWrite); if (cpuId == 0) { this.interrupt = Initialize(); DebugStub.Print("RTClock: interrupt {0:x2}\n", __arglist(this.interrupt)); } }
// // Methods // internal ApicTimer(Apic apic) { this.apic = apic; SetDivisor(1); SetOneShot(); SetInterruptEnabled(false); interrupt = apic.IrqToInterrupt(Apic.TimerIrq); }
internal HalClockApic(Apic apic, RTClockApic rtClock, PMClock pmClock) { this.apic = apic; this.rtClock = rtClock; this.pmClock = pmClock; this.hpetClock = null; this.spinLock = new SpinLock(SpinLock.Types.MpHalClock); }
public override void ReleaseResources() { rtClock.ReleaseResources(); rtClock = null; halTimer.ReleaseResources(); halTimer = null; halPic.ReleaseResources(); halPic = null; pic.ReleaseResources(); pic = null; }
internal HalClockApic(Apic apic, RTClockApic rtClock, PMClock /* ! */ pmClock) { this.apic = apic; this.rtClock = rtClock; this.pmClock = pmClock; this.hpetClock = null; this.tscSnapshot = 0; this.ticksSnapshot = 0; int ticksPerKernelTick = (int)(Processor.CyclesPerSecond / 10000000); this.tickScale = (1 << tickRoll) / ticksPerKernelTick; lastKernelTicks = InternalGetKernelTicks(); }
private void InitializeBsp(Processor rootProcessor) { DebugStub.Print("HalDevicesApic.Initialize()\n"); pmTimer = AcpiTables.GetPMTimer(); // Get PIC resources. Pic is masked by default. PnpConfig picConfig = (PnpConfig)IoSystem.YieldResources("/pnp/PNP0000", typeof(PicStub)); pic = new PicStub(picConfig); pic.Initialize(PicBaseVector); // Parse MP Table and create IO apics MpResources.ParseMpTables(); ioApics = IoApic.CreateIOApics(); halPic = new Apic(ioApics); halPic.Initialize(ApicBaseVector); // Apic timer is used to provide one-shot timer interrupts. halTimer = new ApicTimer(halPic); halTimer.Initialize(); // Calibrate timers Calibrate.CpuCycleCounter(pmTimer); Calibrate.ApicTimer(pmTimer, halTimer); // Legacy timer is used to time stalls when starting CPUs. PnpConfig i8254Config = (PnpConfig)IoSystem.YieldResources("/pnp/PNP0100", typeof(Timer8254Apic)); stallTimer = new Timer8254Apic(i8254Config); // Real-time clock PnpConfig rtClockConfig = (PnpConfig)IoSystem.YieldResources("/pnp/PNP0B00", typeof(RTClockApic)); rtClock = new RTClockApic(rtClockConfig, halPic); // Compose our HalClock from the component clocks we have available halClock = new HalClockApic(halPic, rtClock, new PMClock(pmTimer)); SystemClock.Initialize(halClock, TimeSpan.FromHours(8).Ticks); rootProcessor.AddPic(halPic); rootProcessor.AddTimer(halTimer.Interrupt, halTimer); rootProcessor.AddClock(halClock.Interrupt, halClock); InitializeProcessorCount(); DebugReportProcessors(); halTimer.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; halPic.DumpState(); foreach (IoApic ioApic in ioApics) { ioApic.DumpRedirectionEntries(); } pic.DumpRegisters(); }