]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kern/sfi.h
xnu-4903.270.47.tar.gz
[apple/xnu.git] / osfmk / kern / sfi.h
CommitLineData
fe8ab488
A
1/*
2 * Copyright (c) 2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
fe8ab488
A
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.
0a7de745 14 *
fe8ab488
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
fe8ab488
A
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.
0a7de745 25 *
fe8ab488
A
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29#ifndef _KERN_SFI_H_
30#define _KERN_SFI_H_
31
32#include <stdint.h>
33#include <mach/mach_types.h>
34#include <mach/kern_return.h>
35#include <mach/sfi_class.h>
36#include <kern/ast.h>
37#include <kern/kern_types.h>
38#include <kern/ledger.h>
39
40extern void sfi_init(void);
41extern void sfi_early_init(void);
42extern sfi_class_id_t sfi_get_ledger_alias_for_class(sfi_class_id_t class_id);
43extern int sfi_ledger_entry_add(ledger_template_t template, sfi_class_id_t class_id);
44
45kern_return_t sfi_set_window(uint64_t window_usecs);
46kern_return_t sfi_window_cancel(void);
47kern_return_t sfi_get_window(uint64_t *window_usecs);
48
49kern_return_t sfi_set_class_offtime(sfi_class_id_t class_id, uint64_t offtime_usecs);
50kern_return_t sfi_class_offtime_cancel(sfi_class_id_t class_id);
51kern_return_t sfi_get_class_offtime(sfi_class_id_t class_id, uint64_t *offtime_usecs);
52
53#ifdef MACH_KERNEL_PRIVATE
54/*
55 * Classifying a thread requires no special locks to be held (although attribute
56 * changes that cause an inconsistent snapshot may cause a spurious AST). Final
57 * evaluation will happen at the AST boundary with the thread locked. If possible,
0a7de745 58 *
fe8ab488
A
59 */
60sfi_class_id_t sfi_thread_classify(thread_t thread);
61sfi_class_id_t sfi_processor_active_thread_classify(processor_t processor);
62ast_t sfi_thread_needs_ast(thread_t thread, sfi_class_id_t *out_class /* optional */);
63ast_t sfi_processor_needs_ast(processor_t processor);
64
65void sfi_ast(thread_t thread);
66void sfi_reevaluate(thread_t thread);
04b8595b 67kern_return_t sfi_defer(uint64_t);
fe8ab488
A
68#endif /* MACH_KERNEL_PRIVATE */
69
70#endif /* _KERN_SFI_H_ */