|
NAMEeventtimers —
kernel event timers subsystem
SYNOPSIS#include <sys/timeet.h>
struct eventtimer; typedef int et_start_t(struct eventtimer *et, sbintime_t first, sbintime_t period); typedef int et_stop_t(struct eventtimer *et); typedef void et_event_cb_t(struct eventtimer *et, void *arg); typedef int et_deregister_cb_t(struct eventtimer *et, void *arg); struct eventtimer { SLIST_ENTRY(eventtimer) et_all; char *et_name; int et_flags; #define ET_FLAGS_PERIODIC 1 #define ET_FLAGS_ONESHOT 2 #define ET_FLAGS_PERCPU 4 #define ET_FLAGS_C3STOP 8 #define ET_FLAGS_POW2DIV 16 int et_quality; int et_active; uint64_t et_frequency; sbintime_t et_min_period; sbintime_t et_max_period; et_start_t *et_start; et_stop_t *et_stop; et_event_cb_t *et_event_cb; et_deregister_cb_t *et_deregister_cb; void *et_arg; void *et_priv; struct sysctl_oid *et_sysctl; }; int et_register (struct
eventtimer *et);
int
void
struct eventtimer *
int
int
int
int
int
DESCRIPTIONEvent timers are responsible for generating interrupts at specified time or periodically, to run different time-based events. Subsystem consists of three main parts:
DRIVER APIDriver API is built around eventtimer structure. To register its functionality driver allocates that structure and callset_register (). Driver should fill following fields
there:
After the event timer functionality is registered, it is controlled via et_start and et_stop methods. et_start method is called to start the specified event timer. The last two arguments are used to specify time when events should be generated. first argument specifies time period before the first event generated. In periodic mode NULL value specifies that first period is equal to the period argument value. period argument specifies the time period between following events for the periodic mode. The NULL value there specifies the one-shot mode. At least one of these two arguments should be not NULL. When event time arrive, driver should call et_event_cb callback function, passing et_arg as the second argument. et_stop method is called to stop the specified event timer. For the per-CPU event timers et_start and et_stop methods control timers associated with the current CPU. Driver may deregister its functionality by calling
If the frequency of the clock hardware can change while it is
running (for example, during power-saving modes), the driver must call
CONSUMER APIet_find () allows consumer to find available event timer,
optionally matching specific name and/or capability flags. Consumer may read
returned eventtimer structure, but should not modify it. When wanted event
timer is found, et_init () should be called for it,
submitting event and optionally
deregister callbacks functions, and the opaque argument
arg. That argument will be passed as argument to the
callbacks. Event callback function will be called on scheduled time events. It
is called from the hardware interrupt context, so no sleep is permitted there.
Deregister callback function may be called to report consumer that the event
timer functionality is no longer available. On this call, consumer should stop
using event timer before the return.
After the timer is found and initialized, it can be controlled via
SEE ALSOeventtimers(4)AUTHORSAlexander Motin <mav@FreeBSD.org>
Visit the GSP FreeBSD Man Page Interface. |