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.
267c478bdstevel@tonic-gate */
277c478bdstevel@tonic-gate
287c478bdstevel@tonic-gate#ifndef _SYS_CYCLIC_H
297c478bdstevel@tonic-gate#define	_SYS_CYCLIC_H
307c478bdstevel@tonic-gate
317c478bdstevel@tonic-gate#ifdef	__cplusplus
327c478bdstevel@tonic-gateextern "C" {
337c478bdstevel@tonic-gate#endif
347c478bdstevel@tonic-gate
357c478bdstevel@tonic-gate#ifndef _ASM
367c478bdstevel@tonic-gate#include <sys/time.h>
377c478bdstevel@tonic-gate#include <sys/cpuvar.h>
387c478bdstevel@tonic-gate#include <sys/cpupart.h>
397c478bdstevel@tonic-gate#endif /* !_ASM */
407c478bdstevel@tonic-gate
417c478bdstevel@tonic-gate#define	CY_LOW_LEVEL		0
427c478bdstevel@tonic-gate#define	CY_LOCK_LEVEL		1
437c478bdstevel@tonic-gate#define	CY_HIGH_LEVEL		2
447c478bdstevel@tonic-gate#define	CY_SOFT_LEVELS		2
457c478bdstevel@tonic-gate#define	CY_LEVELS		3
467c478bdstevel@tonic-gate
477c478bdstevel@tonic-gate#ifndef _ASM
487c478bdstevel@tonic-gate
497c478bdstevel@tonic-gatetypedef uintptr_t cyclic_id_t;
507c478bdstevel@tonic-gatetypedef int cyc_index_t;
517c478bdstevel@tonic-gatetypedef int cyc_cookie_t;
527c478bdstevel@tonic-gatetypedef uint16_t cyc_level_t;
537c478bdstevel@tonic-gatetypedef void (*cyc_func_t)(void *);
547c478bdstevel@tonic-gatetypedef void *cyb_arg_t;
557c478bdstevel@tonic-gate
567c478bdstevel@tonic-gate#define	CYCLIC_NONE		((cyclic_id_t)0)
577c478bdstevel@tonic-gate
587c478bdstevel@tonic-gatetypedef struct cyc_handler {
597c478bdstevel@tonic-gate	cyc_func_t cyh_func;
607c478bdstevel@tonic-gate	void *cyh_arg;
617c478bdstevel@tonic-gate	cyc_level_t cyh_level;
627c478bdstevel@tonic-gate} cyc_handler_t;
637c478bdstevel@tonic-gate
647c478bdstevel@tonic-gatetypedef struct cyc_time {
657c478bdstevel@tonic-gate	hrtime_t cyt_when;
667c478bdstevel@tonic-gate	hrtime_t cyt_interval;
677c478bdstevel@tonic-gate} cyc_time_t;
687c478bdstevel@tonic-gate
697c478bdstevel@tonic-gatetypedef struct cyc_omni_handler {
707c478bdstevel@tonic-gate	void (*cyo_online)(void *, cpu_t *, cyc_handler_t *, cyc_time_t *);
717c478bdstevel@tonic-gate	void (*cyo_offline)(void *, cpu_t *, void *);
727c478bdstevel@tonic-gate	void *cyo_arg;
737c478bdstevel@tonic-gate} cyc_omni_handler_t;
747c478bdstevel@tonic-gate
7587a18d3Madhavan Venkataraman#define	CY_INFINITY	INT64_MAX
7687a18d3Madhavan Venkataraman
77f06dce2Andrew Stormont#if defined(_KERNEL) || defined(_FAKE_KERNEL)
787c478bdstevel@tonic-gate
797c478bdstevel@tonic-gateextern cyclic_id_t cyclic_add(cyc_handler_t *, cyc_time_t *);
807c478bdstevel@tonic-gateextern cyclic_id_t cyclic_add_omni(cyc_omni_handler_t *);
817c478bdstevel@tonic-gateextern void cyclic_remove(cyclic_id_t);
827c478bdstevel@tonic-gateextern void cyclic_bind(cyclic_id_t, cpu_t *, cpupart_t *);
8387a18d3Madhavan Venkataramanextern int cyclic_reprogram(cyclic_id_t, hrtime_t);
847c478bdstevel@tonic-gateextern hrtime_t cyclic_getres();
857c478bdstevel@tonic-gate
867c478bdstevel@tonic-gateextern int cyclic_offline(cpu_t *cpu);
877c478bdstevel@tonic-gateextern void cyclic_online(cpu_t *cpu);
887c478bdstevel@tonic-gateextern int cyclic_juggle(cpu_t *cpu);
897c478bdstevel@tonic-gateextern void cyclic_move_in(cpu_t *);
907c478bdstevel@tonic-gateextern int cyclic_move_out(cpu_t *);
917c478bdstevel@tonic-gateextern void cyclic_suspend();
927c478bdstevel@tonic-gateextern void cyclic_resume();
937c478bdstevel@tonic-gate
947c478bdstevel@tonic-gateextern void cyclic_fire(cpu_t *cpu);
957c478bdstevel@tonic-gateextern void cyclic_softint(cpu_t *cpu, cyc_level_t level);
967c478bdstevel@tonic-gate
97f06dce2Andrew Stormont#endif /* _KERNEL || _FAKE_KERNEL */
987c478bdstevel@tonic-gate
997c478bdstevel@tonic-gate#endif /* !_ASM */
1007c478bdstevel@tonic-gate
1017c478bdstevel@tonic-gate#ifdef	__cplusplus
1027c478bdstevel@tonic-gate}
1037c478bdstevel@tonic-gate#endif
1047c478bdstevel@tonic-gate
1057c478bdstevel@tonic-gate#endif /* _SYS_CYCLIC_H */
106