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