xref: /illumos-gate/usr/src/uts/intel/sys/hrtcntl.h (revision 2d6eb4a5)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1997-1999 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.	*/
28*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T	*/
29*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #ifndef _SYS_HRTCNTL_H
32*7c478bd9Sstevel@tonic-gate #define	_SYS_HRTCNTL_H
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
35*7c478bd9Sstevel@tonic-gate extern "C" {
36*7c478bd9Sstevel@tonic-gate #endif
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate /*
39*7c478bd9Sstevel@tonic-gate  * The following are the possible commands for the hrtcntl,
40*7c478bd9Sstevel@tonic-gate  * hrtalarm, and hrtsleep system calls.
41*7c478bd9Sstevel@tonic-gate  */
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate typedef	enum	hrtcmds {
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate 		/*   hrtcntl	commands   */
46*7c478bd9Sstevel@tonic-gate 	HRT_GETRES,		/* Get the resolution of a clock.	*/
47*7c478bd9Sstevel@tonic-gate 	HRT_TOFD,		/* Get the value of time since		*/
48*7c478bd9Sstevel@tonic-gate 				/* 00:00:00 GMT, January 1, 1970	*/
49*7c478bd9Sstevel@tonic-gate 	HRT_STARTIT,		/* Start timing an activity		*/
50*7c478bd9Sstevel@tonic-gate 	HRT_GETIT,		/* Return the interval time elapsed	*/
51*7c478bd9Sstevel@tonic-gate 				/* since the corresponding HRT_STARTIT	*/
52*7c478bd9Sstevel@tonic-gate 				/* command has been issued.		*/
53*7c478bd9Sstevel@tonic-gate 		/*   hrtalarm   commands   */
54*7c478bd9Sstevel@tonic-gate 	HRT_ALARM,		/* Start a timer and post an alarm	*/
55*7c478bd9Sstevel@tonic-gate 				/* event after the time interval has	*/
56*7c478bd9Sstevel@tonic-gate 				/* elapsed.				*/
57*7c478bd9Sstevel@tonic-gate 	HRT_RALARM,		/* Post an alarm repeatedly after	*/
58*7c478bd9Sstevel@tonic-gate 				/* every time interval.			*/
59*7c478bd9Sstevel@tonic-gate 	HRT_TODALARM,		/* Similar to HRT_ALARM except that	*/
60*7c478bd9Sstevel@tonic-gate 				/* the time at which the alarm is to	*/
61*7c478bd9Sstevel@tonic-gate 				/* posted is specified by an absolute	*/
62*7c478bd9Sstevel@tonic-gate 				/* time.				*/
63*7c478bd9Sstevel@tonic-gate 	HRT_INT_RPT,		/* Start a repeating alarm some time	*/
64*7c478bd9Sstevel@tonic-gate 				/* in the future.			*/
65*7c478bd9Sstevel@tonic-gate 	HRT_TOD_RPT,		/* Similar to HRT_INT_RPT except that	*/
66*7c478bd9Sstevel@tonic-gate 				/* the time of day when the alarm	*/
67*7c478bd9Sstevel@tonic-gate 				/* should begin is specified.		*/
68*7c478bd9Sstevel@tonic-gate 	HRT_PENDING,		/* Determine the time remaining until	*/
69*7c478bd9Sstevel@tonic-gate 				/* a pending alarm fires.		*/
70*7c478bd9Sstevel@tonic-gate 		/*   hrtsleep   commands  */
71*7c478bd9Sstevel@tonic-gate 	HRT_INTSLP,		/* Put the process to sleep for an	*/
72*7c478bd9Sstevel@tonic-gate 				/* interval.				*/
73*7c478bd9Sstevel@tonic-gate 	HRT_TODSLP,		/* Put the process to sleep until	*/
74*7c478bd9Sstevel@tonic-gate 				/* a specified time of day.		*/
75*7c478bd9Sstevel@tonic-gate 		/*
76*7c478bd9Sstevel@tonic-gate 		 * The following fields will be used
77*7c478bd9Sstevel@tonic-gate 		 * to implement BSD timers
78*7c478bd9Sstevel@tonic-gate 		 */
79*7c478bd9Sstevel@tonic-gate 	HRT_BSD,
80*7c478bd9Sstevel@tonic-gate 	HRT_BSD_PEND,
81*7c478bd9Sstevel@tonic-gate 	HRT_RBSD,
82*7c478bd9Sstevel@tonic-gate 	HRT_BSD_REP,
83*7c478bd9Sstevel@tonic-gate 	HRT_BSD_CANCEL
84*7c478bd9Sstevel@tonic-gate } hrtcmds_t;
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate /*
87*7c478bd9Sstevel@tonic-gate  *	Definitions for specifying rounding mode.
88*7c478bd9Sstevel@tonic-gate  */
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate #define	HRT_TRUNC	0	/* Round results down.	*/
91*7c478bd9Sstevel@tonic-gate #define	HRT_RND		1	/* Round results (rnd up if fractional	*/
92*7c478bd9Sstevel@tonic-gate 				/*   part >= .5 otherwise round down).	*/
93*7c478bd9Sstevel@tonic-gate #define	HRT_RNDUP	2	/* Always round results up.	*/
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate /*
96*7c478bd9Sstevel@tonic-gate  *	Definition for the type of internal buffer used with the
97*7c478bd9Sstevel@tonic-gate  *	HRT_STARTIT and HRT_GETIT commands.
98*7c478bd9Sstevel@tonic-gate  */
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate typedef	struct interval {
101*7c478bd9Sstevel@tonic-gate 	unsigned long	i_word1;
102*7c478bd9Sstevel@tonic-gate 	unsigned long	i_word2;
103*7c478bd9Sstevel@tonic-gate 	int		i_clock;
104*7c478bd9Sstevel@tonic-gate } interval_t;
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate /*
107*7c478bd9Sstevel@tonic-gate  *	Structure used to represent a high-resolution time-of-day
108*7c478bd9Sstevel@tonic-gate  *	or interval.
109*7c478bd9Sstevel@tonic-gate  */
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate typedef struct hrtime {
112*7c478bd9Sstevel@tonic-gate 	ulong_t	hrt_secs;	/* Seconds.				*/
113*7c478bd9Sstevel@tonic-gate 	long	hrt_rem;	/* A value less than a second.		*/
114*7c478bd9Sstevel@tonic-gate 	ulong_t	hrt_res;	/* The resolution of hrt_rem.		*/
115*7c478bd9Sstevel@tonic-gate } hrtimes_t;
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate /*
119*7c478bd9Sstevel@tonic-gate  *	The structure used for the hrtalarm and hrtsleep system calls.
120*7c478bd9Sstevel@tonic-gate  */
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate typedef struct hrtcmd {
123*7c478bd9Sstevel@tonic-gate 	int		hrtc_cmd;	/* A timer command.		*/
124*7c478bd9Sstevel@tonic-gate 	int		hrtc_clk;	/* Which clock to use.		*/
125*7c478bd9Sstevel@tonic-gate 	hrtimes_t	hrtc_int;	/* A time interval.		*/
126*7c478bd9Sstevel@tonic-gate 	hrtimes_t	hrtc_tod;	/* A time of day.		*/
127*7c478bd9Sstevel@tonic-gate 	int		hrtc_flags;	/* Various flags. 		*/
128*7c478bd9Sstevel@tonic-gate 	int		hrtc_error;	/* An error code		*/
129*7c478bd9Sstevel@tonic-gate 					/* (see eys/errno.h).		*/
130*7c478bd9Sstevel@tonic-gate #ifdef notdef
131*7c478bd9Sstevel@tonic-gate 	ecb_t		hrtc_ecb;	/* An event control block.	*/
132*7c478bd9Sstevel@tonic-gate #endif
133*7c478bd9Sstevel@tonic-gate } hrtcmd_t;
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate /*
136*7c478bd9Sstevel@tonic-gate  * Flags for the hrtc_flags field.
137*7c478bd9Sstevel@tonic-gate  */
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate #define	HRTF_DONE	0x0001	/* The requested alarm has been set.	*/
140*7c478bd9Sstevel@tonic-gate #define	HRTF_ERROR	0x0002	/* An error has been encountered.	*/
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate /*
143*7c478bd9Sstevel@tonic-gate  * Multiple clocks
144*7c478bd9Sstevel@tonic-gate  */
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate #define	CLK_STD		0x0001	/* The standard real-time clock.	*/
147*7c478bd9Sstevel@tonic-gate #define	CLK_USERVIRT	0x0002	/* A clock measuring user process	*/
148*7c478bd9Sstevel@tonic-gate 				/* virtual time.			*/
149*7c478bd9Sstevel@tonic-gate #define	CLK_PROCVIRT	0x0004	/* A clock measuring a process' virtual */
150*7c478bd9Sstevel@tonic-gate 				/* time.				*/
151*7c478bd9Sstevel@tonic-gate 
152*7c478bd9Sstevel@tonic-gate /*
153*7c478bd9Sstevel@tonic-gate  * Function Prototypes
154*7c478bd9Sstevel@tonic-gate  * ===================
155*7c478bd9Sstevel@tonic-gate  *
156*7c478bd9Sstevel@tonic-gate  *	The following are prototypes for the library functions which
157*7c478bd9Sstevel@tonic-gate  *	users call.
158*7c478bd9Sstevel@tonic-gate  */
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) && !defined(_KERNEL)
161*7c478bd9Sstevel@tonic-gate int   hrtcntl(int, int, interval_t *, hrtimes_t *);
162*7c478bd9Sstevel@tonic-gate int   hrtalarm(hrtcmd_t *, int);
163*7c478bd9Sstevel@tonic-gate int   hrtsleep(hrtcmd_t *);
164*7c478bd9Sstevel@tonic-gate int   hrtcancel(const long *, int);
165*7c478bd9Sstevel@tonic-gate #endif
166*7c478bd9Sstevel@tonic-gate 
167*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
168*7c478bd9Sstevel@tonic-gate }
169*7c478bd9Sstevel@tonic-gate #endif
170*7c478bd9Sstevel@tonic-gate 
171*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_HRTCNTL_H */
172