Skip to content

Commit 1e6fc09

Browse files
committed
feat: add read_bulk() API
1 parent 38a1429 commit 1e6fc09

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

inc/udmaio/HwAccessor.hpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#pragma once
1313

1414
#include <cstddef>
15+
#include <cstring>
1516
#include <filesystem>
1617
#include <fstream>
1718
#include <iostream>
@@ -63,9 +64,14 @@ class HwAccessor : public Logger, private boost::noncopyable {
6364
void _wr_mem32(uint32_t offs, const void* __restrict__ mem, size_t size);
6465
void _wr_mem64(uint32_t offs, const void* __restrict__ mem, size_t size);
6566

67+
virtual std::vector<uint8_t> read_bulk([[maybe_unused]] uint32_t offs,
68+
[[maybe_unused]] uint32_t size) {
69+
return {};
70+
}
71+
6672
/**
6773
* @brief Read register from UIO interface
68-
*
74+
*
6975
* @tparam C Register data type
7076
* @param offs Register offset into address space
7177
* @return C Value read from register
@@ -87,7 +93,7 @@ class HwAccessor : public Logger, private boost::noncopyable {
8793

8894
/**
8995
* @brief Write register to UIO interface
90-
*
96+
*
9197
* @tparam C Register data type
9298
* @param offs Register offset into address space
9399
* @param value Value to write
@@ -223,6 +229,14 @@ class HwAccessorMmap : public HwAccessor {
223229
return irq_count;
224230
}
225231

232+
std::vector<uint8_t> read_bulk(uint32_t offs, uint32_t size) final override {
233+
std::vector<uint8_t> result;
234+
result.resize(size);
235+
auto src = _mem_ptr<uint8_t>(offs);
236+
memcpy(&result[0], const_cast<uint8_t*>(src), size);
237+
return result;
238+
}
239+
226240
public:
227241
UioRegion get_phys_region() const final override {
228242
const size_t access_offs =

inc/udmaio/UioIf.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ class UioIf : private boost::noncopyable {
7575
inline void _wr32(uint32_t offs, uint32_t data) { _hw->_wr32(offs, data); }
7676
inline void _wr64(uint32_t offs, uint64_t data) { _hw->_wr64(offs, data); }
7777

78+
std::vector<uint8_t> read_bulk(uint32_t offs, uint32_t size) {
79+
return _hw->read_bulk(offs, size);
80+
}
81+
7882
template <typename C>
7983
C _rd_reg(uint32_t offs) const {
8084
return _hw->template _rd_reg<C>(offs);

0 commit comments

Comments
 (0)