public static void DebugQueryStatus(IdeController !controller) { byte statusBits = controller.ReadAlternateStatusPort(); byte errorBits = controller.ReadErrorPort(); Tracing.Log(Tracing.Debug, "ATAcontroller: Status Register({0:x2}): ", statusBits); Tracing.Log(Tracing.Debug, ((statusBits & (byte)ATA6.IdeStatus.BSY) > 0) ? "BSY " : "!bsy "); Tracing.Log(Tracing.Debug, ((statusBits & (byte)ATA6.IdeStatus.DRDY) > 0) ? "DRDY " : "!drdy "); Tracing.Log(Tracing.Debug, ((statusBits & (byte)ATA6.IdeStatus.DWF) > 0) ? "DWF " : "!dwf "); Tracing.Log(Tracing.Debug, ((statusBits & (byte)ATA6.IdeStatus.DSC) > 0) ? "DSC " : "!dsc "); Tracing.Log(Tracing.Debug, ((statusBits & (byte)ATA6.IdeStatus.DRQ) > 0) ? "DRQ " : "!drq "); Tracing.Log(Tracing.Debug, ((statusBits & (byte)ATA6.IdeStatus.CORR) > 0) ? "CORR " : "!corr "); Tracing.Log(Tracing.Debug, ((statusBits & (byte)ATA6.IdeStatus.IDX) > 0) ? "IDX " : "!idx"); Tracing.Log(Tracing.Debug, ((statusBits & (byte)ATA6.IdeStatus.ERR) > 0) ? "ERR " : "!err "); Tracing.Log(Tracing.Debug, "\n"); Tracing.Log(Tracing.Debug, "ATAcontroller: Error Register:({0:x2}): ", errorBits); Tracing.Log(Tracing.Debug, ((errorBits & (byte)ATA6.IdeError.UNC) > 0) ? "UNC " : "!unc "); Tracing.Log(Tracing.Debug, ((errorBits & (byte)ATA6.IdeError.MC) > 0) ? "MC " : "!mc "); Tracing.Log(Tracing.Debug, ((errorBits & (byte)ATA6.IdeError.IDNF) > 0) ? "IDNF " : "!idnf "); Tracing.Log(Tracing.Debug, ((errorBits & (byte)ATA6.IdeError.ABRT) > 0) ? "ABRT " : "!abrt "); Tracing.Log(Tracing.Debug, ((errorBits & (byte)ATA6.IdeError.MCR) > 0) ? "MCR " : "!mcr "); Tracing.Log(Tracing.Debug, ((errorBits & (byte)ATA6.IdeError.TK0NF) > 0) ? "TK0NF " : "!tk0nf "); Tracing.Log(Tracing.Debug, ((errorBits & (byte)ATA6.IdeError.AMNF) > 0) ? "AMNF " : "!amnf "); Tracing.Log(Tracing.Debug, "\n"); ushort lbaLow = controller.ReadLBALowPort(); ushort lbaMid = controller.ReadLBAMidPort(); ushort lbaHigh = controller.ReadLBAHighPort(); Tracing.Log(Tracing.Debug, "LBA={0:x2},{1:x2},{2:x2}\n", (UIntPtr)lbaHigh, (UIntPtr)lbaMid, (UIntPtr)lbaLow); }
IdentifyDeviceInformation GetDeviceIdentification(IdeController !controller, int devsel, bool atapi) { ushort[] identifyData = new ushort[256]; if (!controller.PollBSY(false)) { // should fail here. } controller.SelectDevice(devsel, atapi); //DebugStub.Print(" IDE GetDeviceIdentification starting\n"); bool iflag = PrivilegedGate.DisableInterrupts(); try { controller.SetIdentifyInProgress(true); controller.PollDRDY(true); byte cmd = (atapi)? (byte)IdeCommand.IdentifyPacketDevice: (byte)IdeCommand.IdentifyDevice; controller.WriteCommandPort(cmd); //will post interrupt controller.Delay400ns(); Tracing.Log(Tracing.Debug, "status={0}", (UIntPtr)controller.ReadFullStatus()); controller.PollDRDY(true); // Device indicates ready. } finally { PrivilegedGate.RestoreInterrupts(iflag); } IdeConfig config = controller.GetConfig(); bool success = (config != null) && config.IdentifyEndEvent.WaitOne(TimeSpan.FromMilliseconds(250)); if (!success) { //DebugStub.Break(); Tracing.Log(Tracing.Debug, " IDE GetDeviceIdentification did NOT receive interrupt\n"); controller.SetIdentifyInProgress(false); } //DebugStub.Print(" IDE GetDeviceIdentification received interrupt\n"); // XXX: We should check for an Error condition here. // XXX: We should check for the ATAPI signature here. byte statusBits = controller.ReadAlternateStatusPort(); if ((statusBits & (byte)ATA6.IdeStatus.ERR) > 0) { Tracing.Log(Tracing.Debug, "ERR reported in status after IdentifyDevice!\n"); DebugStub.Break(); } for (int i = 0; i < 256; i++) { identifyData[i] = controller.ReadDataPort(); } IdentifyDeviceInformation ident = ParseIdentifyInformation(identifyData); //// if (atapi) if (ident.ModelNumber == "Virtual CD") // SECTOR_SIZE is actually 2048 { ident.MaxLBASectors = 650 * 1024 * 1024 / IdeRequest.SECTOR_SIZE; } // for IdeDisk::ReadWrite tests return(ident); }