17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
587a18d3Madhavan Venkataraman * Common Development and Distribution License (the "License").
687a18d3Madhavan Venkataraman * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
217c478bdstevel@tonic-gate/*
2287a18d3Madhavan Venkataraman * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
2387a18d3Madhavan Venkataraman * Use is subject to license terms.
24f06dce2Andrew Stormont *
25f06dce2Andrew Stormont * Copyright 2017 RackTop Systems.
26d0a94a5Patrick Mooney * Copyright 2018 Joyent, Inc.
277c478bdstevel@tonic-gate */
287c478bdstevel@tonic-gate
297c478bdstevel@tonic-gate#ifndef _SYS_CYCLIC_H
307c478bdstevel@tonic-gate#define	_SYS_CYCLIC_H
317c478bdstevel@tonic-gate
327c478bdstevel@tonic-gate#ifdef	__cplusplus
337c478bdstevel@tonic-gateextern "C" {
347c478bdstevel@tonic-gate#endif
357c478bdstevel@tonic-gate
367c478bdstevel@tonic-gate#ifndef _ASM
377c478bdstevel@tonic-gate#include <sys/time.h>
387c478bdstevel@tonic-gate#include <sys/cpuvar.h>
397c478bdstevel@tonic-gate#include <sys/cpupart.h>
407c478bdstevel@tonic-gate#endif /* !_ASM */
417c478bdstevel@tonic-gate
427c478bdstevel@tonic-gate#define	CY_LOW_LEVEL		0
437c478bdstevel@tonic-gate#define	CY_LOCK_LEVEL		1
447c478bdstevel@tonic-gate#define	CY_HIGH_LEVEL		2
457c478bdstevel@tonic-gate#define	CY_SOFT_LEVELS		2
467c478bdstevel@tonic-gate#define	CY_LEVELS		3
477c478bdstevel@tonic-gate
487c478bdstevel@tonic-gate#ifndef _ASM
497c478bdstevel@tonic-gate
507c478bdstevel@tonic-gatetypedef uintptr_t cyclic_id_t;
517c478bdstevel@tonic-gatetypedef int cyc_index_t;
527c478bdstevel@tonic-gatetypedef int cyc_cookie_t;
537c478bdstevel@tonic-gatetypedef uint16_t cyc_level_t;
547c478bdstevel@tonic-gatetypedef void (*cyc_func_t)(void *);
557c478bdstevel@tonic-gatetypedef void *cyb_arg_t;
567c478bdstevel@tonic-gate
577c478bdstevel@tonic-gate#define	CYCLIC_NONE		((cyclic_id_t)0)
587c478bdstevel@tonic-gate
597c478bdstevel@tonic-gatetypedef struct cyc_handler {
607c478bdstevel@tonic-gate	cyc_func_t cyh_func;
617c478bdstevel@tonic-gate	void *cyh_arg;
627c478bdstevel@tonic-gate	cyc_level_t cyh_level;
637c478bdstevel@tonic-gate} cyc_handler_t;
647c478bdstevel@tonic-gate
657c478bdstevel@tonic-gatetypedef struct cyc_time {
667c478bdstevel@tonic-gate	hrtime_t cyt_when;
677c478bdstevel@tonic-gate	hrtime_t cyt_interval;
687c478bdstevel@tonic-gate} cyc_time_t;
697c478bdstevel@tonic-gate
707c478bdstevel@tonic-gatetypedef struct cyc_omni_handler {
717c478bdstevel@tonic-gate	void (*cyo_online)(void *, cpu_t *, cyc_handler_t *, cyc_time_t *);
727c478bdstevel@tonic-gate	void (*cyo_offline)(void *, cpu_t *, void *);
737c478bdstevel@tonic-gate	void *cyo_arg;
747c478bdstevel@tonic-gate} cyc_omni_handler_t;
757c478bdstevel@tonic-gate
7687a18d3Madhavan Venkataraman#define	CY_INFINITY	INT64_MAX
7787a18d3Madhavan Venkataraman
78f06dce2Andrew Stormont#if defined(_KERNEL) || defined(_FAKE_KERNEL)
797c478bdstevel@tonic-gate
807c478bdstevel@tonic-gateextern cyclic_id_t cyclic_add(cyc_handler_t *, cyc_time_t *);
817c478bdstevel@tonic-gateextern cyclic_id_t cyclic_add_omni(cyc_omni_handler_t *);
827c478bdstevel@tonic-gateextern void cyclic_remove(cyclic_id_t);
837c478bdstevel@tonic-gateextern void cyclic_bind(cyclic_id_t, cpu_t *, cpupart_t *);
8487a18d3Madhavan Venkataramanextern int cyclic_reprogram(cyclic_id_t, hrtime_t);
85d0a94a5Patrick Mooneyextern void cyclic_move_here(cyclic_id_t);
867c478bdstevel@tonic-gateextern hrtime_t cyclic_getres();
877c478bdstevel@tonic-gate
887c478bdstevel@tonic-gateextern int cyclic_offline(cpu_t *cpu);
897c478bdstevel@tonic-gateextern void cyclic_online(cpu_t *cpu);
907c478bdstevel@tonic-gateextern int cyclic_juggle(cpu_t *cpu);
917c478bdstevel@tonic-gateextern void cyclic_move_in(cpu_t *);
927c478bdstevel@tonic-gateextern int cyclic_move_out(cpu_t *);
937c478bdstevel@tonic-gateextern void cyclic_suspend();
947c478bdstevel@tonic-gateextern void cyclic_resume();
957c478bdstevel@tonic-gate
967c478bdstevel@tonic-gateextern void cyclic_fire(cpu_t *cpu);
977c478bdstevel@tonic-gateextern void cyclic_softint(cpu_t *cpu, cyc_level_t level);
987c478bdstevel@tonic-gate
99f06dce2Andrew Stormont#endif /* _KERNEL || _FAKE_KERNEL */
1007c478bdstevel@tonic-gate
1017c478bdstevel@tonic-gate#endif /* !_ASM */
1027c478bdstevel@tonic-gate
1037c478bdstevel@tonic-gate#ifdef	__cplusplus
1047c478bdstevel@tonic-gate}
1057c478bdstevel@tonic-gate#endif
1067c478bdstevel@tonic-gate
1077c478bdstevel@tonic-gate#endif /* _SYS_CYCLIC_H */
108