private void SetPaletteEntry(byte index, uint RGB) { dacAddressWritePort.Write8(index); dacDataRegPort.Write8((byte)(RGB & 0xff)); dacDataRegPort.Write8((byte)((RGB >> 8) & 0xff)); dacDataRegPort.Write8((byte)((RGB >> 16) & 0xff)); }
public byte Initialize(byte baseVector) { DebugStub.Print("Pic.Initializing IRQs at interrupt {0:x2}\n", __arglist(baseVector)); this.baseVector = baseVector; irqMask = unchecked ((ushort)~PIC_I_PIC1); // Set ICW1 (must be followed by ICW2, ICW3, and ICW4). // 00010001b - 8-byte,cascaded,triggered,w/ICW4 pic1CtrlPort.Write8(0x11); pic0CtrlPort.Write8(0x11); // Set ICW2..ICW3 (must follow ICW1) pic1MaskPort.Write8((byte)(baseVector + 8)); pic0MaskPort.Write8(baseVector); pic1MaskPort.Write8(0x02); // Cascaded interrupt number pic0MaskPort.Write8(0x04); // Cascaded interrupt bit. pic1MaskPort.Write8(1); // End of Interrupt pic0MaskPort.Write8(1); pic1CtrlPort.Write8(0x20); // EOI pic0CtrlPort.Write8(0x20); // EOI MaskAll(); return(PIC_VECTORS); }
private void AtcOut(IoPort port, byte[] values) { for (byte i = 0; i < values.Length; i++) { port.Write8(i); port.Write8(values[i]); } }
internal void Stop() { // Half-program counter to stop counter running. Trick copied // from MMOSA i386 timer code CWPort.Write8(i8254_CW_MODE0 | i8254_CW_BOTH | i8254_CW_SEL0); C0Port.Write8((byte)(0)); // LSB // C0Port.Write8((byte)(0)); MSB DON'T! }
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); }
public int Arm(IdeRequest !ideRequest) { byte value = BUSMASTER_CONTROL_MASK_START; if (ideRequest.Command == IdeCmdType.Read) { value |= BUSMASTER_CONTROL_MASK_WRITE; } commandPort.Write8(value); // enable BM return(0); } // BmArm
// 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)); }
public void Write8(AcpiObject.RegionSpace regionSpace, ulong offset, byte value) { #if DUMP_RAW_READ_WRITES DebugStub.WriteLine("ACPI write: space: " + regionSpace + ", offset: " + offset + ", bytes: " + 1 + ", value: " + value.ToString("X")); #endif switch (regionSpace) { case AcpiObject.RegionSpace.SystemMemory: IoMemory region = IoMemory.MapPhysicalMemory(offset, 1, true /*readable*/, true /*writable*/); region.Write8(0, value); break; case AcpiObject.RegionSpace.SystemIO: IoPort port = new IoPort((ushort)offset, 1, Access.ReadWrite); port.Write8(value); break; case AcpiObject.RegionSpace.PCI_Config: pciConfigAddressPort.Write32(PciConfigEnableMask | (uint)offset); pciConfigDataPort.Write8(value); break; default: throw new Exception("Unimplemented operation region type" + regionSpace); } }
// 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)); }
public void BmPrepareController(IdeRequest !ideRequest) { // Perform steps 1 and 2 above: set up PRD, clear // error snd interrupt // Init. Scatter Gather List Register uint thePrd = FillPrdTable(ideRequest); prdPort.Write32(thePrd); // Clear Errors byte status = (byte)(BUSMASTER_STATUS_MASK_INTERRUPT | BUSMASTER_STATUS_MASK_ERROR); statusPort.Write8(status); return; } // BmPrepareController
internal void Initialize(byte baseVector) { DebugStub.Assert(255 - baseVector >= 48); this.baseVector = baseVector; Write(ApicOffset.LvtTimer, LvtFlags.Masked); Write(ApicOffset.LvtThermalSensor, LvtFlags.Masked); Write(ApicOffset.LvtPerfCounts, LvtFlags.Masked); Write(ApicOffset.LvtError, LvtFlags.Masked); Write(ApicOffset.SpuriousIntVector, 0xdfu); // set task priority to 0 so that it can // receive all interrupts from IPI // Write(ApicOffset.TaskPriority, 0x20u); Write(ApicOffset.TaskPriority, 0); Write(ApicOffset.LvtLint0, LvtFlags.Masked); Write(ApicOffset.LvtLint1, LvtFlags.Masked); SetId((byte)Processor.GetCurrentProcessorId()); if (this.IsBsp) { InitializeRouteableEntries(); InitializeMpResourceEntries(); } // Enable in s/w SetEnabled(true); // Enable in h/w Isa.WriteMsr(ApicMSR, Isa.ReadMsr(ApicMSR) | (1 << 11)); // Watch out for the uniprocessor case where the // FloatingPointer may be null. MpFloatingPointer floatingPointer = MpResources.FloatingPointer; if (floatingPointer != null && floatingPointer.ImcrPresent && this.IsBsp) { IoPort addrPort = new IoPort(ImcrAddressPort, 1, Access.Write); IoPort dataPort = new IoPort(ImcrDataPort, 1, Access.Write); addrPort.Write8(ImcrAddressSelect); dataPort.Write8(ImcrDataApic); } Write(ApicOffset.LvtLint0, LvtFlags.Level | LvtFlags.ExtInt); Write(ApicOffset.LvtLint1, LvtFlags.NMI | 0x02); for (int z = 0; z <= maxIrq; z++) { byte m = IrqToInterrupt((byte)z); byte n = InterruptToIrq(m); DebugStub.Assert((byte)z == n); } }
public byte Initialize(byte baseVector) { this.baseVector = baseVector; // Set ICW1 (must be followed by ICW2, ICW3, and ICW4). // 00010001b - 8-byte,cascaded,triggered,w/ICW4 pic1CtrlPort.Write8(0x11); pic0CtrlPort.Write8(0x11); // ICW2 pic1MaskPort.Write8((byte)(baseVector + 8)); pic0MaskPort.Write8(baseVector); // ICW3 pic1MaskPort.Write8(0x02); // Cascaded interrupt number pic0MaskPort.Write8(0x04); // Cascaded interrupt bit. // ICW4 pic1MaskPort.Write8(1); pic0MaskPort.Write8(1); // OCW2 - EOI pic1CtrlPort.Write8(0x20); pic0CtrlPort.Write8(0x20); MaskAll(); DumpRegisters(); pic1CtrlPort.Write8(0x20); pic0CtrlPort.Write8(0x20); MaskAll(); DumpRegisters(); MaskAll(); // OCW2 - EOI pic1CtrlPort.Write8(0x20); pic0CtrlPort.Write8(0x20); return(PIC_VECTORS); }
// 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); }
internal void Timer2Start() { CWPort.Write8(i8254_CW_MODE2 | i8254_CW_BOTH | i8254_CW_SEL2); C2Port.Write8((byte)0xff); C2Port.Write8((byte)0xff); }
private void BitBlt4(int x, int y, int width, int height, byte[] buffer, int offset, int ScanWidth) { byte[] Plane = new byte [81]; bool bRightEdge = false; bool bCenterSection = false; byte lMask = lMaskTable[x % 8]; byte rMask = rMaskTable[(x + width - 1) % 8]; int bank1 = x / 8; int bank2 = (x + width - 1) / 8; int count = bank2 - bank1; if (bank1 == bank2) { lMask &= rMask; } if (count != 0) { bRightEdge = true; count--; if (count != 0) { bCenterSection = true; } } int pDst = (y * DELTA) + (x / 8); int pSrc = offset; ReadWriteMode(READ_MODE_0 | WRITE_MODE_0); for (uint j = 0; j < height; j++) { for (byte plane = 1; plane < 16; plane <<= 1) { int pSrcTemp = pSrc; int pDstTemp = pDst; // // Convert the packed bitmap data into planar data // for this plane. // int bank = bank1; Plane[bank] = 0; byte Mask = PixelMask[x % 8]; uint toggle = 0; for (uint i = 0; i < width; i++) { if ((toggle++ & 0x1) != 0) { if ((buffer[pSrcTemp] & plane) != 0) { Plane[bank] |= Mask; } pSrcTemp++; } else { if (((buffer[pSrcTemp] >> 4) & plane) != 0) { Plane[bank] |= Mask; } } Mask >>= 1; if (Mask == 0) { bank++; Plane[bank] = 0; Mask = 0x80; } } // // Set up the vga so that we see the correct bit plane. // seqAddrPort.Write8(SEQ_PLANEMASK_REG); seqDataPort.Write8(plane); // // bank will go from bank1 to bank2 // bank = bank1; pDstTemp = pDst; // // Set Bitmask for left edge. // graphAddrPort.Write8(GRAPH_BITMASK_REG); graphDataPort.Write8(lMask); // The read triggers the latch register. screenBuffer.Read8(pDstTemp); screenBuffer.Write8(pDstTemp++, Plane[bank++]); if (bCenterSection) { graphAddrPort.Write8(GRAPH_BITMASK_REG); graphDataPort.Write8(0xff); screenBuffer.Write8(pDstTemp, Plane, bank, count); bank += count; pDstTemp += count; } if (bRightEdge) { // // Set bitmask for right edge. // graphAddrPort.Write8(GRAPH_BITMASK_REG); graphDataPort.Write8(rMask); // The read triggers the latch register. screenBuffer.Read8(pDstTemp); screenBuffer.Write8(pDstTemp, Plane[bank]); } } pDst += DELTA; pSrc += ScanWidth; } // Restore the settings. seqAddrPort.Write8(SEQ_PLANEMASK_REG); seqDataPort.Write8(0x0f); }
private void ReadWriteMode(byte mode) { graphAddrPort.Write8(GRAPH_MODE_REG); graphDataPort.Write8(mode); }