From 5bfd73fb715b3b2af81881c278e111aad19c53f3 Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Sun, 26 Apr 2009 12:55:52 +0000 Subject: [PATCH] Make debugging easier by tracing only status changes. Always first disable interrupts on a device that can be selected, then check for invalid status. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30426 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/bus_managers/ata/ATAChannel.cpp | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/add-ons/kernel/bus_managers/ata/ATAChannel.cpp b/src/add-ons/kernel/bus_managers/ata/ATAChannel.cpp index 493260852c..e00e998301 100644 --- a/src/add-ons/kernel/bus_managers/ata/ATAChannel.cpp +++ b/src/add-ons/kernel/bus_managers/ata/ATAChannel.cpp @@ -323,12 +323,6 @@ ATAChannel::Reset(bool *presence, uint16 *signatures) for (uint8 i = 0; i < deviceCount; i++) { SelectDevice(i); - if (AltStatus() == 0xff) { - TRACE_ALWAYS("illegal status value for device %d," - " assuming not present\n", i); - continue; - } - if (SelectedDevice() != i) { TRACE_ALWAYS("cannot select device %d, assuming not present\n", i); continue; @@ -337,6 +331,12 @@ ATAChannel::Reset(bool *presence, uint16 *signatures) // ensure interrupts are disabled for this device _WriteControl(ATA_DEVICE_CONTROL_DISABLE_INTS); + if (AltStatus() == 0xff) { + TRACE_ALWAYS("illegal status value for device %d," + " assuming not present\n", i); + continue; + } + // wait up to 31 seconds for busy to clear if (Wait(0, ATA_STATUS_BUSY, 0, 31 * 1000 * 1000) != B_OK) { TRACE_ERROR("device %d reset timeout\n", i); @@ -388,6 +388,9 @@ ATAChannel::Wait(uint8 setBits, uint8 clearedBits, uint32 flags, TRACE("waiting for set bits 0x%02x and cleared bits 0x%02x\n", setBits, clearedBits); +#if ATA_TRACING + unsigned lastStatus = 0x100; +#endif while (true) { uint8 status = AltStatus(); if ((flags & ATA_CHECK_ERROR_BIT) != 0 @@ -410,9 +413,18 @@ ATAChannel::Wait(uint8 setBits, uint8 clearedBits, uint32 flags, } bigtime_t elapsedTime = system_time() - startTime; - TRACE("wait status after %lld: 0x%02x\n", elapsedTime, status); - if (elapsedTime > timeout) +#if ATA_TRACING + if (lastStatus != status) { + TRACE("wait status after %lld: 0x%02x\n", elapsedTime, status); + lastStatus = status; + } +#endif + + if (elapsedTime > timeout) { + TRACE("timeout, wait status after %lld: 0x%02x\n", + elapsedTime, status); return B_TIMED_OUT; + } // The device may be ready almost immediatelly. If it isn't, // poll often during the first 20ms, otherwise poll lazyly.