mbgtools-lx  4.2.8
Basic macros used to implemment IOCTL functions

Macros

#define _io_chk_cond(_cond)
 Check if a condition is true. More...
 
#define _io_read_var(_pddev, _cmd, _fld, _pout)
 Read a standard data structure from a device. More...
 
#define _io_write_var(_pddev, _cmd, _fld, _pin)
 Write a standard data structure to a device. More...
 
#define _io_write_cmd(_pddev, _cmd)
 Write a command byte to the device. More...
 
#define _io_read_gps(_pddev, _cmd, _fld, _pout, _size)
 Write a large data structure with variable size to a device. More...
 
#define _io_read_gps_var(_pddev, _cmd, _fld, _pout)
 Read a large data structure with fixed size from a device. More...
 
#define _io_write_gps_var(_pddev, _cmd, _fld, _pin)
 Write a large data structure with fixed size to a device. More...
 

Detailed Description

General functions that read a data structure from a device into a buffer, check the return code and, if no error occurred, copy the data up to user space, or copy data from user space to a buffer and write the buffer to the device.

If device access fails, goto a label which handles the error.

Since USB devices on Linux require a DMA-capable I/O buffer we use a common buffer which is part of the device's private data. Since this buffer is shared between processes the code which copies the data from or to user space has to be protected by the device semaphore in the same way as the actual device access.

Macro Definition Documentation

◆ _io_chk_cond

#define _io_chk_cond (   _cond)
Value:
do \
{ \
if ( !(_cond) ) \
goto err_not_supp_by_dev; \
\
} while ( 0 )

Check if a condition is true.

If condition is false then goto an error label.

Definition at line 444 of file macioctl.h.

Referenced by ioctl_switch().

◆ _io_read_gps

#define _io_read_gps (   _pddev,
  _cmd,
  _fld,
  _pout,
  _size 
)
Value:
do \
{ \
_io_chk_cond( _pcps_ddev_has_gps_data( _pddev ) ); \
_pcps_sem_inc_safe( _pddev ); \
\
rc = pcps_read_gps( _pddev, _cmd, (uchar FAR *) &p_dev_iob->_fld, _size ); \
\
if ( mbg_rc_is_success( rc ) ) \
_iob_to_pout( &p_dev_iob->_fld, _pout, _size ); \
_pcps_sem_dec( _pddev ); \
\
if ( mbg_rc_is_error( rc ) ) \
goto err_dev_access; \
\
} while ( 0 )
#define _pcps_sem_dec(_pddev)
Definition: pcpsdrvr.h:575
#define mbg_rc_is_success(_rc)
Definition: mbgerror.h:618
PCPS_READ_FNC pcps_read_gps
Read a large data structure from a device.
Definition: pcpsdrvr.c:3468
#define _pcps_ddev_has_gps_data(_p)
Definition: pcpsdrvr.h:1272
#define _pcps_sem_inc_safe(_pddev)
Definition: macioctl.h:409
unsigned char uchar
Definition: words.h:277
#define FAR
Definition: mbggenio.h:132
#define mbg_rc_is_error(_rc)
Definition: mbgerror.h:617

Write a large data structure with variable size to a device.

First check if the device supports large (GPS) data structures.

If access fails goto an error label.

Definition at line 526 of file macioctl.h.

◆ _io_read_gps_var

#define _io_read_gps_var (   _pddev,
  _cmd,
  _fld,
  _pout 
)
Value:
do \
{ \
_io_chk_cond( _pcps_ddev_has_gps_data( _pddev ) ); \
_pcps_sem_inc_safe( _pddev ); \
\
rc = _pcps_read_gps_var( _pddev, _cmd, p_dev_iob->_fld ); \
\
if ( mbg_rc_is_success( rc ) ) \
_iob_to_pout_var( p_dev_iob->_fld, _pout ); \
_pcps_sem_dec( _pddev ); \
\
if ( mbg_rc_is_error( rc ) ) \
goto err_dev_access; \
\
} while ( 0 )
#define _pcps_sem_dec(_pddev)
Definition: pcpsdrvr.h:575
#define mbg_rc_is_success(_rc)
Definition: mbgerror.h:618
#define _pcps_ddev_has_gps_data(_p)
Definition: pcpsdrvr.h:1272
#define _pcps_sem_inc_safe(_pddev)
Definition: macioctl.h:409
#define mbg_rc_is_error(_rc)
Definition: mbgerror.h:617
#define _pcps_read_gps_var(_pddev, _cmd, _s)
Definition: pcpsdrvr.h:1406

