summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/config.hpp3
-rw-r--r--host/include/uhd/transport/usb_device_handle.hpp6
-rw-r--r--host/include/uhd/transport/zero_copy.hpp5
-rw-r--r--host/include/uhd/types/CMakeLists.txt1
-rw-r--r--host/include/uhd/types/wb_iface.hpp82
-rw-r--r--host/include/uhd/utils/CMakeLists.txt1
-rw-r--r--host/include/uhd/utils/atomic.hpp4
-rw-r--r--host/include/uhd/utils/msg_task.hpp74
-rw-r--r--host/include/uhd/utils/tasks.hpp1
9 files changed, 175 insertions, 2 deletions
diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp
index 6fd2932cf..619bd0787 100644
--- a/host/include/uhd/config.hpp
+++ b/host/include/uhd/config.hpp
@@ -55,18 +55,21 @@ typedef ptrdiff_t ssize_t;
#define UHD_INLINE __forceinline
#define UHD_DEPRECATED __declspec(deprecated)
#define UHD_ALIGNED(x) __declspec(align(x))
+ #define UHD_UNUSED(x) x
#elif defined(__GNUG__) && __GNUG__ >= 4
#define UHD_EXPORT __attribute__((visibility("default")))
#define UHD_IMPORT __attribute__((visibility("default")))
#define UHD_INLINE inline __attribute__((always_inline))
#define UHD_DEPRECATED __attribute__((deprecated))
#define UHD_ALIGNED(x) __attribute__((aligned(x)))
+ #define UHD_UNUSED(x) x __attribute__((unused))
#else
#define UHD_EXPORT
#define UHD_IMPORT
#define UHD_INLINE inline
#define UHD_DEPRECATED
#define UHD_ALIGNED(x)
+ #define UHD_UNUSED(x) x
#endif
// Define API declaration macro
diff --git a/host/include/uhd/transport/usb_device_handle.hpp b/host/include/uhd/transport/usb_device_handle.hpp
index 2951d7fbb..fdea9e2be 100644
--- a/host/include/uhd/transport/usb_device_handle.hpp
+++ b/host/include/uhd/transport/usb_device_handle.hpp
@@ -73,6 +73,12 @@ public:
virtual boost::uint16_t get_product_id() const = 0;
/*!
+ * Test whether the firmware is loaded on the device.
+ * \return true if firmware is loaded
+ */
+ virtual bool firmware_loaded() = 0;
+
+ /*!
* Return a vector of USB devices on this host
* \return a vector of USB device handles that match vid and pid
*/
diff --git a/host/include/uhd/transport/zero_copy.hpp b/host/include/uhd/transport/zero_copy.hpp
index 1dc0e8e26..40d7b8c59 100644
--- a/host/include/uhd/transport/zero_copy.hpp
+++ b/host/include/uhd/transport/zero_copy.hpp
@@ -29,7 +29,9 @@ namespace uhd{ namespace transport{
//! Simple managed buffer with release interface
class UHD_API managed_buffer{
public:
- managed_buffer(void):_ref_count(0){}
+ managed_buffer(void):_ref_count(0),_buffer(NULL),_length(0){}
+
+ virtual ~managed_buffer(void) {}
/*!
* Signal to the transport that we are done with the buffer.
@@ -72,6 +74,7 @@ namespace uhd{ namespace transport{
}
boost::detail::atomic_count _ref_count;
+ typedef boost::intrusive_ptr<managed_buffer> sptr;
protected:
void *_buffer;
diff --git a/host/include/uhd/types/CMakeLists.txt b/host/include/uhd/types/CMakeLists.txt
index 28e646117..334f1b41b 100644
--- a/host/include/uhd/types/CMakeLists.txt
+++ b/host/include/uhd/types/CMakeLists.txt
@@ -33,6 +33,7 @@ UHD_INSTALL(FILES
time_spec.hpp
tune_request.hpp
tune_result.hpp
+ wb_iface.hpp
DESTINATION ${INCLUDE_DIR}/uhd/types
COMPONENT headers
)
diff --git a/host/include/uhd/types/wb_iface.hpp b/host/include/uhd/types/wb_iface.hpp
new file mode 100644
index 000000000..c508062e4
--- /dev/null
+++ b/host/include/uhd/types/wb_iface.hpp
@@ -0,0 +1,82 @@
+//
+// Copyright 2011-2013 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TYPES_WB_IFACE_HPP
+#define INCLUDED_UHD_TYPES_WB_IFACE_HPP
+
+#include <uhd/config.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace uhd
+{
+
+class UHD_API wb_iface
+{
+public:
+ typedef boost::shared_ptr<wb_iface> sptr;
+ typedef boost::uint32_t wb_addr_type;
+
+ virtual ~wb_iface(void);
+
+ /*!
+ * Write a register (64 bits)
+ * \param addr the address
+ * \param data the 64bit data
+ */
+ virtual void poke64(const wb_addr_type addr, const boost::uint64_t data);
+
+ /*!
+ * Read a register (64 bits)
+ * \param addr the address
+ * \return the 64bit data
+ */
+ virtual boost::uint64_t peek64(const wb_addr_type addr);
+
+ /*!
+ * Write a register (32 bits)
+ * \param addr the address
+ * \param data the 32bit data
+ */
+ virtual void poke32(const wb_addr_type addr, const boost::uint32_t data);
+
+ /*!
+ * Read a register (32 bits)
+ * \param addr the address
+ * \return the 32bit data
+ */
+ virtual boost::uint32_t peek32(const wb_addr_type addr);
+
+ /*!
+ * Write a register (16 bits)
+ * \param addr the address
+ * \param data the 16bit data
+ */
+ virtual void poke16(const wb_addr_type addr, const boost::uint16_t data);
+
+ /*!
+ * Read a register (16 bits)
+ * \param addr the address
+ * \return the 16bit data
+ */
+ virtual boost::uint16_t peek16(const wb_addr_type addr);
+
+};
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_TYPES_WB_IFACE_HPP */
diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt
index cdef2e946..e86826435 100644
--- a/host/include/uhd/utils/CMakeLists.txt
+++ b/host/include/uhd/utils/CMakeLists.txt
@@ -27,6 +27,7 @@ UHD_INSTALL(FILES
images.hpp
log.hpp
msg.hpp
+ msg_task.hpp
paths.hpp
pimpl.hpp
safe_call.hpp
diff --git a/host/include/uhd/utils/atomic.hpp b/host/include/uhd/utils/atomic.hpp
index 8ddee73ca..55769d2fd 100644
--- a/host/include/uhd/utils/atomic.hpp
+++ b/host/include/uhd/utils/atomic.hpp
@@ -78,6 +78,10 @@ namespace uhd{
class UHD_API reusable_barrier{
public:
+ reusable_barrier():_size (0) {}
+
+ reusable_barrier(const size_t size):_size(size) {}
+
//! Resize the barrier for N threads
void resize(const size_t size){
_size = size;
diff --git a/host/include/uhd/utils/msg_task.hpp b/host/include/uhd/utils/msg_task.hpp
new file mode 100644
index 000000000..ebb29af08
--- /dev/null
+++ b/host/include/uhd/utils/msg_task.hpp
@@ -0,0 +1,74 @@
+//
+// Copyright 2011-2013 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_UTILS_MSG_TASK_HPP
+#define INCLUDED_UHD_UTILS_MSG_TASK_HPP
+
+#include <uhd/config.hpp>
+#include <uhd/transport/zero_copy.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/function.hpp>
+#include <boost/utility.hpp>
+#include <boost/optional/optional.hpp>
+#include <vector>
+
+namespace uhd{
+ class UHD_API msg_task : boost::noncopyable{
+ public:
+ typedef boost::shared_ptr<msg_task> sptr;
+ typedef std::vector<uint8_t> msg_payload_t;
+ typedef std::pair<uint32_t, msg_payload_t > msg_type_t;
+ typedef boost::function<boost::optional<msg_type_t>(void)> task_fcn_type;
+
+ /*
+ * During shutdown message queues for radio control cores might not be available anymore.
+ * Such stranded messages get pushed into a dump queue.
+ * With this function radio_ctrl_core can check if one of the messages meant for it got stranded.
+ */
+ virtual msg_payload_t get_msg_from_dump_queue(boost::uint32_t sid) = 0;
+
+ inline static std::vector<uint8_t> buff_to_vector(uint8_t* p, size_t n) {
+ if(p and n > 0){
+ std::vector<uint8_t> v(n);
+ memcpy(&v.front(), p, n);
+ return v;
+ }
+ return std::vector<uint8_t>();
+ }
+
+ /*!
+ * Create a new task object with function callback.
+ * The task function callback will be run in a loop.
+ * until the thread is interrupted by the deconstructor.
+ *
+ * A function may return payload which is then pushed to
+ * a synchronized message queue.
+ *
+ * A task should return in a reasonable amount of time
+ * or may block forever under the following conditions:
+ * - The blocking call is interruptible.
+ * - The task polls the interrupt condition.
+ *
+ * \param task_fcn the task callback function
+ * \return a new task object
+ */
+ static sptr make(const task_fcn_type &task_fcn);
+ };
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_UTILS_MSG_TASK_HPP */
+
diff --git a/host/include/uhd/utils/tasks.hpp b/host/include/uhd/utils/tasks.hpp
index dcb003e39..a1f682a83 100644
--- a/host/include/uhd/utils/tasks.hpp
+++ b/host/include/uhd/utils/tasks.hpp
@@ -46,7 +46,6 @@ namespace uhd{
static sptr make(const task_fcn_type &task_fcn);
};
-
} //namespace uhd
#endif /* INCLUDED_UHD_UTILS_TASKS_HPP */