mbgtools-lx  4.2.8
pcpsdrvr.c File Reference
#include <pcpsdrvr.h>
#include <identdec.h>
#include <mbgddmsg.h>
#include <plxdefs.h>
#include <pci_asic.h>
#include <amccdefs.h>
#include <pcidefs.h>
#include <pci.h>

Go to the source code of this file.

Macros

#define _PCPSDRVR
 
#define REPORT_CFG   10
 
#define REPORT_CFG_DETAILS   1
 
#define REPORT_CFG_LOG_LVL   MBG_LOG_INFO
 
#define TEST_CFG_DETAILS   0
 
#define USE_CMD_PTR   1
 
#define DEBUG_ACCESS_TIMING   0
 
#define DEBUG_IO_TIMING   0
 
#define DEBUG_IO   1
 
#define DEBUG_PORTS   1
 
#define DEBUG_SERNUM   1
 
#define USE_USB_MICRO_FRAMES   0
 
#define TEST_PORT_ACCESS   0
 
#define MUST_REPORT_PROBE_DEVICE_DETAILS   1
 
#define MUST_REPORT_ACCESS_MODE   1
 
#define PCPS_LOG_STD_MSGS   0
 
#define _do_div(_x, _y)   do { _x /= _y; } while ( 0 )
 
#define MAX_BOOT_TIME_PTP270PEX   27
 Max. time required for PTP270PEX v1 card to be ready after power-up. More...
 
#define _fmemcpy(_d, _s, _n)   memcpy( _d, _s, _n )
 
#define _fstrlen(_s)   strlen( _s )
 
#define _fstrncmp(_s1, _s2, _n)   strncmp( (_s1), (_s2), (_n) )
 
#define static_wc
 
#define FMT_03X   "%03X"
 
#define FMT_08X   "%08lX"
 
#define _pcps_irq_flags   unsigned long irq_flags;
 
#define _pcps_disb_local_irq_save()   local_irq_save( irq_flags )
 
#define _pcps_local_irq_restore()   local_irq_restore( irq_flags )
 
#define _pcps_time_after(_curr, _tmo)   ( _curr >= _tmo )
 
#define MBG_TGT_HAS_UPTIME   1
 
#define FP_FMT   "%p"
 

Typedefs

typedef unsigned int PCI_DWORD
 

Functions

static __mbg_inline int pcps_ddev_is_ptp270pex (const PCPS_DDEV *pddev)
 Check if a device is a PTP270PEX card. More...
 
static int mbg_plx_read_pecs_reg (struct pci_dev *pNode, uint16_t reg, uint32_t *pval)
 Read a dword from a PLX PECS register. More...
 
static bool ptp270pex_can_flag_ready (const PCPS_DDEV *pddev)
 Check if a PTP270PEX card can indicate when it's ready. More...
 
static bool ptp270pex_has_flagged_ready (const PCPS_DDEV *pddev)
 Check if a PTP270PEX card indicates it is ready. More...
 
static void report_uptime (const MBG_SYS_UPTIME *p_uptime)
 Report the system uptime. More...
 
static void wait_ptp270pex_ready (const PCPS_DDEV *pddev)
 Wait until a PTP270PEX card is ready after power-up. More...
 
static bool pcps_check_pex_irq_unsafe (PCPS_DDEV *pddev, uint16_t req_fw_ver, uint8_t req_asic_ver_major, uint8_t req_asic_ver_minor)
 Check if IRQ usage with a device is unsafe. More...
 
static int setup_mm_addr (PCPS_DDEV *pddev)
 Setup the memory mapped addresses depending on the device type. More...
 
void pcps_dump_data (const void *buffer, size_t count, const char *info)
 
static void report_io_cmd (uint8_t cmd, uint16_t count, const char *info)
 
static void report_ret_val (int rc, const char *info)
 Report the return code to be returned by a function. More...
 
__mbg_inline int pcps_wait_busy (PCPS_DDEV *pddev)
 Wait as long as a device is busy, or until timeout. More...
 
static int pcps_read_null (PCPS_DDEV *pddev, uint8_t cmd, void FAR *buffer, uint16_t count)
 Dummy read function. More...
 
static int pcps_read_std (PCPS_DDEV *pddev, uint8_t cmd, void FAR *buffer, uint16_t count)
 Read function for devices with ISA or micro channel bus. More...
 
static int pcps_read_amcc_s5933 (PCPS_DDEV *pddev, uint8_t cmd, void FAR *buffer, uint16_t count)
 Read function for devices with AMCC S5933 PCI interface chip. More...
 
static int pcps_read_amcc_s5920 (PCPS_DDEV *pddev, uint8_t cmd, void FAR *buffer, uint16_t count)
 Read function for devices with AMCC S5920 PCI interface chip. More...
 
static int pcps_read_asic (PCPS_DDEV *pddev, uint8_t cmd, void FAR *buffer, uint16_t count)
 Read function for devices with Meinberg PCI interface ASIC. More...
 
int pcps_write (PCPS_DDEV *pddev, uint8_t cmd, const void FAR *buffer, uint16_t count)
 Write data to a device. More...
 
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. More...
 
static int pcps_check_gps_data_size (PCPS_DDEV *pddev, uint16_t count, const char *info)
 Determine which interface buffer size is supported. More...
 
static int pcps_init_gps_transfer (PCPS_DDEV *pddev, uint8_t cmd, uint8_t data_type, uint16_t count, const char *info)
 Initialize GPS data transfer. More...
 
static int pcps_read_gps_block (PCPS_DDEV *pddev, uint8_t data_type, void FAR *buffer, uint16_t count, uint8_t block_num, uint8_t block_size)
 Get a block of data from a GPS device. More...
 
int pcps_read_gps (PCPS_DDEV *pddev, uint8_t data_type, void FAR *buffer, uint16_t count)
 Read a large data structure from a device. More...
 
int pcps_write_gps (PCPS_DDEV *pddev, uint8_t data_type, const void FAR *buffer, uint16_t count)
 Write a large data structure to a device. More...
 
static int pcps_get_fw_id (PCPS_DDEV *pddev, PCPS_ID_STR FAR fw_id)
 Read the firmware ID from a device. More...
 
static int pcps_check_id (PCPS_DDEV *pddev, const char FAR *ref)
 Check an ASCIIZ string for a valid signature. More...
 
static PCPS_FW_REV_NUM pcps_get_rev_num (char FAR *idstr)
 Retrieve a version number from a firmware ID string. More...
 
static bool str_remove_unprintables (char *s, size_t max_len)
 Remove unprintable characters from a string. More...
 
static void beautify_sernum (char *s, size_t max_len)
 
static void check_unknown_sernum (char *s, size_t max_len)
 
static const char * get_bus_type_str (const PCPS_DDEV *pddev)
 
static void report_probe_device (const PCPS_DDEV *pddev)
 
static const char * get_pcps_feature_name (PCPS_FEATURES flag_mask)
 Get the name assigned to one of the PCPS_FEATURE_MASKS flags. More...
 
static void dump_receiver_info (const PCPS_DDEV *pddev)
 
static void dump_xfeature_buffer (const PCPS_DDEV *pddev)
 
static void dump_tlv_info (const PCPS_DDEV *pddev)
 
static void check_feature (PCPS_DDEV *pddev, ushort req_rev_num, PCPS_FEATURES flag_mask)
 Check the firmware to see if a specific feature is supported. More...
 
static void check_ri_features (PCPS_DDEV *pddev)
 Check the receiver info features to see if a specific feature is supported. More...
 
int setup_sernum_and_receiver_info (PCPS_DDEV *pddev)
 Read the serial number and receiver info from the device. More...
 
void check_receiver_info_and_features (PCPS_DDEV *pddev)
 Check the receiver info and features. More...
 
void pcps_release_rsrcs (PCPS_DDEV *pddev)
 Release I/O port and memory resource that have been claimed before. More...
 
PCPS_DEV_TYPEpcps_get_dev_type_table_entry (PCPS_BUS_FLAGS bus_mask, PCPS_DEV_ID dev_id)
 Lookup a specific device in the device table. More...
 
static void pcps_free_ddev_struc (PCPS_DDEV **ppddev)
 Free a previously allocated device info structure. More...
 
static int pcps_alloc_ddev_struc (PCPS_DDEV **ppddev)
 Allocate a device info structure for a device. More...
 
int pcps_init_ddev (PCPS_DDEV **ppddev)
 Allocate and initialize a device info structure. More...
 
void pcps_cleanup_ddev (PCPS_DDEV *pddev)
 Clean up and free a previously initialized device info structure. More...
 
static void rsrc_port_to_cfg_port (PCPS_SHORT_PORT_RSRC *p_short_port_rsrc, const MBG_IOPORT_RSRC *p_io_rsrc)
 Convert a raw I/O base address to a short format. More...
 
int pcps_add_rsrc_io (PCPS_DDEV *pddev, MBG_IOPORT_ADDR_RAW base, ulong num)
 Add an I/O address range resource to the device structure. More...
 
