FreeBSD kernel kern code
subr_rtc.c File Reference
#include <sys/cdefs.h>
#include "opt_ffclock.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/clock.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/taskqueue.h>
#include <sys/timetc.h>
#include "clock_if.h"
Include dependency graph for subr_rtc.c:

Go to the source code of this file.

Data Structures

struct  rtc_instance
 

Functions

 __FBSDID ("$FreeBSD$")
 
 SYSCTL_INT (_debug, OID_AUTO, clock_show_io, CTLFLAG_RWTUN, &show_io, 0, "Enable debug printing of RTC clock I/O; 1=reads, 2=writes, 3=both.")
 
static int sysctl_clock_do_io (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_debug, OID_AUTO, clock_do_io, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_MPSAFE, 0, 0, sysctl_clock_do_io, "I", "Trigger one-time IO on RTC clocks; 1=read (and discard), 2=write")
 
 SYSCTL_INT (_machdep, OID_AUTO, disable_rtc_set, CTLFLAG_RW, &disable_rtc_set, 0, "Disallow adjusting time-of-day clock")
 
static void settime_task_func (void *arg, int pending)
 
 LIST_HEAD (rtc_listhead, rtc_instance)
 
 SX_SYSINIT (rtc_list_lock_init, &rtc_list_lock, "rtc list")
 
static void clock_dbgprint_hdr (device_t dev, int rw)
 
void clock_dbgprint_bcd (device_t dev, int rw, const struct bcd_clocktime *bct)
 
void clock_dbgprint_ct (device_t dev, int rw, const struct clocktime *ct)
 
void clock_dbgprint_err (device_t dev, int rw, int err)
 
void clock_dbgprint_ts (device_t dev, int rw, const struct timespec *ts)
 
void clock_register_flags (device_t clockdev, long resolution, int flags)
 
void clock_register (device_t dev, long res)
 
void clock_unregister (device_t clockdev)
 
void clock_schedule (device_t clockdev, u_int offsetns)
 
static int read_clocks (struct timespec *ts, bool debug_read)
 
void inittodr (time_t base)
 
void resettodr (void)
 

Variables

static int show_io
 
static int disable_rtc_set
 
static struct rtc_listhead rtc_list = LIST_HEAD_INITIALIZER(rtc_list)
 
static struct sx rtc_list_lock
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ clock_dbgprint_bcd()

void clock_dbgprint_bcd ( device_t  dev,
int  rw,
const struct bcd_clocktime *  bct 
)

Definition at line 171 of file subr_rtc.c.

References clock_dbgprint_hdr(), clock_print_bcd(), printf(), and show_io.

Here is the call graph for this function:

◆ clock_dbgprint_ct()

void clock_dbgprint_ct ( device_t  dev,
int  rw,
const struct clocktime *  ct 
)

Definition at line 182 of file subr_rtc.c.

References clock_dbgprint_hdr(), clock_print_ct(), printf(), and show_io.

Here is the call graph for this function:

◆ clock_dbgprint_err()

void clock_dbgprint_err ( device_t  dev,
int  rw,
int  err 
)

Definition at line 193 of file subr_rtc.c.

References clock_dbgprint_hdr(), printf(), and show_io.

Here is the call graph for this function:

◆ clock_dbgprint_hdr()

static void clock_dbgprint_hdr ( device_t  dev,
int  rw 
)
static

Definition at line 160 of file subr_rtc.c.

References clock_print_ts(), device_printf(), getnanotime(), and printf().

Referenced by clock_dbgprint_bcd(), clock_dbgprint_ct(), clock_dbgprint_err(), and clock_dbgprint_ts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clock_dbgprint_ts()

void clock_dbgprint_ts ( device_t  dev,
int  rw,
const struct timespec *  ts 
)

Definition at line 203 of file subr_rtc.c.

References clock_dbgprint_hdr(), clock_print_ts(), printf(), show_io, and ts.

Here is the call graph for this function:

◆ clock_register()

void clock_register ( device_t  dev,
long  res 
)

