USRP Hardware Driver and USRP Manual  Version: 003.008.002-0-ge9d11b35
UHD and USRP Manual
nirio_resource_manager.h
Go to the documentation of this file.
1 //
2 // Copyright 2013 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 
19 #ifndef INCLUDED_UHD_TRANSPORT_NIRIO_NIRIO_RESOURCE_MANAGER_H
20 #define INCLUDED_UHD_TRANSPORT_NIRIO_NIRIO_RESOURCE_MANAGER_H
21 
24 #include <vector>
25 #include <map>
26 #include <string>
27 #include <stdint.h>
28 
29 namespace uhd { namespace niusrprio
30 {
34 };
35 
38  uint32_t arg_offset,
39  const char* arg_name,
40  register_direction_t arg_direction) :
41  offset(arg_offset),
42  name(arg_name),
43  direction(arg_direction)
44  {}
45 
46  uint32_t offset;
47  std::string name;
49 };
50 
51 typedef std::vector<nirio_register_info_t> nirio_register_info_vtr;
52 
53 
54 
55 typedef std::vector<nirio_fifo_info_t> nirio_fifo_info_vtr;
56 
57 
59 {
60 public:
62  void set_proxy(niriok_proxy::sptr proxy);
63  virtual ~nirio_resource_manager();
64 
65  nirio_status initialize(const nirio_register_info_vtr& reg_info_vtr, const nirio_fifo_info_vtr& fifo_info_vtr);
66  void finalize();
67 
68  nirio_status get_register_offset(const char* register_name, uint32_t& offset);
69 
70  template<typename data_t>
71  nirio_status create_tx_fifo(const char* fifo_name, boost::shared_ptr< nirio_fifo<data_t> >& fifo)
72  {
73  nirio_fifo_info_t* fifo_info_ptr = _lookup_fifo_info(fifo_name);
74  if (fifo_info_ptr) {
75  fifo.reset(new nirio_fifo<data_t>(_kernel_proxy, OUTPUT_FIFO, fifo_info_ptr->name, fifo_info_ptr->channel));
76  } else {
77  return NiRio_Status_ResourceNotFound;
78  }
79 
80  if (fifo->get_channel() != fifo_info_ptr->channel) return NiRio_Status_InvalidParameter;
81  if (fifo->get_scalar_type() != fifo_info_ptr->scalar_type) return NiRio_Status_InvalidParameter;
82 
83  return NiRio_Status_Success;
84  }
85 
86  template<typename data_t>
87  nirio_status create_rx_fifo(const char* fifo_name, boost::shared_ptr< nirio_fifo<data_t> >& fifo)
88  {
89  nirio_fifo_info_t* fifo_info_ptr = _lookup_fifo_info(fifo_name);
90  if (fifo_info_ptr) {
91  fifo.reset(new nirio_fifo<data_t>(_kernel_proxy, INPUT_FIFO, fifo_info_ptr->name, fifo_info_ptr->channel));
92  } else {
93  return NiRio_Status_ResourceNotFound;
94  }
95 
96  if (fifo->get_channel() != fifo_info_ptr->channel) return NiRio_Status_InvalidParameter;
97  if (fifo->get_scalar_type() != fifo_info_ptr->scalar_type) return NiRio_Status_InvalidParameter;
98 
99  return NiRio_Status_Success;
100  }
101 
102 private:
104  nirio_resource_manager& operator = (const nirio_resource_manager&);
105 
106  typedef std::map<const std::string, nirio_fifo_info_t> fifo_info_map_t;
107  typedef std::map<const std::string, nirio_register_info_t> register_info_map_t;
108 
109  nirio_status _add_fifo_resource(const nirio_fifo_info_t& fifo_info);
110  nirio_status _set_driver_config();
111  nirio_fifo_info_t* _lookup_fifo_info(const char* fifo_name);
112 
113  niriok_proxy::sptr _kernel_proxy;
114  fifo_info_map_t _fifo_info_map;
115  register_info_map_t _reg_info_map;
116 };
117 
118 }}
119 #endif /* INCLUDED_UHD_TRANSPORT_NIRIO_NIRIO_RESOURCE_MANAGER_H */
Definition: nirio_resource_manager.h:58
register_direction_t direction
Definition: nirio_resource_manager.h:48
Definition: niriok_proxy.h:109
std::vector< nirio_register_info_t > nirio_register_info_vtr
Definition: nirio_resource_manager.h:51
boost::shared_ptr< niriok_proxy > sptr
Definition: niriok_proxy.h:168
Definition: nirio_resource_manager.h:36
Definition: nirio_resource_manager.h:33
std::vector< nirio_fifo_info_t > nirio_fifo_info_vtr
Definition: nirio_resource_manager.h:55
std::string name
Definition: nirio_resource_manager.h:47
std::string name
Definition: niriok_proxy.h:136
uint32_t offset
Definition: nirio_resource_manager.h:46
Definition: niriok_proxy.h:113
register_direction_t
Definition: nirio_resource_manager.h:31
Definition: convert.hpp:28
int32_t nirio_status
Definition: status.h:31
nirio_status create_rx_fifo(const char *fifo_name, boost::shared_ptr< nirio_fifo< data_t > > &fifo)
Definition: nirio_resource_manager.h:87
uint32_t channel
Definition: niriok_proxy.h:135
Definition: nirio_resource_manager.h:32
Definition: nirio_fifo.h:41
Definition: niriok_proxy.h:110
nirio_scalar_type_t scalar_type
Definition: niriok_proxy.h:140
nirio_status create_tx_fifo(const char *fifo_name, boost::shared_ptr< nirio_fifo< data_t > > &fifo)
Definition: nirio_resource_manager.h:71
nirio_register_info_t(uint32_t arg_offset, const char *arg_name, register_direction_t arg_direction)
Definition: nirio_resource_manager.h:37