18329232Gordon Ross/*
28329232Gordon Ross * CDDL HEADER START
38329232Gordon Ross *
48329232Gordon Ross * The contents of this file are subject to the terms of the
58329232Gordon Ross * Common Development and Distribution License (the "License").
68329232Gordon Ross * You may not use this file except in compliance with the License.
78329232Gordon Ross *
88329232Gordon Ross * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
98329232Gordon Ross * or http://www.opensolaris.org/os/licensing.
108329232Gordon Ross * See the License for the specific language governing permissions
118329232Gordon Ross * and limitations under the License.
128329232Gordon Ross *
138329232Gordon Ross * When distributing Covered Code, include this CDDL HEADER in each
148329232Gordon Ross * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
158329232Gordon Ross * If applicable, add the following below this CDDL HEADER, with the
168329232Gordon Ross * fields enclosed by brackets "[]" replaced with your own identifying
178329232Gordon Ross * information: Portions Copyright [yyyy] [name of copyright owner]
188329232Gordon Ross *
198329232Gordon Ross * CDDL HEADER END
208329232Gordon Ross */
218329232Gordon Ross/*
228329232Gordon Ross * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
238329232Gordon Ross * Use is subject to license terms.
248329232Gordon Ross *
258329232Gordon Ross * Copyright 2017 RackTop Systems.
268329232Gordon Ross */
278329232Gordon Ross
288329232Gordon Ross#ifndef _SYS_CYCLIC_H
298329232Gordon Ross#define	_SYS_CYCLIC_H
308329232Gordon Ross
318329232Gordon Ross#ifdef	__cplusplus
328329232Gordon Rossextern "C" {
338329232Gordon Ross#endif
348329232Gordon Ross
358329232Gordon Ross#ifndef _ASM
368329232Gordon Ross#include <sys/time.h>
378329232Gordon Ross#endif /* !_ASM */
388329232Gordon Ross
398329232Gordon Ross#define	CY_LOW_LEVEL		0
408329232Gordon Ross#define	CY_LOCK_LEVEL		1
418329232Gordon Ross#define	CY_HIGH_LEVEL		2
428329232Gordon Ross#define	CY_SOFT_LEVELS		2
438329232Gordon Ross#define	CY_LEVELS		3
448329232Gordon Ross
458329232Gordon Ross#ifndef _ASM
468329232Gordon Ross
478329232Gordon Rosstypedef uintptr_t cyclic_id_t;
488329232Gordon Rosstypedef int cyc_index_t;
498329232Gordon Rosstypedef int cyc_cookie_t;
508329232Gordon Rosstypedef uint16_t cyc_level_t;
518329232Gordon Rosstypedef void (*cyc_func_t)(void *);
528329232Gordon Rosstypedef void *cyb_arg_t;
538329232Gordon Ross
548329232Gordon Ross#define	CYCLIC_NONE		((cyclic_id_t)0)
558329232Gordon Ross
568329232Gordon Rosstypedef struct cyc_handler {
578329232Gordon Ross	cyc_func_t cyh_func;
588329232Gordon Ross	void *cyh_arg;
598329232Gordon Ross	cyc_level_t cyh_level;
608329232Gordon Ross} cyc_handler_t;
618329232Gordon Ross
628329232Gordon Rosstypedef struct cyc_time {
638329232Gordon Ross	hrtime_t cyt_when;
648329232Gordon Ross	hrtime_t cyt_interval;
658329232Gordon Ross} cyc_time_t;
668329232Gordon Ross
678329232Gordon Ross#define	CY_INFINITY	INT64_MAX
688329232Gordon Ross
698329232Gordon Ross#if defined(_KERNEL) || defined(_FAKE_KERNEL)
708329232Gordon Ross
718329232Gordon Rossextern cyclic_id_t cyclic_add(cyc_handler_t *, cyc_time_t *);
728329232Gordon Rossextern void cyclic_remove(cyclic_id_t);
738329232Gordon Rossextern int cyclic_reprogram(cyclic_id_t, hrtime_t);
748329232Gordon Rossextern hrtime_t cyclic_getres();
758329232Gordon Ross
768329232Gordon Rossextern void cyclic_suspend();
778329232Gordon Rossextern void cyclic_resume();
788329232Gordon Ross
798329232Gordon Ross#endif /* _KERNEL || _FAKE_KERNEL */
808329232Gordon Ross
818329232Gordon Ross#endif /* !_ASM */
828329232Gordon Ross
838329232Gordon Ross#ifdef	__cplusplus
848329232Gordon Ross}
858329232Gordon Ross#endif
868329232Gordon Ross
878329232Gordon Ross#endif /* _SYS_CYCLIC_H */
88