Definition at line 250 of file subr_rtc.c.

References clock_register_flags(), and res.

Here is the call graph for this function:

◆ clock_register_flags()

void clock_register_flags ( device_t  clockdev,
long  resolution,
int  flags 
)

Definition at line 214 of file subr_rtc.c.

References rtc_instance::clockdev, device_printf(), rtc_instance::flags, malloc(), rtc_instance::resadj, rtc_instance::resolution, rtc_instance::rtc_entries, rtc_list, rtc_list_lock, rtc_instance::schedns, settime_task_func(), and rtc_instance::stask.

Referenced by clock_register().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clock_schedule()

void clock_schedule ( device_t  clockdev,
u_int  offsetns 
)

◆ clock_unregister()

void clock_unregister ( device_t  clockdev)

◆ inittodr()

void inittodr ( time_t  base)

Definition at line 334 of file subr_rtc.c.

References printf(), read_clocks(), tc_setclock(), and ts.

Referenced by vfs_mountroot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LIST_HEAD()

LIST_HEAD ( rtc_listhead  ,
rtc_instance   
)

◆ read_clocks()

static int read_clocks ( struct timespec *  ts,
bool  debug_read 
)
static

Definition at line 292 of file subr_rtc.c.

References bootverbose, rtc_instance::clockdev, device_printf(), rtc_instance::flags, rtc_instance::resadj, rtc_instance::rtc_entries, rtc_list, rtc_list_lock, ts, and utc_offset().

Referenced by inittodr(), and sysctl_clock_do_io().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resettodr()

void resettodr ( void  )

Definition at line 377 of file subr_rtc.c.

References disable_rtc_set, getnanotime(), rtc_instance::rtc_entries, rtc_list, rtc_list_lock, rtc_instance::schedns, rtc_instance::stask, and taskqueue_enqueue_timeout_sbt().

Referenced by periodic_resettodr(), settime(), shutdown_resettodr(), sysctl_clock_do_io(), and sysctl_machdep_adjkerntz().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ settime_task_func()

static void settime_task_func ( void *  arg,
int  pending 
)
static

Definition at line 137 of file subr_rtc.c.

References bootverbose, rtc_instance::clockdev, device_printf(), rtc_instance::flags, getnanotime(), rtc_instance::resadj, ts, and utc_offset().

Referenced by clock_register_flags().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SX_SYSINIT()

SX_SYSINIT ( rtc_list_lock_init  ,
rtc_list_lock,
"rtc list"   
)

◆ sysctl_clock_do_io()

static int sysctl_clock_do_io ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 404 of file subr_rtc.c.

References printf(), read_clocks(), resettodr(), sysctl_handle_int(), and value.

Here is the call graph for this function:

◆ SYSCTL_INT() [1/2]

SYSCTL_INT ( _debug  ,
OID_AUTO  ,
clock_show_io  ,
CTLFLAG_RWTUN  ,
show_io,
,
"Enable debug printing of RTC clock I/O;  1 = reads,
= writes 
)

◆ SYSCTL_INT() [2/2]

SYSCTL_INT ( _machdep  ,
OID_AUTO  ,
disable_rtc_set  ,
CTLFLAG_RW  ,
disable_rtc_set,
,
"Disallow adjusting time-of-day clock  
)

◆ SYSCTL_PROC()

SYSCTL_PROC ( _debug  ,
OID_AUTO  ,
clock_do_io  ,
CTLTYPE_INT|CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
,
sysctl_clock_do_io  ,
"I"  ,
"Trigger one-time IO on RTC clocks;  1 = read (and discard) 
)

Variable Documentation

◆ disable_rtc_set

int disable_rtc_set
static

Definition at line 89 of file subr_rtc.c.

Referenced by resettodr().

◆ rtc_list

struct rtc_listhead rtc_list = LIST_HEAD_INITIALIZER(rtc_list)
static

◆ rtc_list_lock

struct sx rtc_list_lock
static

◆ show_io

int show_io
static