1 | /* |
2 | * Copyright (c) 2013 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 | #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 | |
40 | extern void sfi_init(void); |
41 | extern sfi_class_id_t sfi_get_ledger_alias_for_class(sfi_class_id_t class_id); |
42 | extern int sfi_ledger_entry_add(ledger_template_t template, sfi_class_id_t class_id); |
43 | |
44 | kern_return_t sfi_set_window(uint64_t window_usecs); |
45 | kern_return_t sfi_window_cancel(void); |
46 | kern_return_t sfi_get_window(uint64_t *window_usecs); |
47 | |
48 | kern_return_t sfi_set_class_offtime(sfi_class_id_t class_id, uint64_t offtime_usecs); |
49 | kern_return_t sfi_class_offtime_cancel(sfi_class_id_t class_id); |
50 | kern_return_t sfi_get_class_offtime(sfi_class_id_t class_id, uint64_t *offtime_usecs); |
51 | |
52 | #ifdef MACH_KERNEL_PRIVATE |
53 | /* |
54 | * Classifying a thread requires no special locks to be held (although attribute |
55 | * changes that cause an inconsistent snapshot may cause a spurious AST). Final |
56 | * evaluation will happen at the AST boundary with the thread locked. If possible, |
57 | * |
58 | */ |
59 | sfi_class_id_t sfi_thread_classify(thread_t thread); |
60 | sfi_class_id_t sfi_processor_active_thread_classify(processor_t processor); |
61 | ast_t sfi_thread_needs_ast(thread_t thread, sfi_class_id_t *out_class /* optional */); |
62 | ast_t sfi_processor_needs_ast(processor_t processor); |
63 | |
64 | void sfi_ast(thread_t thread); |
65 | void sfi_reevaluate(thread_t thread); |
66 | kern_return_t sfi_defer(uint64_t); |
67 | #endif /* MACH_KERNEL_PRIVATE */ |
68 | |
69 | #endif /* _KERN_SFI_H_ */ |
70 | |