FreeBSD/contrib/ntp/ntpdc/ntpdc_ops.c
/*
 * kerninfo - display the kernel pll/pps variables
 */
display the kernel pll/pps variables
display the kernel pll / pps variables
static void
kerninfo(
	struct parse *pcmd,
	FILE *fp
	)
{
	struct info_kernel *ik;
	size_t items;
	size_t itemsize;
	int res;
	unsigned status;
	double tscale = 1e-6;
again:
	res = doquery(impl_ver, REQ_GET_KERNEL, 0, 0, 0, (char *)NULL,
		      &items, &itemsize, (void *)&ik, 0, 
		      sizeof(struct info_kernel));
	if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
		impl_ver = IMPL_XNTPD_OLD;
		goto again;
	}
	if (res != 0)
	    return;
	if (!check1item(items, fp))
	    return;
	if (!checkitemsize(itemsize, sizeof(struct info_kernel)))
	    return;
	status = ntohs(ik->status) & 0xffff;
#ifdef STA_NANO
	if (status & STA_NANO)
		tscale = 1e-9;
#endif
	(void)fprintf(fp, "pll offset:           %g s\n",
	    (int32)ntohl(ik->offset) * tscale);
	(void)fprintf(fp, "pll frequency:        %s ppm\n",
	    fptoa((s_fp)ntohl(ik->freq), 3));
	(void)fprintf(fp, "maximum error:        %g s\n",
	    (u_long)ntohl(ik->maxerror) * tscale);
	(void)fprintf(fp, "estimated error:      %g s\n",
	    (u_long)ntohl(ik->esterror) * tscale);
	(void)fprintf(fp, "status:               %04x ", status);
#ifdef STA_PLL
	if (status & STA_PLL) (void)fprintf(fp, " pll");
#endif
#ifdef STA_PPSFREQ
	if (status & STA_PPSFREQ) (void)fprintf(fp, " ppsfreq");
#endif
#ifdef STA_PPSTIME
	if (status & STA_PPSTIME) (void)fprintf(fp, " ppstime");
#endif
#ifdef STA_FLL
	if (status & STA_FLL) (void)fprintf(fp, " fll");
#endif
#ifdef STA_INS
	if (status & STA_INS) (void)fprintf(fp, " ins");
#endif
#ifdef STA_DEL
	if (status & STA_DEL) (void)fprintf(fp, " del");
#endif
#ifdef STA_UNSYNC
	if (status & STA_UNSYNC) (void)fprintf(fp, " unsync");
#endif
#ifdef STA_FREQHOLD
	if (status & STA_FREQHOLD) (void)fprintf(fp, " freqhold");
#endif
#ifdef STA_PPSSIGNAL
	if (status & STA_PPSSIGNAL) (void)fprintf(fp, " ppssignal");
#endif
#ifdef STA_PPSJITTER
	if (status & STA_PPSJITTER) (void)fprintf(fp, " ppsjitter");
#endif
#ifdef STA_PPSWANDER
	if (status & STA_PPSWANDER) (void)fprintf(fp, " ppswander");
#endif
#ifdef STA_PPSERROR
	if (status & STA_PPSERROR) (void)fprintf(fp, " ppserror");
#endif
#ifdef STA_CLOCKERR
	if (status & STA_CLOCKERR) (void)fprintf(fp, " clockerr");
#endif
#ifdef STA_NANO
	if (status & STA_NANO) (void)fprintf(fp, " nano");
#endif
#ifdef STA_MODE
	if (status & STA_MODE) (void)fprintf(fp, " mode=fll");
#endif
#ifdef STA_CLK
	if (status & STA_CLK) (void)fprintf(fp, " src=B");
