]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kperf/kperf_timer.h
4 * Copyright (c) 2011 Apple Computer, Inc. All rights reserved.
6 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. The rights granted to you under the License
12 * may not be used to create, or enable the creation or redistribution of,
13 * unlawful or unlicensed copies of an Apple operating system, or to
14 * circumvent, violate, or enable the circumvention or violation of, any
15 * terms of an Apple operating system software license agreement.
17 * Please obtain a copy of the License at
18 * http://www.opensource.apple.com/apsl/ and read it before using this file.
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
31 #include <kern/timer_call.h>
32 #include <kern/bits.h>
35 struct timer_call tcall
;
38 volatile unsigned active
;
41 * A bitmap of CPUs that have a pending timer to service. On Intel, it
42 * allows the core responding to the timer interrupt to not queue up
43 * cross-calls on cores that haven't yet responded. On ARM, it allows
44 * the signal handler to multiplex simultaneous fires of different
47 bitmap_t pending_cpus
;
50 extern struct kperf_timer
*kperf_timerv
;
51 extern unsigned int kperf_timerc
;
53 void kperf_timer_reprogram(void);
54 void kperf_timer_reprogram_all(void);
56 void kperf_ipi_handler(void *param
);
58 // return values from the action
59 #define TIMER_REPROGRAM (0)
60 #define TIMER_STOP (1)
62 #if defined(__x86_64__)
64 #define KP_MIN_PERIOD_NS (20 * NSEC_PER_USEC)
65 #define KP_MIN_PERIOD_BG_NS (10 * NSEC_PER_MSEC)
66 #define KP_MIN_PERIOD_PET_NS (2 * NSEC_PER_MSEC)
67 #define KP_MIN_PERIOD_PET_BG_NS (10 * NSEC_PER_MSEC)
69 #elif defined(__arm64__)
71 #define KP_MIN_PERIOD_NS (50 * NSEC_PER_USEC)
72 #define KP_MIN_PERIOD_BG_NS (20 * NSEC_PER_MSEC)
73 #define KP_MIN_PERIOD_PET_NS (2 * NSEC_PER_MSEC)
74 #define KP_MIN_PERIOD_PET_BG_NS (50 * NSEC_PER_MSEC)
76 #elif defined(__arm__)
78 #define KP_MIN_PERIOD_NS (100 * NSEC_PER_USEC)
79 #define KP_MIN_PERIOD_BG_NS (50 * NSEC_PER_MSEC)
80 #define KP_MIN_PERIOD_PET_NS (2 * NSEC_PER_MSEC)
81 #define KP_MIN_PERIOD_PET_BG_NS (100 * NSEC_PER_MSEC)
83 #else /* defined(__x86_64__) */
84 #error "unsupported architecture"
85 #endif /* defined(__x86_64__) */
87 /* getters and setters on timers */
88 unsigned kperf_timer_get_count(void);
89 int kperf_timer_set_count(unsigned int count
);
91 int kperf_timer_get_period(unsigned int timer
, uint64_t *period
);
92 int kperf_timer_set_period(unsigned int timer
, uint64_t period
);
94 int kperf_timer_get_action(unsigned int timer
, uint32_t *action
);
95 int kperf_timer_set_action(unsigned int timer
, uint32_t action
);
97 void kperf_timer_go(void);
98 void kperf_timer_stop(void);
99 void kperf_timer_reset(void);
101 unsigned int kperf_timer_get_petid(void);
102 int kperf_timer_set_petid(unsigned int count
);
104 /* so PET thread can re-arm the timer */
105 void kperf_timer_pet_rearm(uint64_t elapsed_ticks
);
107 #endif /* !defined(KPERF_TIMER_H) */