45 #include <boost/python.hpp>
46namespace bp = boost::python;
56rha::AxiMemMap::AxiMemMap(std::string path) :
rim::Slave(4, 0xFFFFFFFF) {
57 fd_ = ::open(path.c_str(), O_RDWR);
65 R
"(Bad kernel driver version detected. Please re-compile kernel driver.
66 Note that aes-stream-driver (v5.15.2 or earlier) and rogue (v5.11.1 or earlier) are compatible with the 32-bit address API.
67 To use later versions (64-bit address API),, you will need to upgrade both rogue and aes-stream-driver at the same time to:
68 \t\taes-stream-driver = v5.16.0 (or later)
69 \t\trogue = v5.13.0 (or later))"));
76 "AxiMemMap::AxiMemMap",
77 "Rogue DmaDriver.h API Version (DMA_VERSION) does not match the aes-stream-driver API version"));
82 thread_ =
new std::thread(&rha::AxiMemMap::runThread,
this);
86rha::AxiMemMap::~AxiMemMap() {
91void rha::AxiMemMap::stop() {
108void rha::AxiMemMap::runThread() {
110 rim::Transaction::iterator it;
118 dataSize =
sizeof(uint32_t);
119 ptr =
reinterpret_cast<uint8_t*
>(&data);
124 if ((tran = queue_.pop()) != NULL) {
125 if ((tran->size() % dataSize) != 0) {
126 tran->error(
"Invalid transaction size %" PRIu32
", must be an integer number of %" PRIu32
" bytes",
138 if (tran->expired()) {
139 log_->warning(
"Transaction expired. Id=%" PRIu32, tran->id());
146 while ((ret == 0) && (count != tran->size())) {
149 std::memcpy(ptr, it, dataSize);
153 std::memcpy(it, ptr, dataSize);
159 log_->debug(
"Transaction id=%" PRIu32
", addr 0x%016" PRIx64
". Size=%" PRIu32
", type=%" PRIu32
160 ", data=0x%08" PRIu32,
167 tran->error(
"Memory transaction failed with error code %" PRIi32
", see driver error codes", ret);
174void rha::AxiMemMap::setup_python() {
177 bp::class_<rha::AxiMemMap, rha::AxiMemMapPtr, bp::bases<rim::Slave>, boost::noncopyable>(
"AxiMemMap",
178 bp::init<std::string>());
180 bp::implicitly_convertible<rha::AxiMemMapPtr, rim::SlavePtr>();
static ssize_t dmaGetApiVersion(int32_t fd)
Get API version of the DMA driver.
static ssize_t dmaReadRegister(int32_t fd, uint64_t address, uint32_t *data)
Read a value from a DMA register.
static ssize_t dmaWriteRegister(int32_t fd, uint64_t address, uint32_t data)
Write to a DMA register.
static ssize_t dmaCheckVersion(int32_t fd)
Check API version of the DMA driver.
Generic Rogue exception type.
static GeneralError create(std::string src, const char *fmt,...)
Creates a formatted error instance.
RAII helper that releases the Python GIL for a scope.
static std::shared_ptr< rogue::Logging > create(const std::string &name, bool quiet=false)
Creates a logger instance.
std::shared_ptr< rogue::hardware::axi::AxiMemMap > AxiMemMapPtr
Shared pointer alias for AxiMemMap.
std::shared_ptr< rogue::interfaces::memory::TransactionLock > TransactionLockPtr
Shared pointer alias for TransactionLock.
static const uint32_t Write
Memory write transaction type.
std::shared_ptr< rogue::interfaces::memory::Transaction > TransactionPtr
Shared pointer alias for Transaction.
static const uint32_t Post
Memory posted write transaction type.