xref: /onnv-gate/usr/src/uts/common/sys/cyclic.h (revision 8048:4b8c6e469829)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*8048SMadhavan.Venkataraman@Sun.COM  * Common Development and Distribution License (the "License").
6*8048SMadhavan.Venkataraman@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*8048SMadhavan.Venkataraman@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*8048SMadhavan.Venkataraman@Sun.COM  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_CYCLIC_H
270Sstevel@tonic-gate #define	_SYS_CYCLIC_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifdef	__cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #ifndef _ASM
340Sstevel@tonic-gate #include <sys/time.h>
350Sstevel@tonic-gate #include <sys/cpuvar.h>
360Sstevel@tonic-gate #include <sys/cpupart.h>
370Sstevel@tonic-gate #endif /* !_ASM */
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #define	CY_LOW_LEVEL		0
400Sstevel@tonic-gate #define	CY_LOCK_LEVEL		1
410Sstevel@tonic-gate #define	CY_HIGH_LEVEL		2
420Sstevel@tonic-gate #define	CY_SOFT_LEVELS		2
430Sstevel@tonic-gate #define	CY_LEVELS		3
440Sstevel@tonic-gate 
450Sstevel@tonic-gate #ifndef _ASM
460Sstevel@tonic-gate 
470Sstevel@tonic-gate typedef uintptr_t cyclic_id_t;
480Sstevel@tonic-gate typedef int cyc_index_t;
490Sstevel@tonic-gate typedef int cyc_cookie_t;
500Sstevel@tonic-gate typedef uint16_t cyc_level_t;
510Sstevel@tonic-gate typedef void (*cyc_func_t)(void *);
520Sstevel@tonic-gate typedef void *cyb_arg_t;
530Sstevel@tonic-gate 
540Sstevel@tonic-gate #define	CYCLIC_NONE		((cyclic_id_t)0)
550Sstevel@tonic-gate 
560Sstevel@tonic-gate typedef struct cyc_handler {
570Sstevel@tonic-gate 	cyc_func_t cyh_func;
580Sstevel@tonic-gate 	void *cyh_arg;
590Sstevel@tonic-gate 	cyc_level_t cyh_level;
600Sstevel@tonic-gate } cyc_handler_t;
610Sstevel@tonic-gate 
620Sstevel@tonic-gate typedef struct cyc_time {
630Sstevel@tonic-gate 	hrtime_t cyt_when;
640Sstevel@tonic-gate 	hrtime_t cyt_interval;
650Sstevel@tonic-gate } cyc_time_t;
660Sstevel@tonic-gate 
670Sstevel@tonic-gate typedef struct cyc_omni_handler {
680Sstevel@tonic-gate 	void (*cyo_online)(void *, cpu_t *, cyc_handler_t *, cyc_time_t *);
690Sstevel@tonic-gate 	void (*cyo_offline)(void *, cpu_t *, void *);
700Sstevel@tonic-gate 	void *cyo_arg;
710Sstevel@tonic-gate } cyc_omni_handler_t;
720Sstevel@tonic-gate 
73*8048SMadhavan.Venkataraman@Sun.COM #define	CY_INFINITY	INT64_MAX
74*8048SMadhavan.Venkataraman@Sun.COM 
750Sstevel@tonic-gate #ifdef _KERNEL
760Sstevel@tonic-gate 
770Sstevel@tonic-gate extern cyclic_id_t cyclic_add(cyc_handler_t *, cyc_time_t *);
780Sstevel@tonic-gate extern cyclic_id_t cyclic_add_omni(cyc_omni_handler_t *);
790Sstevel@tonic-gate extern void cyclic_remove(cyclic_id_t);
800Sstevel@tonic-gate extern void cyclic_bind(cyclic_id_t, cpu_t *, cpupart_t *);
81*8048SMadhavan.Venkataraman@Sun.COM extern int cyclic_reprogram(cyclic_id_t, hrtime_t);
820Sstevel@tonic-gate extern hrtime_t cyclic_getres();
830Sstevel@tonic-gate 
840Sstevel@tonic-gate extern int cyclic_offline(cpu_t *cpu);
850Sstevel@tonic-gate extern void cyclic_online(cpu_t *cpu);
860Sstevel@tonic-gate extern int cyclic_juggle(cpu_t *cpu);
870Sstevel@tonic-gate extern void cyclic_move_in(cpu_t *);
880Sstevel@tonic-gate extern int cyclic_move_out(cpu_t *);
890Sstevel@tonic-gate extern void cyclic_suspend();
900Sstevel@tonic-gate extern void cyclic_resume();
910Sstevel@tonic-gate 
920Sstevel@tonic-gate extern void cyclic_fire(cpu_t *cpu);
930Sstevel@tonic-gate extern void cyclic_softint(cpu_t *cpu, cyc_level_t level);
940Sstevel@tonic-gate 
950Sstevel@tonic-gate #endif /* _KERNEL */
960Sstevel@tonic-gate 
970Sstevel@tonic-gate #endif /* !_ASM */
980Sstevel@tonic-gate 
990Sstevel@tonic-gate #ifdef	__cplusplus
1000Sstevel@tonic-gate }
1010Sstevel@tonic-gate #endif
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate #endif /* _SYS_CYCLIC_H */
104