xref: /illumos-gate/usr/src/lib/libfakekernel/common/sys/cyclic.h (revision 8a2b682e57a046b828f37bcde1776f131ef4629f)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  *
25  * Copyright 2017 RackTop Systems.
26  */
27 
28 #ifndef _SYS_CYCLIC_H
29 #define	_SYS_CYCLIC_H
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #ifndef _ASM
36 #include <sys/time.h>
37 #endif /* !_ASM */
38 
39 #define	CY_LOW_LEVEL		0
40 #define	CY_LOCK_LEVEL		1
41 #define	CY_HIGH_LEVEL		2
42 #define	CY_SOFT_LEVELS		2
43 #define	CY_LEVELS		3
44 
45 #ifndef _ASM
46 
47 typedef uintptr_t cyclic_id_t;
48 typedef int cyc_index_t;
49 typedef int cyc_cookie_t;
50 typedef uint16_t cyc_level_t;
51 typedef void (*cyc_func_t)(void *);
52 typedef void *cyb_arg_t;
53 
54 #define	CYCLIC_NONE		((cyclic_id_t)0)
55 
56 typedef struct cyc_handler {
57 	cyc_func_t cyh_func;
58 	void *cyh_arg;
59 	cyc_level_t cyh_level;
60 } cyc_handler_t;
61 
62 typedef struct cyc_time {
63 	hrtime_t cyt_when;
64 	hrtime_t cyt_interval;
65 } cyc_time_t;
66 
67 #define	CY_INFINITY	INT64_MAX
68 
69 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
70 
71 extern cyclic_id_t cyclic_add(cyc_handler_t *, cyc_time_t *);
72 extern void cyclic_remove(cyclic_id_t);
73 extern int cyclic_reprogram(cyclic_id_t, hrtime_t);
74 extern hrtime_t cyclic_getres();
75 
76 extern void cyclic_suspend();
77 extern void cyclic_resume();
78 
79 #endif /* _KERNEL || _FAKE_KERNEL */
80 
81 #endif /* !_ASM */
82 
83 #ifdef	__cplusplus
84 }
85 #endif
86 
87 #endif /* _SYS_CYCLIC_H */
88