Ejemplo n.º 1
0
        uint capabilities;          // bits 0-31 at offset 0

        internal Hpet(PnpConfig config)
        {
            int cpuId;

            Microsoft.Singularity.Hal.Platform p = Microsoft.Singularity.Hal.Platform.ThePlatform;
            cpuId = p.ApicId;

            this.config = config;
            IoMemoryRange imr = (IoMemoryRange)config.DynamicRanges[0];

            this.region = imr.MemoryAtOffset(0, (int)imr.Length.ToUInt32(),
                                             Access.ReadWrite);

            capabilities = region.Read32(0x00);
            periodFs     = region.Read32(0x04);

            if (cpuId == 0)
            {
                DebugStub.Print("new Hpet writing regions\n");
                // Disable interrupts on timers
                for (uint i = 0; i <= MaxCounterIndex; i++)
                {
                    DisableInterrupt(i);
                }

                uint gc = region.Read32(0x10) & ~3u;    // Clear legacy bits
                region.Write32(0x10, gc | 1);           // Enable main counter
            }
        }
Ejemplo n.º 2
0
        public static unsafe bool GetFixedIoMemoryRange(uint range,
                                                        out byte *data,
                                                        out uint size,
                                                        out bool readable,
                                                        out bool writable)
        {
            bool ret = false;

            data     = null;
            size     = 0;
            readable = false;
            writable = false;

            IoConfig config = Thread.CurrentProcess.IoConfig;

            if (config != null && config.FixedRanges.Length > range)
            {
                IoMemoryRange imr = config.FixedRanges[range] as IoMemoryRange;
                if (imr != null)
                {
                    data = (byte *)imr.PhysicalAddress.Value;
                    DebugStub.Assert(data != null);
                    size     = (uint)imr.Length;
                    readable = imr.Readable;
                    writable = imr.Writable;
                    ret      = true;
                }
            }

            Tracing.Log(Tracing.Debug,
                        "DeviceService.GetFixedIoMemoryRange(range={0}, out data={1:x8}, out size={2})",
                        range, (UIntPtr)data, size);

            return(ret);
        }
Ejemplo n.º 3
0
        private uint irqMask2;                   // copy of interrupt mask

        internal Pic(PnpConfig config)
        {
            PicResources pr = new PicResources(config);

            IoMemoryRange range = pr.registers;
            IoMemory      regs  = range.MemoryAtOffset(0, PicRegisterSize, Access.ReadWrite);

            intcps_revision     = regs.MappedPortAtOffset(INTCPS_REVISION, 4, Access.Read);
            intcps_sysconfig    = regs.MappedPortAtOffset(INTCPS_SYSCONFIG, 4, Access.ReadWrite);
            intcps_sysstatus    = regs.MappedPortAtOffset(INTCPS_SYSSTATUS, 4, Access.Read);
            intcps_sir_irq      = regs.MappedPortAtOffset(INTCPS_SIR_IRQ, 4, Access.Read);
            intcps_sir_fiq      = regs.MappedPortAtOffset(INTCPS_SIR_FIQ, 4, Access.Read);
            intcps_control      = regs.MappedPortAtOffset(INTCPS_CONTROL, 4, Access.ReadWrite);
            intcps_protection   = regs.MappedPortAtOffset(INTCPS_PROTECTION, 4, Access.ReadWrite);
            intcps_idle         = regs.MappedPortAtOffset(INTCPS_IDLE, 4, Access.ReadWrite);
            intcps_irq_priority = regs.MappedPortAtOffset(INTCPS_IRQ_PRIORITY, 4, Access.ReadWrite);
            intcps_fiq_priority = regs.MappedPortAtOffset(INTCPS_FIQ_PRIORITY, 4, Access.ReadWrite);
            intcps_threshhold   = regs.MappedPortAtOffset(INTCPS_THRESHHOLD, 4, Access.ReadWrite);
            intcps_itr          = CreatePortVector(regs, INTCPS_ITR, Access.Read);
            intcps_mir          = CreatePortVector(regs, INTCPS_MIR, Access.ReadWrite);
            intcps_mir_clear    = CreatePortVector(regs, INTCPS_MIR_CLEAR, Access.Write);
            intcps_mir_set      = CreatePortVector(regs, INTCPS_MIR_SET, Access.Write);
            intcps_isr_set      = CreatePortVector(regs, INTCPS_ISR_SET, Access.ReadWrite);
            intcps_isr_clear    = CreatePortVector(regs, INTCPS_ISR_CLEAR, Access.Write);
            intcps_pending_irq  = CreatePortVector(regs, INTCPS_PENDING_IRQ, Access.Read);
            intcps_pending_fiq  = CreatePortVector(regs, INTCPS_PENDING_FIQ, Access.Read);
            intcps_ilr          = regs.MappedPortAtOffset(
                INTCPS_ILR_Base,
                INTCPS_ILR_Offset * INTCPS_Vectors,
                Access.ReadWrite
                );
        }
Ejemplo n.º 4
0
 private static IoRange ProcessExceptions(string deviceId, IoRange resource)
 {
     // Some Dells like the Dell Precision 490 make the HPET range
     // read-only - but it needs to be read-write.
     if (deviceId == "/pnp/PNP0103" && resource is IoMemoryRange &&
         !((IoMemoryRange)resource).Writable)
     {
         IoMemoryRange resourceMemoryRange = (IoMemoryRange)resource;
         return(new IoMemoryRange(resourceMemoryRange.RangeBase, resourceMemoryRange.RangeLength,
                                  true /*readable*/, true /*writable*/));
     }
     else
     {
         return(resource);
     }
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 // CTR will create the rest of this class:
 public TimerResources(IoConfig config)
 {
     // dynamic resources
     registers = (IoMemoryRange)config.DynamicRanges[0];
     irq       = (IoIrqRange)config.DynamicRanges[1];
 }
Ejemplo n.º 7
0
 // CTR will create the rest of this class:
 public PicResources(IoConfig config)
 {
     // dynamic resources
     registers = (IoMemoryRange)config.DynamicRanges[0];
 }