From f7ba5f6a15124cc88bdd1432e05ebf3199898514 Mon Sep 17 00:00:00 2001 From: gly11 Date: Wed, 27 May 2026 12:49:56 +0800 Subject: [PATCH] fix(debug): handle unaligned bus reset captures --- ASFWDriver/Debug/BusResetPacketCapture.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ASFWDriver/Debug/BusResetPacketCapture.cpp b/ASFWDriver/Debug/BusResetPacketCapture.cpp index 18d27f91..d1a68f4a 100644 --- a/ASFWDriver/Debug/BusResetPacketCapture.cpp +++ b/ASFWDriver/Debug/BusResetPacketCapture.cpp @@ -51,12 +51,17 @@ void BusResetPacketCapture::CapturePacket(const uint32_t* dmaQuadlets, snapshot.captureTimestamp = GetCurrentTimestamp(); snapshot.generation = generation; - // Copy raw quadlets (little-endian from DMA) - std::memcpy(snapshot.rawQuadlets, dmaQuadlets, sizeof(snapshot.rawQuadlets)); + // The synthetic bus-reset packet can be routed from an unaligned AR buffer. + // DriverKit's memcpy may still use wider loads, so copy byte-by-byte. + const auto* bytes = reinterpret_cast(dmaQuadlets); + auto* rawBytes = reinterpret_cast(snapshot.rawQuadlets); + for (size_t i = 0; i < sizeof(snapshot.rawQuadlets); ++i) { + rawBytes[i] = bytes[i]; + } // Convert to wire format (big-endian) for (int i = 0; i < 4; ++i) { - snapshot.wireQuadlets[i] = LEtoBE(dmaQuadlets[i]); + snapshot.wireQuadlets[i] = LEtoBE(snapshot.rawQuadlets[i]); } // Extract tCode from wire format Q0[31:28]