diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-06-07 21:29:34 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:27 -0800 |
commit | 491a74269e7d7d7589119c22f229c994d8a2c3f8 (patch) | |
tree | 299c1ea5f1a88266ff42aa8007bf6bc75665dfc9 | |
parent | 51742c90911ecd10ca8abfddaa851b510a4a5aa7 (diff) | |
download | uhd-491a74269e7d7d7589119c22f229c994d8a2c3f8.tar.gz uhd-491a74269e7d7d7589119c22f229c994d8a2c3f8.tar.bz2 uhd-491a74269e7d7d7589119c22f229c994d8a2c3f8.zip |
rfnoc: register_iface_holder: Add ability to invalidate and update
This lets child classes of register_iface_holder change the register
interface, or even invalidate it.
-rw-r--r-- | host/include/uhd/rfnoc/register_iface_holder.hpp | 3 | ||||
-rw-r--r-- | host/lib/rfnoc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/lib/rfnoc/register_iface_holder.cpp | 92 |
3 files changed, 96 insertions, 0 deletions
diff --git a/host/include/uhd/rfnoc/register_iface_holder.hpp b/host/include/uhd/rfnoc/register_iface_holder.hpp index 453b0cf10..e6eafc736 100644 --- a/host/include/uhd/rfnoc/register_iface_holder.hpp +++ b/host/include/uhd/rfnoc/register_iface_holder.hpp @@ -31,6 +31,9 @@ public: return *(_reg.get()); }; +protected: + void update_reg_iface(register_iface::sptr new_iface = nullptr); + private: register_iface::sptr _reg; }; diff --git a/host/lib/rfnoc/CMakeLists.txt b/host/lib/rfnoc/CMakeLists.txt index 93e7ff5b2..dfef4f90f 100644 --- a/host/lib/rfnoc/CMakeLists.txt +++ b/host/lib/rfnoc/CMakeLists.txt @@ -37,6 +37,7 @@ LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/node_ctrl_base.cpp ${CMAKE_CURRENT_SOURCE_DIR}/node.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rate_node_ctrl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/register_iface_holder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ctrlport_endpoint.cpp ${CMAKE_CURRENT_SOURCE_DIR}/chdr_ctrl_endpoint.cpp ${CMAKE_CURRENT_SOURCE_DIR}/registry_factory.cpp diff --git a/host/lib/rfnoc/register_iface_holder.cpp b/host/lib/rfnoc/register_iface_holder.cpp new file mode 100644 index 000000000..ea5bf0149 --- /dev/null +++ b/host/lib/rfnoc/register_iface_holder.cpp @@ -0,0 +1,92 @@ +// +// Copyright 2019 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#include <uhd/rfnoc/register_iface_holder.hpp> +#include <uhd/utils/log.hpp> + +using namespace uhd::rfnoc; + +/*! Special type of register interface: Invalidated interface + * + * This interface does nothing, other than log error messages and implement + * register_iface. It is meant to be used as a replacement for another + * register_iface when that interface is no longer accessible. + * Because this should be safely usable in a destructor, it never throws. + */ +class invalid_register_iface : public register_iface +{ +public: + ~invalid_register_iface() = default; + + void poke32(uint32_t, uint32_t, uhd::time_spec_t, bool) + { + UHD_LOG_ERROR("REGS", "Attempting to use invalidated register interface!"); + } + + void multi_poke32( + const std::vector<uint32_t>, const std::vector<uint32_t>, uhd::time_spec_t, bool) + { + UHD_LOG_ERROR("REGS", "Attempting to use invalidated register interface!"); + } + + void block_poke32(uint32_t, const std::vector<uint32_t>, uhd::time_spec_t, bool) + { + UHD_LOG_ERROR("REGS", "Attempting to use invalidated register interface!"); + } + + uint32_t peek32(uint32_t, uhd::time_spec_t) + { + UHD_LOG_ERROR("REGS", "Attempting to use invalidated register interface!"); + return {}; + } + + std::vector<uint32_t> block_peek32(uint32_t, size_t, uhd::time_spec_t) + { + UHD_LOG_ERROR("REGS", "Attempting to use invalidated register interface!"); + return {}; + } + + void poll32(uint32_t, uint32_t, uint32_t, uhd::time_spec_t, uhd::time_spec_t, bool) + { + UHD_LOG_ERROR("REGS", "Attempting to use invalidated register interface!"); + } + + void sleep(uhd::time_spec_t, bool) + { + UHD_LOG_ERROR("REGS", "Attempting to use invalidated register interface!"); + } + + void register_async_msg_handler(async_msg_callback_t) + { + UHD_LOG_ERROR("REGS", "Attempting to use invalidated register interface!"); + } + + void set_policy(const std::string&, const uhd::device_addr_t&) + { + UHD_LOG_ERROR("REGS", "Attempting to use invalidated register interface!"); + } + + uint16_t get_src_epid() const + { + UHD_LOG_ERROR("REGS", "Attempting to use invalidated register interface!"); + return 0; + } + + uint16_t get_port_num() const + { + UHD_LOG_ERROR("REGS", "Attempting to use invalidated register interface!"); + return 0; + } +}; // class invalid_register_iface + +void register_iface_holder::update_reg_iface(register_iface::sptr new_iface) +{ + if (new_iface) { + _reg = new_iface; + } else { + _reg = std::make_shared<invalid_register_iface>(); + } +} |