USRP Hardware Driver and USRP Manual  Version: 003.008.002-0-ge9d11b35
UHD and USRP Manual
niriok_proxy_impl_v1.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_V1_H
19 #define INCLUDED_UHD_TRANSPORT_NIRIO_NIRIO_PROXY_IMPL_V1_H
20 
21 #include <boost/smart_ptr.hpp>
22 #include <boost/noncopyable.hpp>
26 
27 namespace uhd { namespace niusrprio
28 {
29  /*
30  This file defines the types, enumerations, and classes needed to
31  directly access a subset of the NI-RIO kernel interface.
32  These definitions are specific to NI-RIO versions < 14.0. These
33  are not compatible with NI-RIO 14.0 and later.
34  */
35 
36  class UHD_API niriok_proxy_impl_v1 : virtual public niriok_proxy {
37  public:
38 
39  // -------------------------------
40  // Function Codes: defined as integers rather than enums because they
41  // are going to be carried accross boundaries so size matters
42 
43  struct NIRIO_FUNC
44  {
45  static const uint32_t GET32 = 0x00000001;
46  static const uint32_t SET32 = 0x00000002;
47  static const uint32_t SET_DRIVER_CONFIG = 0x00000007;
48  static const uint32_t FIFO = 0x00000008;
49  static const uint32_t IO = 0x0000000A;
50  static const uint32_t FIFO_STOP_ALL = 0x0000000C;
51  static const uint32_t ADD_RESOURCE = 0x0000000D;
52  static const uint32_t GET_STRING = 0x0000000E;
53  static const uint32_t SET_STRING = 0x0000000F;
54  static const uint32_t DOWNLOAD = 0x00000013;
55  static const uint32_t RESET = 0x00000014;
56  };
57 
59  {
60  static const uint32_t INPUT_FIFO = 0xD0000001;
61  static const uint32_t OUTPUT_FIFO = 0xD0000002;
62  };
63 
64  struct NIRIO_FIFO
65  {
66  static const uint32_t CONFIGURE = 0x80000001;
67  static const uint32_t START = 0x80000002;
68  static const uint32_t STOP = 0x80000003;
69  static const uint32_t READ = 0x80000004;
70  static const uint32_t WRITE = 0x80000005;
71  static const uint32_t WAIT = 0x80000006;
72  static const uint32_t GRANT = 0x80000007;
73  };
74 
75  struct NIRIO_IO
76  {
77  static const uint32_t POKE64 = 0xA0000005;
78  static const uint32_t POKE32 = 0xA0000006;
79  static const uint32_t POKE16 = 0xA0000007;
80  static const uint32_t POKE8 = 0xA0000008;
81  static const uint32_t PEEK64 = 0xA0000009;
82  static const uint32_t PEEK32 = 0xA000000A;
83  static const uint32_t PEEK16 = 0xA000000B;
84  static const uint32_t PEEK8 = 0xA000000C;
85  static const uint32_t READ_BLOCK = 0xA000000D;
86  static const uint32_t WRITE_BLOCK = 0xA000000E;
87  static const uint32_t GET_IO_WINDOW = 0xA000000F;
88  static const uint32_t GET_IO_WINDOW_SIZE = 0xA0000010;
89  };
90 
92  {
93  uint32_t function;
94  uint32_t subfunction;
95 
96  union
97  {
98  struct
99  {
100  uint32_t attribute;
101  uint32_t value;
102  } attribute32;
103 
104  struct
105  {
106  uint32_t attribute;
107  uint64_t value;
108  } attribute64;
109 
110  struct
111  {
112  uint32_t attribute;
113  } attributeStr;
114 
115  struct
116  {
117  uint32_t attribute;
118  } download;
119 
120  union
121  {
122  struct
123  {
125  } reserved_field_0_0;
126  struct
127  {
130  } reserved_field_0_1;
131  struct
132  {
134  } reserved_field_0_2;
135  } reserved_field_0;
136 
137  union
138  {
139  struct
140  {
141  uint32_t channel;
142  uint32_t baseAddress;
143  uint32_t depthInSamples;
144  uint32_t version;
145  } fifo;
146  struct
147  {
148  uint32_t channel;
149  uint32_t baseAddress;
150  uint32_t depthInSamples;
151  uint32_t version;
152  uint32_t scalarType;
153  uint32_t bitWidth;
154  } fifoWithDataType;
155  struct
156  {
159  uint32_t rangeAttribute;
160  } atomic; // obsolete
161  } add;
162 
163  struct
164  {
165  uint32_t channel;
166 
167  union
168  {
169  struct
170  {
171  uint32_t requestedDepth;
173  } config;
174  struct
175  {
176  uint32_t timeout;
177  } read;
178  struct
179  {
180  uint32_t timeout;
181  uint32_t scalarType;
182  uint32_t bitWidth;
183  } readWithDataType;
184  struct
185  {
186  uint32_t timeout;
187  } write;
188  struct
189  {
190  uint32_t timeout;
191  uint32_t scalarType;
192  uint32_t bitWidth;
193  } writeWithDataType;
194  struct
195  {
197  uint32_t scalarType;
198  uint32_t bitWidth;
199  uint32_t timeout;
200  uint8_t output;
201  } wait;
202  struct
203  {
204  uint32_t elements;
205  } grant;
206  } op;
207  } fifo;
208 
209  struct
210  {
214  } reserved_field_1; // Obsolete
215 
216  struct
217  {
218  uint32_t offset;
219  union
220  {
221  uint64_t value64;
222  uint32_t value32;
223  uint16_t value16;
224  uint8_t value8;
225  } value;
226  union
227  {
228  uint32_t sizeToMap;
229  } memoryMappedIoWindow;
230  } io;
231 
232  struct
233  {
236  } reserved_field_2;
237 
238  struct
239  {
241  } reserved_field_3;
242 
243  union
244  {
245  struct
246  {
249  } wait;
250  } reserved_field_4;
251 
252  } params;
253 
254  uint32_t inbufByteLen;
255 
256  union
257  {
258  const void* pointer;
259  uint64_t _64BitField;
260  } inbuf;
261  };
262 
263  static inline void init_syncop_in_params(nirio_syncop_in_params_t& param, const void* const buf, const uint32_t len)
264  {
265  param.inbuf._64BitField = 0;
266  param.inbuf.pointer = buf;
267  param.inbufByteLen = len;
268  }
269 
270 
272  {
273  union
274  {
275  struct
276  {
277  uint32_t value;
278  } attribute32;
279 
280  struct
281  {
282  uint64_t value;
283  } attribute64;
284 
285  union
286  {
287  struct
288  {
290  } enable;
291  } reserved_field_0;
292 
293  struct
294  {
295  union
296  {
297  struct
298  {
299  uint32_t actualDepth;
300  uint32_t actualSize;
301  } config;
302  struct
303  {
304  uint32_t numberRead;
305  uint32_t numberRemaining;
306  } read;
307  struct
308  {
309  uint32_t numberRemaining;
310  } write;
311  struct
312  {
313  union
314  {
315  void* pointer;
316  uint64_t _64BitField;
317  } elements;
318  } wait;
319  } op;
320  } fifo;
321 
322  struct
323  {
324  union
325  {
326  union
327  {
328  uint64_t value64;
329  uint32_t value32;
330  uint16_t value16;
331  uint8_t value8;
332  } value;
333  union
334  {
336  uint64_t _64BitField;
337  } memoryMappedIoWindow;
338  union
339  {
340  uint32_t size;
341  } memoryMappedIoWindowSize;
342  };
343  } io;
344 
345  uint32_t stringLength;
346 
347  struct
348  {
350  } reserved_field_1;
351 
352  } params;
353 
354  uint32_t outbufByteLen;
355 
356  union
357  {
358  void* pointer;
359  uint64_t _64BitField;
360  } outbuf;
361  };
362 
363 
364  static inline void init_syncop_out_params(nirio_syncop_out_params_t& param, void* buf, uint32_t len)
365  {
366  param.outbuf._64BitField = 0;
367  param.outbuf.pointer = buf;
368  param.outbufByteLen = len;
369  }
370 
372  virtual ~niriok_proxy_impl_v1();
373 
374  //File operations
375  virtual nirio_status open(const std::string& interface_path);
376  virtual void close(void);
377 
378  virtual nirio_status reset();
379 
380  virtual nirio_status get_cached_session(
381  uint32_t& session);
382 
383  virtual nirio_status get_version(
384  nirio_version_t type,
385  uint32_t& major,
386  uint32_t& upgrade,
387  uint32_t& maintenance,
388  char& phase,
389  uint32_t& build);
390 
391  virtual nirio_status get_attribute(
392  const nirio_device_attribute32_t attribute,
393  uint32_t& attrValue);
394 
395  virtual nirio_status set_attribute(
396  const nirio_device_attribute32_t attribute,
397  const uint32_t value);
398 
399  virtual nirio_status peek(uint32_t offset, uint32_t& value);
400 
401  virtual nirio_status peek(uint32_t offset, uint64_t& value);
402 
403  virtual nirio_status poke(uint32_t offset, const uint32_t& value);
404 
405  virtual nirio_status poke(uint32_t offset, const uint64_t& value);
406 
407  virtual nirio_status map_fifo_memory(
408  uint32_t fifo_instance,
409  size_t size,
411 
412  virtual nirio_status unmap_fifo_memory(
414 
415  virtual nirio_status stop_all_fifos();
416 
417  virtual nirio_status add_fifo_resource(const nirio_fifo_info_t& fifo_info);
418 
419  virtual nirio_status set_device_config();
420 
421  virtual nirio_status start_fifo(
422  uint32_t channel);
423 
424  virtual nirio_status stop_fifo(
425  uint32_t channel);
426 
427  virtual nirio_status configure_fifo(
428  uint32_t channel,
429  uint32_t requested_depth,
430  uint8_t requires_actuals,
431  uint32_t& actual_depth,
432  uint32_t& actual_size);
433 
434  virtual nirio_status wait_on_fifo(
435  uint32_t channel,
436  uint32_t elements_requested,
437  uint32_t scalar_type,
438  uint32_t bit_width,
439  uint32_t timeout,
440  uint8_t output,
441  void*& data_pointer,
442  uint32_t& elements_acquired,
443  uint32_t& elements_remaining);
444 
445  virtual nirio_status grant_fifo(
446  uint32_t channel,
447  uint32_t elements_to_grant);
448 
449  virtual nirio_status read_fifo(
450  uint32_t channel,
451  uint32_t elements_to_read,
452  void* buffer,
453  uint32_t buffer_datatype_width,
454  uint32_t scalar_type,
455  uint32_t bit_width,
456  uint32_t timeout,
457  uint32_t& number_read,
458  uint32_t& number_remaining);
459 
460  virtual nirio_status write_fifo(
461  uint32_t channel,
462  uint32_t elements_to_write,
463  void* buffer,
464  uint32_t buffer_datatype_width,
465  uint32_t scalar_type,
466  uint32_t bit_width,
467  uint32_t timeout,
468  uint32_t& number_remaining);
469 
470  protected:
471  // protected close function that doesn't acquire synchronization lock
472  virtual void _close();
473 
474  private:
475  nirio_status sync_operation(
476  const void *writeBuffer,
477  size_t writeBufferLength,
478  void *readBuffer,
479  size_t readBufferLength);
480 
481  };
482 
483 }}
484 
485 #endif /* INCLUDED_UHD_TRANSPORT_NIRIO_NIRIO_PROXY_IMPL_V1_H */
uint32_t outbufByteLen
Definition: niriok_proxy_impl_v1.h:354
Definition: niriok_proxy.h:109
uint8_t value8
Definition: niriok_proxy_impl_v1.h:224
void * memoryMappedAddress
Definition: niriok_proxy_impl_v1.h:335
uint32_t reserved_field_0_1_0
Definition: niriok_proxy_impl_v1.h:128
uint32_t requestedDepth
Definition: niriok_proxy_impl_v1.h:171
uint32_t reserved_field_1_0
Definition: niriok_proxy_impl_v1.h:349
uint32_t value32
Definition: niriok_proxy_impl_v1.h:222
uint32_t subfunction
Definition: niriok_proxy_impl_v1.h:94
uint32_t attribute
Definition: niriok_proxy_impl_v1.h:100
uint32_t version
Definition: niriok_proxy_impl_v1.h:144
nirio_version_t
Definition: niriok_proxy.h:54
Definition: niriok_proxy_impl_v1.h:36
uint32_t reserved_field_2_1
Definition: niriok_proxy_impl_v1.h:235
uint32_t rangeAttribute
Definition: niriok_proxy_impl_v1.h:159
uint32_t rangeSizeInBytes
Definition: niriok_proxy_impl_v1.h:158
uint32_t bitWidth
Definition: niriok_proxy_impl_v1.h:153
uint64_t value
Definition: niriok_proxy_impl_v1.h:107
uint32_t stringLength
Definition: niriok_proxy_impl_v1.h:345
uint32_t sizeToMap
Definition: niriok_proxy_impl_v1.h:228
union uhd::niusrprio::niriok_proxy_impl_v1::nirio_syncop_in_params_t::@3 inbuf
uint32_t numberRemaining
Definition: niriok_proxy_impl_v1.h:305
uint32_t size
Definition: niriok_proxy_impl_v1.h:340
void * pointer
Definition: niriok_proxy_impl_v1.h:315
uint32_t depthInSamples
Definition: niriok_proxy_impl_v1.h:143
Definition: niriok_proxy.h:113
Definition: niriok_proxy_impl_v1.h:64
#define UHD_API
Definition: config.hpp:79
uint64_t rangeBaseAddress
Definition: niriok_proxy_impl_v1.h:157
uint32_t inbufByteLen
Definition: niriok_proxy_impl_v1.h:254
Definition: convert.hpp:28
Definition: niriok_proxy_impl_v1.h:75
uint8_t output
Definition: niriok_proxy_impl_v1.h:200
uint32_t elementsRequested
Definition: niriok_proxy_impl_v1.h:196
uint32_t elements
Definition: niriok_proxy_impl_v1.h:204
uint32_t scalarType
Definition: niriok_proxy_impl_v1.h:152
uint64_t reserved_field_1_0
Definition: niriok_proxy_impl_v1.h:211
static void init_syncop_in_params(nirio_syncop_in_params_t &param, const void *const buf, const uint32_t len)
Definition: niriok_proxy_impl_v1.h:263
Definition: nirio_driver_iface.h:130
int32_t nirio_status
Definition: status.h:31
uint32_t numberRead
Definition: niriok_proxy_impl_v1.h:304
uint32_t channel
Definition: niriok_proxy_impl_v1.h:141
Definition: niriok_proxy_impl_v1.h:43
uint32_t reserved_field_3_0
Definition: niriok_proxy_impl_v1.h:240
uint32_t value
Definition: niriok_proxy_impl_v1.h:101
uint32_t actualSize
Definition: niriok_proxy_impl_v1.h:300
Definition: niriok_proxy.h:146
union uhd::niusrprio::niriok_proxy_impl_v1::nirio_syncop_out_params_t::@34 outbuf
uint32_t value32
Definition: niriok_proxy_impl_v1.h:329
uint32_t actualDepth
Definition: niriok_proxy_impl_v1.h:299
uint32_t reserved_field_0_0_0
Definition: niriok_proxy_impl_v1.h:124
const void * pointer
Definition: niriok_proxy_impl_v1.h:258
uint32_t reserved_field_0_1_1
Definition: niriok_proxy_impl_v1.h:129
Definition: niriok_proxy_impl_v1.h:58
int32_t reserved_field_4_1
Definition: niriok_proxy_impl_v1.h:248
uint64_t value64
Definition: niriok_proxy_impl_v1.h:328
uint16_t value16
Definition: niriok_proxy_impl_v1.h:223
uint8_t value8
Definition: niriok_proxy_impl_v1.h:331
uint64_t _64BitField
Definition: niriok_proxy_impl_v1.h:259
uint64_t value
Definition: niriok_proxy_impl_v1.h:282
uint32_t offset
Definition: niriok_proxy_impl_v1.h:218
uint32_t reserved_field_4_0
Definition: niriok_proxy_impl_v1.h:247
uint16_t value16
Definition: niriok_proxy_impl_v1.h:330
uint32_t reserved_field_1_1
Definition: niriok_proxy_impl_v1.h:212
uint32_t timeout
Definition: niriok_proxy_impl_v1.h:176
uint32_t baseAddress
Definition: niriok_proxy_impl_v1.h:142
Definition: niriok_proxy.h:110
uint64_t value64
Definition: niriok_proxy_impl_v1.h:221
uint8_t requiresActuals
Definition: niriok_proxy_impl_v1.h:172
static void init_syncop_out_params(nirio_syncop_out_params_t &param, void *buf, uint32_t len)
Definition: niriok_proxy_impl_v1.h:364
uint32_t reserved_field_0_2_0
Definition: niriok_proxy_impl_v1.h:133
uint64_t _64BitField
Definition: niriok_proxy_impl_v1.h:316
uint32_t reserved_field_1_2
Definition: niriok_proxy_impl_v1.h:213
uint32_t reserved_field_0_0
Definition: niriok_proxy_impl_v1.h:289
nirio_device_attribute32_t
Definition: niriok_proxy.h:69
uint32_t reserved_field_2_0
Definition: niriok_proxy_impl_v1.h:234
uint32_t value
Definition: niriok_proxy_impl_v1.h:277