int pcps_add_rsrc_mem (PCPS_DDEV *pddev, MBG_IOMEM_ADDR_RAW start, ulong len)
 Add a memory address range resource to the device structure. More...
 
int pcps_add_rsrc_irq (PCPS_DDEV *pddev, int16_t irq_num)
 Add an IRQ number resource to the device structure. More...
 
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. More...
 
static void set_access_mode (PCPS_DDEV *pddev, uint mode, bool forced, PCPS_READ_FNC *read_fnc)
 
static void report_access_mode (const PCPS_DDEV *pddev)
 
int pcps_probe_device (PCPS_DDEV *pddev, PCPS_BUS_NUM bus_num, PCPS_SLOT_NUM dev_fnc_num)
 Probe if a device is supported, and allocate and setup the device structure. More...
 
void pcps_cleanup_device (PCPS_DDEV *pddev)
 Clean up function called by pcps_probe_device on error. More...
 
void pcps_detect_isa_devices (PCPS_DDEV_INIT_FNC *ddev_init_fnc, PCPS_DDEV_CLEANUP_FNC *ddev_cleanup_fnc, PCPS_DDEV_REGISTER_FNC *ddev_register_fnc, int isa_ports[PCPS_MAX_ISA_CARDS], int isa_irqs[PCPS_MAX_ISA_CARDS])
 Detect and initialize ISA devices in a non-PnP system. More...
 
static void _MBG_INIT_CODE_ATTR pcps_detect_devices_init (PCPS_DDEV_INIT_FNC *ddev_init_fnc, PCPS_DDEV_CLEANUP_FNC *ddev_cleanup_fnc, int isa_ports[PCPS_MAX_ISA_CARDS], int isa_irqs[PCPS_MAX_ISA_CARDS])
 _PCPS_USE_ISA_PNP More...
 
void _MBG_INIT_CODE_ATTR pcps_detect_devices (int isa_ports[PCPS_MAX_ISA_CARDS], int isa_irqs[PCPS_MAX_ISA_CARDS])
 Detect all bus-level devices in a non-PnP system. More...
 

Variables

static const char str_empty [] = ""
 
static const char str_unkn_braced [] = "(unknown)"
 
static const char str_spc_gps [] = " GPS"
 
static MBG_PC_CYCLES_FREQUENCY pc_cycles_frequency
 Clock frequency of the PC's cycles counter, in [Hz]. More...
 
static uint32_t ri_feat_tbl [N_GPS_FEATURE]
 A table used to map RECEIVER_INFO::features to PCPS_DEV_CFG::features. More...
 
static const char * gps_ri_feature_names [N_GPS_FEATURE] = { "Pulse Per Second", "Pulse Per Minute", "Programmable Synth.", "DCF77 Time Marks", "IRIG Out", "IRIG In", "IPv4 LAN Interface", "Multiple Ref. Sources", "Receive Timeout", "Ignore Lock", "5 MHz Output", "Ext. Multiple Ref. Src. Cfg.", "Optional Settings", "Configurable Time Scale", "IRIG Control Bits", "PTP/IEEE1588", "Nav. Engine Settings", "Raw IRIG Data", "Raw IRIG Time", "PTP/IEEE1588 Unicast", "General Purpose I/O", "Multiple XMRS Instances", "10 MHz Output Disabled", "Event Logging", "IMS data", "HaveQuick", "NTP", "Ext. Network Config", "Versatile Storage", "SHS", "Extended Binary Protocol", "Extended Features" }
 A table of name strings associated with GPS_FEATURE_BITS. More...
 
static const char * pcps_feature_names [N_PCPS_FEATURE_BITS] = PCPS_FEATURE_NAMES
 A table of name strings associated with PCPS_FEATURE_BITS. More...
 
PCPS_READ_FNC pcps_read_null
 
PCPS_READ_FNC pcps_read_std
 
PCPS_READ_FNC pcps_read_amcc_s5933
 
PCPS_READ_FNC pcps_read_amcc_s5920
 
PCPS_READ_FNC pcps_read_asic
 
PCPS_WRITE_FNC pcps_write
 
PCPS_READ_FNC pcps_read_gps
 
PCPS_WRITE_FNC pcps_write_gps
 

Macro Definition Documentation

◆ _do_div

#define _do_div (   _x,
  _y 
)    do { _x /= _y; } while ( 0 )

Definition at line 516 of file pcpsdrvr.c.

Referenced by report_io_cmd().

◆ _fmemcpy

#define _fmemcpy (   _d,
  _s,
  _n 
)    memcpy( _d, _s, _n )

Definition at line 558 of file pcpsdrvr.c.

◆ _fstrlen

#define _fstrlen (   _s)    strlen( _s )

Definition at line 559 of file pcpsdrvr.c.

Referenced by pcps_check_id(), and pcps_get_rev_num().

◆ _fstrncmp

#define _fstrncmp (   _s1,
  _s2,
  _n 
)    strncmp( (_s1), (_s2), (_n) )

Definition at line 560 of file pcpsdrvr.c.

Referenced by pcps_check_id().

◆ _pcps_disb_local_irq_save

#define _pcps_disb_local_irq_save ( )    local_irq_save( irq_flags )

◆ _pcps_irq_flags

#define _pcps_irq_flags   unsigned long irq_flags;

◆ _pcps_local_irq_restore

#define _pcps_local_irq_restore ( )    local_irq_restore( irq_flags )

◆ _pcps_time_after

#define _pcps_time_after (   _curr,
  _tmo 
)    ( _curr >= _tmo )

Definition at line 625 of file pcpsdrvr.c.

Referenced by pcps_wait_busy().

◆ _PCPSDRVR

#define _PCPSDRVR

Definition at line 362 of file pcpsdrvr.c.

◆ DEBUG_ACCESS_TIMING

#define DEBUG_ACCESS_TIMING   0

Definition at line 438 of file pcpsdrvr.c.

◆ DEBUG_IO

#define DEBUG_IO   1

Definition at line 454 of file pcpsdrvr.c.

◆ DEBUG_IO_TIMING

#define DEBUG_IO_TIMING   0

Definition at line 447 of file pcpsdrvr.c.

◆ DEBUG_PORTS

#define DEBUG_PORTS   1

Definition at line 462 of file pcpsdrvr.c.

◆ DEBUG_SERNUM

#define DEBUG_SERNUM   1

Definition at line 470 of file pcpsdrvr.c.

◆ FMT_03X

#define FMT_03X   "%03X"

Definition at line 573 of file pcpsdrvr.c.

Referenced by pcps_detect_isa_devices().

◆ FMT_08X

#define FMT_08X   "%08lX"

Definition at line 574 of file pcpsdrvr.c.

Referenced by pcps_cleanup_device(), and pcps_detect_isa_devices().

◆ FP_FMT

#define FP_FMT   "%p"

◆ MAX_BOOT_TIME_PTP270PEX

#define MAX_BOOT_TIME_PTP270PEX   27

Max. time required for PTP270PEX v1 card to be ready after power-up.

The PTP270PEX cards have an on-board Linux system which must have finished booting before the card can be accessed via the PCI bus. If the card is accessed earlier then the PCI bus and thus the computer may hang.

There are 2 different hardware versions of the PTP270PEX card. PTP270PEX v2 hardware and firmware can flag via a bit in the PCI configuration space when the card is ready, so the driver can just wait until the card has flagged that it's ready.

However, the PTP270PEX v1 hardware doesn't support this, so the driver checks the system uptime and waits until it is greater or equal the maximum time required for a PTP270PEX v1 card to finish booting.

The nominal time is 27 s, but if a firmware update has been submitted then the update is applied first, which takes another few seconds.

See also
wait_ptp270pex_ready
report_uptime

Definition at line 543 of file pcpsdrvr.c.

Referenced by report_uptime(), and wait_ptp270pex_ready().

◆ MBG_TGT_HAS_UPTIME

#define MBG_TGT_HAS_UPTIME   1

Definition at line 638 of file pcpsdrvr.c.

◆ MUST_REPORT_ACCESS_MODE

#define MUST_REPORT_ACCESS_MODE   1

Definition at line 495 of file pcpsdrvr.c.

◆ MUST_REPORT_PROBE_DEVICE_DETAILS

#define MUST_REPORT_PROBE_DEVICE_DETAILS   1

Definition at line 489 of file pcpsdrvr.c.

◆ PCPS_LOG_STD_MSGS

#define PCPS_LOG_STD_MSGS   0

Definition at line 504 of file pcpsdrvr.c.

◆ REPORT_CFG

#define REPORT_CFG   10

Definition at line 409 of file pcpsdrvr.c.

◆ REPORT_CFG_DETAILS

#define REPORT_CFG_DETAILS   1

Definition at line 417 of file pcpsdrvr.c.

◆ REPORT_CFG_LOG_LVL

◆ static_wc

#define static_wc

Definition at line 572 of file pcpsdrvr.c.

Referenced by pcps_release_rsrcs().

◆ TEST_CFG_DETAILS

#define TEST_CFG_DETAILS   0

