aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/rfnoc/CMakeLists.txt1
-rw-r--r--host/lib/rfnoc/register_iface_holder.cpp92
2 files changed, 93 insertions, 0 deletions
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>();
+ }
+}