From 99192606a26d80a2942f1fdefeb106bc298e7a81 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Oct 2023 09:27:24 +0200 Subject: [PATCH] bugfixes for PAPB IF --- linux/ipcore/PapbVcInterface.cpp | 19 ++++++++++++------- linux/ipcore/PapbVcInterface.h | 3 +-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/linux/ipcore/PapbVcInterface.cpp b/linux/ipcore/PapbVcInterface.cpp index 5e63aebc..2329a32e 100644 --- a/linux/ipcore/PapbVcInterface.cpp +++ b/linux/ipcore/PapbVcInterface.cpp @@ -37,7 +37,7 @@ ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size, size_t& w abortPacketTransfer(); return returnvalue::FAILED; } - return finishWritePartialOpt(data, size, true); + return finishWriteInternal(data, size, writtenSize); } void PapbVcInterface::startPacketTransfer(ByteWidthCfg initWidth) { @@ -53,11 +53,20 @@ bool PapbVcInterface::pollReadyForPacket() const { return (reg >> 6) & 0b1; } -ReturnValue_t PapbVcInterface::finishWritePartialOpt(const uint8_t* data, size_t remainingSize, - bool handlePartial) { +ReturnValue_t PapbVcInterface::finishWrite(const uint8_t* data, size_t remainingSize) { + if (not pollReadyForPacket()) { + return returnvalue::FAILED; + } + size_t dummy = 0; + return finishWriteInternal(data, remainingSize, dummy); +} + +ReturnValue_t PapbVcInterface::finishWriteInternal(const uint8_t* data, size_t remainingSize, + size_t& writtenSize) { for (size_t idx = 0; idx < remainingSize; idx++) { if (not pollReadyForOctet(MAX_BUSY_POLLS)) { if (not pollReadyForPacket()) { + writtenSize = idx; return PARTIALLY_WRITTEN; } abortPacketTransfer(); @@ -109,8 +118,4 @@ inline bool PapbVcInterface::pollReadyForOctet(uint32_t maxCycles) const { return false; } -ReturnValue_t PapbVcInterface::finishWrite(const uint8_t* data, size_t remainingSize) { - return finishWritePartialOpt(data, remainingSize, false); -} - void PapbVcInterface::abortPacketTransfer() { *vcBaseReg = CONFIG_ABORT; } diff --git a/linux/ipcore/PapbVcInterface.h b/linux/ipcore/PapbVcInterface.h index 72b9b9f3..201580bc 100644 --- a/linux/ipcore/PapbVcInterface.h +++ b/linux/ipcore/PapbVcInterface.h @@ -43,8 +43,7 @@ class PapbVcInterface : public VirtualChannelIF { ReturnValue_t write(const uint8_t* data, size_t size, size_t& writtenSize) override; ReturnValue_t finishWrite(const uint8_t* data, size_t remainingSize) override; - ReturnValue_t finishWritePartialOpt(const uint8_t* data, size_t remainingSize, - bool handlePartial); + ReturnValue_t finishWriteInternal(const uint8_t* data, size_t remainingSize, size_t& writtenSize); void cancelTransfer() override;