diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-05-27 21:05:56 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:10 -0800 |
commit | 1ee9529abdf32be8ff254114a108aeb14534cf98 (patch) | |
tree | 6ebb08c8f5f384543fb0b1ff3fddea10746bd86c /host | |
parent | 4d5ae0cc69424ecc9a7fcc0943d22832e5f37b8d (diff) | |
download | uhd-1ee9529abdf32be8ff254114a108aeb14534cf98.tar.gz uhd-1ee9529abdf32be8ff254114a108aeb14534cf98.tar.bz2 uhd-1ee9529abdf32be8ff254114a108aeb14534cf98.zip |
uhd: utils: Add compat check for 32-bit compat numbers
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/include/uhdlib/utils/compat_check.hpp | 13 | ||||
-rw-r--r-- | host/lib/utils/compat_check.cpp | 18 |
2 files changed, 31 insertions, 0 deletions
diff --git a/host/lib/include/uhdlib/utils/compat_check.hpp b/host/lib/include/uhdlib/utils/compat_check.hpp index b2d7652d0..8fe96d118 100644 --- a/host/lib/include/uhdlib/utils/compat_check.hpp +++ b/host/lib/include/uhdlib/utils/compat_check.hpp @@ -25,6 +25,19 @@ namespace uhd { const bool fail_on_minor_behind=false ); + /*! Checks for FPGA compatibility, and throws an exception on mismatch. + * + * \throws uhd::runtime_error on mismatch. + */ + void assert_fpga_compat( + const size_t uhd_major, + const size_t uhd_minor, + const uint32_t fpga_compat, + const std::string& fpga_component, + const std::string& log_component, + const bool fail_on_minor_behind=false + ); + } /* namespace uhd */ #endif /* INCLUDED_UHDLIB_UTILS_COMPATCHECK_HPP */ diff --git a/host/lib/utils/compat_check.cpp b/host/lib/utils/compat_check.cpp index f15ba8bba..e340e5c67 100644 --- a/host/lib/utils/compat_check.cpp +++ b/host/lib/utils/compat_check.cpp @@ -112,3 +112,21 @@ void uhd::assert_fpga_compat( } // We got here? Then all is good. } + +void uhd::assert_fpga_compat(const size_t uhd_major, + const size_t uhd_minor, + const uint32_t fpga_compat, + const std::string& fpga_component, + const std::string& log_component, + const bool fail_on_minor_behind) +{ + const size_t fpga_major = fpga_compat >> 16; + const size_t fpga_minor = fpga_compat & 0xFFFF; + const uint64_t fpga_scaled = uint64_t(fpga_major) << 32 | fpga_minor; + uhd::assert_fpga_compat(uhd_major, + uhd_minor, + fpga_scaled, + fpga_component, + log_component, + fail_on_minor_behind); +} |