296 #if !defined( MBG_TGT_KERNEL ) 300 #if defined( MBG_TGT_LINUX ) 302 #if !defined( MBG_TGT_KERNEL ) 306 #elif defined( MBG_TGT_FREEBSD ) 308 #if defined( MBG_TGT_KERNEL ) 309 #include <sys/sysproto.h> 310 #include <sys/pcpu.h> 311 #include <sys/param.h> 312 #include <sys/systm.h> 313 #include <sys/proc.h> 316 #include <sys/time.h> 319 #elif defined( MBG_TGT_NETBSD ) 321 #if !defined( MBG_TGT_KERNEL ) 323 #include <sys/time.h> 326 #elif defined( MBG_TGT_QNX_NTO ) 330 #elif defined( MBG_TGT_DOS ) 339 #if defined( _USE_PACK ) 340 #if !defined( _NO_USE_PACK_INTF ) 341 #pragma pack( 1 ) // set byte alignment 342 #define _USING_BYTE_ALIGNMENT 347 #if defined( MBG_TGT_LINUX ) 349 #define MBG_TGT_SUPP_MEM_ACC 1 351 #elif defined( MBG_TGT_BSD ) 353 #define MBG_TGT_SUPP_MEM_ACC 1 355 #elif defined( MBG_TGT_WIN32 ) 357 #define MBG_TGT_SUPP_MEM_ACC 1 359 #elif defined( MBG_TGT_DOS ) 364 #if !defined( MBG_TGT_SUPP_MEM_ACC ) 365 #define MBG_TGT_SUPP_MEM_ACC 0 394 #define _mbg_swab_mbg_sys_time_cycles( _p ) \ 397 _mbg_swab_mbg_pc_cycles( &(_p)->cyc_before ); \ 398 _mbg_swab_mbg_pc_cycles( &(_p)->cyc_after ); \ 399 _mbg_swab_mbg_sys_time( &(_p)->sys_time ); \ 413 #define PCPS_BUS_ISA 0x0001 414 #define PCPS_BUS_MCA 0x0002 415 #define PCPS_BUS_PCI 0x0004 416 #define PCPS_BUS_USB 0x0008 424 #define PCPS_BUS_PCI_CHIP_S5920 0x8000 425 #define PCPS_BUS_PCI_CHIP_ASIC 0x4000 426 #define PCPS_BUS_PCI_CHIP_PEX8311 0x2000 427 #define PCPS_BUS_PCI_CHIP_MBGPEX 0x1000 430 #define PCPS_BUS_PCI_S5933 ( PCPS_BUS_PCI ) 431 #define PCPS_BUS_PCI_S5920 ( PCPS_BUS_PCI | PCPS_BUS_PCI_CHIP_S5920 ) 432 #define PCPS_BUS_PCI_ASIC ( PCPS_BUS_PCI | PCPS_BUS_PCI_CHIP_ASIC ) 433 #define PCPS_BUS_PCI_PEX8311 ( PCPS_BUS_PCI | PCPS_BUS_PCI_CHIP_PEX8311 ) 434 #define PCPS_BUS_PCI_MBGPEX ( PCPS_BUS_PCI | PCPS_BUS_PCI_CHIP_MBGPEX ) 441 #define PCPS_BUS_USB_FLAG_V2 0x8000 444 #define PCPS_BUS_USB_V2 ( PCPS_BUS_USB | PCPS_BUS_USB_FLAG_V2 ) 496 #define PCPS_CLOCK_NAME_SZ 10 // including terminating 0 555 #define N_PCPS_PORT_RSRC 2 567 #if defined( MBG_TGT_LINUX ) 624 #define PCPS_EF_TIMEOUT 0x00000001 625 #define PCPS_EF_INV_FW_ID 0x00000002 626 #define PCPS_EF_IO_INIT 0x00000004 627 #define PCPS_EF_IO_CFG 0x00000008 628 #define PCPS_EF_IO_ENB 0x00000010 629 #define PCPS_EF_IO_RSRC_IO 0x00000020 630 #define PCPS_EF_IO_RSRC_MEM 0x00000040 707 #define PCPS_CAN_SET_TIME ( 1UL << PCPS_BIT_CAN_SET_TIME ) 708 #define PCPS_HAS_SERIAL ( 1UL << PCPS_BIT_HAS_SERIAL ) 709 #define PCPS_HAS_SYNC_TIME ( 1UL << PCPS_BIT_HAS_SYNC_TIME ) 710 #define PCPS_HAS_TZDL ( 1UL << PCPS_BIT_HAS_TZDL ) 711 #define PCPS_HAS_IDENT ( 1UL << PCPS_BIT_HAS_IDENT ) 712 #define PCPS_HAS_UTC_OFFS ( 1UL << PCPS_BIT_HAS_UTC_OFFS ) 713 #define PCPS_HAS_HR_TIME ( 1UL << PCPS_BIT_HAS_HR_TIME ) 714 #define PCPS_HAS_SERNUM ( 1UL << PCPS_BIT_HAS_SERNUM ) 716 #define PCPS_HAS_TZCODE ( 1UL << PCPS_BIT_HAS_TZCODE ) 717 #define PCPS_HAS_CABLE_LEN ( 1UL << PCPS_BIT_HAS_CABLE_LEN ) 718 #define PCPS_HAS_EVENT_TIME ( 1UL << PCPS_BIT_HAS_EVENT_TIME ) 719 #define PCPS_HAS_RECEIVER_INFO ( 1UL << PCPS_BIT_HAS_RECEIVER_INFO ) 720 #define PCPS_CAN_CLR_UCAP_BUFF ( 1UL << PCPS_BIT_CAN_CLR_UCAP_BUFF ) 721 #define PCPS_HAS_PCPS_TZDL ( 1UL << PCPS_BIT_HAS_PCPS_TZDL ) 722 #define PCPS_HAS_UCAP ( 1UL << PCPS_BIT_HAS_UCAP ) 723 #define PCPS_HAS_IRIG_TX ( 1UL << PCPS_BIT_HAS_IRIG_TX ) 725 #define PCPS_HAS_GPS_DATA_16 ( 1UL << PCPS_BIT_HAS_GPS_DATA_16 ) 726 #define PCPS_HAS_SYNTH ( 1UL << PCPS_BIT_HAS_SYNTH ) 727 #define PCPS_HAS_GENERIC_IO ( 1UL << PCPS_BIT_HAS_GENERIC_IO ) 728 #define PCPS_HAS_TIME_SCALE ( 1UL << PCPS_BIT_HAS_TIME_SCALE ) 729 #define PCPS_HAS_UTC_PARM ( 1UL << PCPS_BIT_HAS_UTC_PARM ) 730 #define PCPS_HAS_IRIG_CTRL_BITS ( 1UL << PCPS_BIT_HAS_IRIG_CTRL_BITS ) 731 #define PCPS_HAS_LAN_INTF ( 1UL << PCPS_BIT_HAS_LAN_INTF ) 732 #define PCPS_HAS_PTP ( 1UL << PCPS_BIT_HAS_PTP ) 734 #define PCPS_HAS_IRIG_TIME ( 1UL << PCPS_BIT_HAS_IRIG_TIME ) 735 #define PCPS_HAS_FAST_HR_TSTAMP ( 1UL << PCPS_BIT_HAS_FAST_HR_TSTAMP ) 736 #define PCPS_HAS_RAW_IRIG_DATA ( 1UL << PCPS_BIT_HAS_RAW_IRIG_DATA ) 737 #define PCPS_HAS_PZF ( 1UL << PCPS_BIT_HAS_PZF ) 738 #define PCPS_HAS_EVT_LOG ( 1UL << PCPS_BIT_HAS_EVT_LOG ) 739 #define PCPS_IS_GNSS ( 1UL << PCPS_BIT_IS_GNSS ) 744 #define PCPS_FEATURE_NAMES \ 746 "PCPS_CAN_SET_TIME", \ 748 "PCPS_HAS_SYNC_TIME", \ 751 "PCPS_HAS_UTC_OFFS", \ 752 "PCPS_HAS_HR_TIME", \ 755 "PCPS_HAS_CABLE_LEN", \ 756 "PCPS_HAS_EVENT_TIME", \ 757 "PCPS_HAS_RECEIVER_INFO", \ 758 "PCPS_CAN_CLR_UCAP_BUFF", \ 759 "PCPS_HAS_PCPS_TZDL", \ 761 "PCPS_HAS_IRIG_TX", \ 762 "PCPS_HAS_GPS_DATA_16", \ 764 "PCPS_HAS_GENERIC_IO", \ 765 "PCPS_HAS_TIME_SCALE", \ 766 "PCPS_HAS_UTC_PARM", \ 767 "PCPS_HAS_IRIG_CTRL_BITS", \ 768 "PCPS_HAS_LAN_INTF", \ 770 "PCPS_HAS_IRIG_TIME", \ 771 "PCPS_HAS_FAST_HR_TSTAMP", \ 772 "PCPS_HAS_RAW_IRIG_DATA", \ 774 "PCPS_HAS_EVT_LOG", \ 786 #define PCPS_FEAT_PC31PS31 0 790 #define PCPS_FEAT_LVL2 ( PCPS_CAN_SET_TIME \ 792 | PCPS_HAS_SYNC_TIME \ 793 | PCPS_HAS_UTC_OFFS ) 795 #define PCPS_FEAT_PC32 ( PCPS_FEAT_LVL2 ) 797 #define PCPS_FEAT_PCI32 ( PCPS_FEAT_LVL2 ) 799 #define PCPS_FEAT_PCI509 ( PCPS_FEAT_LVL2 \ 803 #define PCPS_FEAT_PCI510 ( PCPS_FEAT_PCI509 ) 805 #define PCPS_FEAT_PCI511 ( PCPS_FEAT_PCI510 ) 807 #define PCPS_FEAT_GPS167PC ( PCPS_FEAT_LVL2 \ 811 #define PCPS_FEAT_GPS167PCI ( PCPS_FEAT_LVL2 \ 816 #define PCPS_FEAT_GPS168PCI ( PCPS_FEAT_LVL2 \ 820 | PCPS_HAS_CABLE_LEN \ 821 | PCPS_HAS_RECEIVER_INFO ) 823 #define PCPS_FEAT_GPS169PCI ( PCPS_FEAT_GPS168PCI \ 824 | PCPS_CAN_CLR_UCAP_BUFF \ 827 #define PCPS_FEAT_GPS170PCI ( PCPS_FEAT_GPS169PCI \ 829 | PCPS_HAS_GPS_DATA_16 \ 830 | PCPS_HAS_GENERIC_IO ) 832 #define PCPS_FEAT_TCR510PCI ( PCPS_FEAT_LVL2 \ 835 #define PCPS_FEAT_TCR167PCI ( PCPS_FEAT_LVL2 \ 839 | PCPS_HAS_RECEIVER_INFO \ 840 | PCPS_CAN_CLR_UCAP_BUFF \ 843 | PCPS_HAS_GPS_DATA_16 \ 844 | PCPS_HAS_GENERIC_IO ) 846 #define PCPS_FEAT_TCR511PCI ( PCPS_FEAT_TCR510PCI \ 849 #define PCPS_FEAT_PEX511 ( PCPS_FEAT_PCI511 ) 851 #define PCPS_FEAT_TCR511PEX ( PCPS_FEAT_TCR511PCI ) 853 #define PCPS_FEAT_GPS170PEX ( PCPS_FEAT_GPS170PCI ) 855 #define PCPS_FEAT_USB5131 ( PCPS_HAS_UTC_OFFS \ 857 | PCPS_HAS_SYNC_TIME \ 859 | PCPS_CAN_SET_TIME \ 862 #define PCPS_FEAT_TCR51USB ( PCPS_HAS_UTC_OFFS \ 864 | PCPS_HAS_SYNC_TIME \ 866 | PCPS_CAN_SET_TIME ) 868 #define PCPS_FEAT_MSF51USB ( PCPS_HAS_UTC_OFFS \ 870 | PCPS_HAS_SYNC_TIME \ 872 | PCPS_CAN_SET_TIME ) 874 #define PCPS_FEAT_PTP270PEX ( PCPS_HAS_SERNUM \ 875 | PCPS_HAS_SYNC_TIME \ 877 | PCPS_HAS_RECEIVER_INFO \ 878 | PCPS_CAN_SET_TIME \ 879 | PCPS_CAN_CLR_UCAP_BUFF \ 881 | PCPS_HAS_GPS_DATA_16 ) 883 #define PCPS_FEAT_FRC511PEX ( PCPS_HAS_SERNUM \ 885 | PCPS_HAS_RECEIVER_INFO \ 886 | PCPS_CAN_SET_TIME \ 887 | PCPS_CAN_CLR_UCAP_BUFF \ 889 | PCPS_HAS_GPS_DATA_16 ) 891 #define PCPS_FEAT_TCR170PEX ( PCPS_FEAT_TCR167PCI ) 893 #define PCPS_FEAT_WWVB51USB ( PCPS_FEAT_MSF51USB ) 895 #define PCPS_FEAT_GPS180PEX ( ( PCPS_FEAT_GPS170PEX | PCPS_HAS_FAST_HR_TSTAMP ) \ 896 & ~PCPS_HAS_IRIG_TX ) 899 #define PCPS_FEAT_TCR180PEX ( ( PCPS_FEAT_TCR170PEX | PCPS_HAS_FAST_HR_TSTAMP ) \ 900 & ~PCPS_HAS_IRIG_TX ) 903 #define PCPS_FEAT_DCF600USB ( PCPS_FEAT_USB5131 ) 905 #define PCPS_FEAT_PZF180PEX ( PCPS_FEAT_LVL2 \ 909 | PCPS_HAS_RECEIVER_INFO \ 910 | PCPS_CAN_CLR_UCAP_BUFF \ 912 | PCPS_HAS_GPS_DATA_16 \ 913 | PCPS_HAS_GENERIC_IO \ 914 | PCPS_HAS_UTC_PARM \ 917 #define PCPS_FEAT_TCR600USB ( PCPS_FEAT_TCR51USB \ 918 | PCPS_HAS_IRIG_CTRL_BITS \ 919 | PCPS_HAS_IRIG_TIME \ 920 | PCPS_HAS_RAW_IRIG_DATA ) 922 #define PCPS_FEAT_MSF600USB ( PCPS_FEAT_MSF51USB ) 924 #define PCPS_FEAT_WVB600USB ( PCPS_FEAT_WWVB51USB ) 926 #define PCPS_FEAT_GLN180PEX ( PCPS_FEAT_GPS180PEX | PCPS_IS_GNSS ) 928 #define PCPS_FEAT_GPS180AMC ( PCPS_FEAT_GPS180PEX ) 930 #define PCPS_FEAT_GNS181PEX ( PCPS_FEAT_GLN180PEX ) 932 #define PCPS_FEAT_TCR180USB ( PCPS_FEAT_TCR600USB \ 934 | PCPS_HAS_RECEIVER_INFO \ 935 | PCPS_HAS_GPS_DATA_16 \ 936 | PCPS_CAN_CLR_UCAP_BUFF \ 938 | PCPS_HAS_GENERIC_IO ) 954 #define REV_HAS_IRQ_FIX_MINOR_PEX511 0x0106 955 #define REV_HAS_IRQ_FIX_MINOR_TCR511PEX 0x0105 956 #define REV_HAS_IRQ_FIX_MINOR_GPS170PEX 0x0104 961 #define _pcps_pex_irq_is_safe( _curr_fw_ver, _req_fw_ver, _curr_asic_ver, \ 962 _req_asic_ver_major, _req_asic_ver_minor ) \ 963 ( ( (_curr_fw_ver) >= (_req_fw_ver) ) && _pcps_asic_version_greater_equal( \ 964 (_curr_asic_ver), (_req_asic_ver_major), (_req_asic_ver_minor ) ) \ 968 #define REV_HAS_RAW_IRIG_DATA_TCR511PEX 0x0111 969 #define REV_HAS_RAW_IRIG_DATA_TCR511PCI 0x0111 970 #define REV_HAS_RAW_IRIG_DATA_TCR51USB 0x0106 973 #define REV_HAS_IRIG_TIME_TCR511PEX 0x0109 974 #define REV_HAS_IRIG_TIME_TCR511PCI 0x0109 975 #define REV_HAS_IRIG_TIME_TCR51USB 0x0106 978 #define REV_HAS_IRIG_CTRL_BITS_TCR511PEX 0x0107 979 #define REV_HAS_IRIG_CTRL_BITS_TCR511PCI 0x0107 980 #define REV_HAS_IRIG_CTRL_BITS_TCR51USB 0x0106 985 #define REV_HAS_GPS_DATA_16_GPS169PCI 0x0202 988 #define REV_HAS_SERIAL_HS_PCI509 0x0104 991 #define REV_HAS_UCAP_GPS167PCI 0x0421 992 #define REV_HAS_UCAP_GPS168PCI 0x0104 995 #define REV_CAN_CLR_UCAP_BUFF_GPS167PCI 0x0419 996 #define REV_CAN_CLR_UCAP_BUFF_GPS168PCI 0x0101 1000 #define REV_HAS_CABLE_LEN_GPS167PCI 0x0411 1001 #define REV_HAS_CABLE_LEN_GPS167PC 0x0411 1004 #define REV_HAS_HR_TIME_GPS167PC 0x0305 1005 #define REV_HAS_HR_TIME_TCR510PCI 0x0200 1006 #define REV_HAS_HR_TIME_PEX511 0x0105 // This also requires a certain ASIC version. 1007 #define REV_HAS_HR_TIME_PCI511 0x0103 1010 #define REV_HAS_UTC_OFFS_PC31PS31 0x0300 1013 #define REV_HAS_SYNC_TIME_PC31PS31 0x0300 1016 #define REV_HAS_SERIAL_PC31PS31 0x0300 1019 #define REV_GIVE_TIME_NOCLEAR_PC31PS31 0x0300 1022 #define REV_PCPS_LS_ANN_PC31PS31 0x0300 1025 #define REV_PCPS_IFTM_PC31PS31 0x0300 1028 #define REV_CAN_SET_TIME_PC31PS31 0x0240 1051 #if 1 || defined( MBG_TGT_KERNEL ) //### FIXME 1052 #define _USE_DEV_MACROS 1 1054 #define _USE_DEV_MACROS 0 1067 #define _pcps_type_num( _d ) ( (_d)->type.num ) 1068 #define _pcps_type_name( _d ) ( (_d)->type.name ) 1069 #define _pcps_dev_id( _d ) ( (_d)->type.dev_id ) 1070 #define _pcps_ref_type( _d ) ( (_d)->type.ref_type ) 1071 #define _pcps_bus_flags( _d ) ( (_d)->type.bus_flags ) 1074 #define _pcps_is_gps( _d ) ( _pcps_ref_type( _d ) == PCPS_REF_GPS ) 1075 #define _pcps_is_dcf( _d ) ( _pcps_ref_type( _d ) == PCPS_REF_DCF ) 1076 #define _pcps_is_msf( _d ) ( _pcps_ref_type( _d ) == PCPS_REF_MSF ) 1077 #define _pcps_is_wwvb( _d ) ( _pcps_ref_type( _d ) == PCPS_REF_WWVB ) 1078 #define _pcps_is_irig_rx( _d ) ( _pcps_ref_type( _d ) == PCPS_REF_IRIG ) 1079 #define _pcps_is_ptp( _d ) ( _pcps_ref_type( _d ) == PCPS_REF_PTP ) 1080 #define _pcps_is_frc( _d ) ( _pcps_ref_type( _d ) == PCPS_REF_FRC ) 1081 #define _pcps_is_gnss( _d ) _pcps_has_feature( (_d), PCPS_IS_GNSS ) 1083 #define _pcps_is_lwr( _d ) ( _pcps_is_dcf( _d ) || _pcps_is_msf( _d ) || _pcps_is_wwvb( _d ) ) 1086 #define _pcps_is_isa( _d ) ( _pcps_bus_flags( _d ) & PCPS_BUS_ISA ) 1087 #define _pcps_is_mca( _d ) ( _pcps_bus_flags( _d ) & PCPS_BUS_MCA ) 1088 #define _pcps_is_pci( _d ) ( _pcps_bus_flags( _d ) & PCPS_BUS_PCI ) 1089 #define _pcps_is_usb( _d ) ( _pcps_bus_flags( _d ) & PCPS_BUS_USB ) 1092 #define _pcps_is_usb_v2( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_USB_V2 ) 1093 #define _pcps_is_pci_s5933( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_PCI_S5933 ) 1094 #define _pcps_is_pci_s5920( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_PCI_S5920 ) 1095 #define _pcps_is_pci_amcc( _d ) ( _pcps_is_pci_s5920( _d ) || _pcps_is_pci_s5933( _d ) ) 1096 #define _pcps_is_pci_asic( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_PCI_ASIC ) 1097 #define _pcps_is_pci_pex8311( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_PCI_PEX8311 ) 1098 #define _pcps_is_pci_mbgpex( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_PCI_MBGPEX ) 1102 #define _pcps_bus_num( _d ) ( (_d)->cfg.bus_num ) 1103 #define _pcps_slot_num( _d ) ( (_d)->cfg.slot_num ) 1105 #define _pcps_cfg_short_port_rsrc( _c, _n ) ( (_c)->port[_n] ) 1106 #define _pcps_short_port_rsrc( _d, _n ) _pcps_cfg_short_port_rsrc( &(_d)->cfg, (_n) ) 1108 #define _pcps_cfg_short_port_base( _c, _n ) ( _pcps_cfg_short_port_rsrc( (_c), (_n) ).base ) 1109 #define _pcps_short_port_base( _d, _n ) ( _pcps_short_port_rsrc( (_d), (_n) ).base ) 1111 #define _pcps_cfg_irq_num( _c ) ( (_c)->irq_num ) 1112 #define _pcps_irq_num( _d ) _pcps_cfg_irq_num( &(_d)->cfg ) 1114 #define _pcps_cfg_timeout_clk( _c ) ( (_c)->timeout_clk ) 1115 #define _pcps_timeout_clk( _d ) _pcps_cfg_timeout_clk( &(_d)->cfg ) 1117 #define _pcps_fw_rev_num( _d ) ( (_d)->cfg.fw_rev_num ) 1118 #define _pcps_features( _d ) ( (_d)->cfg.features ) 1119 #define _pcps_fw_id( _d ) ( (_d)->cfg.fw_id ) 1120 #define _pcps_sernum( _d ) ( (_d)->cfg.sernum ) 1124 #define _pcps_err_flags( _d ) ( (_d)->cfg.err_flags ) 1125 #define _pcps_chk_err_flags( _d, _msk ) ( _pcps_err_flags( _d ) & (_msk) ) 1126 #define _pcps_set_err_flags( _d, _msk ) ( _pcps_err_flags( _d ) |= (_msk) ) 1127 #define _pcps_clr_err_flags( _d, _msk ) ( _pcps_err_flags( _d ) &= ~(_msk) ) 1133 #define _pcps_has_feature( _d, _f ) ( ( (_d)->cfg.features & (_f) ) != 0 ) 1136 #define _pcps_has_ri_feature( _p_ri, _f ) ( ( (_p_ri)->features & (_f) ) != 0 ) 1138 #define _ri_addr( _p ) &(_p)->xdev_features.receiver_info 1139 #define _xfeat_addr( _p ) &(_p)->xdev_features.xfeature_buffer 1140 #define _tlv_info_addr( _p ) &(_p)->xdev_features.tlv_info 1141 #define _tlv_feat_buffp( _p ) &(_p)->xdev_features.tlv_info.supp_tlv_feat 1144 #define _pcps_can_set_time( _d ) _pcps_has_feature( (_d), PCPS_CAN_SET_TIME ) 1145 #define _pcps_has_serial( _d ) _pcps_has_feature( (_d), PCPS_HAS_SERIAL ) 1146 #define _pcps_has_sync_time( _d ) _pcps_has_feature( (_d), PCPS_HAS_SYNC_TIME ) 1147 #define _pcps_has_ident( _d ) _pcps_has_feature( (_d), PCPS_HAS_IDENT ) 1148 #define _pcps_has_utc_offs( _d ) _pcps_has_feature( (_d), PCPS_HAS_UTC_OFFS ) 1149 #define _pcps_has_hr_time( _d ) _pcps_has_feature( (_d), PCPS_HAS_HR_TIME ) 1150 #define _pcps_has_sernum( _d ) _pcps_has_feature( (_d), PCPS_HAS_SERNUM ) 1151 #define _pcps_has_cab_len( _d ) _pcps_has_feature( (_d), PCPS_HAS_CABLE_LEN ) 1152 #define _pcps_has_tzdl( _d ) _pcps_has_feature( (_d), PCPS_HAS_TZDL ) 1153 #define _pcps_has_pcps_tzdl( _d ) _pcps_has_feature( (_d), PCPS_HAS_PCPS_TZDL ) 1154 #define _pcps_has_tzcode( _d ) _pcps_has_feature( (_d), PCPS_HAS_TZCODE ) 1155 #define _pcps_has_tz( _d ) _pcps_has_feature( (_d), PCPS_HAS_TZDL \ 1156 | PCPS_HAS_PCPS_TZDL \ 1159 #define _pcps_has_event_time( _d ) _pcps_has_feature( (_d), PCPS_HAS_EVENT_TIME ) 1160 #define _pcps_has_receiver_info( _d ) _pcps_has_feature( (_d), PCPS_HAS_RECEIVER_INFO ) 1161 #define _pcps_can_clr_ucap_buff( _d ) _pcps_has_feature( (_d), PCPS_CAN_CLR_UCAP_BUFF ) 1162 #define _pcps_has_ucap( _d ) _pcps_has_feature( (_d), PCPS_HAS_UCAP ) 1163 #define _pcps_has_irig_tx( _d ) _pcps_has_feature( (_d), PCPS_HAS_IRIG_TX ) 1167 #define _pcps_has_serial_hs( _d ) \ 1168 ( ( _pcps_type_num( _d ) == PCPS_TYPE_TCR511PEX ) || \ 1169 ( _pcps_type_num( _d ) == PCPS_TYPE_PEX511 ) || \ 1170 ( _pcps_type_num( _d ) == PCPS_TYPE_TCR511PCI ) || \ 1171 ( _pcps_type_num( _d ) == PCPS_TYPE_TCR510PCI ) || \ 1172 ( _pcps_type_num( _d ) == PCPS_TYPE_PCI511 ) || \ 1173 ( _pcps_type_num( _d ) == PCPS_TYPE_PCI510 ) || \ 1174 ( _pcps_type_num( _d ) == PCPS_TYPE_PCI509 && \ 1175 _pcps_fw_rev_num( _d ) >= REV_HAS_SERIAL_HS_PCI509 ) ) 1178 #define _pcps_has_signal( _d ) \ 1179 ( _pcps_is_dcf( _d ) || _pcps_is_msf( _d ) || _pcps_is_wwvb( _d ) || _pcps_is_irig_rx( _d ) ) 1181 #define _pcps_has_mod( _d ) \ 1182 ( _pcps_is_dcf( _d ) || _pcps_is_msf( _d ) || _pcps_is_wwvb( _d ) ) 1184 #define _pcps_has_irig( _d ) \ 1185 ( _pcps_is_irig_rx( _d ) || _pcps_has_irig_tx( _d ) ) 1187 #define _pcps_has_irig_ctrl_bits( _d ) \ 1188 _pcps_has_feature( (_d), PCPS_HAS_IRIG_CTRL_BITS ) 1190 #define _pcps_has_irig_time( _d ) \ 1191 _pcps_has_feature( (_d), PCPS_HAS_IRIG_TIME ) 1193 #define _pcps_has_raw_irig_data( _d ) \ 1194 _pcps_has_feature( (_d), PCPS_HAS_RAW_IRIG_DATA ) 1196 #define _pcps_has_ref_offs( _d ) \ 1197 _pcps_is_irig_rx( _d ) 1199 #define _pcps_ref_offs_out_of_range( _n ) \ 1200 ( ( (_n) > MBG_REF_OFFS_MAX ) || ( (_n) < -MBG_REF_OFFS_MAX ) ) 1202 #define _pcps_has_opt_flags( _d ) \ 1203 _pcps_is_irig_rx( _d ) 1205 #define _pcps_has_gps_data_16( _d ) _pcps_has_feature( (_d), PCPS_HAS_GPS_DATA_16 ) 1207 #define _pcps_has_gps_data( _d ) \ 1208 ( _pcps_is_gps( _d ) || _pcps_has_gps_data_16( _d ) ) 1210 #define _pcps_has_synth( _d ) _pcps_has_feature( (_d), PCPS_HAS_SYNTH ) 1212 #define _pcps_has_generic_io( _d ) _pcps_has_feature( (_d), PCPS_HAS_GENERIC_IO ) 1214 #define _pcps_has_time_scale( _d ) _pcps_has_feature( (_d), PCPS_HAS_TIME_SCALE ) 1216 #define _pcps_has_utc_parm( _d ) _pcps_has_feature( (_d), PCPS_HAS_UTC_PARM ) 1218 #define _pcps_has_asic_version( _d ) ( _pcps_is_pci_asic( _d ) \ 1219 || _pcps_is_pci_pex8311( _d ) \ 1220 || _pcps_is_pci_mbgpex( _d ) ) 1222 #define _pcps_has_asic_features( _d ) _pcps_has_asic_version( _d ) 1224 #define _pcps_has_fast_hr_timestamp( _d ) _pcps_has_feature( (_d), PCPS_HAS_FAST_HR_TSTAMP ) 1226 #define _pcps_has_lan_intf( _d ) _pcps_has_feature( (_d), PCPS_HAS_LAN_INTF ) 1228 #define _pcps_has_ptp( _d ) _pcps_has_feature( (_d), PCPS_HAS_PTP ) 1230 #define _pcps_has_ri_ptp_unicast( _p_ri ) _pcps_has_ri_feature( (_p_ri), GPS_HAS_PTP_UNICAST ) 1232 #define _pcps_has_pzf( _d ) _pcps_has_feature( (_d), PCPS_HAS_PZF ) 1234 #define _pcps_has_corr_info( _d ) _pcps_has_pzf( _d ) 1236 #define _pcps_has_tr_distance( _d ) _pcps_has_pzf( _d ) 1238 #define _pcps_has_evt_log( _d ) _pcps_has_feature( (_d), PCPS_HAS_EVT_LOG ) 1240 #define _pcps_has_debug_status( _d ) _pcps_is_irig_rx( _d ) 1242 #define _pcps_has_stat_info( _d ) ( _pcps_is_gps( _d ) || _pcps_has_pzf( _d ) ) 1244 #define _pcps_has_stat_info_mode( _d ) _pcps_is_gps( _d ) 1246 #define _pcps_has_stat_info_svs( _d ) _pcps_is_gps( _d ) 1248 #define _pcps_has_ri_gpio( _p_ri ) _pcps_has_ri_feature( (_p_ri), GPS_HAS_GPIO ) 1251 #define _pcps_has_ri_xmr( _p_ri ) ( _pcps_has_ri_feature( (_p_ri), GPS_HAS_XMULTI_REF ) && \ 1252 _pcps_has_ri_feature( (_p_ri), GPS_HAS_XMRS_MULT_INSTC ) ) 1255 #endif // _USE_DEV_MACROS 1269 #define _pcps_incoming_tfom_ignored( _d ) \ 1270 ( ( ( _pcps_type_num( _d ) == PCPS_TYPE_TCR167PCI ) && ( _pcps_fw_rev_num( _d ) <= 0x121 ) ) \ 1271 || ( ( _pcps_type_num( _d ) == PCPS_TYPE_TCR170PEX ) && ( _pcps_fw_rev_num( _d ) <= 0x103 ) ) ) 1286 #define _pcps_pci_cfg_err( _d ) \ 1287 ( _pcps_is_pci( _d ) && _pcps_short_port_base( _d, 0 ) && \ 1288 ( _pcps_short_port_base( _d, 1 ) == _pcps_short_port_base( _d, 0 ) ) ) 1300 #define _pcps_fw_has_20ms_bug( _d ) \ 1302 ( _pcps_type_num( _d ) == PCPS_TYPE_GPS168PCI && _pcps_fw_rev_num( _d ) < 0x0102 ) || \ 1303 ( _pcps_type_num( _d ) == PCPS_TYPE_GPS167PCI && _pcps_fw_rev_num( _d ) < 0x0420 ) \ 1343 #define _pcps_time_set_unread( _t ) do { (_t)->sec = 0xFF; } while ( 0 ) 1344 #define _pcps_time_is_read( _t ) ( (uchar) (_t)->sec != 0xFF ) 1376 #define _mbg_swab_pcps_time_stamp_cycles( _p ) \ 1379 _mbg_swab_mbg_pc_cycles( &(_p)->cycles ); \ 1380 _mbg_swab_pcps_time_stamp( &(_p)->tstamp ); \ 1399 #define _mbg_swab_pcps_hr_time_cycles( _p ) \ 1402 _mbg_swab_mbg_pc_cycles( &(_p)->cycles ); \ 1403 _mbg_swab_pcps_hr_time( &(_p)->t ); \ 1425 #define _mbg_swab_mbg_time_info_hrt( _p ) \ 1428 _mbg_swab_pcps_hr_time_cycles( &(_p)->ref_hr_time_cycles ); \ 1429 _mbg_swab_mbg_sys_time_cycles( &(_p)->sys_time_cycles ); \ 1452 #define _mbg_swab_mbg_time_info_tstamp( _p ) \ 1455 _mbg_swab_pcps_time_stamp_cycles( &(_p)->ref_tstamp_cycles ); \ 1456 _mbg_swab_mbg_sys_time_cycles( &(_p)->sys_time_cycles ); \ 1471 #define PCPS_IRQ_STAT_ENABLE_CALLED 0x01 1472 #define PCPS_IRQ_STAT_ENABLED 0x02 1473 #define PCPS_IRQ_STAT_UNSAFE 0x04 // IRQs unsafe with this firmeware version / ASIC 1475 #define PCPS_IRQ_STATE_DANGER ( PCPS_IRQ_STAT_ENABLED | PCPS_IRQ_STAT_UNSAFE ) 1481 #define PCPS_FW_STR_FMT "%X.%02X" 1483 #define _pcps_fw_rev_num_major( _v ) \ 1486 #define _pcps_fw_rev_num_minor( _v ) \ 1491 #if defined( _USING_BYTE_ALIGNMENT ) 1492 #pragma pack() // set default alignment 1493 #undef _USING_BYTE_ALIGNMENT 1497 #if !defined( MBG_TGT_KERNEL ) 1503 memset( p_ht_c, 0,
sizeof( *p_ht_c ) );
1534 #define MBG_DEV_NAME_FMT "%s_%s" PCPS_DEV_ID dev_id
see MEINBERG_PCI_DEVICE_IDS and MBG_USB_DEVICE_IDS
uint16_t ver_num
the device driver's version number
High resolution device time, system time, and associated cycles counts.
MBG_SYS_TIME_CYCLES sys_time_cycles
system time stamp plus associated cycles
PCPS_ID_STR id_str
the device driver's ID string
System time plus associated cycles counter values.
PCPS_ERR_FLAGS err_flags
See PCPS_ERR_FLAG_MASKS.
PCPS_BUS_FLAGS bus_flags
see PCPS_BUS_FLAG_MASKS
feat_num field contains one of the GPS_FEATURE_BITS
A structure used to retrieve an address to be mapped into user space.
A timestamp with nanosecond resolution, but 64 bit size.
PCPS_FEATURE_BITS
Feature bits for bus-level devices.
feat_num field contains one of the PCPS_FEATURE_BITS
MBG_PC_CYCLES cyc_before
cycles count before sys time is read
feat_num field contains one of the GPS_BUILTIN_FEATURE_BITS
Time read from a device plus associated system cycles count.
feat_num field contains one of the MBG_TLV_FEAT_TYPES
uint32_t PCPS_FEATURES
see PCPS_FEATURE_MASKS
High resolution time stamp plus associated system cycles count.
MBG_SYS_TIME_CYCLES sys_time_cycles
system timestamp plus associated cycles
PCPS_FEATURES features
See PCPS_FEATURE_MASKS.
PCPS_TIME_STAMP tstamp
High resolution time stamp (UTC)
PCPS_FW_REV_NUM fw_rev_num
PCPS_REF_TYPE ref_type
see PCPS_REF_TYPES
uint16_t n_devs
the number of devices handled by the driver
void * user_virtual_address
High resolution device time stamp, system time, and associated cycles counts.
char PCPS_SN_STR[(16+1)]
A buffer for a serial number string, including terminating 0.
PCPS_TIME_STAMP tstamp
High resolution time stamp (UTC)
MBG_SYS_TIME sys_time
system time stamp
PCPS_TYPES
A list of known devices.
#define N_PCPS_PORT_RSRC
The max. number of I/O port resources used by a clock.
PCPS_TIME_STAMP_CYCLES ref_tstamp_cycles
HR timestamp from the card, plus cycles.
char MBG_DEV_NAME[10+(16+1)+1]
A string buffer for a unique device ID.
char PCPS_ID_STR[(2 *16+1)]
A buffer for an ID string, including terminating 0.
#define PCPS_SN_SIZE
The maximum length of a serial number string, including terminating 0.
An I/O port resource used by a device.
uint32_t PCPS_IRQ_STAT_INFO
PCPS_HR_TIME_CYCLES ref_hr_time_cycles
HR time read from the card, plus cycles.
MBG_PC_CYCLES cyc_after
cycles count after sys time has been read
uint16_t num
see PCPS_TYPES
Device type specification.
#define PCPS_CLOCK_NAME_SZ
High resolution time including status and local time offset.
High resolution time plus associated system cycles count.
uint32_t PCPS_ERR_FLAGS
see PCPS_ERR_FLAG_MASKS
Local calendar date and time, plus sync status.
feat_num field contains one of the MBG_XFEATURE_BITS
A high resolution time stamp.
feat_num field contains one of the PCPS_REF_TYPES
Device driver information.
PCPS_SHORT_PORT_ADDR base
unsigned __int64 uint64_t
uint16_t PCPS_SHORT_PORT_ADDR
Legacy I/O address type, see PCPS_SHORT_PORT_RSRC.
int64_t MBG_PC_CYCLES
Generic types to hold PC cycle counter values.
uint16_t PCPS_FW_REV_NUM
firmware revision number, MSB major, LSB minor version
DEV_FEAT_TYPES
Codes used with IOCTL_DEV_FEAT_REQ::feat_type.
static __mbg_inline void setup_hr_time_cycles_from_timestamp_cycles(PCPS_HR_TIME_CYCLES *p_ht_c, const PCPS_TIME_STAMP_CYCLES *p_ts_c)
PCPS_SHORT_PORT_ADDR short_status_port