Read a large data structure with fixed size from a device.

First check if the device supports large (GPS) data structures.

If access fails goto an error label.

Definition at line 554 of file macioctl.h.

Referenced by ioctl_switch().

◆ _io_read_var

#define _io_read_var (   _pddev,
  _cmd,
  _fld,
  _pout 
)
Value:
do \
{ \
_pcps_sem_inc_safe( _pddev ); \
\
rc = _pcps_read_var( _pddev, _cmd, p_dev_iob->_fld ); \
\
if ( mbg_rc_is_success( rc ) ) \
_iob_to_pout_var( p_dev_iob->_fld, _pout ); \
_pcps_sem_dec( _pddev ); \
\
if ( mbg_rc_is_error( rc ) ) \
goto err_dev_access; \
\
} while ( 0 )
#define _pcps_sem_dec(_pddev)
Definition: pcpsdrvr.h:575
#define mbg_rc_is_success(_rc)
Definition: mbgerror.h:618
#define _pcps_read_var(_pddev, _cmd, _s)
Definition: pcpsdrvr.h:1391
#define mbg_rc_is_error(_rc)
Definition: mbgerror.h:617

Read a standard data structure from a device.

If access fails goto an error label.

Definition at line 459 of file macioctl.h.

Referenced by ioctl_switch().

◆ _io_write_cmd

#define _io_write_cmd (   _pddev,
  _cmd 
)
Value:
do \
{ \
_pcps_sem_inc_safe( _pddev ); \
rc = _pcps_write_byte( _pddev, _cmd ); \
_pcps_sem_dec( _pddev ); \
\
if ( mbg_rc_is_error( rc ) ) \
goto err_dev_access; \
\
} while ( 0 )
#define _pcps_write_byte(_pddev, _b)
Definition: pcpsdrvr.h:1358
#define mbg_rc_is_error(_rc)
Definition: mbgerror.h:617

Write a command byte to the device.

If access fails goto an error label.

We don't have a buffer here that needs to be protected.

Definition at line 505 of file macioctl.h.

◆ _io_write_gps_var

#define _io_write_gps_var (   _pddev,
  _cmd,
  _fld,
  _pin 
)
Value:
do \
{ \
_io_chk_cond( _pcps_ddev_has_gps_data( _pddev ) ); \
_pcps_sem_inc_safe( _pddev ); \
_iob_from_pin_var( p_dev_iob->_fld, _pin ); \
rc = _pcps_write_gps_var( _pddev, _cmd, p_dev_iob->_fld ); \
_pcps_sem_dec( _pddev ); \
\
if ( mbg_rc_is_error( rc ) ) \
goto err_dev_access; \
\
} while ( 0 )
#define _pcps_write_gps_var(_pddev, _cmd, _s)
Definition: pcpsdrvr.h:1410
#define _pcps_ddev_has_gps_data(_p)
Definition: pcpsdrvr.h:1272
#define _pcps_sem_inc_safe(_pddev)
Definition: macioctl.h:409
#define mbg_rc_is_error(_rc)
Definition: mbgerror.h:617

Write a large data structure with fixed size to a device.

First check if the device supports large (GPS) data structures.

If access fails goto an error label.

Definition at line 582 of file macioctl.h.

Referenced by ioctl_switch().

◆ _io_write_var

#define _io_write_var (   _pddev,
  _cmd,
  _fld,
  _pin 
)
Value:
do \
{ \
_pcps_sem_inc_safe( _pddev ); \
_iob_from_pin_var( p_dev_iob->_fld, _pin ); \
rc = _pcps_write_var( _pddev, _cmd, p_dev_iob->_fld ); \
_pcps_sem_dec( _pddev ); \
\
if ( mbg_rc_is_error( rc ) ) \
goto err_dev_access; \
\
} while ( 0 )
#define _pcps_write_var(_pddev, _cmd, _s)
Definition: pcpsdrvr.h:1397
#define mbg_rc_is_error(_rc)
Definition: mbgerror.h:617

Write a standard data structure to a device.

If access fails goto an error label.

Definition at line 483 of file macioctl.h.

Referenced by ioctl_switch().