USRP Hardware Driver and USRP Manual  Version: 003.008.002-0-ge9d11b35
UHD and USRP Manual
niriok_proxy_impl_v2.h
Go to the documentation of this file.
1 //
2 // Copyright 2013-2014 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 #ifndef INCLUDED_UHD_TRANSPORT_NIRIO_NIRIO_PROXY_IMPL_V2_H
19 #define INCLUDED_UHD_TRANSPORT_NIRIO_NIRIO_PROXY_IMPL_V2_H
20 
21 #include <boost/smart_ptr.hpp>
22 #include <boost/noncopyable.hpp>
26 
27 #if __GNUC__
28  typedef uint64_t tAlignedU64 __attribute__ ((aligned(8)));
29 #else
30  typedef uint64_t tAlignedU64;
31 #endif
32 
33 namespace uhd { namespace niusrprio
34 {
35  /*
36  This file defines the types, enumerations, and classes needed to
37  directly access a subset of the NI-RIO kernel interface.
38  These definitions are specific to NI-RIO versions >= 14.0. These
39  are not compatible with NI-RIO versions older than 14.0.
40  */
41 
42  #define IOCTL(type, function, access) \
43  CTL_CODE((0x8000+type), (0x800+function), METHOD_BUFFERED, access)
44 
45  #define IOCTL_ACCESS_ANY (FILE_ANY_ACCESS)
46  #define IOCTL_ACCESS_READ (FILE_READ_ACCESS)
47  #define IOCTL_ACCESS_WRITE (FILE_WRITE_ACCESS)
48  #define IOCTL_ACCESS_RW (FILE_READ_ACCESS | FILE_WRITE_ACCESS)
49 
50  #define IOCTL_TRANSPORT_GET32 IOCTL(0, 0, IOCTL_ACCESS_READ)
51  #define IOCTL_TRANSPORT_SET32 IOCTL(0, 1, IOCTL_ACCESS_WRITE)
52  #define IOCTL_TRANSPORT_GET_STRING IOCTL(0, 2, IOCTL_ACCESS_READ)
53  #define IOCTL_TRANSPORT_SET_STRING IOCTL(0, 3, IOCTL_ACCESS_WRITE)
54  #define IOCTL_TRANSPORT_RESET IOCTL(1, 1, IOCTL_ACCESS_WRITE)
55  #define IOCTL_TRANSPORT_ADD_INPUT_FIFO_RESOURCE IOCTL(2, 0, IOCTL_ACCESS_ANY)
56  #define IOCTL_TRANSPORT_ADD_OUTPUT_FIFO_RESOURCE IOCTL(2, 1, IOCTL_ACCESS_ANY)
57  #define IOCTL_TRANSPORT_SET_DEVICE_CONFIG IOCTL(2, 3, IOCTL_ACCESS_WRITE)
58  #define IOCTL_TRANSPORT_FIFO_CONFIG IOCTL(4, 0, IOCTL_ACCESS_ANY)
59  #define IOCTL_TRANSPORT_FIFO_START IOCTL(4, 1, IOCTL_ACCESS_ANY)
60  #define IOCTL_TRANSPORT_FIFO_STOP IOCTL(4, 2, IOCTL_ACCESS_ANY)
61  #define IOCTL_TRANSPORT_FIFO_READ IOCTL(4, 3, IOCTL_ACCESS_READ)
62  #define IOCTL_TRANSPORT_FIFO_WRITE IOCTL(4, 4, IOCTL_ACCESS_WRITE)
63  #define IOCTL_TRANSPORT_FIFO_WAIT IOCTL(4, 5, IOCTL_ACCESS_ANY)
64  #define IOCTL_TRANSPORT_FIFO_GRANT IOCTL(4, 6, IOCTL_ACCESS_ANY)
65  #define IOCTL_TRANSPORT_FIFO_STOP_ALL IOCTL(4, 7, IOCTL_ACCESS_ANY)
66  #define IOCTL_TRANSPORT_PEEK64 IOCTL(5, 2, IOCTL_ACCESS_READ)
67  #define IOCTL_TRANSPORT_PEEK32 IOCTL(5, 3, IOCTL_ACCESS_READ)
68  #define IOCTL_TRANSPORT_POKE64 IOCTL(5, 6, IOCTL_ACCESS_WRITE)
69  #define IOCTL_TRANSPORT_POKE32 IOCTL(5, 7, IOCTL_ACCESS_WRITE)
70  #define IOCTL_TRANSPORT_POST_OPEN IOCTL(8, 0, IOCTL_ACCESS_ANY)
71  #define IOCTL_TRANSPORT_PRE_CLOSE IOCTL(8, 1, IOCTL_ACCESS_ANY)
72 
73  typedef struct {
78 
79  class UHD_API niriok_proxy_impl_v2 : virtual public niriok_proxy {
80  public:
81  typedef struct in_transport_get32
82  {
84  int32_t status;
86  typedef struct out_transport_get32
87  {
88  uint32_t retVal__;
89  int32_t status;
91  typedef struct in_transport_set32
92  {
94  uint32_t value;
95  int32_t status;
97  typedef struct out_transport_set32
98  {
99  int32_t status;
102  {
103  uint32_t stringLen;
104  int32_t status;
107  {
108  int32_t status;
110  typedef struct in_transport_reset
111  {
112  int32_t status;
114  typedef struct out_transport_reset
115  {
116  int32_t status;
119  {
120  uint32_t channel;
121  uint32_t baseAddress;
122  uint32_t depthInSamples;
124  uint32_t version;
125  int32_t status;
128  {
129  int32_t status;
132  {
133  uint32_t channel;
134  uint32_t baseAddress;
135  uint32_t depthInSamples;
137  uint32_t version;
138  int32_t status;
141  {
142  int32_t status;
145  {
146  uint32_t attribute;
147  int32_t status;
150  {
151  int32_t status;
154  {
155  uint32_t channel;
156  tAlignedU64 requestedDepth;
157  int32_t status;
160  {
161  tAlignedU64 actualDepth;
162  tAlignedU64 actualSize;
163  int32_t status;
165  typedef struct in_transport_fifo_start
166  {
167  uint32_t channel;
168  int32_t status;
171  {
172  int32_t status;
174  typedef struct in_transport_fifo_stop
175  {
176  uint32_t channel;
177  int32_t status;
179  typedef struct out_transport_fifo_stop
180  {
181  int32_t status;
183  typedef struct in_transport_fifo_read
184  {
185  uint32_t channel;
186  tAlignedU64 buf;
187  uint32_t numberElements;
189  uint32_t timeout;
190  int32_t status;
192  typedef struct out_transport_fifo_read
193  {
194  uint32_t read;
195  uint32_t remaining;
196  int32_t status;
198  typedef struct in_transport_fifo_write
199  {
200  uint32_t channel;
201  tAlignedU64 buf;
202  uint32_t numberElements;
204  uint32_t timeout;
205  int32_t status;
208  {
209  uint32_t remaining;
210  int32_t status;
212  typedef struct in_transport_fifo_wait
213  {
214  uint32_t channel;
215  tAlignedU64 elementsRequested;
217  bool output;
218  uint32_t timeout;
219  int32_t status;
221  typedef struct out_transport_fifo_wait
222  {
223  tAlignedU64 elements;
224  tAlignedU64 elementsAcquired;
225  tAlignedU64 elementsRemaining;
226  int32_t status;
228  typedef struct in_transport_fifo_grant
229  {
230  uint32_t channel;
231  tAlignedU64 elements;
232  int32_t status;
235  {
236  int32_t status;
239  {
240  int32_t status;
243  {
244  int32_t status;
246  typedef struct in_transport_peek64
247  {
248  uint32_t offset;
249  int32_t status;
251  typedef struct out_transport_peek64
252  {
253  tAlignedU64 retVal__;
254  int32_t status;
256  typedef struct in_transport_peek32
257  {
258  uint32_t offset;
259  int32_t status;
261  typedef struct out_transport_peek32
262  {
263  uint32_t retVal__;
264  int32_t status;
266  typedef struct in_transport_poke64
267  {
268  uint32_t offset;
269  tAlignedU64 value;
270  int32_t status;
272  typedef struct out_transport_poke64
273  {
274  int32_t status;
276  typedef struct in_transport_poke32
277  {
278  uint32_t offset;
279  uint32_t value;
280  int32_t status;
282  typedef struct out_transport_poke32
283  {
284  int32_t status;
286  typedef struct in_transport_post_open
287  {
288  int32_t status;
290  typedef struct out_transport_post_open
291  {
292  int32_t status;
294  typedef struct in_transport_pre_close
295  {
296  int32_t status;
298  typedef struct out_transport_pre_close
299  {
300  int32_t status;
302 
304  virtual ~niriok_proxy_impl_v2();
305 
306  //File operations
307  virtual nirio_status open(const std::string& interface_path);
308  virtual void close(void);
309 
310  virtual nirio_status reset();
311 
312  virtual nirio_status get_cached_session(
313  uint32_t& session);
314 
315  virtual nirio_status get_version(
316  nirio_version_t type,
317  uint32_t& major,
318  uint32_t& upgrade,
319  uint32_t& maintenance,
320  char& phase,
321  uint32_t& build);
322 
323  virtual nirio_status get_attribute(
324  const nirio_device_attribute32_t attribute,
325  uint32_t& attrValue);
326 
327  virtual nirio_status set_attribute(
328  const nirio_device_attribute32_t attribute,
329  const uint32_t value);
330 
331  virtual nirio_status peek(uint32_t offset, uint32_t& value);
332 
333  virtual nirio_status peek(uint32_t offset, uint64_t& value);
334 
335  virtual nirio_status poke(uint32_t offset, const uint32_t& value);
336 
337  virtual nirio_status poke(uint32_t offset, const uint64_t& value);
338 
339  virtual nirio_status map_fifo_memory(
340  uint32_t fifo_instance,
341  size_t size,
343 
344  virtual nirio_status unmap_fifo_memory(
346 
347  virtual nirio_status stop_all_fifos();
348 
349  virtual nirio_status add_fifo_resource(const nirio_fifo_info_t& fifo_info);
350 
351  virtual nirio_status set_device_config();
352 
353  virtual nirio_status start_fifo(
354  uint32_t channel);
355 
356  virtual nirio_status stop_fifo(
357  uint32_t channel);
358 
359  virtual nirio_status configure_fifo(
360  uint32_t channel,
361  uint32_t requested_depth,
362  uint8_t requires_actuals,
363  uint32_t& actual_depth,
364  uint32_t& actual_size);
365 
366  virtual nirio_status wait_on_fifo(
367  uint32_t channel,
368  uint32_t elements_requested,
369  uint32_t scalar_type,
370  uint32_t bit_width,
371  uint32_t timeout,
372  uint8_t output,
373  void*& data_pointer,
374  uint32_t& elements_acquired,
375  uint32_t& elements_remaining);
376 
377  virtual nirio_status grant_fifo(
378  uint32_t channel,
379  uint32_t elements_to_grant);
380 
381  virtual nirio_status read_fifo(
382  uint32_t channel,
383  uint32_t elements_to_read,
384  void* buffer,
385  uint32_t buffer_datatype_width,
386  uint32_t scalar_type,
387  uint32_t bit_width,
388  uint32_t timeout,
389  uint32_t& number_read,
390  uint32_t& number_remaining);
391 
392  virtual nirio_status write_fifo(
393  uint32_t channel,
394  uint32_t elements_to_write,
395  void* buffer,
396  uint32_t buffer_datatype_width,
397  uint32_t scalar_type,
398  uint32_t bit_width,
399  uint32_t timeout,
400  uint32_t& number_remaining);
401 
402  protected:
403  // protected close function that doesn't acquire synchronization lock
404  virtual void _close();
405 
406  };
407 
408 }}
409 
410 #endif /* INCLUDED_UHD_TRANSPORT_NIRIO_NIRIO_PROXY_IMPL_V2_H */
Definition: niriok_proxy_impl_v2.h:256
int32_t status
Definition: niriok_proxy_impl_v2.h:288
int32_t status
Definition: niriok_proxy_impl_v2.h:84
uint32_t baseAddress
Definition: niriok_proxy_impl_v2.h:121
uint32_t read
Definition: niriok_proxy_impl_v2.h:194
uint32_t offset
Definition: niriok_proxy_impl_v2.h:258
tAlignedU64 buf
Definition: niriok_proxy_impl_v2.h:201
int32_t status
Definition: niriok_proxy_impl_v2.h:104
uint32_t numberElements
Definition: niriok_proxy_impl_v2.h:187
int32_t status
Definition: niriok_proxy_impl_v2.h:292
Definition: niriok_proxy_impl_v2.h:114
nirio_fifo_data_type_t dataType
Definition: niriok_proxy_impl_v2.h:216
Definition: niriok_proxy_impl_v2.h:246
uint32_t retVal__
Definition: niriok_proxy_impl_v2.h:263
int32_t status
Definition: niriok_proxy_impl_v2.h:244
uint32_t channel
Definition: niriok_proxy_impl_v2.h:167
tAlignedU64 retVal__
Definition: niriok_proxy_impl_v2.h:253
tAlignedU64 elementsRemaining
Definition: niriok_proxy_impl_v2.h:225
int32_t nirio_i32_t
Definition: niriok_proxy.h:67
uint32_t channel
Definition: niriok_proxy_impl_v2.h:155
int32_t status
Definition: niriok_proxy_impl_v2.h:99
nirio_version_t
Definition: niriok_proxy.h:54
Definition: niriok_proxy_impl_v2.h:110
int32_t status
Definition: niriok_proxy_impl_v2.h:147
uint32_t value
Definition: niriok_proxy_impl_v2.h:94
int32_t status
Definition: niriok_proxy_impl_v2.h:280
tAlignedU64 actualSize
Definition: niriok_proxy_impl_v2.h:162
int32_t status
Definition: niriok_proxy_impl_v2.h:254
int32_t status
Definition: niriok_proxy_impl_v2.h:274
tAlignedU64 requestedDepth
Definition: niriok_proxy_impl_v2.h:156
Definition: niriok_proxy_impl_v2.h:290
uint32_t channel
Definition: niriok_proxy_impl_v2.h:185
uint32_t nirio_u32_t
Definition: niriok_proxy.h:64
int32_t status
Definition: niriok_proxy_impl_v2.h:226
Definition: niriok_proxy_impl_v2.h:73
uint32_t offset
Definition: niriok_proxy_impl_v2.h:248
Definition: niriok_proxy.h:113
uint32_t baseAddress
Definition: niriok_proxy_impl_v2.h:134
int32_t status
Definition: niriok_proxy_impl_v2.h:157
int32_t status
Definition: niriok_proxy_impl_v2.h:190
tAlignedU64 value
Definition: niriok_proxy_impl_v2.h:269
tAlignedU64 buf
Definition: niriok_proxy_impl_v2.h:186
Definition: niriok_proxy_impl_v2.h:79
#define UHD_API
Definition: config.hpp:79
nirio_scalar_type_t
Definition: niriok_proxy.h:81
Definition: convert.hpp:28
int32_t status
Definition: niriok_proxy_impl_v2.h:205
uint32_t channel
Definition: niriok_proxy_impl_v2.h:176
Definition: niriok_proxy_impl_v2.h:286
uint32_t numberElements
Definition: niriok_proxy_impl_v2.h:202
nirio_device_attribute32_t attribute
Definition: niriok_proxy_impl_v2.h:93
uint32_t attribute
Definition: niriok_proxy_impl_v2.h:146
uint32_t timeout
Definition: niriok_proxy_impl_v2.h:218
int32_t status
Definition: niriok_proxy_impl_v2.h:116
int32_t status
Definition: niriok_proxy_impl_v2.h:172
uint32_t depthInSamples
Definition: niriok_proxy_impl_v2.h:135
int32_t status
Definition: niriok_proxy_impl_v2.h:236
Definition: nirio_driver_iface.h:130
int32_t status
Definition: niriok_proxy_impl_v2.h:270
int32_t nirio_status
Definition: status.h:31
uint32_t channel
Definition: niriok_proxy_impl_v2.h:200
int32_t status
Definition: niriok_proxy_impl_v2.h:284
uint32_t stringLen
Definition: niriok_proxy_impl_v2.h:103
int32_t status
Definition: niriok_proxy_impl_v2.h:240
uint32_t depthInSamples
Definition: niriok_proxy_impl_v2.h:122
uint32_t channel
Definition: niriok_proxy_impl_v2.h:230
nirio_i32_t integerWordLength
Definition: niriok_proxy_impl_v2.h:76
uint32_t timeout
Definition: niriok_proxy_impl_v2.h:189
uint64_t tAlignedU64
Definition: niriok_proxy_impl_v2.h:30
int32_t status
Definition: niriok_proxy_impl_v2.h:168
int32_t status
Definition: niriok_proxy_impl_v2.h:210
Definition: niriok_proxy.h:146
int32_t status
Definition: niriok_proxy_impl_v2.h:177
tAlignedU64 actualDepth
Definition: niriok_proxy_impl_v2.h:161
uint32_t timeout
Definition: niriok_proxy_impl_v2.h:204
uint32_t offset
Definition: niriok_proxy_impl_v2.h:268
Definition: niriok_proxy_impl_v2.h:276
uint32_t value
Definition: niriok_proxy_impl_v2.h:279
int32_t status
Definition: niriok_proxy_impl_v2.h:181
int32_t status
Definition: niriok_proxy_impl_v2.h:151
nirio_fifo_data_type_t dataType
Definition: niriok_proxy_impl_v2.h:203
int32_t status
Definition: niriok_proxy_impl_v2.h:89
tAlignedU64 elements
Definition: niriok_proxy_impl_v2.h:231
int32_t status
Definition: niriok_proxy_impl_v2.h:264
Definition: niriok_proxy_impl_v2.h:266
nirio_u32_t bitWidth
Definition: niriok_proxy_impl_v2.h:75
int32_t status
Definition: niriok_proxy_impl_v2.h:232
int32_t status
Definition: niriok_proxy_impl_v2.h:249
uint32_t channel
Definition: niriok_proxy_impl_v2.h:214
tAlignedU64 elements
Definition: niriok_proxy_impl_v2.h:223
uint32_t retVal__
Definition: niriok_proxy_impl_v2.h:88
tAlignedU64 elementsAcquired
Definition: niriok_proxy_impl_v2.h:224
tAlignedU64 elementsRequested
Definition: niriok_proxy_impl_v2.h:215
nirio_device_attribute32_t attribute
Definition: niriok_proxy_impl_v2.h:83
int32_t status
Definition: niriok_proxy_impl_v2.h:163
int32_t status
Definition: niriok_proxy_impl_v2.h:108
int32_t status
Definition: niriok_proxy_impl_v2.h:196
uint32_t remaining
Definition: niriok_proxy_impl_v2.h:209
nirio_scalar_type_t scalarType
Definition: niriok_proxy_impl_v2.h:74
int32_t status
Definition: niriok_proxy_impl_v2.h:219
int32_t status
Definition: niriok_proxy_impl_v2.h:95
uint32_t offset
Definition: niriok_proxy_impl_v2.h:278
nirio_fifo_data_type_t dataType
Definition: niriok_proxy_impl_v2.h:188
uint32_t remaining
Definition: niriok_proxy_impl_v2.h:195
int32_t status
Definition: niriok_proxy_impl_v2.h:112
nirio_fifo_data_type_t dataType
Definition: niriok_proxy_impl_v2.h:136
nirio_device_attribute32_t
Definition: niriok_proxy.h:69
int32_t status
Definition: niriok_proxy_impl_v2.h:300
int32_t status
Definition: niriok_proxy_impl_v2.h:259
int32_t status
Definition: niriok_proxy_impl_v2.h:296
bool output
Definition: niriok_proxy_impl_v2.h:217
nirio_fifo_data_type_t dataType
Definition: niriok_proxy_impl_v2.h:123