Definition at line 426 of file pcpsdrvr.c.

◆ TEST_PORT_ACCESS

#define TEST_PORT_ACCESS   0

Definition at line 484 of file pcpsdrvr.c.

◆ USE_CMD_PTR

#define USE_CMD_PTR   1

Definition at line 430 of file pcpsdrvr.c.

◆ USE_USB_MICRO_FRAMES

#define USE_USB_MICRO_FRAMES   0

Definition at line 477 of file pcpsdrvr.c.

Typedef Documentation

◆ PCI_DWORD

typedef unsigned int PCI_DWORD

Definition at line 578 of file pcpsdrvr.c.

Function Documentation

◆ beautify_sernum()

static void beautify_sernum ( char *  s,
size_t  max_len 
)
static

Definition at line 3749 of file pcpsdrvr.c.

References _pcps_ddev_sernum, and str_remove_unprintables().

Referenced by setup_sernum_and_receiver_info().

◆ check_feature()

static void check_feature ( PCPS_DDEV pddev,
ushort  req_rev_num,
PCPS_FEATURES  flag_mask 
)
static

Check the firmware to see if a specific feature is supported.

Some devices provide a specific feature only starting with a specific firmware version, but the device provides no way to test this, so the feature flag in the device structure is set if the firmware has the required version.

Parameters
[in,out]pddevPointer to the device structure
[in]req_rev_numRevision number required for the feature to be supported
[in]flag_maskFlag mask of the feature to be tested

Definition at line 4001 of file pcpsdrvr.c.

References _mbg_kdd_msg_5, _pcps_ddev_fw_rev_num, _pcps_ddev_type_name, PCPS_DEV::cfg, PCPS_DDEV_s::dev, PCPS_DEV_CFG::features, get_pcps_feature_name(), REPORT_CFG_LOG_LVL, and str_empty.

Referenced by pcps_probe_device().

◆ check_receiver_info_and_features()

◆ check_ri_features()

static void check_ri_features ( PCPS_DDEV pddev)
static

Check the receiver info features to see if a specific feature is supported.

Some devices provide a RECEIVER_INFO which provides some flags that can be mapped to the feature flags we use internally, so we scan these features and update the internal features mask accordingly.

Parameters
[in,out]pddevPointer to the device structure

Definition at line 4031 of file pcpsdrvr.c.

References _mbg_kdd_msg_3, _mbg_kdd_msg_4, _pcps_ddev_fw_rev_num, _pcps_ddev_type_name, _ri_addr, PCPS_DEV::cfg, PCPS_DDEV_s::dev, PCPS_DEV_CFG::features, RECEIVER_INFO::features, gps_ri_feature_names, N_GPS_FEATURE, pcps_feature_names, REPORT_CFG_LOG_LVL, and ri_feat_tbl.

Referenced by check_receiver_info_and_features().

◆ check_unknown_sernum()

static void check_unknown_sernum ( char *  s,
size_t  max_len 
)
static

Definition at line 3792 of file pcpsdrvr.c.

Referenced by setup_sernum_and_receiver_info().

◆ dump_receiver_info()

◆ dump_tlv_info()

◆ dump_xfeature_buffer()

◆ get_bus_type_str()

◆ get_pcps_feature_name()

static const char* get_pcps_feature_name ( PCPS_FEATURES  flag_mask)
static

Get the name assigned to one of the PCPS_FEATURE_MASKS flags.

Parameters
[in]flag_maskone of the PCPS_FEATURE_MASKS flags
Returns
The associated feature name, or "unknown"
See also
PCPS_FEATURE_MASKS

Definition at line 3872 of file pcpsdrvr.c.

References N_PCPS_FEATURE_BITS, pcps_feature_names, and str_unkn_braced.

Referenced by check_feature().

◆ mbg_plx_read_pecs_reg()

static int mbg_plx_read_pecs_reg ( struct pci_dev *  pNode,
uint16_t  reg,
uint32_t *  pval 
)
static

Read a dword from a PLX PECS register.

Parameters
[in]pNodeDevice structure
[in]regNumber of the register to read
[out]pvalPointer to a variable to take the value read from the register
Returns
PCI_SUCCESS on success, else one of the PCI BIOS error codes

Definition at line 804 of file pcpsdrvr.c.

References PCI_BAD_REGISTER_NUMB, PCI_SUCCESS, PLX_PECS_MAINDATA, and PLX_PECS_MAININDEX.

Referenced by ptp270pex_can_flag_ready().

◆ pcps_add_rsrc_io()

int pcps_add_rsrc_io ( PCPS_DDEV pddev,
MBG_IOPORT_ADDR_RAW  base,
ulong  num 
)

Add an I/O address range resource to the device structure.

Parameters
[in,out]pddevPointer to the device structure
[in]baseBase address of the I/O address range
[in]numNumber of addresses of the I/O address range
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES

Definition at line 4897 of file pcpsdrvr.c.

References _mbg_kdd_msg_2, _mbg_kdd_msg_4, _pcps_ddev_set_err_flags, MBG_IOPORT_RSRC::base_mapped, MBG_IOPORT_RSRC::base_raw, MBG_ERR_RSRC_ITEM, MBG_LOG_ERR, MBG_LOG_INFO, mbg_map_ioport_rsrc(), mbg_rc_is_error, mbg_strerror(), MBG_SUCCESS, N_PCPS_PORT_RSRC, MBG_IOPORT_RSRC::num, PCPS_RSRC_INFO::num_rsrc_io, PCPS_EF_IO_RSRC_IO, PCPS_RSRC_INFO::port, rsrc_alloc_ports(), and PCPS_DDEV_s::rsrc_info.

◆ pcps_add_rsrc_irq()

int pcps_add_rsrc_irq ( PCPS_DDEV pddev,
int16_t  irq_num 
)

◆ pcps_add_rsrc_mem()

int pcps_add_rsrc_mem ( PCPS_DDEV pddev,
MBG_IOMEM_ADDR_RAW  start,
ulong  len 
)

Add a memory address range resource to the device structure.

Parameters
[in,out]pddevPointer to the device structure
[in]startStart address of the memory range
[in]lenSize of the memory range
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES

Definition at line 4959 of file pcpsdrvr.c.

References _mbg_kdd_msg_2, _mbg_kdd_msg_4, _pcps_ddev_set_err_flags, MBG_IOMEM_RSRC::len, MBG_ERR_RSRC_ITEM, MBG_LOG_ERR, MBG_LOG_INFO, mbg_map_iomem_rsrc(), mbg_rc_is_error, mbg_strerror(), MBG_SUCCESS, PCPS_RSRC_INFO::mem, N_PCPS_MEM_RSRC, PCPS_RSRC_INFO::num_rsrc_mem, PCPS_EF_IO_RSRC_MEM, rsrc_alloc_mem(), PCPS_DDEV_s::rsrc_info, MBG_IOMEM_RSRC::start_mapped, and MBG_IOMEM_RSRC::start_raw.

◆ pcps_alloc_ddev_struc()

static int pcps_alloc_ddev_struc ( PCPS_DDEV **  ppddev)
static

Allocate a device info structure for a device.

On success, the pointer to the device structure is set to the allocated memory for the device structure.

Parameters
[in,out]ppddevAddress of a pointer to a device structure to be allocated
Returns
MBG_SUCCESS on success, or MBG_ERR_NO_MEM if no memory could be allocated
See also
pcps_free_ddev_struc

Definition at line 4744 of file pcpsdrvr.c.

References _mbgddmsg_0, _mbgddmsg_fnc_entry, _mbgddmsg_fnc_exit_chk_mbg_rc, _pcps_kmalloc, DEBUG_DEV_INIT, MBG_ERR_NO_MEM, MBG_LOG_ERR, MBG_SUCCESS, n_ddevs, N_SUPP_DEV_BUS, and pcps_ddev.

Referenced by pcps_init_ddev().

◆ pcps_check_gps_data_size()

static int pcps_check_gps_data_size ( PCPS_DDEV pddev,
uint16_t  count,
const char *  info 
)
static

Determine which interface buffer size is supported.

Parameters
[in]pddevPointer to the device structure
[in]countThe number of bytes to be read according to the data_type
[in]infoAn info string, e.g. the name of the calling function
Returns
MBG_SUCCESS on success, or MBG_ERR_NBYTES if the actual buffer size exceeds the supported size

Definition at line 3170 of file pcpsdrvr.c.

References _mbg_kdd_msg_1, _pcps_ddev_has_gps_data_16, MBG_ERR_NBYTES, MBG_LOG_ERR, MBG_SUCCESS, and PCPS_DDEV_s::size_n_bytes.

Referenced by pcps_read_gps_block().

◆ pcps_check_id()

static int pcps_check_id ( PCPS_DDEV pddev,
const char FAR ref 
)
static

Check an ASCIIZ string for a valid signature.

This function is only used to determine the type of a legacy ISA card. For PCI and USB devices the type can be determined from the device ID.