#endif
	(void)fprintf(fp, "\n");
	(void)fprintf(fp, "pll time constant:    %ld\n",
	    (u_long)ntohl(ik->constant));
	(void)fprintf(fp, "precision:            %g s\n",
	    (u_long)ntohl(ik->precision) * tscale);
	(void)fprintf(fp, "frequency tolerance:  %s ppm\n",
	    fptoa((s_fp)ntohl(ik->tolerance), 0));
	if (!ik->shift)
	    return;
	(void)fprintf(fp, "pps frequency:        %s ppm\n",
	    fptoa((s_fp)ntohl(ik->ppsfreq), 3));
	(void)fprintf(fp, "pps stability:        %s ppm\n",
	    fptoa((s_fp)ntohl(ik->stabil), 3));
	(void)fprintf(fp, "pps jitter:           %g s\n",
	    (u_long)ntohl(ik->jitter) * tscale);
	(void)fprintf(fp, "calibration interval: %d s\n",
		      1 << ntohs(ik->shift));
	(void)fprintf(fp, "calibration cycles:   %ld\n",
		      (u_long)ntohl(ik->calcnt));
	(void)fprintf(fp, "jitter exceeded:      %ld\n",
		      (u_long)ntohl(ik->jitcnt));
	(void)fprintf(fp, "stability exceeded:   %ld\n",
		      (u_long)ntohl(ik->stbcnt));
	(void)fprintf(fp, "calibration errors:   %ld\n",
		      (u_long)ntohl(ik->errcnt));
}
static void kerninfo ( struct parse * pcmd , FILE * fp ) { struct info_kernel * ik ; size_t items ; size_t itemsize ; int res ; unsigned status ; double tscale = 1e-6 ; again : res = doquery ( impl_ver , REQ_GET_KERNEL , 0 , 0 , 0 , ( char * ) NULL , & items , & itemsize , ( void * ) & ik , 0 , sizeof ( struct info_kernel ) ) ; if ( res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD ) { impl_ver = IMPL_XNTPD_OLD ; goto again ; } if ( res != 0 ) return ; if ( ! check1item ( items , fp ) ) return ; if ( ! checkitemsize ( itemsize , sizeof ( struct info_kernel ) ) ) return ; status = ntohs ( ik -> status ) & 0xffff ; #ifdef STA_NANO if ( status & STA_NANO ) tscale = 1e-9 ; #endif ( void ) fprintf ( fp , " \n " , ( int32 ) ntohl ( ik -> offset ) * tscale ) ; ( void ) fprintf ( fp , " \n " , fptoa ( ( s_fp ) ntohl ( ik -> freq ) , 3 ) ) ; ( void ) fprintf ( fp , " \n " , ( u_long ) ntohl ( ik -> maxerror ) * tscale ) ; ( void ) fprintf ( fp , " \n " , ( u_long ) ntohl ( ik -> esterror ) * tscale ) ; ( void ) fprintf ( fp , " " , status ) ; #ifdef STA_PLL if ( status & STA_PLL ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_PPSFREQ if ( status & STA_PPSFREQ ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_PPSTIME if ( status & STA_PPSTIME ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_FLL if ( status & STA_FLL ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_INS if ( status & STA_INS ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_DEL if ( status & STA_DEL ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_UNSYNC if ( status & STA_UNSYNC ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_FREQHOLD if ( status & STA_FREQHOLD ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_PPSSIGNAL if ( status & STA_PPSSIGNAL ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_PPSJITTER if ( status & STA_PPSJITTER ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_PPSWANDER if ( status & STA_PPSWANDER ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_PPSERROR if ( status & STA_PPSERROR ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_CLOCKERR if ( status & STA_CLOCKERR ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_NANO if ( status & STA_NANO ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_MODE if ( status & STA_MODE ) ( void ) fprintf ( fp , " " ) ; #endif #ifdef STA_CLK if ( status & STA_CLK ) ( void ) fprintf ( fp , " " ) ; #endif ( void ) fprintf ( fp , " \n " ) ; ( void ) fprintf ( fp , " \n " , ( u_long ) ntohl ( ik -> constant ) ) ; ( void ) fprintf ( fp , " \n " , ( u_long ) ntohl ( ik -> precision ) * tscale ) ; ( void ) fprintf ( fp , " \n " , fptoa ( ( s_fp ) ntohl ( ik -> tolerance ) , 0 ) ) ; if ( ! ik -> shift ) return ; ( void ) fprintf ( fp , " \n " , fptoa ( ( s_fp ) ntohl ( ik -> ppsfreq ) , 3 ) ) ; ( void ) fprintf ( fp , " \n " , fptoa ( ( s_fp ) ntohl ( ik -> stabil ) , 3 ) ) ; ( void ) fprintf ( fp , " \n " , ( u_long ) ntohl ( ik -> jitter ) * tscale ) ; ( void ) fprintf ( fp , " \n " , 1 << ntohs ( ik -> shift ) ) ; ( void ) fprintf ( fp , " \n " , ( u_long ) ntohl ( ik -> calcnt ) ) ; ( void ) fprintf ( fp , " \n " , ( u_long ) ntohl ( ik -> jitcnt ) ) ; ( void ) fprintf ( fp , " \n " , ( u_long ) ntohl ( ik -> stbcnt ) ) ; ( void ) fprintf ( fp , " \n " , ( u_long ) ntohl ( ik -> errcnt ) ) ; }
kerninfo - display the kernel pll/pps variables
kerninfo - display the kernel pll / pps variables
/*
	 * pll variables. We know more than we should about the NANO bit.
	 */ /*
	 * For backwards compatibility (ugh), we find the pps variables
	 * only if the shift member is nonzero.
	 */ /*
	 * pps variables
	 */