1 | /* |
2 | * Copyright (c) 2005, 2015 Apple Computer, 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 _SYS_BSDTASK_INFO_H |
30 | #define _SYS_BSDTASK_INFO_H |
31 | |
32 | #include <vm/vm_map.h> |
33 | |
34 | struct proc_taskinfo_internal { |
35 | uint64_t pti_virtual_size; /* virtual memory size (bytes) */ |
36 | uint64_t pti_resident_size; /* resident memory size (bytes) */ |
37 | uint64_t pti_total_user; /* total time */ |
38 | uint64_t pti_total_system; |
39 | uint64_t pti_threads_user; /* existing threads only */ |
40 | uint64_t pti_threads_system; |
41 | int32_t pti_policy; /* default policy for new threads */ |
42 | int32_t pti_faults; /* number of page faults */ |
43 | int32_t pti_pageins; /* number of actual pageins */ |
44 | int32_t pti_cow_faults; /* number of copy-on-write faults */ |
45 | int32_t pti_messages_sent; /* number of messages sent */ |
46 | int32_t pti_messages_received; /* number of messages received */ |
47 | int32_t pti_syscalls_mach; /* number of mach system calls */ |
48 | int32_t pti_syscalls_unix; /* number of unix system calls */ |
49 | int32_t pti_csw; /* number of context switches */ |
50 | int32_t pti_threadnum; /* number of threads in the task */ |
51 | int32_t pti_numrunning; /* number of running threads */ |
52 | int32_t pti_priority; /* task priority*/ |
53 | }; |
54 | |
55 | #define MAXTHREADNAMESIZE 64 |
56 | |
57 | struct proc_threadinfo_internal { |
58 | uint64_t pth_user_time; /* user run time */ |
59 | uint64_t pth_system_time; /* system run time */ |
60 | int32_t pth_cpu_usage; /* scaled cpu usage percentage */ |
61 | int32_t pth_policy; /* scheduling policy in effect */ |
62 | int32_t pth_run_state; /* run state (see below) */ |
63 | int32_t pth_flags; /* various flags (see below) */ |
64 | int32_t pth_sleep_time; /* number of seconds that thread */ |
65 | int32_t pth_curpri; /* cur priority*/ |
66 | int32_t pth_priority; /* priority*/ |
67 | int32_t pth_maxpriority; /* max priority*/ |
68 | char pth_name[MAXTHREADNAMESIZE]; /* thread name, if any */ |
69 | }; |
70 | |
71 | struct proc_threadschedinfo_internal { |
72 | uint64_t int_time_ns; /* time spent in interrupt context */ |
73 | }; |
74 | |
75 | |
76 | struct proc_regioninfo_internal { |
77 | uint32_t pri_protection; |
78 | uint32_t pri_max_protection; |
79 | uint32_t pri_inheritance; |
80 | uint32_t pri_flags; /* shared, external pager, is submap */ |
81 | uint64_t pri_offset; |
82 | uint32_t pri_behavior; |
83 | uint32_t pri_user_wired_count; |
84 | uint32_t pri_user_tag; |
85 | uint32_t pri_pages_resident; |
86 | uint32_t pri_pages_shared_now_private; |
87 | uint32_t pri_pages_swapped_out; |
88 | uint32_t pri_pages_dirtied; |
89 | uint32_t pri_ref_count; |
90 | uint32_t pri_shadow_depth; |
91 | uint32_t pri_share_mode; |
92 | uint32_t pri_private_pages_resident; |
93 | uint32_t pri_shared_pages_resident; |
94 | uint32_t pri_obj_id; |
95 | uint32_t pri_depth; |
96 | uint64_t pri_address; |
97 | uint64_t pri_size; |
98 | }; |
99 | |
100 | #ifdef MACH_KERNEL_PRIVATE |
101 | |
102 | #define PROC_REGION_SUBMAP 1 |
103 | #define PROC_REGION_SHARED 2 |
104 | |
105 | extern uint32_t vnode_vid(void *vp); |
106 | |
107 | #if CONFIG_IOSCHED |
108 | kern_return_t (memory_object_t mem_obj, uintptr_t *devvp); |
109 | extern struct vnode *vnode_mountdevvp(struct vnode *); |
110 | #endif |
111 | |
112 | extern boolean_t vnode_isonexternalstorage(void *vp); |
113 | |
114 | #endif /* MACH_KERNEL_PRIVATE */ |
115 | |
116 | extern int fill_procregioninfo(task_t t, uint64_t arg, struct proc_regioninfo_internal *pinfo, uintptr_t *vp, uint32_t *vid); |
117 | extern int fill_procregioninfo_onlymappedvnodes(task_t t, uint64_t arg, struct proc_regioninfo_internal *pinfo, uintptr_t *vp, uint32_t *vid); |
118 | extern int find_region_details(task_t task, vm_map_offset_t offset, uintptr_t *vnodeaddr, uint32_t *vid, uint64_t *start, uint64_t *len); |
119 | void fill_taskprocinfo(task_t task, struct proc_taskinfo_internal * ptinfo); |
120 | int fill_taskthreadinfo(task_t task, uint64_t thaddr, bool thuniqueid, struct proc_threadinfo_internal * ptinfo, void *, int *); |
121 | int fill_taskthreadlist(task_t task, void * buffer, int thcount, bool thuniqueid); |
122 | int fill_taskthreadschedinfo(task_t task, uint64_t thaddr, struct proc_threadschedinfo_internal *thread_sched_info); |
123 | int get_numthreads(task_t); |
124 | boolean_t bsd_hasthreadname(void *uth); |
125 | void bsd_getthreadname(void *uth, char* buffer); |
126 | void bsd_setthreadname(void *uth, uint64_t tid, const char* buffer); |
127 | void bsd_threadcdir(void * uth, void *vptr, int *vidp); |
128 | extern void bsd_copythreadname(void *dst_uth, void *src_uth); |
129 | int fill_taskipctableinfo(task_t task, uint32_t *table_size, uint32_t *table_free); |
130 | |
131 | #endif /*_SYS_BSDTASK_INFO_H */ |
132 | |