Parameters
[in]pddevPointer to a device structure
[in]refThe reference signature, i.e. the expected signature at the beginning of the device's firmware ID
Returns
MBG_SUCCESS if a signature was specified and the signature was found, or MBG_ERR_FW_ID if the firmware ID is unknown or invalid

Definition at line 3648 of file pcpsdrvr.c.

References _fstrlen, _fstrncmp, _pcps_ddev_fw_id, MBG_ERR_FW_ID, and MBG_SUCCESS.

Referenced by pcps_probe_device().

◆ pcps_check_pex_irq_unsafe()

static bool pcps_check_pex_irq_unsafe ( PCPS_DDEV pddev,
uint16_t  req_fw_ver,
uint8_t  req_asic_ver_major,
uint8_t  req_asic_ver_minor 
)
static

Check if IRQ usage with a device is unsafe.

A few early PCI Express cards had a problem where usage of IRQs was unsafe. Firmware upgrades are available to fix this. See http://www.meinberg.de/english/info/pex-upgrades.htm

Parameters
[in]pddevPointer to the device structure
[in]req_fw_verRequired firmware version
[in]req_asic_ver_majorRequired ASIC major version
[in]req_asic_ver_minorRequired ASIC major version
Returns
true if IRQ operation is unsafe

Definition at line 1152 of file pcpsdrvr.c.

References _pcps_ddev_asic_version, _pcps_ddev_fw_rev_num, _pcps_pex_irq_is_safe, PCPS_DDEV_s::irq_ack_mask, PCPS_DDEV_s::irq_ack_port, PCPS_DDEV_s::irq_stat_info, and PCPS_IRQ_STAT_UNSAFE.

Referenced by pcps_probe_device().

◆ pcps_chk_dev_feat()

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.

There are different structures where information can be stored if a specific feature is supported. All information is set up when the pcps_probe_device function is called to probe and initialize the device. This generic low-level function can be called by API functions to check if a specific feature is supported.

Parameters
[in]p_ddevPointer to the device structure
[in]feat_typeSee DEV_FEAT_TYPES
[in]feat_numNumber and range depending on feat_type value
Returns
MBG_SUCCESS if the requested feature is supported, MBG_ERR_NOT_SUPP_BY_DEV if not supported, or one of the other MBG_ERROR_CODES
See also
pcps_probe_device

Definition at line 5112 of file pcpsdrvr.c.

References _check_feat_supp_bit, _mbg_kdd_msg_3, _mbgddmsg_4, _mbgddmsg_5, _pcps_ddev_ref_type, MBG_XFEATURE_BUFFER::b, MBG_TLV_FEAT_BUFFER::b, PCPS_DDEV_s::builtin_features, PCPS_DEV::cfg, check_feat_supp_byte_array(), DEBUG_DEV_INIT, PCPS_DDEV_s::dev, DEV_FEAT_TYPE_BUILTIN, DEV_FEAT_TYPE_PCPS, DEV_FEAT_TYPE_REF_TYPE, DEV_FEAT_TYPE_RI, DEV_FEAT_TYPE_TLV_FEAT, DEV_FEAT_TYPE_XFEAT, PCPS_DEV_CFG::features, RECEIVER_INFO::features, MBG_ERR_INV_PARM, MBG_ERR_NOT_SUPP_BY_DEV, MBG_ERR_NOT_SUPP_ON_OS, MBG_LOG_ERR, MBG_LOG_INFO, mbg_posix_errno_to_mbg(), mbg_rc_is_success, mbg_strerror(), MBG_SUCCESS, N_GPS_BUILTIN_FEATURE_BITS, N_GPS_FEATURE, N_MBG_TLV_FEAT_TYPES, N_MBG_XFEATURE, N_PCPS_FEATURE_BITS, N_PCPS_REF, MBG_XDEV_FEATURES::receiver_info, MBG_TLV_INFO::supp_tlv_feat, MBG_XDEV_FEATURES::tlv_info, PCPS_DDEV_s::xdev_features, and MBG_XDEV_FEATURES::xfeature_buffer.

◆ pcps_cleanup_ddev()

void pcps_cleanup_ddev ( PCPS_DDEV pddev)

Clean up and free a previously initialized device info structure.

Parameters
[in]pddevAddress of a device structure to be cleaned up and released
See also
pcps_init_ddev

Definition at line 4845 of file pcpsdrvr.c.

References _mbg_mutex_destroy, _mbgddmsg_fnc_entry, _mbgddmsg_fnc_exit, PCPS_DDEV_s::dev_mutex, and pcps_free_ddev_struc().

◆ pcps_cleanup_device()

◆ pcps_ddev_is_ptp270pex()

static __mbg_inline int pcps_ddev_is_ptp270pex ( const PCPS_DDEV pddev)
static

Check if a device is a PTP270PEX card.

Definition at line 782 of file pcpsdrvr.c.

References _pcps_ddev_dev_id, _pcps_ddev_is_pci, and PCI_DEV_PTP270PEX.

Referenced by pcps_probe_device().

◆ pcps_detect_devices()

void _MBG_INIT_CODE_ATTR pcps_detect_devices ( int  isa_ports[PCPS_MAX_ISA_CARDS],
int  isa_irqs[PCPS_MAX_ISA_CARDS] 
)

Detect all bus-level devices in a non-PnP system.

Note
If a DOS TSR is installed, be sure it is disabled (BUSY flag set) when this function is called.
Parameters
[in]isa_portsAn array with potential I/O base addresses for ISA devices.
[in]isa_irqsAn array with potential IRQ numbers assigned to ISA devices.

Definition at line 6683 of file pcpsdrvr.c.

References pcps_cleanup_ddev(), pcps_detect_devices_init(), and pcps_init_ddev().

◆ pcps_detect_devices_init()

static void _MBG_INIT_CODE_ATTR pcps_detect_devices_init ( PCPS_DDEV_INIT_FNC ddev_init_fnc,
PCPS_DDEV_CLEANUP_FNC ddev_cleanup_fnc,
int  isa_ports[PCPS_MAX_ISA_CARDS],
int  isa_irqs[PCPS_MAX_ISA_CARDS] 
)
static

_PCPS_USE_ISA_PNP

Detect all bus-level devices in a non-PnP system, use specific alloc/cleanup functions

Note
If a DOS TSR is installed, be sure it is disabled (BUSY flag set) when this function is called.
Parameters
[in]ddev_init_fncPointer to function called to allocate a device structure for each detected device.
[in]ddev_cleanup_fncPointer to function called if the device structure needs to be de-allocated in case of error.
[in]isa_portsAn array with potential I/O base addresses for ISA devices.
[in]isa_irqsAn array with potential IRQ numbers assigned to ISA devices.

Definition at line 6647 of file pcpsdrvr.c.

References N_PCPS_DEV_TYPE, PCI_VENDOR_MEINBERG, pcps_detect_isa_devices(), pcps_detect_pci_devices(), and pcps_dev_type.

Referenced by pcps_detect_devices().

◆ pcps_detect_isa_devices()

void pcps_detect_isa_devices ( PCPS_DDEV_INIT_FNC ddev_init_fnc,
PCPS_DDEV_CLEANUP_FNC ddev_cleanup_fnc,
PCPS_DDEV_REGISTER_FNC ddev_register_fnc,
int  isa_ports[PCPS_MAX_ISA_CARDS],
int  isa_irqs[PCPS_MAX_ISA_CARDS] 
)

Detect and initialize ISA devices in a non-PnP system.

Parameters
[in]ddev_init_fncPointer to function called to allocate a device structure for each detected device.
[in]ddev_cleanup_fncPointer to function called if the device structure needs to be de-allocated in case of error.
[in]ddev_register_fncPointer to function called to register a detected device.
[in]isa_portsAn array with potential I/O base addresses for ISA devices.
[in]isa_irqsAn array with potential IRQ numbers assigned to ISA devices.

Definition at line 6559 of file pcpsdrvr.c.

References _mbgddmsg_1, _mbgddmsg_2, PCPS_DEV_TYPE::bus_flags, PCPS_DEV::cfg, DEBUG_DEV_INIT, PCPS_DDEV_s::dev, PCPS_DEV_CFG::err_flags, FMT_03X, FMT_08X, MBG_LOG_INFO, MBG_LOG_WARN, mbg_rc_is_success, pcps_add_rsrc_io(), pcps_add_rsrc_irq(), PCPS_BUS_ISA, PCPS_MAX_ISA_CARDS, PCPS_NUM_PORTS_ISA, pcps_probe_device(), and PCPS_DEV::type.

◆ pcps_dump_data()

void pcps_dump_data ( const void *  buffer,
size_t  count,
const char *  info 
)

Definition at line 1219 of file pcpsdrvr.c.

References _mbg_kdd_msg_2, mbg_kdd_snprintf(), and MBG_LOG_INFO.

◆ pcps_free_ddev_struc()

static void pcps_free_ddev_struc ( PCPS_DDEV **  ppddev)
static

Free a previously allocated device info structure.

The pointer to the device structure is set to NULL after the associated memory has been freed.

