Skip to content

Commit 6ae7b89

Browse files
committed
feat: add UioAxiDmaIf::dump_status()
1 parent 0790a2a commit 6ae7b89

6 files changed

Lines changed: 34 additions & 1 deletion

File tree

example/demo_cpp/src/axi_dma_demo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ int main(int argc, char* argv[]) {
147147
if (g_stop_loop) {
148148
data_handler.stop();
149149
fut.wait();
150+
axi_dma->dump_status();
150151
break;
151152
}
152153
}

example/demo_python/axi_dma_demo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def main():
169169
print(f'{words_total} words OK')
170170
traffic_gen.stop()
171171
data_handler.stop()
172+
axi_dma.dump_status()
172173

173174

174175
if __name__ == '__main__':

inc/udmaio/UioAxiDmaIf.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class UioAxiDmaIf : public UioIf, AxiDmaBlock {
4141
/// @brief Check status register and log any errors
4242
/// @return true if any error occurred
4343
bool check_for_errors();
44+
45+
/// @brief Dump all status register flags in the log
46+
void dump_status();
4447
};
4548

4649
} // namespace udmaio

pyudmaio/src/PythonBinding.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ PYBIND11_MODULE(binding, m) {
109109
py::class_<udmaio::UioAxiDmaIf, udmaio::UioIf, std::shared_ptr<udmaio::UioAxiDmaIf>>(
110110
m,
111111
"UioAxiDmaIf")
112-
.def(py::init<udmaio::UioDeviceLocation>());
112+
.def(py::init<udmaio::UioDeviceLocation>())
113+
.def("dump_status", &udmaio::UioAxiDmaIf::dump_status);
113114

114115
py::class_<udmaio::UioMemSgdma, udmaio::UioIf, std::shared_ptr<udmaio::UioMemSgdma>>(
115116
m,

src/DataHandlerAbstract.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ void DataHandlerAbstract::_handle_input(const boost::system::error_code& ec) {
6464
if (dma_stat.err_irq && _dma.check_for_errors()) {
6565
BOOST_LOG_SEV(_lg, bls::fatal)
6666
<< "DMA error, curr.desc 0x" << std::hex << _dma.get_curr_desc();
67+
_dma.dump_status();
6768
_desc.print_descs();
6869
throw std::runtime_error("DMA engine error raised");
6970
}

src/UioAxiDmaIf.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@
1515
#include <ios>
1616
#include <stdexcept>
1717

18+
#include "udmaio/FrameFormat.hpp"
19+
20+
namespace axi_dma {
21+
22+
std::ostream& operator<<(std::ostream& os, const s2mm_dmasr_t& stat) {
23+
auto fmt = [](std::string name, bool val) { return (val ? "+" : "-") + name; };
24+
os << fmt("halted", stat.halted) << " ";
25+
os << fmt("idle", stat.idle) << " ";
26+
os << fmt("sg_incld", stat.sg_incld) << " ";
27+
os << fmt("dma_int_err", stat.dma_int_err) << " ";
28+
os << fmt("dma_slv_err", stat.dma_slv_err) << " ";
29+
os << fmt("dma_dec_err", stat.dma_dec_err) << " ";
30+
os << fmt("sg_int_err", stat.sg_int_err) << " ";
31+
os << fmt("sg_slv_err", stat.sg_slv_err) << " ";
32+
os << fmt("sg_dec_err", stat.sg_dec_err) << " ";
33+
os << fmt("ioc_irq", stat.ioc_irq) << " ";
34+
os << fmt("dly_irq", stat.dly_irq) << " ";
35+
os << fmt("err_irq", stat.err_irq);
36+
return os;
37+
}
38+
39+
} // namespace axi_dma
40+
1841
namespace udmaio {
1942

2043
void UioAxiDmaIf::start(uintptr_t start_desc) {
@@ -123,4 +146,7 @@ bool UioAxiDmaIf::check_for_errors() {
123146
return has_errors;
124147
}
125148

149+
void UioAxiDmaIf::dump_status() {
150+
BOOST_LOG_SEV(_lg, bls::info) << s2mm_dmasr.rd();
151+
}
126152
} // namespace udmaio

0 commit comments

Comments
 (0)