1/* 2 * Copyright (c) 1993-1995, 1999-2008 Apple Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28/* 29 * Declarations for timer interrupt callouts. 30 */ 31 32#ifndef _KERN_TIMER_CALL_H_ 33#define _KERN_TIMER_CALL_H_ 34 35#include <mach/mach_types.h> 36#include <kern/kern_types.h> 37 38#ifdef XNU_KERNEL_PRIVATE 39 40#include <kern/call_entry.h> 41 42#ifdef MACH_KERNEL_PRIVATE 43#include <kern/queue.h> 44 45extern boolean_t mach_timer_coalescing_enabled; 46extern void timer_call_queue_init(mpqueue_head_t *); 47#endif 48 49/* 50 * NOTE: for now, bsd/dev/dtrace/dtrace_glue.c has its own definition 51 * of this data structure, and the two had better match. 52 */ 53typedef struct timer_call { 54 struct call_entry call_entry; 55 decl_simple_lock_data( ,lock); /* protects call_entry queue */ 56 uint64_t soft_deadline; 57 uint32_t flags; 58 boolean_t async_dequeue; /* this field is protected by 59 call_entry queue's lock */ 60 uint64_t ttd; /* Time to deadline at creation */ 61} timer_call_data_t, *timer_call_t; 62 63#define EndOfAllTime 0xFFFFFFFFFFFFFFFFULL 64 65typedef void *timer_call_param_t; 66typedef void (*timer_call_func_t)( 67 timer_call_param_t param0, 68 timer_call_param_t param1); 69 70/* 71 * Flags to alter the default timer/timeout coalescing behavior 72 * on a per-timer_call basis. 73 * 74 * The SYS urgency classes indicate that the timer_call is not 75 * directly related to the current thread at the time the timer_call 76 * is entered, so it is ignored in the calculation entirely (only 77 * the subclass specified is used). 78 * 79 * The USER flags indicate that both the current thread scheduling and QoS 80 * attributes, in addition to the per-timer_call urgency specification, 81 * are used to establish coalescing behavior. 82 */ 83#define TIMER_CALL_SYS_NORMAL TIMEOUT_URGENCY_SYS_NORMAL 84#define TIMER_CALL_SYS_CRITICAL TIMEOUT_URGENCY_SYS_CRITICAL 85#define TIMER_CALL_SYS_BACKGROUND TIMEOUT_URGENCY_SYS_BACKGROUND 86 87#define TIMER_CALL_USER_MASK TIMEOUT_URGENCY_USER_MASK 88#define TIMER_CALL_USER_NORMAL TIMEOUT_URGENCY_USER_NORMAL 89#define TIMER_CALL_USER_CRITICAL TIMEOUT_URGENCY_USER_CRITICAL 90#define TIMER_CALL_USER_BACKGROUND TIMEOUT_URGENCY_USER_BACKGROUND 91 92#define TIMER_CALL_URGENCY_MASK TIMEOUT_URGENCY_MASK 93 94/* 95 * Indicate that a specific leeway value is being provided (otherwise 96 * the leeway parameter is ignored). This supplied value can currently 97 * only be used to extend the leeway calculated internally from the 98 * urgency class provided. 99 */ 100#define TIMER_CALL_LEEWAY TIMEOUT_URGENCY_LEEWAY 101 102/* 103 * Non-migratable timer_call 104 */ 105#define TIMER_CALL_LOCAL TIMEOUT_URGENCY_FIRST_AVAIL 106 107extern boolean_t timer_call_enter( 108 timer_call_t call, 109 uint64_t deadline, 110 uint32_t flags); 111 112extern boolean_t timer_call_enter1( 113 timer_call_t call, 114 timer_call_param_t param1, 115 uint64_t deadline, 116 uint32_t flags); 117 118extern boolean_t timer_call_enter_with_leeway( 119 timer_call_t call, 120 timer_call_param_t param1, 121 uint64_t deadline, 122 uint64_t leeway, 123 uint32_t flags, 124 boolean_t ratelimited); 125 126extern boolean_t timer_call_cancel( 127 timer_call_t call); 128 129extern void timer_call_init(void); 130 131extern void timer_call_setup( 132 timer_call_t call, 133 timer_call_func_t func, 134 timer_call_param_t param0); 135 136#endif /* XNU_KERNEL_PRIVATE */ 137 138#endif /* _KERN_TIMER_CALL_H_ */ 139