Parameters
[in,out]ppddevAddress of a pointer to a device structure to be freed
See also
pcps_alloc_ddev_struc

Definition at line 4704 of file pcpsdrvr.c.

References _mbgddmsg_fnc_entry, _mbgddmsg_fnc_exit, _pcps_kfree, and n_ddevs.

Referenced by pcps_cleanup_ddev().

◆ pcps_get_dev_type_table_entry()

PCPS_DEV_TYPE* pcps_get_dev_type_table_entry ( PCPS_BUS_FLAGS  bus_mask,
PCPS_DEV_ID  dev_id 
)

Lookup a specific device in the device table.

The function below takes a bus flag and device ID to search the table of known devices for a device which matches the given criteria.

Parameters
[in]bus_maskMask of the bus type to look up, see PCPS_BUS_FLAG_MASKS
[in]dev_idThe device ID to lookup, see MEINBERG_PCI_DEVICE_IDS or MBG_USB_DEVICE_IDS, depending on the bus_mask
Returns
A pointer to the device table entry, or NULL if no entry found

Definition at line 4672 of file pcpsdrvr.c.

References PCPS_DEV_TYPE::bus_flags, PCPS_DEV_TYPE::dev_id, N_PCPS_DEV_TYPE, and pcps_dev_type.

◆ pcps_get_fw_id()

static int pcps_get_fw_id ( PCPS_DDEV pddev,
PCPS_ID_STR FAR  fw_id 
)
static

Read the firmware ID from a device.

This is usually done first when probing a device to check if the device is properly installed and can be accessed without problems.

Parameters
[in]pddevPointer to a device structure
[out]fw_idA buffer to be filled withtthe firmware ID
Returns
MBG_SUCCESS if the the signature was found, or signature was specified, or MBG_ERR_FW_ID if the firmware ID is unknown or invalid

Definition at line 3591 of file pcpsdrvr.c.

References _mbgddmsg_1, _mbgddmsg_2, _pcps_ddev_type_name, _pcps_read, DEBUG_DEV_INIT, PCPS_IO_BUFFER::fw_id, PCPS_DDEV_s::io_buffer, MBG_LOG_INFO, mbg_rc_is_error, PCPS_FIFO_SIZE, PCPS_GIVE_FW_ID_1, PCPS_GIVE_FW_ID_2, and PCPS_ID_SIZE.

Referenced by pcps_probe_device().

◆ pcps_get_rev_num()

static PCPS_FW_REV_NUM pcps_get_rev_num ( char FAR idstr)
static

Retrieve a version number from a firmware ID string.

Parameters
[in]idstrThe ID string, e.g. a PCPS_ID_STR
Returns
A version number in hex format, e.g. 0x0270 for version 2.7, or 0 if no version number could be found.

Definition at line 3671 of file pcpsdrvr.c.

References _fstrlen.

Referenced by pcps_probe_device().

◆ pcps_init_ddev()

int pcps_init_ddev ( PCPS_DDEV **  ppddev)

Allocate and initialize a device info structure.

On success, the pointer to the device structure is set to the device structure, and the device structure has been initialized.

Parameters
[in,out]ppddevAddress of a pointer to a device structure to be allocated and initialized
Returns
MBG_SUCCESS on success, or MBG_ERR_NO_MEM if no memory could be allocated
See also
pcps_cleanup_ddev

Definition at line 4799 of file pcpsdrvr.c.

References _mbg_mutex_init, _mbg_spin_lock_init, _mbgddmsg_fnc_entry, _mbgddmsg_fnc_exit_chk_mbg_rc, PCPS_DDEV_s::dev_mutex, MBG_DRVR_NAME, mbg_rc_is_success, and pcps_alloc_ddev_struc().

◆ pcps_init_gps_transfer()

static int pcps_init_gps_transfer ( PCPS_DDEV pddev,
uint8_t  cmd,
uint8_t  data_type,
uint16_t  count,
const char *  info 
)
static

Initialize GPS data transfer.

Parameters
[in]pddevPointer to the device structure
[in]cmdPCPS_READ_GPS_DATA or PCPS_WRITE_GPS_DATA
[in]data_typeThe code assigned to the data type, see PC_GPS_CMD_CODES
[in]countThe number of bytes to be read according to the data_type
[in]infoAn info string, e.g. the name of the calling function
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES

Definition at line 3215 of file pcpsdrvr.c.

References _mbg16_to_cpu, _mbg_kdd_msg_1, _mbg_kdd_msg_2, _mbg_kdd_msg_3, _pcps_read, _pcps_read_var, MBG_ERR_INV_TYPE, MBG_ERR_NBYTES, MBG_ERR_NOT_READY, MBG_LOG_DEBUG, MBG_LOG_ERR, MBG_LOG_WARN, mbg_rc_is_error, PCPS_DDEV_s::n_bytes, PCPS_DDEV_s::size_n_bytes, and PCPS_DDEV_s::uc.

Referenced by pcps_read_gps_block().

◆ pcps_probe_device()

int pcps_probe_device ( PCPS_DDEV pddev,
PCPS_BUS_NUM  bus_num,
PCPS_SLOT_NUM  dev_fnc_num 
)

Probe if a device is supported, and allocate and setup the device structure.

This function should be called by the probe routine of any target-specific kernel driver. If the device is supported then all specific information including supported features is read from the device and stored in sub-structures of the device structure addressed by pdev.

Parameters
[in,out]pddevPointer to the device structure which has been initialized and will be set up
[in]bus_numThe bus number if supported (e.g. PCI), else 0
[in]dev_fnc_numThe device/function number if supported (e.g. PCI), else 0
Returns
MBG_SUCCESS if the requested feature is supported, MBG_ERR_NOT_SUPP_BY_DEV if not supported, or one of the other MBG_ERROR_CODES
See also
pcps_cleanup_device
pcps_chk_dev_feat

Definition at line 5409 of file pcpsdrvr.c.

