Skip to content

Commit

Permalink
feat: shorten desc. fmt, add curr.desc.ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
patrislav1 committed May 30, 2024
1 parent 030f949 commit 06069bd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
4 changes: 4 additions & 0 deletions inc/udmaio/UioAxiDmaIf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@

#pragma once

#include <cstdint>
#include <tuple>

#include <sys/types.h>

#include "RegAccessor.hpp"
#include "UioIf.hpp"
#include "udmaio/rdl/AxiDma.hpp"
Expand All @@ -28,6 +31,7 @@ class UioAxiDmaIf : public UioIf, AxiDmaBlock {
/// @brief Configure and start the AXI DMA controller
/// @param start_desc Address of first SGDMA descriptor
void start(uintptr_t start_desc);
uintptr_t get_curr_desc();

using UioIf::arm_interrupt;

Expand Down
2 changes: 2 additions & 0 deletions src/DataHandlerAbstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ void DataHandlerAbstract::_handle_input(const boost::system::error_code& ec) {
auto [irq_count, dma_stat] = _dma.clear_interrupt();
BOOST_LOG_SEV(_lg, bls::trace) << "irq count = " << irq_count;
if (dma_stat.err_irq && _dma.check_for_errors()) {
BOOST_LOG_SEV(_lg, bls::fatal)
<< "DMA error, curr.desc 0x" << std::hex << _dma.get_curr_desc();
_desc.print_descs();
throw std::runtime_error("DMA engine error raised");
}
Expand Down
12 changes: 12 additions & 0 deletions src/UioAxiDmaIf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "udmaio/UioAxiDmaIf.hpp"

#include <cstdint>
#include <ios>
#include <stdexcept>

Expand Down Expand Up @@ -51,6 +52,17 @@ void UioAxiDmaIf::start(uintptr_t start_desc) {
<< "DMA ctrl = 0x" << std::hex << reg_to_raw(s2mm_dmacr.rd()) << std::dec;
}

uintptr_t UioAxiDmaIf::get_curr_desc() {
uintptr_t result = s2mm_curdesc.rd().current_descriptor_pointer;
result <<= 6;
if (sizeof(result) > sizeof(uint32_t)) {
uintptr_t msb = s2mm_curdesc_msb.rd();
msb <<= 32;
result |= msb;
}
return result;
}

std::tuple<uint32_t, axi_dma::s2mm_dmasr_t> UioAxiDmaIf::clear_interrupt() {
uint32_t irq_count = wait_for_interrupt();

Expand Down
26 changes: 10 additions & 16 deletions src/UioMemSgdma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,17 @@ void UioMemSgdma::init_buffers(std::shared_ptr<DmaBufferAbstract> mem,
}

void UioMemSgdma::print_desc(const S2mmDesc& desc) const {
auto fmt_flag = [](std::string name, bool val) { return (val ? "+" : "-") + name; };
#define BLI BOOST_LOG_SEV(_lg, bls::info) << ""
BLI << "S2mmDesc {";
BLI << " next desc = 0x" << std::hex << desc.nxtdesc;
BLI << " buffer addr = 0x" << std::hex << desc.buffer_addr;
BLI << " control";
BLI << " buffer_len = " << std::dec << desc.control.buffer_len;
BLI << " sof = " << std::dec << desc.control.rxsof;
BLI << " eof = " << std::dec << desc.control.rxeof;
BLI << " status";
BLI << " buffer_len = " << std::dec << desc.status.num_stored_bytes;
BLI << " sof = " << std::dec << desc.status.rxsof;
BLI << " eof = " << std::dec << desc.status.rxeof;
BLI << " dmainterr = " << std::dec << desc.status.dmainterr;
BLI << " dmaslverr = " << std::dec << desc.status.dmaslverr;
BLI << " dmadecerr = " << std::dec << desc.status.dmadecerr;
BLI << " cmplt = " << std::dec << desc.status.cmplt;
BLI << "}" << std::dec;
BLI << "next_desc: 0x" << std::hex << desc.nxtdesc << ", " << "buff_addr: 0x" << std::hex
<< desc.buffer_addr;
BLI << "ctrl: buf_len " << std::dec << desc.control.buffer_len << ", "
<< fmt_flag("sof", desc.control.rxsof) << " " << fmt_flag("eof", desc.control.rxeof) << " ";
BLI << "status: num_bytes " << std::dec << desc.status.num_stored_bytes << ", "
<< fmt_flag("sof", desc.status.rxsof) << " " << fmt_flag("eof", desc.status.rxeof) << " "
<< fmt_flag("interr", desc.status.dmainterr) << " "
<< fmt_flag("slverr", desc.status.dmaslverr) << " "
<< fmt_flag("decerr", desc.status.dmadecerr) << " " << fmt_flag("cmplt", desc.status.cmplt);
}

void UioMemSgdma::print_descs() const {
Expand Down

0 comments on commit 06069bd

Please sign in to comment.