158 for (
size_t i = 0; i < aData.size(); i++)
159 lNrBytes += aData.at(i).second;
161 assert((lNrBytes % 4) == 0);
162 size_t lNrWords = lNrBytes / 4;
167 for (
size_t i = 0; i < aData.size(); ++i) {
168 for (
size_t j = 0; j < aData.at(i).second; ++j) {
169 mBuffer[k] = aData.at(i).first[j];
174 auto mBuffer32b =
reinterpret_cast<const uint32_t*
>(
mBuffer);
176 for (
size_t i(0); i < lNrWords; ++i) {
177 mBar[aAddr + i] = htole32(mBuffer32b[i]);
417 Integer(aBuffers->sendCounter() / 4),
418 "-word packet to page ",
423 const uint32_t lHeaderWord = (0x10000 | (((aBuffers->sendCounter() / 4) - 1) & 0xFFFF));
424 std::vector<std::pair<const uint8_t*, size_t>> lDataToWrite;
425 lDataToWrite.push_back(std::make_pair(
reinterpret_cast<const uint8_t*
>(&lHeaderWord),
sizeof lHeaderWord));
426 lDataToWrite.push_back(std::make_pair(aBuffers->getSendBuffer(), aBuffers->sendCounter()));
432 Integer((aBuffers->sendCounter() / 4) + 1),
433 " 32-bit words at address ",
446 SteadyClock_t::time_point lStartTime = SteadyClock_t::now();
449 uint32_t lHwPublishedPageCount = 0x0;
451 std::vector<uint32_t> lValues;
456 lHwPublishedPageCount = lValues.at(3);
458 "Read status info from addr 0 (",
459 Integer(lValues.at(0)),
461 Integer(lValues.at(1)),
463 Integer(lValues.at(2)),
465 Integer(lValues.at(3)),
467 PacketFmt((
const uint8_t*)lValues.data(), 4 * lValues.size()));
475 if (SteadyClock_t::now() - lStartTime > std::chrono::microseconds(getBoostTimeoutPeriod().total_microseconds())) {
476 exception::Axi4LiteTimeout lExc;
479 Integer(lPageIndexToRead),
482 ") of Axi4Lite device '" +
mMappedFile.
getPath() +
"' is not ready after timeout period");
491 ") : Trying to read page index ",
492 Integer(lPageIndexToRead),
495 "; published page count is ",
496 Integer(lHwPublishedPageCount),
511 Integer(lPageIndexToRead),
512 " (published count ",
513 Integer(lHwPublishedPageCount),
514 ", surpasses required, ",
521 std::shared_ptr<uhal::Buffers> lBuffers =
mReplyQueue.front();
524 uint32_t lNrWordsToRead(lBuffers->replyCounter() >> 2);
527 std::vector<uint32_t> lPageContents;
533 Integer(lNrWordsToRead),
534 " 32-bit words from address ",
535 Integer(4 + lPageIndexToRead * 4 *
mPageSize),
537 PacketFmt((
const uint8_t*)lPageContents.data(), 4 * lPageContents.size()));
540 const std::deque<std::pair<uint8_t*, uint32_t>>& lReplyBuffers(lBuffers->getReplyBuffer());
541 size_t lNrWordsInPacket = (lPageContents.at(0) >> 16) + (lPageContents.at(0) & 0xFFFF);
542 if (lNrWordsInPacket != (lBuffers->replyCounter() >> 2))
544 "Expected reply packet to contain ",
545 Integer(lBuffers->replyCounter() >> 2),
546 " words, but it actually contains ",
547 Integer(lNrWordsInPacket),
550 size_t lNrBytesCopied = 0;
551 for (
const auto& lBuffer : lReplyBuffers) {
553 if (lNrBytesCopied >= 4 * lNrWordsInPacket)
556 size_t lNrBytesToCopy = std::min(lBuffer.second, uint32_t(4 * lNrWordsInPacket - lNrBytesCopied));
557 memcpy(lBuffer.first, &lPageContents.at(1 + (lNrBytesCopied / 4)), lNrBytesToCopy);
558 lNrBytesCopied += lNrBytesToCopy;
562 uhal::exception::exception* lExc = NULL;
564 lExc = ClientInterface::validate(lBuffers);
565 }
catch (uhal::exception::exception& aExc) {
566 uhal::exception::ValidationError lExc2;
568 "Exception caught during reply validation for Axi4Lite device with URI ",
569 uhal::Quote(this->uri()),
571 uhal::Quote(aExc.what()));
576 lExc->throwAsDerivedType();