From faa4786e025e787c196eec99f213da0d51a1f87e Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 31 May 2019 22:11:42 -0700 Subject: rfnoc: Add mb_controller API The mb_controller is an interface to hardware-specific functions of the motherboard. The API works in two ways: - The user can request access to it, and thus interact directly with the motherboard - RFNoC blocks can request access to it, if they need to interact with the motherboard themselves. --- host/lib/rfnoc/registry_factory.cpp | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'host/lib/rfnoc/registry_factory.cpp') diff --git a/host/lib/rfnoc/registry_factory.cpp b/host/lib/rfnoc/registry_factory.cpp index e9ad4f89c..d03cb183a 100644 --- a/host/lib/rfnoc/registry_factory.cpp +++ b/host/lib/rfnoc/registry_factory.cpp @@ -35,6 +35,17 @@ using block_descriptor_reg_t = UHD_SINGLETON_FCN(block_descriptor_reg_t, get_descriptor_block_registry); /////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +// These registries are for blocks that have requested motherboard access +using block_direct_mb_access_req_t = std::unordered_set; +UHD_SINGLETON_FCN(block_direct_mb_access_req_t, get_direct_block_mb_access_requested); +// +// This is the descriptor registry: +using block_descriptor_mb_access_req_t = std::unordered_set; +UHD_SINGLETON_FCN( + block_descriptor_mb_access_req_t, get_descriptor_block_mb_access_requested); +/////////////////////////////////////////////////////////////////////////////// + /****************************************************************************** * Registry functions * @@ -68,6 +79,20 @@ void registry::register_block_descriptor( get_descriptor_block_registry().emplace(block_key, std::move(factory_fn)); } +void registry::request_mb_access(noc_block_base::noc_id_t noc_id) +{ + if (!get_direct_block_mb_access_requested().count(noc_id)) { + get_direct_block_mb_access_requested().emplace(noc_id); + } +} + +void registry::request_mb_access(const std::string& block_key) +{ + if (!get_descriptor_block_mb_access_requested().count(block_key)) { + get_descriptor_block_mb_access_requested().emplace(block_key); + } +} + /****************************************************************************** * Factory functions *****************************************************************************/ @@ -87,3 +112,18 @@ std::pair factory::get_block_factory( auto& block_info = get_direct_block_registry().at(noc_id); return {std::get<1>(block_info), std::get<0>(block_info)}; } + +bool factory::has_requested_mb_access(noc_block_base::noc_id_t noc_id) +{ + if (get_direct_block_mb_access_requested().count(noc_id)) { + return true; + } + + // FIXME tbw: + // - Map noc_id to block key + // - Check that key's descriptor + // - If that block has requested MB access, stash the noc ID in + // get_direct_block_mb_access_requested() for faster lookups in the future + + return false; +} -- cgit v1.2.3