/// <summary> /// Disables the data received interrupt. /// </summary> public void DisableDataReceivedInterrupt() { IER ier = (IER)(ierBase.Read8()); ier &= ~IER.DR; ierBase.Write8((byte)ier); }
/// <summary> /// Gets the palette. /// </summary> /// <param name="colorIndex">Index of the color.</param> /// <returns></returns> public Color GetPalette(byte colorIndex) { Color color = new Color(); dacPaletteMask.Write8(0xFF); dacIndexRead.Write8(colorIndex); color.Red = dacData.Read8(); color.Green = dacData.Read8(); color.Blue = dacData.Read8(); return(color); }
/// <summary> /// Writes the settings. /// </summary> /// <param name="settings">The settings.</param> protected void WriteSettings(byte[] settings) { // Write MISCELLANEOUS reg miscellaneousOutputWrite.Write8(settings[0]); // Write SEQUENCER regs for (byte i = 0; i < 5; i++) { sequencerAddress.Write8(i); sequencerData.Write8(settings[1 + i]); } // Unlock CRTC registers crtControllerIndexColor.Write8(0x03); crtControllerDataColor.Write8((byte)(crtControllerData.Read8() | 0x80)); crtControllerIndexColor.Write8(0x11); crtControllerDataColor.Write8((byte)(crtControllerData.Read8() & ~0x80)); // Make sure they remain unlocked settings[0x03] = (byte)(settings[0x03] | 0x80); settings[0x11] = (byte)(settings[0x11] & ~0x80); // Write CRTC regs for (byte i = 0; i < 25; i++) { crtControllerIndexColor.Write8(i); crtControllerDataColor.Write8(settings[6 + i]); } // Write GRAPHICS CONTROLLER regs for (byte i = 0; i < 9; i++) { graphicsControllerAddress.Write8(i); graphicsControllerData.Write8(settings[31 + i]); } // Write ATTRIBUTE CONTROLLER regs for (byte i = 0; i < 21; i++) { inputStatus1ReadB.Read8(); attributeAddress.Write8(i); attributeAddress.Write8(settings[52 + i]); } // Lock 16-color palette and unblank display */ inputStatus1ReadB.Read8(); attributeAddress.Write8(0x20); }
public override void Start() { if (Device.Status != DeviceStatus.Available) { return; } WriteSettings(VGAText80x25); colorMode = ((miscellaneousOutput.Read8() & 1) == 1); if (colorMode) { offset = 0x8000; bytePerChar = 2; activeControllerIndex = crtControllerIndexColor; activeControllerData = crtControllerDataColor; } else { offset = 0x0; bytePerChar = 1; activeControllerIndex = crtControllerIndex; activeControllerData = crtControllerData; } width = GetValue(CRTCommands.HorizontalDisplayEnableEnd); height = GetValue(CRTCommands.VerticalDisplayEnableEnd); width++; height = 25; Device.Status = DeviceStatus.Online; }
/// <summary> /// Reads the specified address. /// </summary> /// <param name="address">The address.</param> /// <returns></returns> public byte Read(byte address) { lock (_lock) { commandPort.Write8(address); return(dataPort.Read8()); } }
public override void Probe() { LBALowPort.Write8(0x88); var found = LBALowPort.Read8() == 0x88; Device.Status = (found) ? DeviceStatus.Available : DeviceStatus.NotFound; }
/// <summary> /// Reads in the sequence register's current value. The register is chosen by /// the given index. /// </summary> /// <param name="index">The index to the register</param> /// <returns>The register's value</returns> private byte ReadSequenceRegister(byte index) { // Select register seqControllerIndex.Write8(index); // Read contained value return(seqControllerData.Read8()); }
/// <summary> /// Reads the specified address. /// </summary> /// <param name="address">The address.</param> /// <returns></returns> public byte Read(byte address) { spinLock.Enter(); commandPort.Write8(address); var b = dataPort.Read8(); spinLock.Exit(); return(b); }
public override void Start() { if (Device.Status != DeviceStatus.Available) { return; } vgaEnableController.Write8((byte)(vgaEnableController.Read8() | 0x01)); // Enable colors miscOutputWriter.Write8((byte)(miscOutputReader.Read8() | 0x01)); // Enable MMIO crtcControllerIndex.Write8(0x53); crtcControllerData.Write8((byte)(crtcControllerData.Read8() | 0x8)); // Unlock system registers WriteCrtcRegister(0x38, 0x48); WriteCrtcRegister(0x39, 0xa5); WriteCrtcRegister(0x40, 0x01, 0x01); WriteCrtcRegister(0x35, 0x00, 0x30); WriteCrtcRegister(0x33, 0x20, 0x72); WriteCrtcRegister(0x86, 0x80); WriteCrtcRegister(0x90, 0x00); // Detect number of MB of installed RAM byte[] ramSizes = new byte[] { 4, 0, 3, 8, 2, 6, 1, 0 }; int ramSizeMB = ramSizes[(ReadCrtcRegister(0x36) >> 5) & 0x7]; // Setup video memory memory = Device.Resources.GetMemory((byte)(ramSizeMB * 1024 * 1024)); // Detect current mclk WriteSequenceRegister(0x08, 0x06); byte m = (byte)(ReadSequenceRegister(0x11) & 0x7f); byte n = ReadSequenceRegister(0x10); byte n1 = (byte)(n & 0x1f); byte n2 = (byte)((n >> 5) & 0x03); Device.Status = DeviceStatus.Online; }
/// <summary> /// Reads the scan code from the device /// </summary> protected void ReadScanCode() { spinLock.Enter(); byte v = commandPort.Read8(); AddToFIFO(v); HAL.DebugWrite(" scancode: " + v.ToString() + " "); spinLock.Exit(); }
/// <summary> /// Reads the scan code from the device /// </summary> protected void ReadScanCode() { lock (_lock) { byte status = statusPort.Read8(); if ((status & 0x01) == 0x01) { byte data = dataPort.Read8(); AddToFIFO(data); } } }
public override void Start() { if (Device.Status != DeviceStatus.Available) { return; } Device.Status = DeviceStatus.Online; byte masterMask; byte slaveMask; // Save Masks masterMask = masterDataPort.Read8(); slaveMask = slaveDataPort.Read8(); // ICW1 - Set Initialize Controller & Expect ICW4 masterCommandPort.Write8(0x11); // ICW2 - interrupt offset masterDataPort.Write8(MasterIRQBase); // ICW3 masterDataPort.Write8(0x04); // ICW4 - Set 8086 Mode masterDataPort.Write8(0x01); // ICW1 - Set Initialize Controller & Expect ICW4 slaveCommandPort.Write8(0x11); // ICW2 - interrupt offset slaveDataPort.Write8(SlaveIRQBase); // ICW3 slaveDataPort.Write8(0x02); // ICW4 - Set 8086 Mode slaveDataPort.Write8(0x01); // Restore Masks masterDataPort.Write8(masterMask); slaveDataPort.Write8(slaveMask); DisableIRQs(); }
/// <summary> /// Determines whether this instance can transmit. /// </summary> /// <returns> /// <c>true</c> if this instance can transmit; otherwise, <c>false</c>. /// </returns> protected bool CanTransmit() { return((lsrBase.Read8() & (byte)LSR.THRE) != 0); }
/// <summary> /// Gets the value. /// </summary> /// <param name="command">The command.</param> /// <returns></returns> protected byte GetValue(byte command) { activeControllerIndex.Write8(command); return(activeControllerData.Read8()); }
private void DoIdentifyDrive(byte index) { driveInfo[index].Present = false; //Send the identify command to the selected drive DeviceHeadPort.Write8((byte)((index == 0) ? 0xA0 : 0xB0)); SectorCountPort.Write8(0); LBALowPort.Write8(0); LBAMidPort.Write8(0); LBAHighPort.Write8(0); CommandPort.Write8(IDECommand.IdentifyDrive); if (StatusPort.Read8() == 0) { //Drive doesn't exist return; } //Wait until a ready status is present if (!WaitForReadyStatus()) { return; //There's no ready status, this drive doesn't exist } if (LBAMidPort.Read8() != 0 && LBAHighPort.Read8() != 0) //Check if the drive is ATA { //In this case the drive is ATAPI //HAL.DebugWriteLine("Device " + index.ToString() + " not ATA"); return; } //Wait until the identify data is present (256x16 bits) if (!WaitForIdentifyData()) { //HAL.DebugWriteLine("Device " + index.ToString() + " ID error"); return; } //An ATA drive is present driveInfo[index].Present = true; //Read the identification info var info = new DataBlock(512); for (uint ix = 0; ix < 256; ix++) { info.SetUShort(ix * 2, DataPort.Read16()); } //Find the addressing mode var lba28SectorCount = info.GetUInt(IdentifyDrive.MaxLBA28); AddressingMode aMode = AddressingMode.NotSupported; if ((info.GetUShort(IdentifyDrive.CommandSetSupported83) & 0x200) == 0x200) //Check the LBA48 support bit { aMode = AddressingMode.LBA48; driveInfo[index].MaxLBA = info.GetUInt(IdentifyDrive.MaxLBA48); } else if (lba28SectorCount > 0) //LBA48 not supported, check LBA28 { aMode = AddressingMode.LBA28; driveInfo[index].MaxLBA = lba28SectorCount; } driveInfo[index].AddressingMode = aMode; //HAL.DebugWriteLine("Device " + index.ToString() + " present - MaxLBA=" + driveInfo[index].MaxLBA.ToString()); }
/// <summary> /// Probes this instance. /// </summary> /// <returns></returns> public override bool Probe() { LBALowPort.Write8(0x88); return(LBALowPort.Read8() == 0x88); }
private void DoIdentifyDrive(byte index) { //HAL.DebugWriteLine("Device " + index.ToString() + " ID..."); driveInfo[index].Present = false; //Send the identify command to the selected drive DeviceHeadPort.Write8((byte)((index == 0) ? 0xA0 : 0xB0)); SectorCountPort.Write8(0); LBALowPort.Write8(0); LBAMidPort.Write8(0); LBAHighPort.Write8(0); CommandPort.Write8(IDECommand.IdentifyDrive); if (StatusPort.Read8() == 0) { //HAL.DebugWriteLine("Device " + index.ToString() + " doesnt exist..."); //Drive doesn't exist return; } //Wait until a ready status is present if (!WaitForReadyStatus()) { return; //There's no ready status, this drive doesn't exist } if (LBAMidPort.Read8() != 0 && LBAHighPort.Read8() != 0) //Check if the drive is ATA { //In this case the drive is ATAPI, which is not supported //HAL.DebugWriteLine("Device " + index.ToString() + " not ATA"); return; } //Wait until the identify data is present (256x16 bits) if (!WaitForIdentifyData()) { //HAL.DebugWriteLine("Device " + index.ToString() + " ID error"); return; } //Read the identification info var info = new DataBlock(512); for (uint ix = 0; ix < 256; ix++) { info.SetUShort(ix * 2, DataPort.Read16()); } //Find the addressing mode bool lba48Supported = ((info.GetUShort(IdentifyDrive.CommandSetSupported83) & 0x200) == 0x200); driveInfo[index].AddressingMode = (lba48Supported ? AddressingMode.LBA48 : AddressingMode.LBA28); //Find the max LBA count uint lba28SectorCount = info.GetUInt(IdentifyDrive.MaxLBA28); ulong lba48SectorCount = info.GetULong(IdentifyDrive.MaxLBA48); //HAL.DebugWriteLine("LBA48BIT=" + lba48Supported.ToString()); //HAL.DebugWriteLine("LBA28 =" + lba28SectorCount.ToString("X2")); if (!lba48Supported) //No LBA48 { driveInfo[index].MaxLBA = lba28SectorCount; } else //LBA48 supported { if (lba28SectorCount == 0x0FFFFFFF) //Check the limit according to the d1699r3f-ata8-acs.pdf (4.10.4 IDENTIFY DEVICE data) { driveInfo[index].MaxLBA = (uint)lba48SectorCount; } else { driveInfo[index].MaxLBA = lba28SectorCount; } } //An ATA drive is present and ready to use driveInfo[index].Present = true; //HAL.DebugWriteLine("Device " + index.ToString() + " present - MaxLBA=" + driveInfo[index].MaxLBA.ToString()); }