References _convert_asic_version_number, _mbg_inp16_to_cpu, _mbg_inp32_to_cpu, _mbg_kdd_msg_0, _mbg_kdd_msg_1, _mbg_kdd_msg_2, _mbg_kdd_msg_3, _mbg_kdd_msg_4, _mbg_mmrd32_to_cpu, _mbg_mutex_init, _mbg_spin_lock_init, _mbgddmsg_1, _mbgddmsg_3, _mbgddmsg_fnc_entry, _pcps_asic_version_greater_equal, _pcps_asic_version_major, _pcps_ddev_access_mode_io, _pcps_ddev_access_mode_mm, _pcps_ddev_asic_version, _pcps_ddev_bus_flags, _pcps_ddev_chk_err_flags, _pcps_ddev_dev_id, _pcps_ddev_err_flags, _pcps_ddev_features, _pcps_ddev_fw_id, _pcps_ddev_fw_rev_num, _pcps_ddev_has_asic_features, _pcps_ddev_has_asic_version, _pcps_ddev_io_base_mapped, _pcps_ddev_io_base_raw, _pcps_ddev_is_isa, _pcps_ddev_is_pci_amcc, _pcps_ddev_is_pci_asic, _pcps_ddev_is_pci_mbgpex, _pcps_ddev_is_pci_pex8311, _pcps_ddev_is_usb, _pcps_ddev_pci_cfg_err, _pcps_ddev_set_err_flags, _pcps_ddev_short_port_base, _pcps_ddev_type_name, _pcps_ddev_type_num, _pcps_read, AMCC_INT_ACK, AMCC_INT_ENB, AMCC_INT_FLAG, AMCC_INT_MASK, AMCC_OP_REG_IMB4, AMCC_OP_REG_INTCSR, AMCC_OP_REG_RANGE_S5920, AMCC_OP_REG_RANGE_S5933, PCPS_DDEV_s::asic_features, PCPS_DDEV_s::asic_version, MBG_IOPORT_RSRC::base_mapped, MBG_IOPORT_RSRC::base_raw, BUILTIN_FEAT_FRC511PEX, BUILTIN_FEAT_GLN180PEX, BUILTIN_FEAT_GNS181PEX, BUILTIN_FEAT_GPS167PC, BUILTIN_FEAT_GPS167PCI, BUILTIN_FEAT_GPS168PCI, BUILTIN_FEAT_GPS169PCI, BUILTIN_FEAT_GPS170PCI, BUILTIN_FEAT_GPS170PEX, BUILTIN_FEAT_GPS180AMC, BUILTIN_FEAT_GPS180PEX, BUILTIN_FEAT_PTP270PEX, BUILTIN_FEAT_PZF180PEX, BUILTIN_FEAT_TCR167PCI, BUILTIN_FEAT_TCR170PEX, BUILTIN_FEAT_TCR180PEX, BUILTIN_FEAT_TCR180USB, BUILTIN_FEAT_UNDEFINED, BUILTIN_FEAT_WWVB511, PCPS_DDEV_s::builtin_features, PCPS_DEV_CFG::bus_num, PCPS_DEV::cfg, check_feature(), check_receiver_info_and_features(), DEBUG_DEV_INIT, PCPS_DDEV_s::dev, PCPS_DEV_TYPE::dev_id, PCPS_DDEV_s::dev_mutex, PCI_ASIC::features, PCPS_DEV_CFG::features, force_io_access, force_mm16_access, PCPS_DEV_CFG::fw_id, fw_id_ref_gps, fw_id_ref_pcps, PCPS_DEV_CFG::fw_rev_num, PCPS_TIME::hour, PCPS_DDEV_s::io_buffer, PCPS_RSRC_INFO::irq, PCPS_DDEV_s::irq_ack_mask, PCPS_DDEV_s::irq_ack_port, PCPS_DDEV_s::irq_disb_mask, PCPS_DDEV_s::irq_enb_disb_port, PCPS_DDEV_s::irq_enb_mask, PCPS_DDEV_s::irq_flag_mask, PCPS_DDEV_s::irq_flag_port, PCPS_DEV_CFG::irq_num, MBG_DRVR_NAME, MBG_ERR_GENERIC, mbg_get_pc_cycles_frequency(), mbg_get_sys_uptime(), MBG_LOG_DEBUG, MBG_LOG_ERR, MBG_LOG_INFO, MBG_LOG_WARN, mbg_rc_is_error, mbg_rc_is_success, mbg_sleep_sec(), MBG_SUCCESS, PCPS_TIME::mday, PCPS_RSRC_INFO::mem, PCPS_TIME::min, PCPS_DDEV_s::mm_asic_addr, PCPS_TIME::month, N_PCPS_PORT_RSRC, MBG_IOPORT_RSRC::num, MBG_IRQ_RSRC::num, PCPS_RSRC_INFO::num_rsrc_io, PCPS_RSRC_INFO::num_rsrc_irq, PCPS_RSRC_INFO::num_rsrc_mem, PCPS_TIME::offs_utc, pc_cycles_frequency, PCI_ASIC_FIX_IRQ_MINOR_GPS170PEX, PCI_ASIC_FIX_IRQ_MINOR_PEX511, PCI_ASIC_FIX_IRQ_MINOR_TCR511PEX, PCI_ASIC_HAS_MM_IO, PCI_ASIC_HR_TIME_MINOR_PEX511, PCI_ASIC_MAJOR_GPS170PEX, PCI_ASIC_MAJOR_PCI_0, PCI_ASIC_MAJOR_PEX511, PCI_ASIC_MAJOR_TCR511PEX, PCI_ASIC_PCI_IRQF, PCPS_ACC_MODE_IO, PCPS_ACC_MODE_MM, PCPS_ACC_MODE_MM16, PCPS_ACC_MODE_NULL, PCPS_ACC_MODE_USB, PCPS_BUS_ISA, PCPS_BUS_MCA, PCPS_BUS_PCI_ASIC, PCPS_BUS_PCI_MBGPEX, PCPS_BUS_PCI_PEX8311, PCPS_BUS_PCI_S5920, PCPS_BUS_PCI_S5933, PCPS_BUS_USB, PCPS_BUS_USB_V2, PCPS_CAN_CLR_UCAP_BUFF, PCPS_CAN_SET_TIME, pcps_check_id(), pcps_check_pex_irq_unsafe(), pcps_cleanup_device(), pcps_ddev_is_ptp270pex(), pcps_dev_type, PCPS_EF_INV_FW_ID, PCPS_EF_IO_ENB, PCPS_EF_IO_INIT, PCPS_EF_TIMEOUT, PCPS_FEAT_DCF600USB, PCPS_FEAT_FRC511PEX, PCPS_FEAT_GLN180PEX, PCPS_FEAT_GNS181PEX, PCPS_FEAT_GPS167PC, PCPS_FEAT_GPS167PCI, PCPS_FEAT_GPS168PCI, PCPS_FEAT_GPS169PCI, PCPS_FEAT_GPS170PCI, PCPS_FEAT_GPS170PEX, PCPS_FEAT_GPS180AMC, PCPS_FEAT_GPS180PEX, PCPS_FEAT_MSF51USB, PCPS_FEAT_MSF600USB, PCPS_FEAT_PC31PS31, PCPS_FEAT_PC32, PCPS_FEAT_PCI32, PCPS_FEAT_PCI509, PCPS_FEAT_PCI510, PCPS_FEAT_PCI511, PCPS_FEAT_PEX511, PCPS_FEAT_PTP270PEX, PCPS_FEAT_PZF180PEX, PCPS_FEAT_TCR167PCI, PCPS_FEAT_TCR170PEX, PCPS_FEAT_TCR180PEX, PCPS_FEAT_TCR180USB, PCPS_FEAT_TCR510PCI, PCPS_FEAT_TCR511PCI, PCPS_FEAT_TCR511PEX, PCPS_FEAT_TCR51USB, PCPS_FEAT_TCR600USB, PCPS_FEAT_USB5131, PCPS_FEAT_WVB600USB, PCPS_FEAT_WWVB51USB, pcps_get_fw_id(), pcps_get_rev_num(), PCPS_GIVE_TIME, PCPS_HAS_CABLE_LEN, PCPS_HAS_FAST_HR_TSTAMP, PCPS_HAS_GPS_DATA_16, PCPS_HAS_HR_TIME, PCPS_HAS_IRIG_CTRL_BITS, PCPS_HAS_IRIG_TIME, PCPS_HAS_RAW_IRIG_DATA, PCPS_HAS_SERIAL, PCPS_HAS_SYNC_TIME, PCPS_HAS_UCAP, PCPS_HAS_UTC_OFFS, pcps_read_amcc_s5920, pcps_read_amcc_s5933, pcps_read_asic, pcps_read_null, pcps_read_std, PCPS_IO_BUFFER::pcps_time, PCPS_TIMEOUT_CNT, PCPS_TYPE_DCF600USB, PCPS_TYPE_FRC511PEX, PCPS_TYPE_GLN180PEX, PCPS_TYPE_GNS181PEX, PCPS_TYPE_GPS167PC, PCPS_TYPE_GPS167PCI, PCPS_TYPE_GPS168PCI, PCPS_TYPE_GPS169PCI, PCPS_TYPE_GPS170PCI, PCPS_TYPE_GPS170PEX, PCPS_TYPE_GPS180AMC, PCPS_TYPE_GPS180PEX, PCPS_TYPE_MSF51USB, PCPS_TYPE_MSF600USB, PCPS_TYPE_PC31, PCPS_TYPE_PC32, PCPS_TYPE_PCI32, PCPS_TYPE_PCI509, PCPS_TYPE_PCI510, PCPS_TYPE_PCI511, PCPS_TYPE_PEX511, PCPS_TYPE_PS31, PCPS_TYPE_PS31_OLD, PCPS_TYPE_PTP270PEX, PCPS_TYPE_PZF180PEX, PCPS_TYPE_TCR167PCI, PCPS_TYPE_TCR170PEX, PCPS_TYPE_TCR180PEX, PCPS_TYPE_TCR180USB, PCPS_TYPE_TCR510PCI, PCPS_TYPE_TCR511PCI, PCPS_TYPE_TCR511PEX, PCPS_TYPE_TCR51USB, PCPS_TYPE_TCR600USB, PCPS_TYPE_USB5131, PCPS_TYPE_WVB600USB, PCPS_TYPE_WWVB51USB, PLX_LCS_INTCSR, PLX_LCS_INTCSR_INT_ENB, PLX_LCS_INTCSR_INT_FLAG, PCPS_DEV_CFG::port, PCPS_RSRC_INFO::port, PCPS_DDEV_s::raw_asic_version, PCI_ASIC::raw_version, report_access_mode(), report_probe_device(), REV_CAN_CLR_UCAP_BUFF_GPS167PCI, REV_CAN_CLR_UCAP_BUFF_GPS168PCI, REV_CAN_SET_TIME_PC31PS31, REV_HAS_CABLE_LEN_GPS167PC, REV_HAS_CABLE_LEN_GPS167PCI, REV_HAS_GPS_DATA_16_GPS169PCI, REV_HAS_HR_TIME_GPS167PC, REV_HAS_HR_TIME_PCI511, REV_HAS_HR_TIME_PEX511, REV_HAS_HR_TIME_TCR510PCI, REV_HAS_IRIG_CTRL_BITS_TCR511PCI, REV_HAS_IRIG_CTRL_BITS_TCR511PEX, REV_HAS_IRIG_CTRL_BITS_TCR51USB, REV_HAS_IRIG_TIME_TCR511PCI, REV_HAS_IRIG_TIME_TCR511PEX, REV_HAS_IRIG_TIME_TCR51USB, REV_HAS_IRQ_FIX_MINOR_GPS170PEX, REV_HAS_IRQ_FIX_MINOR_PEX511, REV_HAS_IRQ_FIX_MINOR_TCR511PEX, REV_HAS_RAW_IRIG_DATA_TCR511PCI, REV_HAS_RAW_IRIG_DATA_TCR511PEX, REV_HAS_RAW_IRIG_DATA_TCR51USB, REV_HAS_SERIAL_PC31PS31, REV_HAS_SYNC_TIME_PC31PS31, REV_HAS_UCAP_GPS167PCI, REV_HAS_UCAP_GPS168PCI, REV_HAS_UTC_OFFS_PC31PS31, PCPS_DDEV_s::rsrc_info, rsrc_port_to_cfg_port(), PCPS_TIME::sec, PCPS_TIME::sec100, set_access_mode(), setup_mm_addr(), setup_sernum_and_receiver_info(), PCPS_DEV_CFG::short_status_port, PCPS_TIME::signal, PCPS_DEV_CFG::slot_num, PCPS_TIME::status, PCPS_DDEV_s::status_port, PCPS_DDEV_s::status_port_offs, str_empty, PCPS_DEV_CFG::timeout_clk, PCPS_DEV::type, wait_ptp270pex_ready(), PCPS_TIME::wday, and PCPS_TIME::year.

