mbgtools-lx  4.2.8
macioctl.h
Go to the documentation of this file.
1 
2 /**************************************************************************
3  *
4  * $Id: macioctl.h 1.44 2019/04/03 12:18:11 martin TRASH $
5  *
6  * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
7  *
8  * Description:
9  * Macros used inside the IOCTL handlers of device drivers
10  * for Meinberg PCI and USB devices.
11  *
12  * -----------------------------------------------------------------------
13  * $Log: macioctl.h $
14  * Revision 1.44 2019/04/03 12:18:11 martin
15  * Copying data in and out is now also protected by the device semaphore.
16  * Made SPIN_BUFFER obsolete, use local variables for these few cases.
17  * Gave a more plausible name to a common variable.
18  * Added a couple of comments.
19  * Revision 1.43 2019/03/11 16:15:50 martin
20  * Conditionally use local I/O buffers by again. This may avoid a
21  * potential data corruption problem with PCI devices, but won't work
22  * with USB devices on Linux kernels 4.9 and later.
23  * Revision 1.42 2019/02/08 10:28:27 martin
24  * Fixed potential data corruption in IOCTL_GET_TIME_INFO_HRT which
25  * could have occured with file versions after 1.38, when we started
26  * using a DMA-capable, common buffer to meet USB requirements in
27  * Linux kernels 4.9+.
28  * Revision 1.41 2018/11/22 13:59:08 martin
29  * Refactored debug logging stuff.
30  * Fixed pointer size problems in a mixed 32/64 bit Linux environment.
31  * Revision 1.40 2018/08/20 16:06:42 martin
32  * Use current log level definitions.
33  * Account for renamed library symbols.
34  * Revision 1.39 2018/07/05 08:36:45 martin
35  * Moved some definitions to mbgioctl.h.
36  * Use a DMA capable buffer in the device data structure
37  * for I/O. Required for USB by Linux kernels 4.9+.
38  * Use safer macro syntax.
39  * Renamed some jump labels.
40  * Account for renamed library symbol NSEC_PER_SEC.
41  * Use memory access macros.
42  * Unified kernel driver messages.
43  * Separated test code that should be moved elsewhere.
44  * Revision 1.38 2017/07/05 14:20:58 martin
45  * Support GNSS, GPIO and xmulti_ref stuff.
46  * Support new way to check if a feature is supported.
47  * Attribute always_inline is now in __mbg_inline.
48  * Fixed macro definition syntax to avoid clang compiler warnings.
49  * Account for frac_sec_from_bin() obsoleted by bin_frac_32_to_dec_frac().
50  * IOCTL debugging code.
51  * Removed trailing spaces.
52  * Revision 1.37 2014/05/19 15:57:25 martin
53  * Fixed grammar in a comment.
54  * Revision 1.36 2013/09/26 07:54:22 martin
55  * Support GNSS API.
56  * Revision 1.35 2013/04/11 13:46:05 martin
57  * Account for modified spinlock handling under Windows.
58  * Revision 1.34 2012/10/02 18:29:49Z martin
59  * Account for some renamed library symbols.
60  * Account for renamed structures.
61  * Support on-board event logs.
62  * Support debug status.
63  * Made inline functions static.
64  * Include cfg_hlp.h.
65  * Always read receiver info directly from the device.
66  * Conditionally use older IOCTL request buffer structures.
67  * Modified generic IOCTL handling such that for calls requiring variable sizes
68  * a fixed request block containing input and output buffer pointers and sizes is
69  * passed down to the kernel driver. This simplifies implementation under *BSD
70  * and also works for other target systems.
71  * Support reading CORR_INFO, and reading/writing TR_DISTANCE.
72  * Support IOCTL_DEV_HAS_PZF.
73  * Use a single union type buffer instead of a large number of local
74  * variables in ioctl_switch().
75  * The accumulated size of all local variables required much stack
76  * space which led to problems under Windows.
77  * Support PTP unicast configuration.
78  * Account for some IOCTL codes renamed to follow common naming conventions.
79  * Use common mutex primitives from mbgmutex.h.
80  * Changes by Frank Kardel: Don't require copyin/copyout under NetBSD.
81  * Support NetBSD beside FreeBSD.
82  * Account for modified _pcpc_kfree().
83  * Bug fix: Use PCPS_TIME_STAMP with
84  * IOCTL_GET_FAST_HR_TIMESTAMP as output size.
85  * Specify I/O range number when calling port I/O macros
86  * so they can be used for different ranges under BSD.
87  * Modified inline declarations for gcc.
88  * Fixed build under FreeBSD.
89  * Added _sem_inc_safe_no_irp() macro (Windows only).
90  * Simplified code and renamed some inline functions.
91  * Fixed macro.
92  * Revision 1.33 2009/12/21 16:22:55 martin
93  * Moved code reading memory mapped timestamps to inline functions.
94  * Revision 1.32 2009/12/15 15:34:57 daniel
95  * Support reading the raw IRIG data bits for firmware versions
96  * which support this feature.
97  * Revision 1.31 2009/11/04 14:58:52Z martin
98  * Conditionally exclude port status query from build.
99  * Revision 1.30 2009/09/29 15:08:39 martin
100  * Support retrieving time discipline info.
101  * Revision 1.29 2009/08/18 08:45:16 martin
102  * Removed IOCTL switch macro, inline code used for all targets.
103  * Revision 1.28 2009/06/26 13:16:11Z martin
104  * Fixed duplicate case in inline code (copy and paste error).
105  * Revision 1.27 2009/06/22 13:52:56 martin
106  * Fixed a bug where the size of GPS data had been truncated to 8 bits,
107  * which resulted in an IOCTL error if a buffer larger than 256 bytes had been
108  * used. This had been observed with the PC_GPS_ALL_STR_TYPE_INFO
109  * command if more than 6 string types are supported by a card.
110  * Revision 1.26 2009/06/19 12:21:12 martin
111  * Support reading raw IRIG time.
112  * Revision 1.25 2009/06/09 10:01:01 daniel
113  * Support configuration of LAN intf. and PTP.
114  * Started to support ARM / firmware.
115  * Conditionally compile ioctl_switch as inline function.
116  * Revision 1.24 2009/03/19 15:25:19 martin
117  * Support UTC parms and configurable time scales.
118  * Support IOCTL_DEV_HAS_IRIG_CTRL_BITS and IOCTL_GET_IRIG_CTRL_BITS.
119  * Support reading MM timestamps without cycles.
120  * IOCTL_GET_PCI_ASIC_VERSION now returns the ASIC
121  * version code from the device info structure which already
122  * has the correct endianess.
123  * For consistent naming renamed IOCTL_GET_FAST_HR_TIMESTAMP
124  * to IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES.
125  * Use mbg_get_cycles...() instead of _pcps_get_cycles...().
126  * Revision 1.23 2008/12/11 10:30:38Z martin
127  * _pcps_get_cycles() is now called inside the low level routines
128  * immediately when the command byte is written.
129  * Mutex for hardware access is now acquired/released in _pcps_sem_inc()
130  * and _pcps_sem_dec(), so other IOCTLs which don't access the card
131  * can be run in parallel.
132  * Moved definitions of _pcps_sem_inc(), _pcps_sem_dec(), and
133  * _pcps_get_cycles() to pcpsdrvr.h.
134  * Defined a macro which checks if access is safe (may be unsafe
135  * with certain PEX cards which have IRQs enabled).
136  * Use _pcps_sem_inc_safe() macro to check if access is safe and
137  * inhibit access if this is not the case.
138  * Consistenly use pcps_drvr_name instead of mbgclock_name
139  * for debug messages.
140  * Don't return error for unmap_mm...() under Linux.
141  * Account for ASIC_FEATURES being coded as flags, and account
142  * for new symbol PCI_ASIC_HAS_MM_IO.
143  * Handle new IOCTLs IOCTL_HAS_PCI_ASIC_FEATURES, IOCTL_HAS_PCI_ASIC_VERSION,
144  * IOCTL_DEV_IS_MSF, IOCTL_DEV_IS_LWR, IOCTL_DEV_IS_WWVB,
145  * IOCTL_GET_IRQ_STAT_INFO, IOCTL_GET_CYCLES_FREQUENCY,
146  * IOCTL_HAS_FAST_HR_TIMESTAMP, and IOCTL_GET_FAST_HR_TIMESTAMP.
147  * Support mapped I/O resources.
148  * Revision 1.22 2008/01/17 09:28:49 daniel
149  * Support for memory mapped I/O under Linux and Windows.
150  * Added macros _io_get_mapped_mem_address(),
151  * _io_unmap_mapped_mem_address().
152  * Account for IOCTL_GET_PCI_ASIC_FEATURES
153  * Cleanup for PCI ASIC version.
154  * Revision 1.21 2007/09/26 07:31:47Z martin
155  * Support reading status port of USB devices.
156  * Use kernel malloc/free macros from pcpsdrvr.h.
157  * Modified _pcps_sem..() to take PCPS_DDEV argument.
158  * Revision 1.20 2007/05/21 15:00:00Z martin
159  * Unified naming convention for symbols related to ref_offs.
160  * Revision 1.19 2007/03/30 13:31:42 martin
161  * Changes due to renamed library symbol.
162  * Revision 1.18 2007/03/02 10:31:21Z martin
163  * Use generic port I/O macros.
164  * Preliminary support for *BSD.
165  * Preliminary _cmd_from_ioctl().
166  * Revision 1.17 2006/03/10 10:35:43 martin
167  * Added support for programmable pulse outputs.
168  * Revision 1.16 2005/06/02 10:16:37Z martin
169  * Implemented IOCTL_PCPS_GENERIC_.. calls.
170  * Added support for SYNTH_STATE.
171  * Moved Debug IOCTL handling here.
172  * Revision 1.15 2005/01/14 10:26:41Z martin
173  * Support IOCTLs which query device features.
174  * Revision 1.14 2004/12/09 11:03:36Z martin
175  * Support configuration of on-board frequency synthesizer.
176  * Revision 1.13 2004/11/09 12:47:19Z martin
177  * Use new macro _pcps_ddev_has_gps_data() to check whether GPS large
178  * data I/O is supported.
179  * Changes due to renamed symbols, IRIG RX/TX.
180  * Modifications were required in order to be able to configure IRIG
181  * settings of cards which provide both IRIG input and output.
182  * GPS169PCI cards with IRIG output and early firmware versions
183  * used the same codes to configure the IRIG output as the TCR
184  * cards use to configure the IRIG input. Those codes are now
185  * exclusively used to configure the IRIG input. A workaround
186  * has been included for those GPS169PCI cards, because otherwise
187  * the IRIG configuration would not work properly after a driver
188  * update, without also doing a firmware update.
189  * Show debug msg if GPS169PCI workaround for IRIG cfg in effect.
190  * Use more specific data types than generic types.
191  * Modified contents of debug messages.
192  * Added (uchar FAR *) cast.
193  * Revision 1.12 2004/06/07 09:20:52 martin
194  * Account for renamed symbols.
195  * Revision 1.11 2004/04/07 09:05:17 martin
196  * Support OS dependent IOCTLs used to trigger debug events.
197  * Revision 1.10 2004/03/16 16:25:42Z martin
198  * Support new macro _pcps_has_irig().
199  * Revision 1.9 2004/01/08 10:57:23Z martin
200  * Support codes to read ASIC version, and read times
201  * with associated cycle counter values.
202  * Support higher baud rates for TCR510PCI and PCI510.
203  * Support PCPS_HR_TIME for TCR510PCI.
204  * Revision 1.8 2003/09/17 12:49:57Z martin
205  * Use PCPS_GIVE_TIME_NOCLEAR in API mbg_get_time().
206  * Revision 1.7 2003/09/09 13:33:55Z martin
207  * Support IOCTL_GET_PCPS_TIME_SEC_CHANGE.
208  * Revision 1.6 2003/06/19 09:18:02Z martin
209  * Supports new APIs IOCTL_PCPS_GET_UCAP_ENTRIES
210  * and IOCTL_PCPS_GET_UCAP_EVENT.
211  * Changes due to renamed symbols.
212  * Preliminary _pout_size for Linux.
213  * Revision 1.5 2003/04/15 08:50:38Z martin
214  * Support ALL_STR_TYPE_INFO, ALL_PORT_INFO for Win32.
215  * Revision 1.4 2003/04/09 16:51:29Z martin
216  * Use new common IOCTL codes from mbgioctl.h.
217  * Support almost all IOCTL codes.
218  * Support for Win32.
219  * Revision 1.3 2001/11/30 09:52:47Z martin
220  * Added support for event_time which, however, requires
221  * a custom GPS firmware.
222  * Revision 1.2 2001/09/14 12:01:17 martin
223  * Decode PCPS_IOCTL_SET_GPS_CMD.
224  * Added some comments.
225  * Revision 1.1 2001/04/09 07:47:01 MARTIN
226  *
227  **************************************************************************/
228 
229 #ifndef _MACIOCTL_H
230 #define _MACIOCTL_H
231 
232 #include <mbgioctl.h>
233 #include <cfg_hlp.h>
234 #include <pcpsdrvr.h>
235 #include <pci_asic.h>
236 #include <mbgddmsg.h>
237 
238 
239 // OS dependent primitives
240 #if defined( MBG_TGT_LINUX )
241 
242  // This is helpful for debugging, for example in a mixed
243  // 32/64 bit environment where we pass 32 bit user space pointers
244  // down to a 64 bit kernel.
245  #if DEBUG_IOCTL
246  #define _debug_iob_ptr( _p, _sz, _info ) \
247  _mbg_kdd_msg_4( MBG_LOG_INFO, "%s: 0x%llx --> %p (%lu)", \
248  _info, ( (unsigned long long) (_p) ), \
249  (void *) (_p), (ulong) (_sz) )
250  #else
251  #define _debug_iob_ptr( _p, _sz, _info ) _nop_macro_fnc()
252  #endif
253 
254 
255  #define _iob_to_pout( _piob, _pout, _size ) \
256  do \
257  { \
258  _debug_iob_ptr( _pout, _size, "outp" ); \
259  \
260  if ( copy_to_user( (void *) (uintptr_t) _pout, _piob, _size ) ) \
261  rc = MBG_ERR_COPY_TO_USER; \
262  } while ( 0 )
263 
264 
265  #define _iob_from_pin( _piob, _pin, _size ) \
266  do \
267  { \
268  _debug_iob_ptr( _pin, _size, "inp" ); \
269  \
270  if ( copy_from_user( _piob, (void *) (uintptr_t) _pin, _size ) ) \
271  rc = MBG_ERR_COPY_FROM_USER; \
272  } while ( 0 )
273 
274 
275  #define _io_wait_pcps_sec_change( _pddev, _cmd, _type, _pout ) \
276  goto err_unsupp_ioctl // not supported under Linux
277 
278 
279  // FIXME TODO Eventually this doesn't work with PCPS_BUS_PCI_MBGPEX,
280  // and it won't work with USB devices.
281  // Actually we don't use this anyway.
282  #define _io_get_mapped_mem_address( _pddev, _pout ) \
283  do \
284  { \
285  p_tmp->mapped_mem.pfn_offset = ( pddev->rsrc_info.mem[0].start_raw & ~PAGE_MASK ) + sizeof( PCI_ASIC ); \
286  p_tmp->mapped_mem.len = pddev->rsrc_info.mem[0].len - sizeof( PCI_ASIC ); \
287  _iob_to_pout_var( p_tmp->mapped_mem, _pout ); \
288  } while ( 0 )
289 
290 
291  #define _io_unmap_mapped_mem_address( _pddev, _pin ) \
292  _nop_macro_fnc()
293 
294 #elif defined( MBG_TGT_BSD )
295 
296  #include <sys/malloc.h>
297 
298  #define _iob_to_pout( _piob, _pout, _size ) \
299  memcpy( _pout, _piob, _size )
300 
301  #define _iob_from_pin( _piob, _pin, _size ) \
302  memcpy( _piob, _pin, _size )
303 
304  #define _frc_iob_to_pout( _piob, _pout, _size ) \
305  copyout( _piob, _pout, _size )
306 
307  #define _frc_iob_from_pin( _piob, _pin, _size ) \
308  copyin( _pin, _piob, _size )
309 
310  #define _io_wait_pcps_sec_change( _pddev, _cmd, _type, _pout ) \
311  goto err_unsupp_ioctl // not supported under *BSD
312 
313  #define _io_get_mapped_mem_address( _pddev, _pout ) \
314  goto err_unsupp_ioctl // not supported under *BSD
315 
316  #define _io_unmap_mapped_mem_address( _pddev, _pin ) \
317  goto err_unsupp_ioctl // not supported under *BSD
318 
319 #elif defined( MBG_TGT_WIN32 )
320 
321  // RtlCopyMemory() doesn't provide a return code.
322 
323  #define _iob_to_pout( _piob, _pout, _size ) \
324  do \
325  { \
326  RtlCopyMemory( _pout, _piob, _size ); \
327  *ret_size = _size; \
328  \
329  } while ( 0 )
330 
331  #define _iob_from_pin( _piob, _pin, _size ) \
332  RtlCopyMemory( _piob, _pin, _size )
333 
334  // The following macros are defined in the OS dependent code:
335  //
336  // _io_wait_pcps_sec_change()
337  // _io_get_mapped_mem_address()
338  // _io_unmap_mapped_mem_address()
339  // _io_set_interrupt()
340  //
341 
342 #endif
343 
344 
345 
346 #if !defined( _frc_iob_to_pout )
347  #define _frc_iob_to_pout _iob_to_pout
348 #endif
349 
350 #if !defined( _frc_iob_from_pin )
351  #define _frc_iob_from_pin _iob_from_pin
352 #endif
353 
354 
355 #define _iob_to_pout_var( _iob, _pout ) \
356  _iob_to_pout( &(_iob), _pout, sizeof( _iob ) )
357 
358 #define _iob_from_pin_var( _iob, _pin ) \
359  _iob_from_pin( &(_iob), _pin, sizeof( _iob ) )
360 
361 
362 
363 // For some cards it may be unsafe to access the card while
364 // interrups are enabled for the card since IRQs may during
365 // access may mess up the interface. The macro below checks
366 // whether this is the case.
367 #define _pcps_access_is_unsafe( _pddev ) \
368  ( ( (_pddev)->irq_stat_info & PCPS_IRQ_STATE_DANGER ) == PCPS_IRQ_STATE_DANGER )
369 
370 
371 
372 // Check whether a card can be accessed safely and set a flag
373 // preventing the card from being accessed from IRQ handler.
374 #if defined( MBG_TGT_WIN32 )
375 
376  // Under Windows we need to save a pointer to the current
377  // IRP by default.
378  #define _pcps_sem_inc_safe( _pddev ) \
379  do \
380  { \
381  if ( _pcps_access_is_unsafe( _pddev ) ) \
382  goto err_busy_irq_unsafe; \
383  \
384  _pcps_sem_inc( _pddev ); \
385  (_pddev)->p_irp = p_irp; \
386  \
387  } while ( 0 )
388 
389  // If a function which is exported by our kernel driver
390  // is called from a different kernel driver then there is
391  // no IRP, so we provide a different, Windows-only macro
392  // which is used by those export functions and sets the
393  // IRP pointer of the device structure to NULL.
394  #define _pcps_sem_inc_safe_no_irp( _pddev ) \
395  do \
396  { \
397  if ( _pcps_access_is_unsafe( _pddev ) ) \
398  goto err_busy_irq_unsafe; \
399  \
400  _pcps_sem_inc( _pddev ); \
401  (_pddev)->p_irp = NULL; \
402  \
403  } while ( 0 )
404 
405 #else
406 
407  // Other OSs don't use an IRP, so no IRP pointer
408  // needs to be set up.
409  #define _pcps_sem_inc_safe( _pddev ) \
410  do \
411  { \
412  if ( _pcps_access_is_unsafe( _pddev ) ) \
413  goto err_busy_irq_unsafe; \
414  \
415  _pcps_sem_inc( _pddev ); \
416  \
417  } while ( 0 )
418 
419 #endif
420 
421 
422 
444 #define _io_chk_cond( _cond ) \
445 do \
446 { \
447  if ( !(_cond) ) \
448  goto err_not_supp_by_dev; \
449  \
450 } while ( 0 )
451 
452 
453 
459 #define _io_read_var( _pddev, _cmd, _fld, _pout ) \
460 do \
461 { \
462  _pcps_sem_inc_safe( _pddev ); \
463  \
464  rc = _pcps_read_var( _pddev, _cmd, p_dev_iob->_fld ); \
465  \
466  if ( mbg_rc_is_success( rc ) ) \
467  _iob_to_pout_var( p_dev_iob->_fld, _pout ); \
468  \
469  _pcps_sem_dec( _pddev ); \
470  \
471  if ( mbg_rc_is_error( rc ) ) \
472  goto err_dev_access; \
473  \
474 } while ( 0 )
475 
476 
477 
483 #define _io_write_var( _pddev, _cmd, _fld, _pin ) \
484 do \
485 { \
486  _pcps_sem_inc_safe( _pddev ); \
487  _iob_from_pin_var( p_dev_iob->_fld, _pin ); \
488  rc = _pcps_write_var( _pddev, _cmd, p_dev_iob->_fld ); \
489  _pcps_sem_dec( _pddev ); \
490  \
491  if ( mbg_rc_is_error( rc ) ) \
492  goto err_dev_access; \
493  \
494 } while ( 0 )
495 
496 
497 
505 #define _io_write_cmd( _pddev, _cmd ) \
506 do \
507 { \
508  _pcps_sem_inc_safe( _pddev ); \
509  rc = _pcps_write_byte( _pddev, _cmd ); \
510  _pcps_sem_dec( _pddev ); \
511  \
512  if ( mbg_rc_is_error( rc ) ) \
513  goto err_dev_access; \
514  \
515 } while ( 0 )
516 
517 
518 
526 #define _io_read_gps( _pddev, _cmd, _fld, _pout, _size ) \
527 do \
528 { \
529  _io_chk_cond( _pcps_ddev_has_gps_data( _pddev ) ); \
530  \
531  _pcps_sem_inc_safe( _pddev ); \
532  \
533  rc = pcps_read_gps( _pddev, _cmd, (uchar FAR *) &p_dev_iob->_fld, _size ); \
534  \
535  if ( mbg_rc_is_success( rc ) ) \
536  _iob_to_pout( &p_dev_iob->_fld, _pout, _size ); \
537  \
538  _pcps_sem_dec( _pddev ); \
539  \
540  if ( mbg_rc_is_error( rc ) ) \
541  goto err_dev_access; \
542  \
543 } while ( 0 )
544 
545 
546 
554 #define _io_read_gps_var( _pddev, _cmd, _fld, _pout ) \
555 do \
556 { \
557  _io_chk_cond( _pcps_ddev_has_gps_data( _pddev ) ); \
558  \
559  _pcps_sem_inc_safe( _pddev ); \
560  \
561  rc = _pcps_read_gps_var( _pddev, _cmd, p_dev_iob->_fld ); \
562  \
563  if ( mbg_rc_is_success( rc ) ) \
564  _iob_to_pout_var( p_dev_iob->_fld, _pout ); \
565  \
566  _pcps_sem_dec( _pddev ); \
567  \
568  if ( mbg_rc_is_error( rc ) ) \
569  goto err_dev_access; \
570  \
571 } while ( 0 )
572 
573 
574 
582 #define _io_write_gps_var( _pddev, _cmd, _fld, _pin ) \
583 do \
584 { \
585  _io_chk_cond( _pcps_ddev_has_gps_data( _pddev ) ); \
586  \
587  _pcps_sem_inc_safe( _pddev ); \
588  _iob_from_pin_var( p_dev_iob->_fld, _pin ); \
589  rc = _pcps_write_gps_var( _pddev, _cmd, p_dev_iob->_fld ); \
590  _pcps_sem_dec( _pddev ); \
591  \
592  if ( mbg_rc_is_error( rc ) ) \
593  goto err_dev_access; \
594  \
595 } while ( 0 )
596 
597 
612 #define _io_read_var_chk( _pddev, _cmd, _fld, _pout, _cond ) \
613 do \
614 { \
615  _io_chk_cond( _cond ); \
616  _io_read_var( _pddev, _cmd, _fld, _pout ); \
617  \
618 } while ( 0 )
619 
620 
621 #define _io_write_var_chk( _pddev, _cmd, _fld, _pin, _cond ) \
622 do \
623 { \
624  _io_chk_cond( _cond ); \
625  _io_write_var( _pddev, _cmd, _fld, _pin ); \
626  \
627 } while ( 0 )
628 
629 
630 #define _io_write_cmd_chk( _pddev, _cmd, _cond ) \
631 do \
632 { \
633  _io_chk_cond( _cond ); \
634  _io_write_cmd( _pddev, _cmd ); \
635  \
636 } while ( 0 )
637 
638 
639 #define _io_read_gps_chk( _pddev, _cmd, _fld, _pout, _size, _cond ) \
640 do \
641 { \
642  _io_chk_cond( _cond ); \
643  \
644  if ( (size_t) _size > sizeof( p_dev_iob->_fld ) ) \
645  goto err_inval_param; \
646  \
647  _io_read_gps( _pddev, _cmd, _fld, _pout, _size ); \
648  \
649 } while ( 0 )
650 
651 
652 #define _io_read_gps_var_chk( _pddev, _cmd, _fld, _pout, _cond ) \
653 do \
654 { \
655  _io_chk_cond( _cond ); \
656  _io_read_gps_var( _pddev, _cmd, _fld, _pout ); \
657  \
658 } while ( 0 )
659 
660 
661 #define _io_write_gps_var_chk( _pddev, _cmd, _fld, _pin, _cond ) \
662 do \
663 { \
664  _io_chk_cond( _cond ); \
665  _io_write_gps_var( _pddev, _cmd, _fld, _pin ); \
666  \
667 } while ( 0 )
668 
669 
670 #define _report_cond( _cond, _pout ) \
671 do \
672 { \
673  p_tmp->i = _cond; \
674  _iob_to_pout_var( p_tmp->i, _pout ); \
675  \
676 } while ( 0 )
677 
682 #define _mbg_dbg_set_bit( _d, _v ) \
683 do \
684 { \
685  mbg_dbg_data |= (_v); \
686  _mbg_outp8( (_d), 0, mbg_dbg_port_mapped, mbg_dbg_data ); \
687  \
688 } while ( 0 )
689 
690 
691 #define _mbg_dbg_clr_bit( _d, _v ) \
692 do \
693 { \
694  mbg_dbg_data &= ~(_v); \
695  _mbg_outp8( (_d), 0, mbg_dbg_port_mapped, mbg_dbg_data ); \
696  \
697 } while ( 0 )
698 
699 
700 #define _mbg_dbg_clr_all( _d ) \
701 do \
702 { \
703  mbg_dbg_data = 0; \
704  _mbg_outp8( (_d), 0, mbg_dbg_port_mapped, mbg_dbg_data ); \
705  \
706 } while ( 0 )
707 
708 
709 
710 #if ( 0 && defined( MBG_TGT_LINUX ) )
711  #define TEST_MM_ACCESS_TIME 1
712 #else
713  #define TEST_MM_ACCESS_TIME 0
714 #endif
715 
716 #if TEST_MM_ACCESS_TIME
717  #include <pcpsutil.h>
718 #endif
719 
720 
721 
722 #if defined( __GNUC__ )
723 // Avoid "no previous prototype" with some gcc versions.
724 static __mbg_inline
725 void swap_tstamp( PCPS_TIME_STAMP *p_ts );
726 #endif
727 
728 static __mbg_inline
730 {
731  uint32_t tmp = p_ts->sec;
732  p_ts->sec = p_ts->frac;
733  p_ts->frac = tmp;
734 
735 } // swap_tstamp
736 
737 
738 
739 #if TEST_MM_ACCESS_TIME
740 
741 #if defined( __GNUC__ )
742 // Avoid "no previous prototype" with some gcc versions.
743 static __mbg_inline
744 void test_mm_access_time( PCPS_DDEV *pddev );
745 #endif
746 
747 static __mbg_inline
748 void test_mm_access_time( PCPS_DDEV *pddev )
749 {
750  uint64_t _MBG_IOMEM *p64;
751  uint32_t _MBG_IOMEM *p32;
752  PCPS_TIME_STAMP tmp;
753  MBG_PC_CYCLES cyc_1;
754  MBG_PC_CYCLES cyc_2;
755  long delta_frac;
756  unsigned delta_ns;
757 
758  if ( pddev->mm_tstamp_addr == NULL )
759  return;
760 
761  p64 = (uint64_t _MBG_IOMEM *) pddev->mm_tstamp_addr;
762  p32 = (uint32_t _MBG_IOMEM *) pddev->mm_tstamp_addr;
763 
764  // Read current cycles twice to check how long it takes to read a cycle.
765  mbg_get_pc_cycles( &cyc_1 );
766  mbg_get_pc_cycles( &cyc_2 );
767 
768  // Read a timestamp as a single 64 bit access.
769  mbg_get_pc_cycles( &cyc_1 );
770  *( (volatile uint64_t *) &tmp ) = *p64;
771  mbg_get_pc_cycles( &cyc_2 );
772 
773  // Read a timestamp as a 2 subsequent 32 bit accesses.
774  mbg_get_pc_cycles( &cyc_1 );
775  tmp.frac = _mbg_mmrd32_to_cpu( p32 );
776  tmp.sec = _mbg_mmrd32_to_cpu( p32 + 1 );
777  mbg_get_pc_cycles( &cyc_2 );
778 
779  // Read only the 32 bit fractions part of a timestamp.
780  mbg_get_pc_cycles( &cyc_1 );
781  tmp.frac = _mbg_mmrd32_to_cpu( *p32 );
782  mbg_get_pc_cycles( &cyc_2 );
783  tmp.sec = 0;
784 
785 #if 0 // TODO
786  delta_frac = (long) ( tmp.frac - p_ts->frac );
787  delta_ns = (unsigned) bin_frac_32_to_dec_frac( delta_frac, NSEC_PER_SEC );
788 
789  _mbg_kdd_msg_3( MBG_LOG_INFO, "MM tstamp dev %04X: %li/%li cyc (%lu kHz)"
790  " %08lX.%08lX->%08lX.%08lX: %li (%u.%03u us)",
791  _pcps_ddev_dev_id( pddev ),
792  (long) ( cyc_2 - cyc_1 ),
793  (long) ( cyc_3 - cyc_2 ),
794  (ulong) cpu_khz,
795  (ulong) p_ts->sec, (ulong) p_ts->frac,
796  (ulong) tmp.sec, (ulong) tmp.frac,
797  (long) ( tmp.frac - p_ts->frac ),
798  delta_ns / 1000,
799  delta_ns % 1000
800  );
801 #endif
802 
803 } // test_mm_access_time
804 
805 #endif // TEST_MM_ACCESS_TIME
806 
807 
808 
809 #if defined( __GNUC__ )
810 // Avoid "no previous prototype" with some gcc versions.
811 static __mbg_inline
813 #endif
814 
815 static __mbg_inline
817 {
818  if ( pddev->mm_tstamp_addr )
819  {
820  #if defined( MBG_TGT_WIN32 )
821  KIRQL OldIrql;
822  #endif
823  uint32_t _MBG_IOMEM *p = (uint32_t _MBG_IOMEM *) pddev->mm_tstamp_addr;
824 
825  _mbg_spin_lock_acquire( &pddev->tstamp_lock );
826  p_ts->frac = _mbg_mmrd32_to_cpu( p );
827  p_ts->sec = _mbg_mmrd32_to_cpu( p + 1 );
828  _mbg_spin_lock_release( &pddev->tstamp_lock );
829  }
830  else
831  p_ts->sec = p_ts->frac = 0;
832 
833 } // do_get_fast_hr_timestamp_safe
834 
835 
836 
837 #if defined( __GNUC__ )
838 // Avoid "no previous prototype" with some gcc versions.
839 static __mbg_inline
841 #endif
842 
843 static __mbg_inline
845 {
846  if ( pddev->mm_tstamp_addr )
847  {
848  #if defined( MBG_TGT_WIN32 )
849  KIRQL OldIrql;
850  #endif
851 
852  uint32_t _MBG_IOMEM *p = (uint32_t _MBG_IOMEM *) pddev->mm_tstamp_addr;
853 
854  _mbg_spin_lock_acquire( &pddev->tstamp_lock );
855  mbg_get_pc_cycles( &p_ts_cyc->cycles );
856  p_ts_cyc->tstamp.frac = _mbg_mmrd32_to_cpu( p );
857  p_ts_cyc->tstamp.sec = _mbg_mmrd32_to_cpu( p + 1 );
858  _mbg_spin_lock_release( &pddev->tstamp_lock );
859  }
860  else
861  {
862  mbg_get_pc_cycles( &p_ts_cyc->cycles );
863  p_ts_cyc->tstamp.sec = p_ts_cyc->tstamp.frac = 0;
864  }
865 
866 } // do_get_fast_hr_timestamp_cycles_safe
867 
868 
869 
870 #if defined( __GNUC__ )
871 // Avoid "no previous prototype" with some gcc versions.
872 static __mbg_inline
873 int ioctl_switch( PCPS_DDEV *pddev, unsigned int ioctl_code,
874  #if defined( MBG_TGT_WIN32 )
875  IRP *p_irp, int *ret_size, uint16_t pout_size,
876  #endif
877  void *pin, void *pout );
878 #endif
879 
890 #if defined( MBG_TGT_WIN32 )
891 
896 #endif
897 
903 static __mbg_inline
904 int ioctl_switch( PCPS_DDEV *pddev, unsigned int ioctl_code,
905  #if defined( MBG_TGT_WIN32 )
906  IRP *p_irp, int *ret_size, uint16_t pout_size,
907  #endif
908  void *pin, void *pout )
909 {
910  #if USE_DEBUG_PORT
911  MBG_PC_CYCLES cyc;
912  #endif
913 
914  // A buffer used for normal I/O operations that require interaction
915  // with the device's microcontroller. Linux kernel 4.9 and newer
916  // require that I/O buffers used with USB devices are DMA capable.
917  #if USE_LOCAL_IO_BUFFER
918  // This type of buffer is located on the stack, so this is not
919  // shared between different processes, and actually only the
920  // real device access had to be protected by the device mutex.
921  // However, this type of buffer is *not* DMA capable, and thus
922  // we don't use this approach by default.
923  PCPS_IO_BUFFER io_buffer;
924  PCPS_IO_BUFFER *p_dev_iob = &io_buffer;
925  #else
926  // This type of buffer is part of the device specific data, which
927  // is in fact DMA-capable, and thus we use this approach by default.
928  // The disadvantage is that this buffer is shared between all processes
929  // that access the same device, so not only the real device access
930  // itself needs to be protected by the device semaphore, but copying
931  // data in from and out to user space, too.
932  PCPS_IO_BUFFER *p_dev_iob = &pddev->io_buffer;
933  #endif
934 
935  // A buffer used for generic IOCTL operations that may use
936  // one of the buffers above in addition. We also declare a pointer
937  // to the buffer so we can use the same macro style as for the
938  // I/O buffers above.
939  IOCTL_BUFFER ioctl_buffer;
940  IOCTL_BUFFER *p_tmp = &ioctl_buffer;
941 
942  #if USE_IOCTL_GENERIC_REQ
943  void *p_buff_in;
944  void *p_buff_out;
945  #else
946  IOCTL_GENERIC_BUFFER *p_buff;
947  int buffer_size;
948  #endif
949 
950  uint8_t pcps_cmd;
951  int rc = MBG_SUCCESS;
952  int sys_rc = 0;
953 
954  #if defined( DEBUG )
955  long cmd = ioctl_code;
956  const char *ioctl_name = mbgioctl_get_name( cmd );
957  const char *err_info = NULL;
958  #endif
959 
960  // To provide best maintainability the sequence of cases here should match
961  // the sequence in ioctl_get_required_privilege(), which also makes sure
962  // commands requiring lowest latency are handled first.
963 
964  switch ( ioctl_code )
965  {
966  // Commands requiring lowest latency
967 
969  {
970  // This API call is *NOT* supported for USB devices, so the buffer doesn't
971  // have to be DMA-capable. Thus we can use a local variable as buffer, and
972  // we don't need to protect copying to user space.
973  PCPS_TIME_STAMP pcps_time_stamp;
974 
976  do_get_fast_hr_timestamp_safe( pddev, &pcps_time_stamp );
977  _iob_to_pout_var( pcps_time_stamp, pout );
978 
979  rc = MBG_SUCCESS;
980  break;
981  }
982 
983 
985  _io_read_var_chk( pddev, PCPS_GIVE_HR_TIME, pcps_hr_time, pout,
986  _pcps_ddev_has_hr_time( pddev ) );
987  break;
988 
989 
991  {
992  // This API call is *NOT* supported for USB devices, so the buffer doesn't
993  // have to be DMA-capable. Thus we can use a local variable as buffer, and
994  // we don't need to protect copying to user space.
995  PCPS_TIME_STAMP_CYCLES pcps_time_stamp_cycles;
996 
998  do_get_fast_hr_timestamp_cycles_safe( pddev, &pcps_time_stamp_cycles );
999  _iob_to_pout_var( pcps_time_stamp_cycles, pout );
1000 
1001  rc = MBG_SUCCESS;
1002  break;
1003  }
1004 
1005 
1007  _pcps_sem_inc_safe( pddev );
1008 
1009  rc = _pcps_read_var( pddev, PCPS_GIVE_HR_TIME, p_dev_iob->pcps_hr_time_cycles.t );
1010 
1011  p_dev_iob->pcps_hr_time_cycles.cycles = pddev->acc_cycles;
1012 
1013  if ( mbg_rc_is_success( rc ) )
1014  _iob_to_pout_var( p_dev_iob->pcps_hr_time_cycles, pout );
1015 
1016  _pcps_sem_dec( pddev );
1017 
1018  if ( mbg_rc_is_error( rc ) )
1019  goto err_dev_access;
1020 
1021  break;
1022 
1023 
1025  _io_read_var_chk( pddev, PCPS_GIVE_UCAP_EVENT, pcps_hr_time,
1026  pout, _pcps_ddev_has_ucap( pddev ) );
1027  break;
1028 
1029 
1030  // Other low latency commands
1031 
1032  case IOCTL_GET_PCPS_TIME:
1033  _io_read_var( pddev, PCPS_GIVE_TIME_NOCLEAR, pcps_time, pout );
1034  break;
1035 
1036 
1038  _pcps_sem_inc_safe( pddev );
1039 
1040  rc = _pcps_read_var( pddev, PCPS_GIVE_TIME_NOCLEAR, p_dev_iob->pcps_time_cycles.t );
1041 
1042  p_dev_iob->pcps_time_cycles.cycles = pddev->acc_cycles;
1043 
1044  if ( mbg_rc_is_success( rc ) )
1045  _iob_to_pout_var( p_dev_iob->pcps_time_cycles, pout );
1046 
1047  _pcps_sem_dec( pddev );
1048 
1049  if ( mbg_rc_is_error( rc ) )
1050  goto err_dev_access;
1051 
1052  break;
1053 
1054 
1055  #if !defined( OMIT_STATUS_PORT )
1057  if ( _pcps_ddev_is_usb( pddev ) )
1058  _io_read_var( pddev, PCPS_GET_STATUS_PORT, pcps_status_port_usb, pout );
1059  else
1060  {
1061  PCPS_STATUS_PORT pcps_status_port = _pcps_ddev_read_status_port( pddev );
1062  _iob_to_pout_var( pcps_status_port, pout );
1063  }
1064  break;
1065  #endif
1066 
1067 
1070  break;
1071 
1072 
1073  case IOCTL_GET_GPS_TIME:
1074  _io_read_gps_var( pddev, PC_GPS_TIME, ttm, pout );
1075  break;
1076 
1077 
1078  case IOCTL_GET_GPS_UCAP:
1079  _io_read_gps_var( pddev, PC_GPS_UCAP, ttm, pout );
1080  break;
1081 
1082 
1085 
1086  // This API call is also supported for USB devices, so we have to
1087  // use the DMA-capable common buffer provided by the device data,
1088  // and as a consequence also the code that reads the current
1089  // system time and cycles needs to be inside the critical section
1090  // protected by the semaphore, as well as the code that copies the
1091  // structure up to user space.
1092  _pcps_sem_inc_safe( pddev );
1093 
1097 
1100 
1101  if ( mbg_rc_is_success( rc ) )
1102  _iob_to_pout_var( p_dev_iob->mbg_time_info_hrt, pout );
1103 
1104  _pcps_sem_dec( pddev );
1105 
1106  if ( mbg_rc_is_error( rc ) )
1107  goto err_dev_access;
1108 
1109  break;
1110 
1111 
1113  {
1114  // This API call is *NOT* supported for USB devices, so the buffer doesn't
1115  // have to be DMA-capable. Thus we can use a local variable as buffer for
1116  // the data to be returned, and neither the code that reads the current
1117  // system time and cycles nor copying to user space has to be inside
1118  // a critical section protected by a semaphore.
1119  MBG_TIME_INFO_TSTAMP mbg_time_info_tstamp;
1120 
1122 
1123  mbg_get_pc_cycles( &mbg_time_info_tstamp.sys_time_cycles.cyc_before );
1124  mbg_get_sys_time( &mbg_time_info_tstamp.sys_time_cycles.sys_time );
1125  mbg_get_pc_cycles( &mbg_time_info_tstamp.sys_time_cycles.cyc_after );
1126 
1127  do_get_fast_hr_timestamp_cycles_safe( pddev, &mbg_time_info_tstamp.ref_tstamp_cycles );
1128  rc = MBG_SUCCESS;
1129 
1130  _iob_to_pout_var( mbg_time_info_tstamp, pout );
1131  break;
1132  }
1133 
1134 
1135  // Commands returning public status information
1136 
1138  _iob_to_pout_var( drvr_info, pout );
1139  break;
1140 
1141 
1142  case IOCTL_GET_PCPS_DEV:
1143  _iob_to_pout_var( pddev->dev, pout );
1144  break;
1145 
1146 
1148  _io_read_var_chk( pddev, PCPS_GIVE_SYNC_TIME, pcps_time,
1149  pout, _pcps_ddev_has_sync_time( pddev ) );
1150  break;
1151 
1152 
1153  case IOCTL_GET_GPS_SW_REV:
1154  _io_read_gps_var( pddev, PC_GPS_SW_REV, sw_rev, pout );
1155  break;
1156 
1157 
1159  _io_read_gps_var( pddev, PC_GPS_BVAR_STAT, bvar_stat, pout );
1160  break;
1161 
1162 
1164  _io_read_gps_var( pddev, PC_GPS_ANT_INFO, ant_info, pout );
1165  break;
1166 
1167 
1169  _io_read_gps_var( pddev, PC_GPS_STAT_INFO, stat_info, pout );
1170  break;
1171 
1172 
1173  case IOCTL_GET_GPS_IDENT:
1174  _io_read_gps_var( pddev, PC_GPS_IDENT, ident, pout );
1175  break;
1176 
1177 
1179  // FIXME TODO Call common function used by probe routine.
1180  // Always read the receiver info directly from the device. Never
1181  // just return a previous copy which has been read earlier since
1182  // something may just have been changed by a configuration API call.
1184  receiver_info, pout,
1185  _pcps_ddev_has_receiver_info( pddev ) );
1186  break;
1187 
1188 
1191  _iob_to_pout_var( pddev->raw_asic_version, pout );
1192  rc = MBG_SUCCESS;
1193  break;
1194 
1195 
1196  case IOCTL_GET_SYNTH_STATE:
1197  _io_read_var_chk( pddev, PCPS_GET_SYNTH_STATE, synth_state,
1198  pout, _pcps_ddev_has_synth( pddev ) );
1199  break;
1200 
1201 
1203  _io_read_var_chk( pddev, PCPS_GIVE_UCAP_ENTRIES, pcps_ucap_entries,
1204  pout, _pcps_ddev_has_ucap( pddev ) );
1205  break;
1206 
1207 
1210  _iob_to_pout_var( pddev->asic_features, pout );
1211  rc = MBG_SUCCESS;
1212  break;
1213 
1214 
1216  _iob_to_pout_var( pddev->irq_stat_info, pout );
1217  rc = MBG_SUCCESS;
1218  break;
1219 
1220 
1222  {
1223  MBG_PC_CYCLES_FREQUENCY mbg_pc_cycles_frequency;
1224 
1225  mbg_get_pc_cycles_frequency( &mbg_pc_cycles_frequency );
1226  _iob_to_pout_var( mbg_pc_cycles_frequency, pout );
1227  rc = MBG_SUCCESS;
1228  break;
1229  }
1230 
1231 
1233  _io_read_var_chk( pddev, PCPS_GET_IRIG_CTRL_BITS, mbg_irig_ctrl_bits,
1234  pout, _pcps_ddev_has_irig_ctrl_bits( pddev ) );
1235  break;
1236 
1237 
1238  case IOCTL_GET_IP4_STATE:
1239  _io_read_gps_var_chk( pddev, PC_GPS_IP4_STATE, ip4_settings,
1240  pout, _pcps_ddev_has_lan_intf( pddev ) );
1241  break;
1242 
1243 
1244  case IOCTL_GET_PTP_STATE:
1245  _io_read_gps_var_chk( pddev, PC_GPS_PTP_STATE, ptp_state,
1246  pout, _pcps_ddev_has_ptp( pddev ) );
1247  break;
1248 
1249 
1250  case IOCTL_GET_CORR_INFO:
1251  _io_read_var_chk( pddev, PCPS_GET_CORR_INFO, corr_info,
1252  pout, _pcps_ddev_has_corr_info( pddev ) );
1253  break;
1254 
1255 
1257  _io_read_var_chk( pddev, PCPS_GET_DEBUG_STATUS, debug_status,
1258  pout, _pcps_ddev_has_debug_status( pddev ) );
1259  break;
1260 
1261 
1263  _io_read_var_chk( pddev, PCPS_NUM_EVT_LOG_ENTRIES, num_evt_log_entries,
1264  pout, _pcps_ddev_has_evt_log( pddev ) );
1265  break;
1266 
1267 
1269  _io_read_var_chk( pddev, PCPS_FIRST_EVT_LOG_ENTRY, evt_log_entry,
1270  pout, _pcps_ddev_has_evt_log( pddev ) );
1271  break;
1272 
1273 
1275  _io_read_var_chk( pddev, PCPS_NEXT_EVT_LOG_ENTRY, evt_log_entry,
1276  pout, _pcps_ddev_has_evt_log( pddev ) );
1277  break;
1278 
1279 
1280  #if _MBG_SUPP_VAR_ACC_SIZE // otherwise generic IOCTL functions are used instead
1282  _io_read_gps_chk( pddev, PC_GPS_ALL_GNSS_SAT_INFO, all_gnss_sat_info_idx, pout,
1283  pout_size, _pcps_ddev_is_gnss( pddev ) );
1284  break;
1285  #endif
1286 
1287 
1288 
1289  // Commands returning device capabilities and features
1290 
1291  case IOCTL_DEV_IS_GPS:
1292  _report_cond( _pcps_ddev_is_gps( pddev ), pout );
1293  break;
1294 
1295 
1296  case IOCTL_DEV_IS_DCF:
1297  _report_cond( _pcps_ddev_is_dcf( pddev ), pout );
1298  break;
1299 
1300 
1301  case IOCTL_DEV_IS_MSF:
1302  _report_cond( _pcps_ddev_is_msf( pddev ), pout );
1303  break;
1304 
1305 
1306  case IOCTL_DEV_IS_WWVB:
1307  _report_cond( _pcps_ddev_is_wwvb( pddev ), pout );
1308  break;
1309 
1310 
1311  case IOCTL_DEV_IS_LWR:
1312  _report_cond( _pcps_ddev_is_lwr( pddev ), pout );
1313  break;
1314 
1315 
1316  case IOCTL_DEV_IS_GNSS:
1317  _report_cond( _pcps_ddev_is_gnss( pddev ), pout );
1318  break;
1319 
1320 
1321  case IOCTL_DEV_IS_IRIG_RX:
1322  _report_cond( _pcps_ddev_is_irig_rx( pddev ), pout );
1323  break;
1324 
1325 
1326  case IOCTL_DEV_HAS_HR_TIME:
1327  _report_cond( _pcps_ddev_has_hr_time( pddev ), pout );
1328  break;
1329 
1330 
1331  case IOCTL_DEV_HAS_CAB_LEN:
1332  _report_cond( _pcps_ddev_has_cab_len( pddev ), pout );
1333  break;
1334 
1335 
1336  case IOCTL_DEV_HAS_TZDL:
1337  _report_cond( _pcps_ddev_has_tzdl( pddev ), pout );
1338  break;
1339 
1340 
1342  _report_cond( _pcps_ddev_has_pcps_tzdl( pddev ), pout );
1343  break;
1344 
1345 
1346  case IOCTL_DEV_HAS_TZCODE:
1347  _report_cond( _pcps_ddev_has_tzcode( pddev ), pout );
1348  break;
1349 
1350 
1351  case IOCTL_DEV_HAS_TZ:
1352  _report_cond( _pcps_ddev_has_tz( pddev ), pout );
1353  break;
1354 
1355 
1357  _report_cond( _pcps_ddev_has_event_time( pddev ), pout );
1358  break;
1359 
1360 
1362  _report_cond( _pcps_ddev_has_receiver_info( pddev ), pout );
1363  break;
1364 
1365 
1367  _report_cond( _pcps_ddev_can_clr_ucap_buff( pddev ), pout );
1368  break;
1369 
1370 
1371  case IOCTL_DEV_HAS_UCAP:
1372  _report_cond( _pcps_ddev_has_ucap( pddev ), pout );
1373  break;
1374 
1375 
1376  case IOCTL_DEV_HAS_IRIG_TX:
1377  _report_cond( _pcps_ddev_has_irig_tx( pddev ), pout );
1378  break;
1379 
1380 
1382  _report_cond( _pcps_ddev_has_serial_hs( pddev ), pout );
1383  break;
1384 
1385 
1386  case IOCTL_DEV_HAS_SIGNAL:
1387  _report_cond( _pcps_ddev_has_signal( pddev ), pout );
1388  break;
1389 
1390 
1391  case IOCTL_DEV_HAS_MOD:
1392  _report_cond( _pcps_ddev_has_mod( pddev ), pout );
1393  break;
1394 
1395 
1396  case IOCTL_DEV_HAS_IRIG:
1397  _report_cond( _pcps_ddev_has_irig( pddev ), pout );
1398  break;
1399 
1400 
1402  _report_cond( _pcps_ddev_has_ref_offs( pddev ), pout );
1403  break;
1404 
1405 
1407  _report_cond( _pcps_ddev_has_opt_flags( pddev ), pout );
1408  break;
1409 
1410 
1412  _report_cond( _pcps_ddev_has_gps_data( pddev ), pout );
1413  break;
1414 
1415 
1416  case IOCTL_DEV_HAS_SYNTH:
1417  _report_cond( _pcps_ddev_has_synth( pddev ), pout );
1418  break;
1419 
1420 
1422  _report_cond( _pcps_ddev_has_generic_io( pddev ), pout );
1423  break;
1424 
1425 
1427  _report_cond( _pcps_ddev_has_asic_features( pddev ), pout );
1428  break;
1429 
1430 
1432  _report_cond( _pcps_ddev_has_asic_version( pddev ), pout );
1433  break;
1434 
1435 
1438  break;
1439 
1440 
1442  _report_cond( _pcps_ddev_has_time_scale( pddev ), pout );
1443  break;
1444 
1445 
1447  _report_cond( _pcps_ddev_has_utc_parm( pddev ), pout );
1448  break;
1449 
1450 
1452  _report_cond( _pcps_ddev_has_irig_ctrl_bits( pddev ), pout );
1453  break;
1454 
1455 
1457  _report_cond( _pcps_ddev_has_lan_intf( pddev ), pout );
1458  break;
1459 
1460 
1461  case IOCTL_DEV_IS_PTP:
1462  _report_cond( _pcps_ddev_is_ptp( pddev ), pout );
1463  break;
1464 
1465 
1466  case IOCTL_DEV_HAS_PTP:
1467  _report_cond( _pcps_ddev_has_ptp( pddev ), pout );
1468  break;
1469 
1470 
1472  _report_cond( _pcps_ddev_has_irig_time( pddev ), pout );
1473  break;
1474 
1475 
1477  _report_cond( _pcps_ddev_has_raw_irig_data( pddev ), pout );
1478  break;
1479 
1480 
1482  _report_cond( _pcps_ddev_has_ptp_unicast( pddev ), pout );
1483  break;
1484 
1485 
1486  case IOCTL_DEV_HAS_PZF:
1487  _report_cond( _pcps_ddev_has_pzf( pddev ), pout );
1488  break;
1489 
1490 
1492  _report_cond( _pcps_ddev_has_corr_info( pddev ), pout );
1493  break;
1494 
1495 
1497  _report_cond( _pcps_ddev_has_tr_distance( pddev ), pout );
1498  break;
1499 
1500 
1502  _report_cond( _pcps_ddev_has_debug_status( pddev ), pout );
1503  break;
1504 
1505 
1506  case IOCTL_DEV_HAS_EVT_LOG:
1507  _report_cond( _pcps_ddev_has_evt_log( pddev ), pout );
1508  break;
1509 
1510 
1511  case IOCTL_DEV_HAS_GPIO:
1512  _report_cond( _pcps_ddev_has_gpio( pddev ), pout );
1513  break;
1514 
1515 
1516  case IOCTL_DEV_HAS_XMR:
1517  _report_cond( _pcps_ddev_has_xmr( pddev ), pout );
1518  break;
1519 
1520 
1521  case IOCTL_CHK_DEV_FEAT:
1522  _iob_from_pin_var( p_tmp->dev_feat_req, pin );
1523  rc = pcps_chk_dev_feat( pddev, p_tmp->dev_feat_req.feat_type, p_tmp->dev_feat_req.feat_num );
1524  #if DEBUG_IOCTL
1525  _mbgddmsg_3( DEBUG_IOCTL, MBG_LOG_INFO, "chk_dev_feat %lu:%lu returned %i",
1526  (ulong) p_tmp->dev_feat_req.feat_type, (ulong) p_tmp->dev_feat_req.feat_num, rc );
1527  #endif
1528  if ( mbg_rc_is_error( rc ) )
1529  {
1530  if ( rc == MBG_ERR_NOT_SUPP_BY_DEV )
1531  goto err_not_supp_by_dev;
1532 
1533  goto err_inval_param;
1534  }
1535  break;
1536 
1537 
1538  // The next codes are somewhat special since they change something
1539  // on the board but do not affect basic operation
1540 
1543  _pcps_ddev_can_clr_ucap_buff( pddev ) );
1544  break;
1545 
1546 
1549  pcps_time_stamp, pin,
1550  _pcps_ddev_has_event_time( pddev ) );
1551  break;
1552 
1553 
1554  case IOCTL_CLR_EVT_LOG:
1556  break;
1557 
1558 
1559 
1560  // Status information which may not be available for everybody
1561 
1562  case IOCTL_GET_GPS_POS:
1563  _io_read_gps_var( pddev, PC_GPS_POS, pos, pout );
1564  break;
1565 
1566 
1567 
1568  // Codes reading device configuration
1569 
1570  case IOCTL_GET_PCPS_SERIAL:
1571  _io_read_var( pddev, PCPS_GET_SERIAL, pcps_serial, pout );
1572  break;
1573 
1574 
1575  case IOCTL_GET_PCPS_TZCODE:
1576  _io_read_var_chk( pddev, PCPS_GET_TZCODE, pcps_tzcode, pout,
1577  _pcps_ddev_has_tzcode( pddev ) );
1578  break;
1579 
1580 
1581  case IOCTL_GET_PCPS_TZDL:
1582  _io_read_var_chk( pddev, PCPS_GET_PCPS_TZDL, pcps_tzdl, pout,
1583  _pcps_ddev_has_pcps_tzdl( pddev ) );
1584  break;
1585 
1586 
1587  case IOCTL_GET_REF_OFFS:
1588  _io_read_var_chk( pddev, PCPS_GET_REF_OFFS, mbg_ref_offs, pout,
1589  _pcps_ddev_has_ref_offs( pddev ) );
1590  break;
1591 
1592 
1594  _io_read_var_chk( pddev, PCPS_GET_OPT_INFO, mbg_opt_info, pout,
1595  _pcps_ddev_has_opt_flags( pddev ) );
1596  break;
1597 
1598 
1600  _io_read_var_chk( pddev, PCPS_GET_IRIG_RX_INFO, irig_info, pout,
1601  _pcps_ddev_is_irig_rx( pddev ) );
1602  break;
1603 
1604 
1605  case IOCTL_GET_GPS_TZDL:
1606  _io_read_gps_var( pddev, PC_GPS_TZDL, tzdl, pout );
1607  break;
1608 
1609 
1611  _io_read_gps_var( pddev, PC_GPS_PORT_PARM, port_parm, pout );
1612  break;
1613 
1614 
1616  _io_read_gps_var( pddev, PC_GPS_ENABLE_FLAGS, enable_flags, pout );
1617  break;
1618 
1619 
1621  _io_read_gps_var_chk( pddev, PC_GPS_ANT_CABLE_LEN, ant_cable_len, pout,
1622  _pcps_ddev_has_cab_len( pddev ) );
1623  break;
1624 
1625 
1627  /* This is a workaround for GPS169PCIs with early */
1628  /* firmware versions. See RCS log for details. */
1629  pcps_cmd = PCPS_GET_IRIG_TX_INFO;
1630 
1631  if ( _pcps_ddev_requires_irig_workaround( pddev ) )
1632  {
1633  pcps_cmd = PCPS_GET_IRIG_RX_INFO;
1634  _mbgddmsg_0( DEBUG, MBG_LOG_WARN, "Workaround for GPS169PCI \"get IRIG TX cfg\"" );
1635  }
1636 
1637  _io_read_var_chk( pddev, pcps_cmd, irig_info, pout,
1638  _pcps_ddev_has_irig_tx( pddev ) );
1639  break;
1640 
1641 
1642  case IOCTL_GET_SYNTH:
1643  _io_read_var_chk( pddev, PCPS_GET_SYNTH, synth, pout,
1644  _pcps_ddev_has_synth( pddev ) );
1645  break;
1646 
1647 
1649  _io_read_gps_var_chk( pddev, PC_GPS_TIME_SCALE, mbg_time_scale_info,
1650  pout, _pcps_ddev_has_time_scale( pddev ) );
1651  break;
1652 
1653 
1655  _io_read_gps_var_chk( pddev, PC_GPS_UTC, utc, pout,
1656  _pcps_ddev_has_utc_parm( pddev ) );
1657  break;
1658 
1659 
1660  case IOCTL_GET_LAN_IF_INFO:
1661  _io_read_gps_var_chk( pddev, PC_GPS_LAN_IF_INFO, lan_if_info,
1662  pout, _pcps_ddev_has_lan_intf( pddev ) );
1663  break;
1664 
1665 
1667  _io_read_gps_var_chk( pddev, PC_GPS_IP4_SETTINGS, ip4_settings,
1668  pout, _pcps_ddev_has_lan_intf( pddev ) );
1669  break;
1670 
1671 
1673  _io_read_gps_var_chk( pddev, PC_GPS_PTP_CFG, ptp_cfg_info,
1674  pout, _pcps_ddev_has_ptp( pddev ) );
1675  break;
1676 
1677 
1678  case IOCTL_GET_IRIG_TIME:
1679  _io_read_var_chk( pddev, PCPS_GIVE_IRIG_TIME, pcps_irig_time,
1680  pout, _pcps_ddev_has_irig_time( pddev ) );
1681  break;
1682 
1683 
1685  _io_read_var_chk( pddev, PCPS_GET_RAW_IRIG_DATA, mbg_raw_irig_data,
1686  pout, _pcps_ddev_has_raw_irig_data( pddev ) );
1687  break;
1688 
1689 
1691  _io_read_gps_var_chk( pddev, PC_GPS_PTP_UC_MASTER_CFG_LIMITS, ptp_uc_master_cfg_limits,
1692  pout, _pcps_ddev_has_ptp_unicast( pddev ) );
1693  break;
1694 
1695 
1696  case IOCTL_GET_TR_DISTANCE:
1697  _io_read_var_chk( pddev, PCPS_GET_TR_DISTANCE, tr_distance,
1698  pout, _pcps_ddev_has_tr_distance( pddev ) );
1699  break;
1700 
1701 
1703  #if USE_IOCTL_GENERIC_REQ
1704  _iob_from_pin_var( p_tmp->req, pin );
1705 
1706  p_buff_out = _pcps_kmalloc( p_tmp->req.out_sz );
1707 
1708  if ( p_buff_out == NULL )
1709  {
1710  _mbg_kdd_msg_3( MBG_LOG_WARN, "Failed to alloc %lu bytes for %s, cmd: %02lX",
1711  (ulong) p_tmp->req.out_sz, "IOCTL_PCPS_GENERIC_READ",
1712  (ulong) p_tmp->req.info );
1713  goto err_no_mem;
1714  }
1715 
1716  // We only use local buffers here, and the allocated buffer used
1717  // for device access is anyway DMA-capable, so only the direct access
1718  // to the device needs to be protected by the device semaphore.
1719  _pcps_sem_inc_safe( pddev );
1720  rc = _pcps_read( pddev, (uint8_t) p_tmp->req.info, p_buff_out,
1721  (uint8_t) p_tmp->req.out_sz );
1722  _pcps_sem_dec( pddev );
1723 
1724  if ( mbg_rc_is_success( rc ) )
1725  _frc_iob_to_pout( p_buff_out, p_tmp->req.out_p, p_tmp->req.out_sz );
1726 
1727  _pcps_kfree( p_buff_out, p_tmp->req.out_sz );
1728 
1729  if ( mbg_rc_is_error( rc ) )
1730  goto err_dev_access;
1731 
1732  #else
1733 
1734  _iob_from_pin_var( p_tmp->ctl, pin );
1735 
1736  buffer_size = sizeof( p_tmp->ctl ) + p_tmp->ctl.data_size_out;
1737 
1738  p_buff = _pcps_kmalloc( buffer_size );
1739 
1740  if ( p_buff == NULL )
1741  goto err_no_mem;
1742 
1743  // We only use local buffers here, and the allocated buffer used
1744  // for device access is anyway DMA-capable, so only the direct access
1745  // to the device needs to be protected by the device semaphore.
1746  _pcps_sem_inc_safe( pddev );
1747  rc = _pcps_read( pddev, (uint8_t) p_tmp->ctl.info, p_buff->data,
1748  (uint8_t) p_tmp->ctl.data_size_out );
1749  _pcps_sem_dec( pddev );
1750 
1751  if ( mbg_rc_is_success( rc ) )
1752  {
1753  p_buff->ctl = p_tmp->ctl;
1754  _iob_to_pout( p_buff, pout, buffer_size ); // TODO need to check if correct size is used
1755  }
1756 
1757  _pcps_kfree( p_buff, buffer_size );
1758 
1759  if ( mbg_rc_is_error( rc ) )
1760  goto err_dev_access;
1761 
1762  #endif
1763  break;
1764 
1765 
1767  #if USE_IOCTL_GENERIC_REQ
1768  _iob_from_pin_var( p_tmp->req, pin );
1769 
1770  p_buff_out = _pcps_kmalloc( p_tmp->req.out_sz );
1771 
1772  if ( p_buff_out == NULL )
1773  {
1774  _mbg_kdd_msg_3( MBG_LOG_WARN, "Failed to alloc %lu bytes for %s, GPS cmd: %02lX",
1775  (ulong) p_tmp->req.out_sz, "IOCTL_PCPS_GENERIC_READ_GPS",
1776  (ulong) p_tmp->req.info );
1777  goto err_no_mem;
1778  }
1779 
1780  // We only use local buffers here, and the allocated buffer used
1781  // for device access is anyway DMA-capable, so only the direct access
1782  // to the device needs to be protected by the device semaphore.
1783  _pcps_sem_inc_safe( pddev );
1784  rc = pcps_read_gps( pddev, (uint8_t) p_tmp->req.info, p_buff_out,
1785  (uint16_t) p_tmp->req.out_sz );
1786  _pcps_sem_dec( pddev );
1787 
1788  if ( mbg_rc_is_success( rc ) )
1789  _frc_iob_to_pout( p_buff_out, p_tmp->req.out_p, p_tmp->req.out_sz );
1790 
1791  _pcps_kfree( p_buff_out, p_tmp->req.out_sz );
1792 
1793  if ( mbg_rc_is_error( rc ) )
1794  goto err_dev_access;
1795 
1796  #else
1797 
1798  _iob_from_pin_var( p_tmp->ctl, pin );
1799 
1800  buffer_size = sizeof( p_tmp->ctl ) + p_tmp->ctl.data_size_out;
1801 
1802  p_buff = _pcps_kmalloc( buffer_size );
1803 
1804  if ( p_buff == NULL )
1805  goto err_no_mem;
1806 
1807  // We only use local buffers here, and the allocated buffer used
1808  // for device access is anyway DMA-capable, so only the direct access
1809  // to the device needs to be protected by the device semaphore.
1810  _pcps_sem_inc_safe( pddev );
1811  rc = pcps_read_gps( pddev, (uint8_t) p_tmp->ctl.info, p_buff->data,
1812  (uint16_t) p_tmp->ctl.data_size_out );
1813  _pcps_sem_dec( pddev );
1814 
1815  if ( mbg_rc_is_success( rc ) )
1816  {
1817  p_buff->ctl = p_tmp->ctl;
1818  _iob_to_pout( p_buff, pout, buffer_size ); // TODO need to check if correct size is used
1819  }
1820 
1821  _pcps_kfree( p_buff, buffer_size );
1822 
1823  if ( mbg_rc_is_error( rc ) )
1824  goto err_dev_access;
1825 
1826  #endif
1827  break;
1828 
1829 
1830  #if _MBG_SUPP_VAR_ACC_SIZE
1831 
1832  // These codes are only supported on target systems where a variable size of
1833  // the IOCTL buffer can be specified in the IOCTL call. On other systems the
1834  // generic IOCTL functions are used instead.
1835 
1837  _io_read_gps_chk( pddev, PC_GPS_ALL_STR_TYPE_INFO, all_str_type_info_idx, pout,
1838  pout_size, _pcps_ddev_has_receiver_info( pddev ) );
1839  break;
1840 
1841 
1843  _io_read_gps_chk( pddev, PC_GPS_ALL_PORT_INFO, all_port_info_idx, pout,
1844  pout_size, _pcps_ddev_has_receiver_info( pddev ) );
1845  break;
1846 
1847 
1849  _io_read_gps_chk( pddev, PC_GPS_ALL_POUT_INFO, all_pout_info_idx, pout,
1850  pout_size, _pcps_ddev_has_receiver_info( pddev ) );
1851  break;
1852 
1853 
1855  _io_read_gps_chk( pddev, PC_GPS_ALL_PTP_UC_MASTER_INFO, all_ptp_uc_master_info_idx,
1856  pout, pout_size, _pcps_ddev_has_ptp_unicast( pddev ) );
1857  break;
1858 
1859 
1861  _io_read_gps_chk( pddev, PC_GPS_ALL_GPIO_INFO, all_gpio_info_idx,
1862  pout, pout_size, _pcps_ddev_has_gpio( pddev ) );
1863  break;
1864 
1865 
1867  _io_read_gps_var_chk( pddev, PC_GPS_ALL_GPIO_STATUS, all_gpio_status_idx,
1868  pout, _pcps_ddev_has_gpio( pddev ) ); //##++++++++++++++++++++++++ condition??
1869  break;
1870 
1871 
1873  _io_read_gps_chk( pddev, PC_GPS_ALL_XMR_STATUS, all_xmulti_ref_status_idx,
1874  pout, pout_size, _pcps_ddev_has_xmr( pddev ) );
1875  break;
1876 
1877 
1879  _io_read_gps_chk( pddev, PC_GPS_ALL_XMR_INFO, all_xmulti_ref_info_idx,
1880  pout, pout_size, _pcps_ddev_has_xmr( pddev ) );
1881  break;
1882 
1883  #endif // _MBG_SUPP_VAR_ACC_SIZE
1884 
1885 
1887  _io_read_gps_var_chk( pddev, PC_GPS_GNSS_MODE, gnss_mode_info,
1888  pout, _pcps_ddev_is_gnss( pddev ) );
1889  break;
1890 
1892  _io_read_gps_var_chk( pddev, PC_GPS_GPIO_CFG_LIMITS, mbg_gpio_cfg_limits,
1893  pout, _pcps_ddev_has_gpio( pddev ) );
1894  break;
1895 
1897  _io_read_gps_var_chk( pddev, PC_GPS_XMR_INSTANCES, xmulti_ref_instances,
1898  pout, _pcps_ddev_has_xmr( pddev ) );
1899  break;
1900 
1902  _io_read_gps_var_chk( pddev, PC_GPS_XMR_HOLDOVER_STATUS, xmr_holdover_status,
1903  pout, _pcps_ddev_has_xmr( pddev ) );
1904  break;
1905 
1906 
1907 
1908  // Codes writing device configuration
1909 
1910  case IOCTL_SET_PCPS_SERIAL:
1911  _io_write_var( pddev, PCPS_SET_SERIAL, pcps_serial, pin );
1912  break;
1913 
1914 
1915  case IOCTL_SET_PCPS_TZCODE:
1916  _io_write_var_chk( pddev, PCPS_SET_TZCODE, pcps_tzcode, pin,
1917  _pcps_ddev_has_tzcode( pddev ) );
1918  break;
1919 
1920 
1921  case IOCTL_SET_PCPS_TZDL:
1922  _io_write_var_chk( pddev, PCPS_SET_PCPS_TZDL, pcps_tzdl, pin,
1923  _pcps_ddev_has_pcps_tzdl( pddev ) );
1924  break;
1925 
1926 
1927  case IOCTL_SET_REF_OFFS:
1928  _io_write_var_chk( pddev, PCPS_SET_REF_OFFS, mbg_ref_offs, pin,
1929  _pcps_ddev_has_ref_offs( pddev ) );
1930  break;
1931 
1932 
1934  _io_write_var_chk( pddev, PCPS_SET_OPT_SETTINGS, mbg_opt_settings,
1935  pin, _pcps_ddev_has_opt_flags( pddev ) );
1936  break;
1937 
1938 
1941  irig_settings, pin,
1942  _pcps_ddev_is_irig_rx( pddev ) );
1943  break;
1944 
1945 
1946  case IOCTL_SET_GPS_TZDL:
1947  _io_write_gps_var( pddev, PC_GPS_TZDL, tzdl, pin );
1948  break;
1949 
1950 
1952  _io_write_gps_var( pddev, PC_GPS_PORT_PARM, port_parm, pin );
1953  break;
1954 
1955 
1957  _io_write_gps_var( pddev, PC_GPS_ENABLE_FLAGS, enable_flags, pin );
1958  break;
1959 
1960 
1962  _io_write_gps_var_chk( pddev, PC_GPS_ANT_CABLE_LEN, ant_cable_len,
1963  pin, _pcps_ddev_has_cab_len( pddev ) );
1964  break;
1965 
1966 
1968  _io_write_gps_var_chk( pddev, PC_GPS_PORT_SETTINGS_IDX, port_settings_idx,
1969  pin, _pcps_ddev_has_receiver_info( pddev ) );
1970  break;
1971 
1972 
1974  /* This is a workaround for GPS169PCIs with early */
1975  /* firmware versions. See RCS log for details. */
1976  pcps_cmd = PCPS_SET_IRIG_TX_SETTINGS;
1977 
1978  if ( _pcps_ddev_requires_irig_workaround( pddev ) )
1979  {
1980  pcps_cmd = PCPS_SET_IRIG_RX_SETTINGS;
1981  _mbgddmsg_0( DEBUG, MBG_LOG_WARN, "Workaround for GPS169PCI \"set IRIG TX cfg\"" );
1982  }
1983 
1984  _io_write_var_chk( pddev, pcps_cmd, irig_settings, pin,
1985  _pcps_ddev_has_irig_tx( pddev ) );
1986  break;
1987 
1988 
1989  case IOCTL_SET_SYNTH:
1990  _io_write_var_chk( pddev, PCPS_SET_SYNTH, synth, pin,
1991  _pcps_ddev_has_synth( pddev ) );
1992  break;
1993 
1994 
1996  _io_write_gps_var_chk( pddev, PC_GPS_POUT_SETTINGS_IDX, pout_settings_idx,
1997  pin, _pcps_ddev_has_receiver_info( pddev ) );
1998  break;
1999 
2000 
2002  _io_write_gps_var_chk( pddev, PC_GPS_IP4_SETTINGS, ip4_settings,
2003  pin, _pcps_ddev_has_lan_intf( pddev ) );
2004  break;
2005 
2006 
2008  _io_write_gps_var_chk( pddev, PC_GPS_PTP_CFG, ptp_cfg_settings,
2009  pin, _pcps_ddev_has_ptp( pddev ) );
2010  break;
2011 
2012 
2015  ptp_uc_master_settings_idx, pin,
2016  _pcps_ddev_has_ptp_unicast( pddev ) );
2017  break;
2018 
2019 
2020  case IOCTL_SET_TR_DISTANCE:
2021  _io_write_var_chk( pddev, PCPS_SET_TR_DISTANCE, tr_distance,
2022  pin, _pcps_ddev_has_tr_distance( pddev ) );
2023  break;
2024 
2025 
2027  _io_write_gps_var_chk( pddev, PC_GPS_GNSS_MODE, gnss_mode_settings, pin,
2028  _pcps_ddev_is_gnss( pddev ) );
2029  break;
2030 
2031 
2033  _io_write_var_chk( pddev, PC_GPS_GPIO_SETTINGS_IDX, mbg_gpio_settings_idx,
2034  pin, _pcps_ddev_has_gpio( pddev ) );
2035  break;
2036 
2037 
2038 
2039  // Operations which may severely affect system operation
2040 
2041  case IOCTL_SET_PCPS_TIME:
2042  _io_write_var_chk( pddev, PCPS_SET_TIME, pcps_stime, pin,
2043  _pcps_ddev_can_set_time( pddev ) );
2044  break;
2045 
2046 
2047  case IOCTL_SET_GPS_TIME:
2048  _io_write_gps_var( pddev, PC_GPS_TIME, ttm, pin );
2049  break;
2050 
2051 
2052  case IOCTL_SET_GPS_POS_XYZ:
2053  _io_write_gps_var( pddev, PC_GPS_POS_XYZ, xyzs, pin );
2054  break;
2055 
2056 
2057  case IOCTL_SET_GPS_POS_LLA:
2058  _io_write_gps_var( pddev, PC_GPS_POS_LLA, llas, pin );
2059  break;
2060 
2061 
2063  _io_write_gps_var_chk( pddev, PC_GPS_TIME_SCALE, mbg_time_scale_settings,
2064  pin, _pcps_ddev_has_time_scale( pddev ) );
2065  break;
2066 
2067 
2069  _io_write_gps_var_chk( pddev, PC_GPS_UTC, utc, pin,
2070  _pcps_ddev_has_utc_parm( pddev ) );
2071  break;
2072 
2073 
2074  case IOCTL_SET_GPS_CMD:
2075  _io_write_gps_var( pddev, PC_GPS_CMD, gps_cmd, pin );
2076  break;
2077 
2078 
2080  _io_write_gps_var( pddev, PC_GPS_XMR_SETTINGS_IDX, xmulti_ref_settings_idx, pin );
2081  break;
2082 
2083 
2084 
2085  // Generic read/write operations which can do anything
2086 
2088  #if USE_IOCTL_GENERIC_REQ
2089 
2090  _iob_from_pin_var( p_tmp->req, pin );
2091 
2092  p_buff_in = _pcps_kmalloc( p_tmp->req.in_sz );
2093 
2094  if ( p_buff_in == NULL )
2095  {
2096  _mbg_kdd_msg_3( MBG_LOG_WARN, "Failed to alloc %lu bytes for %s, cmd: %02lX",
2097  (ulong) p_tmp->req.in_sz, "IOCTL_PCPS_GENERIC_WRITE",
2098  (ulong) p_tmp->req.info );
2099  goto err_no_mem;
2100  }
2101 
2102  _frc_iob_from_pin( p_buff_in, p_tmp->req.in_p, p_tmp->req.in_sz );
2103 
2104  // We only use local buffers here, and the allocated buffer used
2105  // for device access is anyway DMA-capable, so only the direct access
2106  // to the device needs to be protected by the device semaphore.
2107  _pcps_sem_inc_safe( pddev );
2108  rc = pcps_write( pddev, (uint8_t) p_tmp->req.info, p_buff_in,
2109  (uint8_t) p_tmp->req.in_sz );
2110  _pcps_sem_dec( pddev );
2111 
2112  _pcps_kfree( p_buff_in, p_tmp->req.in_sz );
2113 
2114  if ( mbg_rc_is_error( rc ) )
2115  goto err_dev_access;
2116 
2117  #else
2118 
2119  _iob_from_pin_var( p_tmp->ctl, pin );
2120 
2121  buffer_size = sizeof( p_tmp->ctl ) + p_tmp->ctl.data_size_in;
2122 
2123  p_buff = _pcps_kmalloc( buffer_size );
2124 
2125  if ( p_buff == NULL )
2126  goto err_no_mem;
2127 
2128  _iob_from_pin( p_buff, pin, buffer_size );
2129 
2130  // We only use local buffers here, and the allocated buffer used
2131  // for device access is anyway DMA-capable, so only the direct access
2132  // to the device needs to be protected by the device semaphore.
2133  _pcps_sem_inc_safe( pddev );
2134  rc = pcps_write( pddev, (uint8_t) p_tmp->ctl.info, p_buff->data,
2135  (uint8_t) p_tmp->ctl.data_size_in );
2136  _pcps_sem_dec( pddev );
2137 
2138  _pcps_kfree( p_buff, buffer_size );
2139 
2140  if ( mbg_rc_is_error( rc ) )
2141  goto err_dev_access;
2142 
2143  #endif
2144  break;
2145 
2146 
2148  #if USE_IOCTL_GENERIC_REQ
2149 
2150  _iob_from_pin_var( p_tmp->req, pin );
2151 
2152  p_buff_in = _pcps_kmalloc( p_tmp->req.in_sz );
2153 
2154  if ( p_buff_in == NULL )
2155  {
2156  _mbg_kdd_msg_3( MBG_LOG_WARN, "Failed to alloc %lu bytes for %s, cmd: %02lX",
2157  (ulong) p_tmp->req.in_sz, "IOCTL_PCPS_GENERIC_WRITE_GPS",
2158  (ulong) p_tmp->req.info );
2159  goto err_no_mem;
2160  }
2161 
2162  _frc_iob_from_pin( p_buff_in, p_tmp->req.in_p, p_tmp->req.in_sz );
2163 
2164  // We only use local buffers here, and the allocated buffer used
2165  // for device access is anyway DMA-capable, so only the direct access
2166  // to the device needs to be protected by the device semaphore.
2167  _pcps_sem_inc_safe( pddev );
2168  rc = pcps_write_gps( pddev, (uint8_t) p_tmp->req.info, p_buff_in,
2169  (uint16_t) p_tmp->req.in_sz );
2170  _pcps_sem_dec( pddev );
2171 
2172  _pcps_kfree( p_buff_in, p_tmp->req.in_sz );
2173 
2174  if ( mbg_rc_is_error( rc ) )
2175  goto err_dev_access;
2176 
2177  #else
2178 
2179  _iob_from_pin_var( p_tmp->ctl, pin );
2180 
2181  buffer_size = sizeof( p_tmp->ctl ) + p_tmp->ctl.data_size_in;
2182 
2183  p_buff = _pcps_kmalloc( buffer_size );
2184 
2185  if ( p_buff == NULL )
2186  goto err_no_mem;
2187 
2188  _iob_from_pin( p_buff, pin, buffer_size );
2189 
2190  // We only use local buffers here, and the allocated buffer used
2191  // for device access is anyway DMA-capable, so only the direct access
2192  // to the device needs to be protected by the device semaphore.
2193  _pcps_sem_inc_safe( pddev );
2194  rc = pcps_write_gps( pddev, (uint8_t) p_tmp->ctl.info, p_buff->data,
2195  (uint8_t) p_tmp->ctl.data_size_in );
2196  _pcps_sem_dec( pddev );
2197 
2198  _pcps_kfree( p_buff, buffer_size );
2199 
2200  if ( mbg_rc_is_error( rc ) )
2201  goto err_dev_access;
2202 
2203  #endif
2204  break;
2205 
2206 
2207  case IOCTL_PCPS_GENERIC_IO:
2208  #if USE_IOCTL_GENERIC_REQ
2210 
2211  _iob_from_pin_var( p_tmp->req, pin );
2212 
2213  if ( p_tmp->req.in_p && p_tmp->req.in_sz )
2214  {
2215  p_buff_in = _pcps_kmalloc( p_tmp->req.in_sz );
2216 
2217  if ( p_buff_in == NULL )
2218  {
2219  _mbg_kdd_msg_3( MBG_LOG_WARN, "Failed to alloc %lu bytes for input in %s, cmd: %02lX",
2220  (ulong) p_tmp->req.in_sz, "IOCTL_PCPS_GENERIC_IO",
2221  (ulong) p_tmp->req.info );
2222  goto err_no_mem;
2223  }
2224 
2225  _frc_iob_from_pin( p_buff_in, p_tmp->req.in_p, p_tmp->req.in_sz );
2226  }
2227  else
2228  {
2229  p_buff_in = NULL;
2230  p_tmp->req.in_sz = 0; // just to be sure
2231  }
2232 
2233  if ( p_tmp->req.out_p && p_tmp->req.out_sz )
2234  {
2235  p_buff_out = _pcps_kmalloc( p_tmp->req.out_sz );
2236 
2237  if ( p_buff_out == NULL )
2238  {
2239  _mbg_kdd_msg_3( MBG_LOG_WARN, "Failed to alloc %lu bytes for output in %s, cmd: %02lX",
2240  (ulong) p_tmp->req.in_sz, "IOCTL_PCPS_GENERIC_IO",
2241  (ulong) p_tmp->req.info );
2242 
2243  // We can't continue this API call, but before we leave we have to free
2244  // the input buffer we already have allocated before.
2245  _pcps_kfree( p_buff_in, p_tmp->req.in_sz );
2246  goto err_no_mem;
2247  }
2248  }
2249  else
2250  {
2251  p_buff_out = NULL;
2252  p_tmp->req.out_sz = 0; // just to be sure
2253  }
2254 
2255  // We only use local buffers here, and the allocated buffer used
2256  // for device access is anyway DMA-capable, so only the direct access
2257  // to the device needs to be protected by the device semaphore.
2258  _pcps_sem_inc_safe( pddev );
2259  rc = pcps_generic_io( pddev, (uint8_t) p_tmp->req.info,
2260  p_buff_in, (uint8_t) p_tmp->req.in_sz,
2261  p_buff_out, (uint8_t) p_tmp->req.out_sz );
2262  _pcps_sem_dec( pddev );
2263 
2264  if ( mbg_rc_is_success( rc ) )
2265  _frc_iob_to_pout( p_buff_out, p_tmp->req.out_p, p_tmp->req.out_sz );
2266 
2267  if ( p_buff_in )
2268  _pcps_kfree( p_buff_in, p_tmp->req.in_sz );
2269 
2270  if ( p_buff_out )
2271  _pcps_kfree( p_buff_out, p_tmp->req.out_sz );
2272 
2273  if ( mbg_rc_is_error( rc ) )
2274  goto err_dev_access;
2275 
2276  #else
2277 
2279 
2280  _iob_from_pin_var( p_tmp->ctl, pin );
2281 
2282  buffer_size = sizeof( p_tmp->ctl ) +
2283  ( ( p_tmp->ctl.data_size_in > p_tmp->ctl.data_size_out ) ?
2284  p_tmp->ctl.data_size_in : p_tmp->ctl.data_size_out );
2285 
2286  p_buff = _pcps_kmalloc( buffer_size );
2287 
2288  if ( p_buff == NULL )
2289  goto err_no_mem;
2290 
2291  _iob_from_pin( p_buff, pin, sizeof( p_buff->ctl ) + p_tmp->ctl.data_size_in );
2292 
2293  // We only use local buffers here, and the allocated buffer used
2294  // for device access is anyway DMA-capable, so only the direct access
2295  // to the device needs to be protected by the device semaphore.
2296  _pcps_sem_inc_safe( pddev );
2297  rc = pcps_generic_io( pddev, (uint8_t) p_tmp->ctl.info,
2298  p_buff->data, (uint8_t) p_tmp->ctl.data_size_in,
2299  p_buff->data, (uint8_t) p_tmp->ctl.data_size_out );
2300  _pcps_sem_dec( pddev );
2301 
2302  if ( mbg_rc_is_success( rc ) )
2303  {
2304  p_buff->ctl = p_tmp->ctl;
2305  _iob_to_pout( p_buff, pout, sizeof( p_buff->ctl ) + p_tmp->ctl.data_size_out ); // TODO need to check if correct size is used
2306  }
2307 
2308  _pcps_kfree( p_buff, buffer_size );
2309 
2310  if ( mbg_rc_is_error( rc ) )
2311  goto err_dev_access;
2312 
2313  #endif
2314  break;
2315 
2316 
2317  // The next codes are somewhat special and normally
2318  // not used by the driver software:
2319 
2322  _io_get_mapped_mem_address( pddev, pout );
2323  break;
2324 
2325 
2328  _io_unmap_mapped_mem_address( pddev, pin );
2329  break;
2330 
2331 
2332  #if USE_DEBUG_PORT
2333  // The codes below are used for debugging only.
2334  // Unrestricted usage may cause system malfunction !!
2335 
2337  _iob_to_pout_var( mbg_dbg_port, pout );
2338  rc = MBG_SUCCESS;
2339  break;
2340 
2341 
2343  _iob_from_pin_var( mbg_dbg_port, pin );
2344  mbg_dbg_port_mapped = _mbg_ioremap( mbg_dbg_port, sizeof( mbg_dbg_port ) );
2345  rc = MBG_SUCCESS;
2346  break;
2347 
2348 
2349  case IOCTL_MBG_DBG_SET_BIT:
2350  {
2351  MBG_DBG_DATA dbg_data;
2352  _iob_from_pin_var( dbg_data, pin );
2353  _mbg_dbg_set_bit( pddev, dbg_data );
2354  mbg_get_pc_cycles( &cyc );
2355  _iob_to_pout_var( cyc, pout );
2356  break;
2357  }
2358 
2359 
2360  case IOCTL_MBG_DBG_CLR_BIT:
2361  {
2362  MBG_DBG_DATA dbg_data;
2363  _iob_from_pin_var( dbg_data, pin );
2364  _mbg_dbg_clr_bit( pddev, dbg_data );
2365  mbg_get_pc_cycles( &cyc );
2366  _iob_to_pout_var( cyc, pout );
2367  break;
2368  }
2369 
2370 
2371  case IOCTL_MBG_DBG_CLR_ALL:
2372  _mbg_dbg_clr_all( pddev );
2373  mbg_get_pc_cycles( &cyc );
2374  _iob_to_pout_var( cyc, pout );
2375  break;
2376 
2377  #endif // USE_DEBUG_PORT
2378 
2379 
2380  default: // Unsupported IOCTL code
2381  goto err_unsupp_ioctl;
2382  }
2383 
2384  // We get here in case of success.
2385  return IOCTL_RC_SUCCESS;
2386 
2387 
2388 err_unsupp_ioctl:
2389  #if defined( DEBUG )
2390  err_info = "unsupported IOCTL";
2391  #endif
2392  sys_rc = IOCTL_RC_ERR_UNSUPP_IOCTL;
2393  goto out;
2394 
2395 
2396 err_inval_param:
2397  #if defined( DEBUG )
2398  err_info = "invalid parameter";
2399  #endif
2400  sys_rc = IOCTL_RC_ERR_INVAL_PARAM;
2401  goto out;
2402 
2403 err_not_supp_by_dev:
2404  #if defined( DEBUG )
2405  err_info = "not supported by device";
2406  #endif
2407  sys_rc = IOCTL_RC_ERR_NOT_SUPP_BY_DEV;
2408  goto out;
2409 
2410 
2411 err_no_mem:
2412  #if defined( DEBUG )
2413  err_info = "failed to allocate buffer";
2414  #endif
2415  sys_rc = IOCTL_RC_ERR_NO_MEM;
2416  goto out;
2417 
2418 
2419 err_busy_irq_unsafe:
2420  #if defined( DEBUG )
2421  err_info = "busy since unsafe IRQ enabled";
2422  #endif
2423  sys_rc = IOCTL_RC_ERR_BUSY_IRQ_UNSAFE;
2424  goto out;
2425 
2426 
2427 err_dev_access:
2428  // On Linux we also get here if copying from/to user space failed,
2429  // so we check rc to distinguish the cases.
2430  switch ( rc )
2431  {
2432  #if defined( MBG_TGT_LINUX )
2433  case MBG_ERR_COPY_TO_USER:
2434  #if defined( DEBUG )
2435  err_info = "failed to copy data to user space";
2436  #endif
2437  sys_rc = IOCTL_RC_ERR_COPY_TO_USER;
2438  break;
2439 
2441  #if defined( DEBUG )
2442  err_info = "failed to copy data from user space";
2443  #endif
2444  sys_rc = IOCTL_RC_ERR_COPY_FROM_USER;
2445  break;
2446  #endif // defined( MBG_TGT_LINUX )
2447 
2448  default:
2449  #if defined( DEBUG )
2450  err_info = "device access failed";
2451  #endif
2452  sys_rc = IOCTL_RC_ERR_DEV_ACCESS;
2453 
2454  } // switch
2455 
2456  // fall through to "out:"
2457 
2458 out:
2459 #if defined( MBG_TGT_WIN32 )
2460  _mbgddmsg_4( DEBUG, MBG_LOG_INFO, "%s (0x%02lX): %s, ret: 0x%08X",
2461  ioctl_name, cmd, err_info, sys_rc );
2462 #else
2463  _mbgddmsg_6( DEBUG, MBG_LOG_INFO, "%s (0x%02lX): %s, dev " MBG_DEV_NAME_FMT ", ret: %i",
2464  ioctl_name, cmd, err_info, _pcps_ddev_type_name( pddev ),
2465  _pcps_ddev_sernum( pddev ), sys_rc );
2466 #endif
2467 
2468  return sys_rc;
2469 
2470 } // ioctl_switch
2471 
2472 #endif /* _MACIOCTL_H */
2473 
#define IOCTL_GET_PCPS_TZCODE
Definition: mbgioctl.h:537
#define IOCTL_DEV_HAS_RAW_IRIG_DATA
Definition: mbgioctl.h:688
#define IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES
Definition: mbgioctl.h:656
#define IOCTL_GET_SYNTH
Definition: mbgioctl.h:604
#define IOCTL_DEV_HAS_PCI_ASIC_VERSION
Definition: mbgioctl.h:646
#define IOCTL_DEV_CAN_CLR_UCAP_BUFF
Definition: mbgioctl.h:620
#define _pcps_ddev_sernum(_p)
Definition: pcpsdrvr.h:1186
(r/w) UTC, UTC corr. param., only if PCPS_HAS_UTC_PARM
Definition: pcpsdefs.h:1688
#define _io_read_gps_var(_pddev, _cmd, _fld, _pout)
Read a large data structure with fixed size from a device.
Definition: macioctl.h:554
#define IOCTL_GET_GPS_ALL_PORT_INFO
Definition: mbgioctl.h:592
#define IOCTL_DEV_HAS_LAN_INTF
Definition: mbgioctl.h:670
(r/-) IDENT, serial number, deprecated by PC_GPS_RECEIVER_INFO
Definition: pcpsdefs.h:1648
(-/w) POUT_SETTINGS_IDX, settings for one programmable output
Definition: pcpsdefs.h:1657
#define PCPS_GET_SERIAL
(r-) Read serial settings as PCPS_SERIAL, deprecated by PC_GPS_ALL_PORT_INFO
Definition: pcpsdefs.h:728
#define _pcps_sem_dec(_pddev)
Definition: pcpsdrvr.h:575
#define IOCTL_SET_GPS_POS_LLA
Definition: mbgioctl.h:585
uint32_t info
E.g. cmd code for the device.
Definition: mbgioctl.h:423
#define IOCTL_GET_MBG_OPT_INFO
Definition: mbgioctl.h:546
MBG_SYS_TIME_CYCLES sys_time_cycles
system time stamp plus associated cycles
Definition: pcpsdev.h:1421
(r/w) TTM, current time, deprecated by PCPS_GIVE_HR_TIME
Definition: pcpsdefs.h:1638
const char * mbgioctl_get_name(long code)
#define IOCTL_MBG_DBG_SET_BIT
Definition: mbgioctl.h:737
int pcps_generic_io(PCPS_DDEV *pddev, uint8_t type, const void FAR *in_buff, uint8_t in_cnt, void FAR *out_buff, uint8_t out_cnt)
Generic I/O function.
Definition: pcpsdrvr.c:3045
#define IOCTL_DEV_HAS_SYNTH
Definition: mbgioctl.h:630
(r/w) ENABLE_FLAGS, when to enable serial, pulses, and synth, only if GPS_MODEL_HAS_ENABLE_FLAGS ...
Definition: pcpsdefs.h:1645
#define _pcps_ddev_is_usb(_p)
Definition: pcpsdrvr.h:1154
#define _pcps_ddev_has_asic_features(_p)
Definition: pcpsdrvr.h:1290
uint32_t in_sz
Size of the input buffer.
Definition: mbgioctl.h:421
#define IOCTL_SET_GPS_POS_XYZ
Definition: mbgioctl.h:584
(r/-) PTP_UC_MASTER_CFG_LIMITS, only if PTP_CFG_MSK_SUPPORT_PTP_UNICAST
Definition: pcpsdefs.h:1665
#define IOCTL_SET_GPS_UTC_PARM
Definition: mbgioctl.h:665
PCPS_HR_TIME t
Definition: pcpsdev.h:1395
#define _io_read_var_chk(_pddev, _cmd, _fld, _pout, _cond)
Definition: macioctl.h:612
#define _mbgddmsg_3(_f, _lvl, _fmt, _p1, _p2, _p3)
Definition: mbgddmsg.h:330
#define IOCTL_GET_GPS_POS
Definition: mbgioctl.h:583
#define IOCTL_DEV_HAS_IRIG_TX
Definition: mbgioctl.h:622
#define _pcps_ddev_has_sync_time(_p)
Definition: pcpsdrvr.h:1222
#define IOCTL_DEV_HAS_OPT_FLAGS
Definition: mbgioctl.h:628
uint64_t in_p
Address of the input buffer.
Definition: mbgioctl.h:419
PCPS_IRQ_STAT_INFO irq_stat_info
Definition: pcpsdrvr.h:820
#define PCPS_CLR_UCAP_BUFF
(-w) No param., clear on-board capture FIFO, only if _pcps_has_ucap
Definition: pcpsdefs.h:768
#define IOCTL_DEV_HAS_FAST_HR_TIMESTAMP
Definition: mbgioctl.h:655
#define IOCTL_SET_PCPS_TIME
Definition: mbgioctl.h:523
#define IOCTL_GET_PCPS_UCAP_EVENT
Definition: mbgioctl.h:554
#define IOCTL_SET_GPS_ENABLE_FLAGS
Definition: mbgioctl.h:575
#define IOCTL_UNMAP_MAPPED_MEM
Definition: mbgioctl.h:641
#define _pcps_ddev_has_cab_len(_p)
Definition: pcpsdrvr.h:1227
#define IOCTL_GET_PCPS_DEV
Definition: mbgioctl.h:511
#define PCPS_GIVE_SYNC_TIME
(r-) Read last sync time as PCPS_TIME, only if _pcps_has_sync_time
Definition: pcpsdefs.h:714
(-/w) MBG_GPIO_SETTINGS_IDX, settings for a specific port, only if GPS_HAS_GPIO
Definition: pcpsdefs.h:1671
#define IOCTL_GET_IRIG_CTRL_BITS
Definition: mbgioctl.h:668
(r/-) XMR_HOLDOVER_STATUS, only if XMRIF_MSK_HOLDOVER_STATUS_SUPP
Definition: pcpsdefs.h:1678
#define IOCTL_GET_PCPS_IRIG_RX_INFO
Definition: mbgioctl.h:549
#define IOCTL_SET_GPS_CMD
Definition: mbgioctl.h:579
#define IOCTL_DEV_HAS_HR_TIME
Definition: mbgioctl.h:612
#define IOCTL_GET_FAST_HR_TIMESTAMP
Definition: mbgioctl.h:657
#define IOCTL_GET_CYCLES_FREQUENCY
Definition: mbgioctl.h:653
unsigned short uint16_t
Definition: words.h:213
static __mbg_inline void mbg_get_pc_cycles(MBG_PC_CYCLES *p)
Definition: mbgpccyc.h:178
MBG_PC_CYCLES cycles
Definition: pcpsdev.h:1394
#define _MBG_IOMEM
Definition: mbggenio.h:165
PCPS_SECONDS sec
seconds since 1970, usually UTC scale
Definition: pcpsdefs.h:974
#define MBG_DEV_NAME_FMT
A string format specifier for MBG_DEV_NAME.
Definition: pcpsdev.h:1534
MBG_CHK_SUPP_FNC _pcps_ddev_is_wwvb
Definition: mbgdevio.c:1142
#define _mbg_kdd_msg_3(_lvl, _fmt, _p1, _p2, _p3)
Definition: mbgddmsg.h:242
PCPS_WRITE_FNC pcps_write
Write data to a device.
Definition: pcpsdrvr.c:3020
#define IOCTL_GET_XMR_HOLDOVER_STATUS
Definition: mbgioctl.h:727
#define _mbgddmsg_6(_f, _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6)
Definition: mbgddmsg.h:348
#define _pcps_ddev_requires_irig_workaround(_d)
Definition: pcpsdrvr.h:1463
#define IOCTL_DEV_HAS_GPS_DATA
Definition: mbgioctl.h:629
#define _pcps_ddev_has_debug_status(_p)
Definition: pcpsdrvr.h:1317
#define _iob_to_pout_var(_iob, _pout)
Definition: macioctl.h:355
#define IOCTL_GET_GPS_TZDL
Definition: mbgioctl.h:557
uint8_t PCPS_STATUS_PORT
Type of the status register port.
Definition: pcpsdefs.h:431
#define IOCTL_SET_PCPS_IRIG_RX_SETTINGS
Definition: mbgioctl.h:550
#define IOCTL_DEV_HAS_DEBUG_STATUS
Definition: mbgioctl.h:703
static __mbg_inline void mbg_get_sys_time(MBG_SYS_TIME *p)
Definition: mbgsystm.h:171
#define DEBUG_IOCTL
Definition: pcpsdrvr.h:426
#define _mbgddmsg_0(_f, _lvl, _fmt)
Definition: mbgddmsg.h:312
#define MBG_ERR_COPY_TO_USER
Kernel driver failed to copy data from kernel to user space.
Definition: mbgerror.h:302
#define _io_get_mapped_mem_address(_pddev, _pout)
Definition: macioctl.h:282
#define mbg_rc_is_success(_rc)
Definition: mbgerror.h:618
(-/w) PORT_SETTINGS_IDX, settings for specified serial port, only if RECEIVER_INFO::n_com_ports > 0 ...
Definition: pcpsdefs.h:1655
#define IOCTL_DEV_IS_GNSS
Definition: mbgioctl.h:712
#define PCPS_GET_SYNTH_STATE
(r-) Read SYNTH_STATE, only if _pcps_has_synth
Definition: pcpsdefs.h:756
#define _mbg_dbg_clr_bit(_d, _v)
Definition: macioctl.h:691
#define IOCTL_GET_GPS_STAT_INFO
Definition: mbgioctl.h:577
#define PCPS_SET_SERIAL
(-w) Write serial settings as PCPS_SERIAL, deprecated by PC_GPS_PORT_SETTINGS_IDX, returns MBG_ERR_CFG on error
Definition: pcpsdefs.h:729
PCPS_HR_TIME_CYCLES pcps_hr_time_cycles
Definition: pcpsiobf.h:133
#define IOCTL_GET_ALL_XMR_INFO
Definition: mbgioctl.h:724
PCPS_READ_FNC pcps_read_gps
Read a large data structure from a device.
Definition: pcpsdrvr.c:3468
MBG_PC_CYCLES cyc_before
cycles count before sys time is read
Definition: pcpsdev.h:388
#define IOCTL_SET_GPS_PORT_PARM
Definition: mbgioctl.h:568
#define IOCTL_DEV_IS_GPS
Definition: mbgioctl.h:608
#define _pcps_ddev_has_gps_data(_p)
Definition: pcpsdrvr.h:1272
#define _pcps_ddev_has_generic_io(_p)
Definition: pcpsdrvr.h:1278
#define PCPS_SET_IRIG_RX_SETTINGS
(-w) Write IRIG_SETTINGS, only if _pcps_is_irig_rx, returns MBG_ERR_CFG on error
Definition: pcpsdefs.h:744
#define _pcps_ddev_has_pcps_tzdl(_p)
Definition: pcpsdrvr.h:1229
(r/-) n * MBG_GPIO_INFO_IDX, all GPIO info, only if GPS_HAS_GPIO
Definition: pcpsdefs.h:1669
#define IOCTL_GET_PCPS_STATUS_PORT
Definition: mbgioctl.h:512
#define _io_read_gps_var_chk(_pddev, _cmd, _fld, _pout, _cond)
Definition: macioctl.h:652
#define _pcps_ddev_is_irig_rx(_p)
Definition: pcpsdrvr.h:1142
#define _pcps_ddev_has_pzf(_p)
Definition: pcpsdrvr.h:1305
#define IOCTL_SET_REF_OFFS
Definition: mbgioctl.h:544
#define IOCTL_SET_IP4_SETTINGS
Definition: mbgioctl.h:674
(-/w) XYZ, current position in ECEF coordinates, only if GPS_MODEL_HAS_POS_XYZ
Definition: pcpsdefs.h:1639
#define IOCTL_GET_GPS_ANT_CABLE_LEN
Definition: mbgioctl.h:587
High resolution time stamp plus associated system cycles count.
Definition: pcpsdev.h:1369
(r/w) TZDL, time zone / daylight saving, only if GPS_MODEL_HAS_TZDL
Definition: pcpsdefs.h:1635
#define IOCTL_SET_GNSS_MODE_SETTINGS
Definition: mbgioctl.h:714
#define _frc_iob_to_pout
Definition: macioctl.h:347
(r/w) ANT_CABLE_LEN, length of antenna cable, only if GPS_MODEL_HAS_ANT_CABLE_LEN ...
Definition: pcpsdefs.h:1650
#define IOCTL_CLR_EVT_LOG
Definition: mbgioctl.h:707
PCPS_TIME_CYCLES pcps_time_cycles
Definition: pcpsiobf.h:132
(r/-) BVAR_STAT, status of buffered variables, only if GPS_MODEL_HAS_BVAR_STAT
Definition: pcpsdefs.h:1637
MBG_TIME_INFO_HRT mbg_time_info_hrt
Definition: pcpsiobf.h:137
#define IOCTL_DEV_HAS_IRIG_TIME
Definition: mbgioctl.h:682
#define IOCTL_DEV_HAS_TZ
Definition: mbgioctl.h:617
#define IOCTL_DEV_HAS_EVT_LOG
Definition: mbgioctl.h:706
static __mbg_inline void do_get_fast_hr_timestamp_safe(PCPS_DDEV *pddev, PCPS_TIME_STAMP *p_ts)
Definition: macioctl.h:816
static __mbg_inline void do_get_fast_hr_timestamp_cycles_safe(PCPS_DDEV *pddev, PCPS_TIME_STAMP_CYCLES *p_ts_cyc)
Definition: macioctl.h:844
#define PCPS_GIVE_TIME_NOCLEAR
(r-) Read current time in PCPS_TIME format, don&#39;t clear sec and min flags (deprecated) ...
Definition: pcpsdefs.h:713
MBG_SYS_TIME_CYCLES sys_time_cycles
system timestamp plus associated cycles
Definition: pcpsdev.h:1448
static __mbg_inline void swap_tstamp(PCPS_TIME_STAMP *p_ts)
Definition: macioctl.h:729
(-/w) LLA, current position in geographic coordinates, only if GPS_MODEL_HAS_POS_LLA ...
Definition: pcpsdefs.h:1640
#define IOCTL_CHK_DEV_FEAT
Definition: mbgioctl.h:730
#define _report_cond(_cond, _pout)
Definition: macioctl.h:670
PCPS_TIME_STAMP tstamp
High resolution time stamp (UTC)
Definition: pcpsdev.h:1372
#define PCPS_SET_TZCODE
(-w) Write PCPS_TZCODE, only if _pcps_has_tzcode, returns MBG_ERR_CFG on error
Definition: pcpsdefs.h:732
#define _io_write_gps_var(_pddev, _cmd, _fld, _pin)
Write a large data structure with fixed size to a device.
Definition: macioctl.h:582
#define IOCTL_GET_DEBUG_STATUS
Definition: mbgioctl.h:704
#define _pcps_ddev_has_ref_offs(_p)
Definition: pcpsdrvr.h:1263
#define PCPS_NUM_EVT_LOG_ENTRIES
(r-) Read MBG_NUM_EVT_LOG_ENTRIES, only if _pcps_has_evt_log
Definition: pcpsdefs.h:777
#define IOCTL_PCPS_GENERIC_READ
Definition: mbgioctl.h:516
#define IOCTL_GET_PTP_CFG_INFO
Definition: mbgioctl.h:679
static __mbg_inline int ioctl_switch(PCPS_DDEV *pddev, unsigned int ioctl_code, void *pin, void *pout)
Decode and handle IOCTL commands.
Definition: macioctl.h:904
(r/-) IP4_SETTINGS, LAN interface state, only if PCPS_HAS_LAN_INTF
Definition: pcpsdefs.h:1660
#define PCPS_GIVE_UCAP_ENTRIES
(r-) Read PCPS_UCAP_ENTRIES, only if _pcps_has_ucap
Definition: pcpsdefs.h:769
#define IOCTL_GET_ALL_GNSS_SAT_INFO
Definition: mbgioctl.h:715
#define IOCTL_GET_PCPS_TIME_SEC_CHANGE
Definition: mbgioctl.h:527
MBG_PC_CYCLES cycles
Definition: pcpsdev.h:1356
#define PCPS_FIRST_EVT_LOG_ENTRY
(r-) Read first (oldest) MBG_EVT_LOG_ENTRY, only if _pcps_has_evt_log
Definition: pcpsdefs.h:778
#define _pcps_sem_inc_safe(_pddev)
Definition: macioctl.h:409
#define IOCTL_GET_GPS_ENABLE_FLAGS
Definition: mbgioctl.h:574
#define _pcps_ddev_has_ptp_unicast(_p)
Definition: pcpsdrvr.h:1302
#define _io_write_var(_pddev, _cmd, _fld, _pin)
Write a standard data structure to a device.
Definition: macioctl.h:483
#define IOCTL_SET_PCPS_SERIAL
Definition: mbgioctl.h:535
#define IOCTL_GET_IRIG_TIME
Definition: mbgioctl.h:683
MBG_PC_CYCLES acc_cycles
Cycles count taken when device was accessed last time.
Definition: pcpsdrvr.h:799
#define _pcps_ddev_has_raw_irig_data(_p)
Definition: pcpsdrvr.h:1260
#define IOCTL_GET_TIME_INFO_TSTAMP
Definition: mbgioctl.h:686
(-/w) GPS_CMD, send one of the PC_GPS_COMMANDS
Definition: pcpsdefs.h:1647
#define IOCTL_PCPS_GENERIC_IO
Definition: mbgioctl.h:633
uint64_t out_p
Address of the output buffer.
Definition: mbgioctl.h:420
#define IOCTL_GET_GPS_ANT_INFO
Definition: mbgioctl.h:570
#define IOCTL_SET_PTP_CFG_SETTINGS
Definition: mbgioctl.h:680
#define IOCTL_DEV_HAS_UCAP
Definition: mbgioctl.h:621
#define _mbg_dbg_set_bit(_d, _v)
Definition: macioctl.h:682
#define _pcps_ddev_has_corr_info(_p)
Definition: pcpsdrvr.h:1308
#define IOCTL_GET_REF_OFFS
Definition: mbgioctl.h:543
#define _pcps_read_var(_pddev, _cmd, _s)
Definition: pcpsdrvr.h:1391
#define IOCTL_PCPS_CLR_UCAP_BUFF
Definition: mbgioctl.h:552
#define IOCTL_GET_CORR_INFO
Definition: mbgioctl.h:699
#define IOCTL_GET_PCPS_UCAP_ENTRIES
Definition: mbgioctl.h:553
#define IOCTL_DEV_IS_WWVB
Definition: mbgioctl.h:650
(r/w) MBG_GNSS_MODE_INFO / MBG_GNSS_MODE_SETTINGS, only if PCPS_IS_GNSS
Definition: pcpsdefs.h:1672
High resolution device time stamp, system time, and associated cycles counts.
Definition: pcpsdev.h:1445
#define IOCTL_GET_PCI_ASIC_VERSION
Definition: mbgioctl.h:596
#define IOCTL_DEV_IS_PTP
Definition: mbgioctl.h:676
#define PCPS_GET_STATUS_PORT
(r-) Read PCPS_STATUS_PORT
Definition: pcpsdefs.h:760
(-/w) XMULTI_REF_SETTINGS_IDX, idx 0..XMULTI_REF_INSTANCES::n_xmr_settings-1, only if GPS_HAS_XMULTI_...
Definition: pcpsdefs.h:1675
#define IOCTL_DEV_HAS_GPS_UTC_PARM
Definition: mbgioctl.h:663
#define IOCTL_SET_GPS_TZDL
Definition: mbgioctl.h:558
#define PCPS_SET_TR_DISTANCE
(-w) Write TR_DISTANCE, only if _pcps_has_tr_distance
Definition: pcpsdefs.h:774
#define _io_chk_cond(_cond)
Check if a condition is true.
Definition: macioctl.h:444
#define _pcps_ddev_has_hr_time(_p)
Definition: pcpsdrvr.h:1225
(r/-) n * MBG_GPIO_STATUS_IDX, where n == MBG_GPIO_CFG_LIMITS::num_io, only if MBG_GPIO_CFG_LIMIT_FLA...
Definition: pcpsdefs.h:1680
#define PCPS_GIVE_UCAP_EVENT
(r-) Return oldest event as PCPS_HR_TIME, only if _pcps_has_ucap
Definition: pcpsdefs.h:770
#define IOCTL_MBG_DBG_CLR_BIT
Definition: mbgioctl.h:738
PCPS_IO_BUFFER io_buffer
Definition: pcpsdrvr.h:855
(r/-) XMULTI_REF_INSTANCES, only if GPS_HAS_XMULTI_REF and GPS_HAS_XMRS_MULT_INSTC ...
Definition: pcpsdefs.h:1674
#define PCPS_GIVE_TIME
Command codes used to communicate with bus level devices.
Definition: pcpsdefs.h:712
PCPS_FRAC_32 frac
binary fractions of second, see PCPS_FRAC_32
Definition: pcpsdefs.h:975
#define PCPS_GET_TR_DISTANCE
(r-) Read TR_DISTANCE, only if _pcps_has_tr_distance
Definition: pcpsdefs.h:773
(r/w) PTP_CFG_SETTINGS / PTP_CFG_INFO, only if PCPS_HAS_PTP
Definition: pcpsdefs.h:1664
#define IOCTL_GET_PCPS_SYNC_TIME
Definition: mbgioctl.h:525
#define IOCTL_DEV_HAS_SIGNAL
Definition: mbgioctl.h:624
uint8_t MBG_DBG_DATA
Definition: pcpsdev.h:369
#define IOCTL_DEV_HAS_IRIG
Definition: mbgioctl.h:626
#define IOCTL_GET_GPIO_CFG_LIMITS
Definition: mbgioctl.h:718
#define _pcps_ddev_has_xmr(_p)
Definition: pcpsdrvr.h:1338
#define _pcps_ddev_can_clr_ucap_buff(_p)
Definition: pcpsdrvr.h:1235
#define IOCTL_DEV_HAS_MOD
Definition: mbgioctl.h:625
#define IOCTL_GET_GPS_BVAR_STAT
Definition: mbgioctl.h:562
MBG_SYS_TIME sys_time
system time stamp
Definition: pcpsdev.h:390
#define IOCTL_MBG_DBG_SET_PORT_ADDR
Definition: mbgioctl.h:736
#define _pcps_ddev_has_irig_ctrl_bits(_p)
Definition: pcpsdrvr.h:1254
#define _io_unmap_mapped_mem_address(_pddev, _pin)
Definition: macioctl.h:291
PCI_ASIC_VERSION raw_asic_version
Raw ASIC version.
Definition: pcpsdrvr.h:794
(r/w) IP4_SETTINGS, LAN interface configuration, only if PCPS_HAS_LAN_INTF
Definition: pcpsdefs.h:1662
#define IOCTL_GET_SYNTH_STATE
Definition: mbgioctl.h:635
#define _io_read_gps_chk(_pddev, _cmd, _fld, _pout, _size, _cond)
Definition: macioctl.h:639
#define PCPS_SET_SYNTH
(-w) Write SYNTH, only if _pcps_has_synth, returns MBG_ERR_CFG on error
Definition: pcpsdefs.h:750
PCPS_TIME_STAMP volatile __iomem * mm_tstamp_addr
Definition: pcpsdrvr.h:811
PCPS_TIME_STAMP_CYCLES ref_tstamp_cycles
HR timestamp from the card, plus cycles.
Definition: pcpsdev.h:1447
#define _pcps_ddev_is_dcf(_p)
Definition: pcpsdrvr.h:1139
#define IOCTL_SET_GPS_POUT_SETTINGS_IDX
Definition: mbgioctl.h:638
#define _pcps_ddev_is_gnss(_p)
Definition: pcpsdrvr.h:1147
#define _pcps_ddev_has_gpio(_p)
Definition: pcpsdrvr.h:1335
unsigned char uint8_t
Definition: words.h:210
PCPS_DRVR_INFO drvr_info
#define IOCTL_GET_ALL_PTP_UC_MASTER_INFO
Definition: mbgioctl.h:693
#define IOCTL_DEV_HAS_CAB_LEN
Definition: mbgioctl.h:613
#define IOCTL_GET_GNSS_MODE_INFO
Definition: mbgioctl.h:713
#define IOCTL_DEV_IS_LWR
Definition: mbgioctl.h:649
(r/-) PTP_STATE, only if PCPS_HAS_PTP
Definition: pcpsdefs.h:1663
#define IOCTL_DEV_IS_MSF
Definition: mbgioctl.h:648
#define _pcps_ddev_has_serial_hs(_p)
Definition: pcpsdrvr.h:1241
(r/-) n * PORT_INFO_IDX, settings and capabilities of all serial ports, only if RECEIVER_INFO::n_com_...
Definition: pcpsdefs.h:1654
(r/-) POS, position XYZ, LLA, and DMS combined, only if GPS_MODEL_HAS_POS
Definition: pcpsdefs.h:1649
(r/-) n * GNSS_SAT_INFO_IDX, satellite info, only if PCPS_IS_GNSS
Definition: pcpsdefs.h:1673
#define _pcps_ddev_has_ucap(_p)
Definition: pcpsdrvr.h:1236
(r/-) MBG_GPIO_CFG_LIMITS, only if GPS_HAS_GPIO
Definition: pcpsdefs.h:1668
#define _frc_iob_from_pin
Definition: macioctl.h:351
#define MBG_ERR_COPY_FROM_USER
Kernel driver failed to copy data from use to kernel space.
Definition: mbgerror.h:303
#define IOCTL_GET_GPS_TIME
Definition: mbgioctl.h:564
#define IOCTL_DEV_HAS_CORR_INFO
Definition: mbgioctl.h:697
#define IOCTL_SET_GPIO_SETTINGS_IDX
Definition: mbgioctl.h:720
#define PCPS_SET_OPT_SETTINGS
(-w) Write MBG_OPT_SETTINGS, only if _pcps_has_opt_flags, returns MBG_ERR_CFG on error ...
Definition: pcpsdefs.h:741
#define IOCTL_GET_PCI_ASIC_FEATURES
Definition: mbgioctl.h:643
#define IOCTL_PCPS_GENERIC_READ_GPS
Definition: mbgioctl.h:518
#define _pcps_kmalloc(_sz)
Definition: pcpsdrvr.h:555
#define IOCTL_GET_GPS_IDENT
Definition: mbgioctl.h:581
An I/O buffer for bus level devices.
Definition: pcpsiobf.h:78
#define PCPS_GET_REF_OFFS
(r-) Read MBG_REF_OFFS, only if _pcps_has_ref_offs
Definition: pcpsdefs.h:737
int pcps_chk_dev_feat(PCPS_DDEV *p_ddev, uint feat_type, uint feat_num)
Check if a specific feature of a specific feature type is supported.
Definition: pcpsdrvr.c:5112
#define IOCTL_GET_PCPS_IRIG_TX_INFO
Definition: mbgioctl.h:601
#define PCPS_GIVE_IRIG_TIME
(r-) Read raw IRIG time as PCPS_IRIG_TIME, only if _pcps_has_irig_time
Definition: pcpsdefs.h:716
#define PCPS_SET_TIME
(-w) Set on-board time, see PCPS_STIME. Returns MBG_ERR_STIME on error.
Definition: pcpsdefs.h:718
(r/-) RECEIVER_INFO, rcvr model info, only if PCPS_HAS_RECEIVER_INFO
Definition: pcpsdefs.h:1651
#define _pcps_ddev_has_irig(_p)
Definition: pcpsdrvr.h:1251
#define IOCTL_DEV_IS_IRIG_RX
Definition: mbgioctl.h:610
(r/-) LAN_IF_INFO, LAN interface info, only if PCPS_HAS_LAN_INTF
Definition: pcpsdefs.h:1659
#define MBG_SUCCESS
Error codes used with Meinberg devices and drivers.
Definition: mbgerror.h:259
#define PCPS_GET_IRIG_RX_INFO
(r-) Read IRIG_INFO, only if _pcps_is_irig_rx
Definition: pcpsdefs.h:743
#define _mbgddmsg_4(_f, _lvl, _fmt, _p1, _p2, _p3, _p4)
Definition: mbgddmsg.h:336
#define IOCTL_SET_PTP_UC_MASTER_SETTINGS_IDX
Definition: mbgioctl.h:694
#define IOCTL_DEV_HAS_PTP
Definition: mbgioctl.h:677
PCI_ASIC_FEATURES asic_features
ASIC feature mask.
Definition: pcpsdrvr.h:796
#define _pcps_ddev_has_signal(_p)
Definition: pcpsdrvr.h:1245
#define IOCTL_DEV_HAS_GPIO
Definition: mbgioctl.h:717
PCPS_HR_TIME_CYCLES ref_hr_time_cycles
HR time read from the card, plus cycles.
Definition: pcpsdev.h:1420
#define _mbg_mmrd32_to_cpu(_iomem_addr)
Definition: mbggenio.h:576
#define _pcps_ddev_has_fast_hr_timestamp(_p)
Definition: pcpsdrvr.h:1293
(r/w) MBG_TIME_SCALE_SETTINGS / MBG_TIME_SCALE_INFO, only if PCPS_HAS_TIME_SCALE
Definition: pcpsdefs.h:1658
MBG_PC_CYCLES cyc_after
cycles count after sys time has been read
Definition: pcpsdev.h:389
#define PCPS_GET_IRIG_TX_INFO
(r-) Read IRIG_INFO, only if _pcps_has_irig_tx
Definition: pcpsdefs.h:746
IOCTL_GENERIC_REQ req
Definition: mbgioctl.h:489
#define _pcps_ddev_has_synth(_p)
Definition: pcpsdrvr.h:1275
#define _pcps_ddev_has_tzcode(_p)
Definition: pcpsdrvr.h:1230
#define IOCTL_GET_ALL_GPIO_INFO
Definition: mbgioctl.h:719
#define IOCTL_PCPS_GENERIC_WRITE_GPS
Definition: mbgioctl.h:519
MBG_PC_CYCLES cycles
Definition: pcpsdev.h:1371
#define _pcps_kfree(_p, _sz)
Definition: pcpsdrvr.h:556
#define IOCTL_SET_GPS_ANT_CABLE_LEN
Definition: mbgioctl.h:588
#define IOCTL_DEV_HAS_REF_OFFS
Definition: mbgioctl.h:627
#define _pcps_read(_pddev, _cmd, _p, _n)
Definition: pcpsdrvr.h:1350
(r/-) n * PTP_UC_MASTER_INFO_IDX, only if PTP_CFG_MSK_SUPPORT_PTP_UNICAST
Definition: pcpsdefs.h:1666
uint64_t MBG_PC_CYCLES_FREQUENCY
Definition: mbgpccyc.h:98
#define IOCTL_GET_IP4_STATE
Definition: mbgioctl.h:672
#define IOCTL_DEV_HAS_IRIG_CTRL_BITS
Definition: mbgioctl.h:667
#define _pcps_ddev_type_name(_p)
Definition: pcpsdrvr.h:1131
#define _pcps_ddev_has_tz(_p)
Definition: pcpsdrvr.h:1231
#define IOCTL_DEV_HAS_PZF
Definition: mbgioctl.h:696
#define IOCTL_GET_PCPS_HR_TIME
Definition: mbgioctl.h:529
#define PCPS_GET_OPT_INFO
(r-) Read MBG_OPT_INFO, only if _pcps_has_opt_flags
Definition: pcpsdefs.h:740
#define IOCTL_GET_XMR_INSTANCES
Definition: mbgioctl.h:723
static __mbg_inline uint8_t _pcps_ddev_read_status_port(const PCPS_DDEV *pddev)
Definition: pcpsdrvr.h:1430
static __mbg_inline uint32_t bin_frac_32_to_dec_frac(uint32_t bin, uint32_t scale)
Convert a 32 bit binary fraction to a scaled decimal.
Definition: mbgtime.h:439
#define IOCTL_SET_TR_DISTANCE
Definition: mbgioctl.h:701
#define IOCTL_SET_SYNTH
Definition: mbgioctl.h:605
#define IOCTL_SET_GPS_TIME_SCALE_SETTINGS
Definition: mbgioctl.h:661
#define PCPS_GET_RAW_IRIG_DATA
(r-) Read MBG_RAW_IRIG_DATA, only if _pcps_has_raw_irig_data
Definition: pcpsdefs.h:758
#define _pcps_ddev_can_set_time(_p)
Definition: pcpsdrvr.h:1220
(r/w) PORT_PARM, param. of the serial ports, deprecated by PC_GPS_ALL_PORT_INFO
Definition: pcpsdefs.h:1641
#define _pcps_ddev_has_asic_version(_p)
Definition: pcpsdrvr.h:1287
#define IOCTL_DEV_HAS_PCPS_TZDL
Definition: mbgioctl.h:615
#define IOCTL_SET_PCPS_TZCODE
Definition: mbgioctl.h:538
#define PCPS_GET_SYNTH
(r-) Read SYNTH, only if _pcps_has_synth
Definition: pcpsdefs.h:749
#define IOCTL_GET_GPS_ALL_POUT_INFO
Definition: mbgioctl.h:637
#define IOCTL_GET_GPS_RECEIVER_INFO
Definition: mbgioctl.h:590
#define PCPS_SET_PCPS_TZDL
(-w) Write PCPS_TZDL, only if _pcps_has_pcps_tzdl, returns MBG_ERR_CFG on error
Definition: pcpsdefs.h:735
PCPS_TIME t
Definition: pcpsdev.h:1357
#define PCPS_GET_PCPS_TZDL
(r-) Read PCPS_TZDL, only if _pcps_has_pcps_tzdl
Definition: pcpsdefs.h:734
#define IOCTL_MBG_DBG_CLR_ALL
Definition: mbgioctl.h:739
#define _pcps_ddev_has_tr_distance(_p)
Definition: pcpsdrvr.h:1311
(r/-) GPS_STAT_INFO, satellite info, mode of operation, and DAC info, only if GPS_MODEL_HAS_STAT_INFO...
Definition: pcpsdefs.h:1646
#define IOCTL_DEV_HAS_TZCODE
Definition: mbgioctl.h:616
#define IOCTL_GET_PCPS_TIME
Definition: mbgioctl.h:522
#define NSEC_PER_SEC
Definition: mbgtime.h:264
Local calendar date and time, plus sync status.
Definition: pcpsdefs.h:1128
#define IOCTL_DEV_HAS_GPS_TIME_SCALE
Definition: mbgioctl.h:659
#define _pcps_ddev_dev_id(_p)
Definition: pcpsdrvr.h:1132
#define IOCTL_GET_IRQ_STAT_INFO
Definition: mbgioctl.h:652
#define IOCTL_GET_IP4_SETTINGS
Definition: mbgioctl.h:673
#define IOCTL_DEV_HAS_GENERIC_IO
Definition: mbgioctl.h:631
#define IOCTL_SET_GPS_TIME
Definition: mbgioctl.h:565
#define IOCTL_SET_XMR_SETTINGS_IDX
Definition: mbgioctl.h:725
#define PCPS_CLR_EVT_LOG
(-w) Write clear on-board event log, only if _pcps_has_evt_log
Definition: pcpsdefs.h:776
A high resolution time stamp.
Definition: pcpsdefs.h:972
#define IOCTL_GET_GPS_UTC_PARM
Definition: mbgioctl.h:664
#define _pcps_ddev_is_msf(_p)
Definition: pcpsdrvr.h:1140
#define _pcps_ddev_has_opt_flags(_p)
Definition: pcpsdrvr.h:1266
(r/-) n * XMULTI_REF_INFO_IDX, where n == XMULTI_REF_INSTANCES::n_xmr_settings, only if GPS_HAS_XMULT...
Definition: pcpsdefs.h:1676
(-/w) PTP_UC_MASTER_SETTINGS_IDX, only if PTP_CFG_MSK_SUPPORT_PTP_UNICAST
Definition: pcpsdefs.h:1667
#define IOCTL_GET_PCPS_TZDL
Definition: mbgioctl.h:540
#define _pcps_ddev_has_irig_time(_p)
Definition: pcpsdrvr.h:1257
#define IOCTL_DEV_HAS_RECEIVER_INFO
Definition: mbgioctl.h:619
#define _io_write_cmd_chk(_pddev, _cmd, _cond)
Definition: macioctl.h:630
#define _io_write_gps_var_chk(_pddev, _cmd, _fld, _pin, _cond)
Definition: macioctl.h:661
#define _pcps_ddev_has_mod(_p)
Definition: pcpsdrvr.h:1248
#define IOCTL_DEV_HAS_PTP_UNICAST
Definition: mbgioctl.h:691
#define PCPS_GET_TZCODE
(r-) Read PCPS_TZCODE, only if _pcps_has_tzcode
Definition: pcpsdefs.h:731
#define IOCTL_DEV_HAS_XMR
Definition: mbgioctl.h:722
#define _pcps_ddev_is_lwr(_p)
Definition: pcpsdrvr.h:1146
#define IOCTL_DEV_IS_DCF
Definition: mbgioctl.h:609
#define _mbg_dbg_clr_all(_d)
Definition: macioctl.h:700
#define IOCTL_GET_TIME_INFO_HRT
Definition: mbgioctl.h:685
#define _pcps_ddev_has_utc_parm(_p)
Definition: pcpsdrvr.h:1284
#define _pcps_ddev_is_gps(_p)
Definition: pcpsdrvr.h:1138
#define MBG_ERR_NOT_SUPP_BY_DEV
Command or feature not supported by device.
Definition: mbgerror.h:286
#define IOCTL_GET_ALL_GPIO_STATUS
Definition: mbgioctl.h:729
#define IOCTL_GET_MAPPED_MEM_ADDR
Definition: mbgioctl.h:640
#define PCPS_NEXT_EVT_LOG_ENTRY
(r-) Read next MBG_EVT_LOG_ENTRY, only if _pcps_has_evt_log
Definition: pcpsdefs.h:779
#define PCPS_GIVE_HR_TIME
(r-) Read high res. time as PCPS_HR_TIME, only if _pcps_has_hr_time
Definition: pcpsdefs.h:715
#define _pcps_ddev_has_event_time(_p)
Definition: pcpsdrvr.h:1233
#define _mbg_ioremap(_base, _num)
Definition: mbggenio.h:189
#define IOCTL_SET_GPS_PORT_SETTINGS_IDX
Definition: mbgioctl.h:594
#define IOCTL_MBG_DBG_GET_PORT_ADDR
Definition: mbgioctl.h:735
#define IOCTL_GET_GPS_PORT_PARM
Definition: mbgioctl.h:567
(r/w) n * XMULTI_REF_STATUS_IDX, where n == XMULTI_REF_INSTANCES::n_xmr_settings, one structure on wr...
Definition: pcpsdefs.h:1677
#define _pcps_ddev_has_lan_intf(_p)
Definition: pcpsdrvr.h:1296
uint32_t out_sz
Size of the output buffer.
Definition: mbgioctl.h:422
#define IOCTL_PCPS_GENERIC_WRITE
Definition: mbgioctl.h:517
(r/-) SW_REV, software revision, deprecated by PC_GPS_RECEIVER_INFO
Definition: pcpsdefs.h:1636
#define mbg_rc_is_error(_rc)
Definition: mbgerror.h:617
#define IOCTL_DEV_HAS_TZDL
Definition: mbgioctl.h:614
#define IOCTL_GET_NUM_EVT_LOG_ENTRIES
Definition: mbgioctl.h:708
#define IOCTL_GET_ALL_XMR_STATUS
Definition: mbgioctl.h:726
#define IOCTL_SET_PCPS_IRIG_TX_SETTINGS
Definition: mbgioctl.h:602
#define IOCTL_GET_FIRST_EVT_LOG_ENTRY
Definition: mbgioctl.h:709
#define IOCTL_GET_TR_DISTANCE
Definition: mbgioctl.h:700
unsigned __int64 uint64_t
Definition: words.h:250
IOCTL_DEV_FEAT_REQ dev_feat_req
Definition: mbgioctl.h:484
PCPS_DEV dev
Device info data that can be passed to user space.
Definition: pcpsdrvr.h:779
#define IOCTL_GET_PCPS_DRVR_INFO
Definition: mbgioctl.h:510
#define IOCTL_DEV_HAS_EVENT_TIME
Definition: mbgioctl.h:618
#define _mbg_spin_lock_release(_spl)
Definition: mbgmutex.h:207
(r/-) TTM, user capture events, deprecated by PCPS_GIVE_UCAP_EVENT
Definition: pcpsdefs.h:1644
int64_t MBG_PC_CYCLES
Generic types to hold PC cycle counter values.
Definition: mbgpccyc.h:97
#define IOCTL_GET_GPS_TIME_SCALE_INFO
Definition: mbgioctl.h:660
#define _pcps_ddev_is_ptp(_p)
Definition: pcpsdrvr.h:1143
#define PCPS_GET_DEBUG_STATUS
(r-) Read MBG_DEBUG_STATUS, only if _pcps_has_debug_status
Definition: pcpsdefs.h:761
#define _io_wait_pcps_sec_change(_pddev, _cmd, _type, _pout)
Definition: macioctl.h:275
#define IOCTL_SET_MBG_OPT_SETTINGS
Definition: mbgioctl.h:547
#define _pcps_ddev_has_time_scale(_p)
Definition: pcpsdrvr.h:1281
#define IOCTL_GET_GPS_ALL_STR_TYPE_INFO
Definition: mbgioctl.h:591
(r/-) ANT_INFO, time diff at sync. after antenna had been disconn., only if GPS_MODEL_HAS_ANT_INFO ...
Definition: pcpsdefs.h:1642
unsigned long ulong
Definition: words.h:292
#define PCPS_GET_CORR_INFO
(r-) Read CORR_INFO structure, only if _pcps_has_pzf
Definition: pcpsdefs.h:772
#define IOCTL_GET_LAN_IF_INFO
Definition: mbgioctl.h:671
#define _io_write_var_chk(_pddev, _cmd, _fld, _pin, _cond)
Definition: macioctl.h:621
#define _iob_to_pout(_piob, _pout, _size)
Definition: macioctl.h:255
#define PCPS_SET_IRIG_TX_SETTINGS
(-w) Write IRIG_SETTINGS, only if _pcps_has_irig_tx, returns MBG_ERR_CFG on error ...
Definition: pcpsdefs.h:747
#define PCPS_SET_EVENT_TIME
(-w) Write event time as PCPS_TIME_STAMP, only if _pcps_has_event_time
Definition: pcpsdefs.h:720
#define IOCTL_GET_PCPS_TIME_CYCLES
Definition: mbgioctl.h:598
(r/-) n * POUT_INFO_IDX, all programmable output info
Definition: pcpsdefs.h:1656
#define PCI_ASIC_HAS_MM_IO
Bit masks used with PCI_ASIC_FEATURES.
Definition: pci_asic.h:175
#define PCPS_GET_IRIG_CTRL_BITS
(r-) Read MBG_IRIG_CTRL_BITS, only if _pcps_has_irig_ctrl_bits
Definition: pcpsdefs.h:757
#define _pcps_ddev_has_ptp(_p)
Definition: pcpsdrvr.h:1299
#define _pcps_ddev_has_tzdl(_p)
Definition: pcpsdrvr.h:1228
#define IOCTL_GET_GPS_SW_REV
Definition: mbgioctl.h:560
#define _mbg_spin_lock_acquire(_spl)
Definition: mbgmutex.h:206
#define IOCTL_SET_PCPS_TZDL
Definition: mbgioctl.h:541
#define _pcps_ddev_has_receiver_info(_p)
Definition: pcpsdrvr.h:1234
#define IOCTL_GET_RAW_IRIG_DATA
Definition: mbgioctl.h:689
#define PCPS_SET_REF_OFFS
(-w) Write MBG_REF_OFFS, only if _pcps_has_ref_offs, returns MBG_ERR_CFG on error ...
Definition: pcpsdefs.h:738
uint32_t feat_num
Number and range depending on IOCTL_DEV_FEAT_REQ::feat_type value.
Definition: mbgioctl.h:476
#define _pcps_ddev_has_irig_tx(_p)
Definition: pcpsdrvr.h:1237
static __mbg_inline void mbg_get_pc_cycles_frequency(MBG_PC_CYCLES_FREQUENCY *p)
Definition: mbgpccyc.h:250
#define _iob_from_pin_var(_iob, _pin)
Definition: macioctl.h:358
#define IOCTL_DEV_HAS_TR_DISTANCE
Definition: mbgioctl.h:698
#define _iob_from_pin(_piob, _pin, _size)
Definition: macioctl.h:265
#define IOCTL_DEV_HAS_PCI_ASIC_FEATURES
Definition: mbgioctl.h:645
#define _pcps_ddev_has_evt_log(_p)
Definition: pcpsdrvr.h:1314
#define IOCTL_GET_GPS_UCAP
Definition: mbgioctl.h:572
#define IOCTL_PTP_UC_MASTER_CFG_LIMITS
Definition: mbgioctl.h:692
#define IOCTL_GET_PCPS_SERIAL
Definition: mbgioctl.h:534
#define IOCTL_GET_NEXT_EVT_LOG_ENTRY
Definition: mbgioctl.h:710
#define _io_read_var(_pddev, _cmd, _fld, _pout)
Read a standard data structure from a device.
Definition: macioctl.h:459
uint32_t feat_type
See DEV_FEAT_TYPES.
Definition: mbgioctl.h:475
#define IOCTL_GET_PTP_STATE
Definition: mbgioctl.h:678
(r/-) n * STR_TYPE_INFO_IDX, names and capabilities of all supp. string types, only if RECEIVER_INFO:...
Definition: pcpsdefs.h:1653
PCPS_WRITE_FNC pcps_write_gps
Write a large data structure to a device.
Definition: pcpsdrvr.c:3573
#define IOCTL_GET_PCPS_HR_TIME_CYCLES
Definition: mbgioctl.h:599
#define IOCTL_SET_PCPS_EVENT_TIME
Definition: mbgioctl.h:532
#define IOCTL_DEV_HAS_SERIAL_HS
Definition: mbgioctl.h:623