示例#1
0
 internal void Start(ushort pitTicks)
 {
     CWPort.Write8(i8254_CW_MODE2 | i8254_CW_BOTH | i8254_CW_SEL2);
     C2Port.Write8((byte)(pitTicks & 0xff));
     C2Port.Write8((byte)(pitTicks >> 8));
     do
     {
         CWPort.Write8(i8254_RB_NOCOUNT | i8254_RB_SEL2);
     } while ((C2Port.Read8() & i8254_RB_NULL) == i8254_RB_NULL);
 }
示例#2
0
        internal int PitRead()
        {
            CWPort.Write8(i8254_RB_ALL | i8254_RB_SEL0);
            byte status = C0Port.Read8();
            int  pit1   = (int)C0Port.Read8() | ((int)C0Port.Read8() << 8);

            // Extend pit value using i8254 output bit
            if ((status & i8254_RB_OUT) == 0 ||
                (pit1 == 0 && interruptPending == true))
            {
                pit1 += PitInterruptThreshold;
            }

            return(pit1);
        }
示例#3
0
        // Constructor
        internal Timer8254LegacyPC(PnpConfig config, Pic pic)
        {
#if VERBOSE
            Tracing.Log(Tracing.Debug, "Timer8254: create");
#endif

            // /pnp/08/02/01/PNP0100 0003 cfg dis : ISA 8254 Timer : AT Timer
            // IRQ mask=0001 type=47
            // I/O Port inf=01 min=0040 max=0040 aln=01 len=04 0040..0043
            this.config = config;
            this.pic    = pic;
            this.irq    = ((IoIrqRange)config.DynamicRanges[1]).Irq;
            IoPortRange ioPorts = (IoPortRange)config.DynamicRanges[0];
            C0Port = ioPorts.PortAtOffset(i8254_C0, 1, Access.ReadWrite);
            C2Port = ioPorts.PortAtOffset(i8254_C2, 1, Access.ReadWrite);
            CWPort = ioPorts.PortAtOffset(i8254_CW, 1, Access.ReadWrite);

            // Enable Timer2
            // Lower 2 bits of port 61 are described in:
            // The Indispensable PC Hardware Book (3rd Edition) p.724
            ioPorts = (IoPortRange)config.FixedRanges[0];
            IoPort p = ioPorts.PortAtOffset(0, 1, Access.ReadWrite);

            //
            // Also clear the NMI RAM parity error to enable the PCI card
            // to generate NMI if the button is depressed
            //

            p.Write8((byte)((p.Read8() & 0xf8) | 0x01));
        }
示例#4
0
            public byte Read8(AcpiObject.RegionSpace regionSpace, ulong offset)
            {
                byte result;

                switch (regionSpace)
                {
                case AcpiObject.RegionSpace.SystemMemory:
                    // TODO: This is a first stab - ideally the AcpiObject.OperationRegion
                    // ought to be holding onto an IoMemoryRange and passing it in repeatedly.
                    IoMemory region = IoMemory.MapPhysicalMemory(offset, 1, true /*readable*/, false /*writable*/);
                    result = region.Read8(0);
                    break;

                case AcpiObject.RegionSpace.SystemIO:
                    IoPort port = new IoPort((ushort)offset, 1, Access.Read);
                    result = port.Read8();
                    break;

                case AcpiObject.RegionSpace.PCI_Config:
                    pciConfigAddressPort.Write32(PciConfigEnableMask | (uint)offset);
                    result = pciConfigDataPort.Read8();
                    break;

                default:
                    throw new Exception("Unimplemented operation region type" + regionSpace);
                }
#if DUMP_RAW_READ_WRITES
                DebugStub.WriteLine("ACPI read: space: " + regionSpace + ", offset: " + offset + ", bytes: " + 1 + ", result: " + result.ToString("X"));
#endif
                return(result);
            }