◆ pcps_read_amcc_s5920()

static int pcps_read_amcc_s5920 ( PCPS_DDEV pddev,
uint8_t  cmd,
void FAR buffer,
uint16_t  count 
)
static

Read function for devices with AMCC S5920 PCI interface chip.

Parameters
[in]pddevPointer to the device structure
[in]cmdThe command code for the board, see PCPS_CMD_CODES
[out]bufferA buffer to take the bytes to be read
[in]countThe number of bytes to be read into the buffer
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES
See also
Device read functions

Definition at line 2324 of file pcpsdrvr.c.

References _mbg_inp32_native, _mbg_outp8, _mbg_put_unaligned, _pcps_ddev_io_base_mapped, _pcps_ddev_read_status_port(), _pcps_disb_local_irq_save, _pcps_irq_flags, _pcps_local_irq_restore, PCPS_DDEV_s::acc_cycles, AMCC_OP_REG_OMB, BYTE_OF, FAR, mbg_get_pc_cycles(), mbg_rc_is_error, pcps_dump_data(), pcps_wait_busy(), report_io_cmd(), and report_ret_val().

◆ pcps_read_amcc_s5933()

static int pcps_read_amcc_s5933 ( PCPS_DDEV pddev,
uint8_t  cmd,
void FAR buffer,
uint16_t  count 
)
static

Read function for devices with AMCC S5933 PCI interface chip.

Parameters
[in]pddevPointer to the device structure
[in]cmdThe command code for the board, see PCPS_CMD_CODES
[out]bufferA buffer to take the bytes to be read
[in]countThe number of bytes to be read into the buffer
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES
See also
Device read functions

Definition at line 2201 of file pcpsdrvr.c.

References _mbg_inp16_to_cpu, _mbg_inp8, _mbg_outp8, _pcps_ddev_io_base_mapped, _pcps_ddev_read_status_port(), _pcps_disb_local_irq_save, _pcps_irq_flags, _pcps_local_irq_restore, PCPS_DDEV_s::acc_cycles, AMCC_OP_REG_FIFO, AMCC_OP_REG_INTCSR, AMCC_OP_REG_MCSR, AMCC_OP_REG_OMB1, FAR, MBG_ERR_NO_DATA, mbg_get_pc_cycles(), mbg_rc_is_error, pcps_dump_data(), pcps_wait_busy(), report_io_cmd(), and report_ret_val().

◆ pcps_read_asic()

static int pcps_read_asic ( PCPS_DDEV pddev,
uint8_t  cmd,
void FAR buffer,
uint16_t  count 
)
static

Read function for devices with Meinberg PCI interface ASIC.

Parameters
[in]pddevPointer to the device structure
[in]cmdThe command code for the board, see PCPS_CMD_CODES
[out]bufferA buffer to take the bytes to be read
[in]countThe number of bytes to be read into the buffer
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES
See also
::pcps_read_asic_mm
::pcps_read_asic_mm16
Device read functions

Definition at line 2470 of file pcpsdrvr.c.

References _mbg_inp32_native, _mbg_inp32_to_cpu, _mbg_outp32_to_mbg, _mbg_put_unaligned, _pcps_ddev_io_base_mapped, _pcps_disb_local_irq_save, _pcps_irq_flags, _pcps_local_irq_restore, PCPS_DDEV_s::acc_cycles, PCI_ASIC_REG::b, FAR, mbg_get_pc_cycles(), mbg_rc_is_error, pcps_dump_data(), pcps_wait_busy(), report_io_cmd(), report_ret_val(), and PCI_ASIC_REG::ul.

◆ pcps_read_gps_block()

static int pcps_read_gps_block ( PCPS_DDEV pddev,
uint8_t  data_type,
void FAR buffer,
uint16_t  count,
uint8_t  block_num,
uint8_t  block_size 
)
static

Get a block of data from a GPS device.

This static function is used by pcps_read_gps.

Parameters
[in]pddevPointer to the device structure
[in]data_typeThe code assigned to the data type, see PC_GPS_CMD_CODES
[out]bufferA buffer with data to be read according to the data_type
[in]countThe number of bytes to be read according to the data_type
[in]block_numA buffer with data to be written according to the type code
[in]block_sizeThe number of bytes to be written according to the type code
Returns
MBG_SUCCESS on success, MBG_ERR_TIMEOUT if device didn't respond in time, MBG_ERR_INV_TYPE if the device didn_t recognize the data type, MBG_ERR_NBYTES if the number of parameter bytes did not match the number of data bytes expected by the device, or one of the other MBG_RETURN_CODES

Definition at line 3342 of file pcpsdrvr.c.

References _mbg_kdd_msg_3, _mbg_kdd_msg_4, _pcps_ddev_is_usb, _pcps_read, FAR, MBG_LOG_DEBUG, mbg_rc_is_error, MBG_SUCCESS, pcps_check_gps_data_size(), PCPS_FIFO_SIZE, pcps_init_gps_transfer(), pcps_read_gps, PCPS_READ_GPS_DATA, report_ret_val(), and PCPS_DDEV_s::size_n_bytes.

◆ pcps_read_null()

static int pcps_read_null ( PCPS_DDEV pddev,
uint8_t  cmd,
void FAR buffer,
uint16_t  count 
)
static

Dummy read function.

Used if a clock is not properly initialized, in order to avoid I/O access on unspecified ports.

Parameters
[in]pddevPointer to the device structure
[in]cmdThe command code for the board, see PCPS_CMD_CODES
[out]bufferA buffer to take the bytes to be read
[in]countThe number of bytes to be read into the buffer
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES
See also
Device read functions

Definition at line 2059 of file pcpsdrvr.c.

References MBG_ERR_TIMEOUT.

◆ pcps_read_std()

static int pcps_read_std ( PCPS_DDEV pddev,
uint8_t  cmd,
void FAR buffer,
uint16_t  count 
)
static

Read function for devices with ISA or micro channel bus.

Parameters
[in]pddevPointer to the device structure
[in]cmdThe command code for the board, see PCPS_CMD_CODES
[out]bufferA buffer to take the bytes to be read
[in]countThe number of bytes to be read into the buffer
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES
See also
Device read functions

Definition at line 2091 of file pcpsdrvr.c.

References _mbg_inp8, _mbg_outp8, _pcps_ddev_io_base_mapped, _pcps_ddev_read_status_port(), _pcps_disb_local_irq_save, _pcps_irq_flags, _pcps_local_irq_restore, PCPS_DDEV_s::acc_cycles, FAR, mbg_get_pc_cycles(), mbg_rc_is_error, pcps_dump_data(), pcps_wait_busy(), report_io_cmd(), and report_ret_val().

◆ pcps_release_rsrcs()

◆ pcps_wait_busy()

__mbg_inline int pcps_wait_busy ( PCPS_DDEV pddev)

Wait as long as a device is busy, or until timeout.

Used by the Device read functions to wait after the command byte has been written until the requested data has been made available by the device.

Parameters
[in]pddevPointer to the device structure
Returns
MBG_SUCCESS on success, or MBG_ERR_TIMEOUT
See also
Device read functions

Definition at line 1981 of file pcpsdrvr.c.

References _pcps_ddev_status_busy, _pcps_ddev_timeout_clk, _pcps_time_after, clock, MBG_ERR_TIMEOUT, and MBG_SUCCESS.

◆ ptp270pex_can_flag_ready()

static bool ptp270pex_can_flag_ready ( const PCPS_DDEV pddev)
static

Check if a PTP270PEX card can indicate when it's ready.

A PTP270PEX card must be accessed by the driver only after it has finished booting. Otherwise the host system may be locked up.

On HW v2 cards the firmware can indicate when the card is ready to be accessed, so this can be checked by the driver. On these cards the on-board GPIO3 pin is hardwired to 0 to indicate this is supported, whereas on older v1 cards the GPIO3 pin is pulled up to 1.

Parameters
[in]pddevPointer to the device structure
Returns
true if the card can flag "ready"
See also
ptp270pex_has_flagged_ready

Definition at line 869 of file pcpsdrvr.c.

