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*3792Sakolb * Common Development and Distribution License (the "License"). 6*3792Sakolb * 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*3792Sakolb * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*3792Sakolb * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_FX_H 270Sstevel@tonic-gate #define _SYS_FX_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/types.h> 320Sstevel@tonic-gate #include <sys/thread.h> 330Sstevel@tonic-gate #include <sys/ddi.h> 340Sstevel@tonic-gate #include <sys/sunddi.h> 35*3792Sakolb #include <sys/cpucaps.h> 360Sstevel@tonic-gate 370Sstevel@tonic-gate #ifdef __cplusplus 380Sstevel@tonic-gate extern "C" { 390Sstevel@tonic-gate #endif 400Sstevel@tonic-gate 410Sstevel@tonic-gate /* 420Sstevel@tonic-gate * Fixed-priority dispatcher parameter table entry 430Sstevel@tonic-gate */ 440Sstevel@tonic-gate typedef struct fxdpent { 450Sstevel@tonic-gate pri_t fx_globpri; /* global (class independent) priority */ 460Sstevel@tonic-gate int fx_quantum; /* time quantum given to procs at this level */ 470Sstevel@tonic-gate } fxdpent_t; 480Sstevel@tonic-gate 490Sstevel@tonic-gate #ifdef _KERNEL 500Sstevel@tonic-gate 510Sstevel@tonic-gate typedef uintptr_t fx_cookie_t; /* handle for callback supplied storage */ 520Sstevel@tonic-gate 530Sstevel@tonic-gate /* 540Sstevel@tonic-gate * callbacks supplied by custom scheduler. In general, a change to quantum 550Sstevel@tonic-gate * and/or priority when returning from a callback has immediate effect. 560Sstevel@tonic-gate * 570Sstevel@tonic-gate * fx_exit - called when a thread exits. This also needs to free any storage 580Sstevel@tonic-gate * for the fx_cookie_t. 590Sstevel@tonic-gate * 600Sstevel@tonic-gate * fx_callb_tick - called at every clock tick attributed to this thread 610Sstevel@tonic-gate * 620Sstevel@tonic-gate * fx_callb_preempt - called when a thread is being preempted or yielding 630Sstevel@tonic-gate * 640Sstevel@tonic-gate * fx_callb_stop/fx_callb_sleep - called when a thread stops running 650Sstevel@tonic-gate * 660Sstevel@tonic-gate * fx_callb_wakeup - called when a thread is again runnable 670Sstevel@tonic-gate */ 680Sstevel@tonic-gate typedef struct fx_callbacks { 690Sstevel@tonic-gate int fx_callb_version; 700Sstevel@tonic-gate void (*fx_callb_exit)(fx_cookie_t); 710Sstevel@tonic-gate void (*fx_callb_tick)(fx_cookie_t, clock_t *, pri_t *); 720Sstevel@tonic-gate void (*fx_callb_preempt)(fx_cookie_t, clock_t *, pri_t *); 730Sstevel@tonic-gate void (*fx_callb_stop)(fx_cookie_t); 740Sstevel@tonic-gate void (*fx_callb_sleep)(fx_cookie_t); 750Sstevel@tonic-gate void (*fx_callb_wakeup)(fx_cookie_t, clock_t *, pri_t *); 760Sstevel@tonic-gate 770Sstevel@tonic-gate } fx_callbacks_t; 780Sstevel@tonic-gate 790Sstevel@tonic-gate 800Sstevel@tonic-gate #define FX_CALLB_VERSION_1 1 810Sstevel@tonic-gate 820Sstevel@tonic-gate #define FX_CALLB_REV FX_CALLB_VERSION_1 830Sstevel@tonic-gate 840Sstevel@tonic-gate #define FX_CB_VERSION(cb) cb->fx_callb_version 850Sstevel@tonic-gate 860Sstevel@tonic-gate #define FX_CB_EXIT(cb, c) cb->fx_callb_exit(c) 870Sstevel@tonic-gate 880Sstevel@tonic-gate #define FX_CB_TICK(cb, c, q, p) cb->fx_callb_tick(c, q, p) 890Sstevel@tonic-gate 900Sstevel@tonic-gate #define FX_CB_PREEMPT(cb, c, q, p) cb->fx_callb_preempt(c, q, p) 910Sstevel@tonic-gate 920Sstevel@tonic-gate #define FX_CB_STOP(cb, c) cb->fx_callb_stop(c) 930Sstevel@tonic-gate 940Sstevel@tonic-gate #define FX_CB_SLEEP(cb, c) cb->fx_callb_sleep(c) 950Sstevel@tonic-gate 960Sstevel@tonic-gate #define FX_CB_WAKEUP(cb, c, q, p) cb->fx_callb_wakeup(c, q, p) 970Sstevel@tonic-gate 980Sstevel@tonic-gate /* priority setting */ 990Sstevel@tonic-gate #define FX_CB_NOCHANGE -32768 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate /* 1030Sstevel@tonic-gate * Fixed-priority class specific thread structure 1040Sstevel@tonic-gate */ 1050Sstevel@tonic-gate typedef struct fxproc { 1060Sstevel@tonic-gate int fx_pquantum; /* time quantum given to this proc */ 1070Sstevel@tonic-gate int fx_timeleft; /* time remaining in procs quantum */ 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate pri_t fx_pri; /* relative priority within fx class */ 1100Sstevel@tonic-gate /* same as user priority */ 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate pri_t fx_uprilim; /* user priority limit */ 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate char fx_nice; /* nice value for compatibility */ 1150Sstevel@tonic-gate uchar_t fx_flags; /* flags defined below */ 1160Sstevel@tonic-gate kthread_t *fx_tp; /* pointer to thread */ 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate /* the following are used only when we have callbacks registered */ 1190Sstevel@tonic-gate kt_did_t fx_ktid; 1200Sstevel@tonic-gate struct fxproc *fx_cb_next; /* pointer to next fxproc that */ 1210Sstevel@tonic-gate /* has a callback */ 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate struct fxproc *fx_cb_prev; /* pointer to previous fxproc that */ 1240Sstevel@tonic-gate /* has a callback */ 1250Sstevel@tonic-gate fx_cookie_t fx_cookie; /* cookie with which callback */ 1260Sstevel@tonic-gate /* was registered */ 1270Sstevel@tonic-gate fx_callbacks_t *fx_callback; /* pointer to callback structure */ 128*3792Sakolb caps_sc_t fx_caps; /* CPU caps specific data */ 1290Sstevel@tonic-gate } fxproc_t; 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate #define FX_CALLB(fxpp) fxpp->fx_callback 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate /* flags */ 1360Sstevel@tonic-gate #define FXBACKQ 0x02 /* thread goes to back of disp q when preempted */ 1370Sstevel@tonic-gate 1380Sstevel@tonic-gate /* 1390Sstevel@tonic-gate * Kernel version of fixed-priority class specific parameter structure 1400Sstevel@tonic-gate */ 1410Sstevel@tonic-gate typedef struct fxkparms { 1420Sstevel@tonic-gate pri_t fx_upri; 1430Sstevel@tonic-gate pri_t fx_uprilim; 1440Sstevel@tonic-gate int fx_tqntm; 1450Sstevel@tonic-gate uint_t fx_cflags; 1460Sstevel@tonic-gate } fxkparms_t; 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate /* 1510Sstevel@tonic-gate * Interface for partner private code. This is not a public interface. 1520Sstevel@tonic-gate */ 1530Sstevel@tonic-gate extern int fx_register_callbacks(fx_callbacks_t *, fx_cookie_t, pri_t, clock_t); 1540Sstevel@tonic-gate extern int fx_unregister_callbacks(); 1550Sstevel@tonic-gate extern int fx_modify_priority(kt_did_t, clock_t, pri_t); 1560Sstevel@tonic-gate extern void *fx_get_mutex_cookie(); 1570Sstevel@tonic-gate extern pri_t fx_get_maxpri(); 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate #endif /* _KERNEL */ 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate #ifdef __cplusplus 1620Sstevel@tonic-gate } 1630Sstevel@tonic-gate #endif 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate #endif /* _SYS_FX_H */ 166