示例#5
0
        // Constructor
        internal Timer8254Apic(PnpConfig config)
        {
            // /pnp/08/02/01/PNP0100 0003 cfg dis : ISA 8254 Timer : AT Timer
            // IRQ mask=0001 type=47
            // I/O Port inf=01 min=0040 max=0040 aln=01 len=04 0040..0043
            this.config = config;
            this.irq    = ((IoIrqRange)config.DynamicRanges[1]).Irq;

            IoPortRange ioPorts = (IoPortRange)config.DynamicRanges[0];

            C2Port = ioPorts.PortAtOffset(i8254_C2, 1, Access.ReadWrite);
            CWPort = ioPorts.PortAtOffset(i8254_CW, 1, Access.ReadWrite);

            // Use Timer2 as it's not connected as interrupt source.
            //
            // Lower 2 bits of port 61 are described in:
            // The Indispensable PC Hardware Book (3rd Edition) p.724
            ioPorts = (IoPortRange)config.FixedRanges[0];
            IoPort p = ioPorts.PortAtOffset(0, 1, Access.ReadWrite);

            //
            // Also clear the NMI RAM parity error to enable the PCI card
            // to generate NMI if the button is depressed
            //

            p.Write8((byte)((p.Read8() & 0xf8) | 0x01));
        }
示例#6
0
        private void DumpRegisters()
        {
            pic0CtrlPort.Write8(0x04 | 0x02); // OCW3  - read IRR
            byte irr0 = pic0CtrlPort.Read8();

            pic0CtrlPort.Write8(0x04 | 0x03); // OCW3  - read ISR
            byte isr0 = pic0CtrlPort.Read8();

            pic1CtrlPort.Write8(0x04 | 0x02); // OCW3  - read IRR
            byte irr1 = pic1CtrlPort.Read8();

            pic1CtrlPort.Write8(0x04 | 0x03); // OCW3  - read ISR
            byte isr1  = pic1CtrlPort.Read8();
            byte mask0 = pic0MaskPort.Read8();
            byte mask1 = pic1MaskPort.Read8();

            DebugStub.Print("PIC IRR: {0:x2}{1:x2} ISR: {2:x2}{3:x2} Mask:{4:x2}{5:x2}\n",
                            __arglist(irr1, irr0, isr1, isr0, mask1, mask0));
        }
示例#7
0
        //
        private void VgaTextMode()
        {
            // start sync reset program up sequencer
            IndxOut(seqAddrPort, new byte[] { 0x01,0x00,0x03,0x00,0x02 } );

            miscOutputRegWritePort.Write8(0x67);
            graphAddrPort.Write16(0x0e06);

            //  EndSyncResetCmd
            seqAddrPort.Write16(0x0300);

            // Unlock the CTC registers.
            crtcAddressColorPort.Write16(0x0E11);

            // program crtc registers
            IndxOut(crtcAddressColorPort, new byte[] { 0x5F,0x4f,0x50,0x82,0x55,0x81,
                                                       0xbf,0x1f,0x00,0x4f,0x0d,0x0e,
                                                       0x00,0x00,0x00,0x00,0x9c,0x8e,
                                                       0x8f,0x28,0x1f,0x96,0xb9,0xa3,
                                                       0xFF } );

            // prepare atc for writing
            inputStatusColorPort.Read8();
            AtcOut(atcAddrPort, new byte[] { 0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
                                             0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
                                             0x04,0x00,0x0F,0x08,0x00 } );

            // program graphics controller registers
            IndxOut(graphAddrPort, new byte[] { 0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,0xff});

            // DAC mask registers
            dacPixelMaskPort.Write8(0xFF);

            // prepare atc for writing
            inputStatusColorPort.Read8();

            // turn video on.
            atcAddrPort.Write8(VIDEO_ENABLE);
        }
示例#8
0
        } // BmArm

        public byte GetStatus()
        {
            byte status = statusPort.Read8();

            return(status);
        }