References _mbg_kdd_msg_1, _mbg_kdd_msg_3, _pcps_ddev_type_name, PCPS_DEV_CFG::bus_num, PCPS_DEV::cfg, PCPS_DDEV_s::dev, MBG_LOG_DEBUG, mbg_plx_read_pecs_reg(), PCI_DEVICE_ID_PLX_8111, PCI_SUCCESS, PLX_PECS_GPIOCTL, and PLX_PECS_GPIOCTL_GPIO3_DATA.

Referenced by wait_ptp270pex_ready().

◆ ptp270pex_has_flagged_ready()

static bool ptp270pex_has_flagged_ready ( const PCPS_DDEV pddev)
static

Check if a PTP270PEX card indicates it is ready.

A PTP270PEX card must be accessed by the driver only after it has finished booting. Otherwise the host system may be locked up.

On HW v2 cards the firmware can indicate when the card is ready to be accessed, so the driver can call this function to check this.

Note
The function ptp270pex_can_flag_ready should have been called before to check if the card actually supports this.
Parameters
[in]pddevPointer to the device structure
Returns
true if the card has flagged "ready"
See also
ptp270pex_can_flag_ready

Definition at line 979 of file pcpsdrvr.c.

References _mbg_inp32_to_cpu, _pcps_ddev_io_base_mapped, PLX_LCS_CNTRL, and PLX_LCS_CNTRL_USERI.

Referenced by wait_ptp270pex_ready().

◆ report_access_mode()

◆ report_io_cmd()

◆ report_probe_device()

◆ report_ret_val()

◆ report_uptime()

static void report_uptime ( const MBG_SYS_UPTIME p_uptime)
static

Report the system uptime.

This is mainly used for debugging, and informational.

Parameters
[in]p_uptimeThe system uptime
See also
wait_ptp270pex_ready
MAX_BOOT_TIME_PTP270PEX

Definition at line 1011 of file pcpsdrvr.c.

References _mbg_kdd_msg_1, _mbg_kdd_msg_2, MAX_BOOT_TIME_PTP270PEX, and MBG_LOG_INFO.

Referenced by wait_ptp270pex_ready().

◆ rsrc_port_to_cfg_port()

static void rsrc_port_to_cfg_port ( PCPS_SHORT_PORT_RSRC p_short_port_rsrc,
const MBG_IOPORT_RSRC p_io_rsrc 
)
static

Convert a raw I/O base address to a short format.

See notes for PCPS_SHORT_PORT_RSRC.

Parameters
[out]p_short_port_rsrcPointer to a variable that takes up the converted address
[in]p_io_rsrcPointer to a variable with the address to be converted

Definition at line 4878 of file pcpsdrvr.c.

References PCPS_SHORT_PORT_RSRC::base, MBG_IOPORT_RSRC::base_raw, MBG_IOPORT_RSRC::num, and PCPS_SHORT_PORT_RSRC::num.

Referenced by pcps_probe_device().

◆ set_access_mode()

static void set_access_mode ( PCPS_DDEV pddev,
uint  mode,
bool  forced,
PCPS_READ_FNC read_fnc 
)
static

◆ setup_mm_addr()

static int setup_mm_addr ( PCPS_DDEV pddev)
static

Setup the memory mapped addresses depending on the device type.

Parameters
[in]pddevPointer to the device structure
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES

Definition at line 1183 of file pcpsdrvr.c.

References _mbg_kdd_msg_1, _pcps_ddev_is_pci_mbgpex, _pcps_ddev_is_pci_pex8311, FAR, MBG_LOG_INFO, MBG_SUCCESS, PCPS_RSRC_INFO::mem, PCPS_DDEV_s::mm_asic_addr, PCPS_DDEV_s::mm_tstamp_addr, PCPS_DDEV_s::rsrc_info, and MBG_IOMEM_RSRC::start_mapped.

Referenced by pcps_probe_device().

◆ setup_sernum_and_receiver_info()

◆ str_remove_unprintables()

static bool str_remove_unprintables ( char *  s,
size_t  max_len 
)
static

Remove unprintable characters from a string.

Parameters
[in,out]sPointer to the string.
[in]max_lenSize of the string buffer.
Returns
true if any unprintable characters have been removed, else false

Definition at line 3716 of file pcpsdrvr.c.

Referenced by beautify_sernum().

◆ wait_ptp270pex_ready()

static void wait_ptp270pex_ready ( const PCPS_DDEV pddev)
static

Wait until a PTP270PEX card is ready after power-up.

A PTP270PEX card must be accessed by the driver only after it has finished booting. Otherwise the host system may be locked up.

Parameters
[in]pddevPointer to the device structure
See also
ptp270pex_can_flag_ready
ptp270pex_has_flagged_ready
report_uptime
MAX_BOOT_TIME_PTP270PEX

Definition at line 1065 of file pcpsdrvr.c.

References _mbg_kdd_msg_2, MAX_BOOT_TIME_PTP270PEX, mbg_delta_sys_time_ms(), mbg_get_sys_time(), mbg_get_sys_uptime(), MBG_LOG_INFO, mbg_sleep_sec(), ptp270pex_can_flag_ready(), ptp270pex_has_flagged_ready(), and report_uptime().

Referenced by pcps_probe_device().

Variable Documentation

◆ gps_ri_feature_names

const char* gps_ri_feature_names[N_GPS_FEATURE] = { "Pulse Per Second", "Pulse Per Minute", "Programmable Synth.", "DCF77 Time Marks", "IRIG Out", "IRIG In", "IPv4 LAN Interface", "Multiple Ref. Sources", "Receive Timeout", "Ignore Lock", "5 MHz Output", "Ext. Multiple Ref. Src. Cfg.", "Optional Settings", "Configurable Time Scale", "IRIG Control Bits", "PTP/IEEE1588", "Nav. Engine Settings", "Raw IRIG Data", "Raw IRIG Time", "PTP/IEEE1588 Unicast", "General Purpose I/O", "Multiple XMRS Instances", "10 MHz Output Disabled", "Event Logging", "IMS data", "HaveQuick", "NTP", "Ext. Network Config", "Versatile Storage", "SHS", "Extended Binary Protocol", "Extended Features" }
static

A table of name strings associated with GPS_FEATURE_BITS.

Definition at line 733 of file pcpsdrvr.c.

Referenced by check_ri_features().

◆ pc_cycles_frequency

MBG_PC_CYCLES_FREQUENCY pc_cycles_frequency
static

Clock frequency of the PC's cycles counter, in [Hz].

An attempt to determine this value is made at the beginning of the pcps_probe_device routine. If the cycles frequency value is 0 then the target system doesn't supported this, or the value couldn't be determined. In this case it's not possible to convert a number of cycles to an associatred time interval.

Definition at line 661 of file pcpsdrvr.c.

Referenced by pcps_probe_device(), report_io_cmd(), and report_ret_val().

◆ pcps_feature_names

const char* pcps_feature_names[N_PCPS_FEATURE_BITS] = PCPS_FEATURE_NAMES
static

A table of name strings associated with PCPS_FEATURE_BITS.

Definition at line 744 of file pcpsdrvr.c.

Referenced by check_ri_features(), and get_pcps_feature_name().

◆ pcps_read_gps

PCPS_READ_FNC pcps_read_gps

Definition at line 3468 of file pcpsdrvr.c.

◆ pcps_write

PCPS_WRITE_FNC pcps_write

Definition at line 3020 of file pcpsdrvr.c.

◆ pcps_write_gps

PCPS_WRITE_FNC pcps_write_gps

Definition at line 3573 of file pcpsdrvr.c.

◆ ri_feat_tbl

uint32_t ri_feat_tbl[N_GPS_FEATURE]
static

A table used to map RECEIVER_INFO::features to PCPS_DEV_CFG::features.

The enumerated GPS_FEATURE_BITS can be used as index to this table, and the table entry contains a combination of associated PCPS_FEATURE_MASKS, if there are any.

Note
Devices which support a configurable time scale do also support reading/writing the GPS UTC parameters via the PC bus. This is not explicitly coded in the RECEIVER_INFO::features since the the RECEIVER_INFO structure can also be read via the serial port, and reading/writing the GPS UTC parameters via the serial port is supported by all GPS devices anyway.
Devices which support reading MBG_RAW_IRIG_DATA via the PC bus interface also support reading PCPS_IRIG_TIME. However, there is no associated flag in RECEIVER_INFO::features since this call is not supported via the serial interface. Thus we use the GPS_HAS_RAW_IRIG_DATA flag to check both features.
See also
GPS_FEATURE_BITS
PCPS_FEATURE_MASKS

Definition at line 688 of file pcpsdrvr.c.

Referenced by check_ri_features().

◆ str_empty

const char str_empty[] = ""
static

Definition at line 642 of file pcpsdrvr.c.

Referenced by check_feature(), pcps_probe_device(), and report_ret_val().

◆ str_spc_gps

const char str_spc_gps[] = " GPS"
static

Definition at line 646 of file pcpsdrvr.c.

Referenced by report_ret_val().

◆ str_unkn_braced

const char str_unkn_braced[] = "(unknown)"
static