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