1 /* $NetBSD: mach_thread.h,v 1.18 2005/12/11 12:20:20 christos Exp $ */
2
3 /*-
4 * Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Emmanuel Dreyfus
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifndef _MACH_THREAD_H_
40 #define _MACH_THREAD_H_
41
42 #include <sys/types.h>
43 #include <sys/param.h>
44 #include <sys/signal.h>
45 #include <sys/proc.h>
46
47 #include <compat/mach/mach_types.h>
48 #include <compat/mach/mach_message.h>
49
50 /* For mach_create_thread_child() */
51 struct mach_create_thread_child_args {
52 struct lwp *mctc_lwp;
53 struct lwp *mctc_oldlwp;
54 mach_natural_t *mctc_state;
55 int mctc_flavor;
56 int mctc_child_done;
57 };
58
59 /* For mach_sys_syscall_thread_switch() */
60 #define MACH_SWITCH_OPTION_NONE 0
61 #define MACH_SWITCH_OPTION_DEPRESS 1
62 #define MACH_SWITCH_OPTION_WAIT 2
63 #define MACH_SWITCH_OPTION_IDLE 3
64
65 /* For mach_thread_info */
66 #define MACH_THREAD_BASIC_INFO 3
67 struct mach_thread_basic_info {
68 mach_time_value_t user_time;
69 mach_time_value_t system_time;
70 mach_integer_t cpu_usage;
71 mach_policy_t policy;
72 mach_integer_t run_state;
73 mach_integer_t flags;
74 mach_integer_t suspend_count;
75 mach_integer_t sleep_time;
76 };
77 #define MACH_TH_STATE_RUNNING 1
78 #define MACH_TH_STATE_STOPPED 2
79 #define MACH_TH_STATE_WAITING 3
80 #define MACH_TH_STATE_UNINTERRUPTIBLE 4
81 #define MACH_TH_STATE_HALTED 5
82
83 #define MACH_TH_FLAGS_SWAPPED 1
84 #define MACH_TH_FLAGS_IDLE 2
85
86 #define MACH_THREAD_SCHED_TIMESHARE_INFO 10
87 struct mach_policy_timeshare_info {
88 mach_integer_t max_priority;
89 mach_integer_t base_priority;
90 mach_integer_t cur_priority;
91 mach_boolean_t depressed;
92 mach_integer_t depress_priority;
93 };
94
95 #define MACH_THREAD_SCHED_RR_INFO 11
96 #define MACH_THREAD_SCHED_FIFO_INFO 12
97
98 /* For mach_policy_t */
99 #define MACH_THREAD_STANDARD_POLICY 1
100 #define MACH_THREAD_TIME_CONSTRAINT_POLICY 2
101 #define MACH_THREAD_PRECEDENCE_POLICY 3
102
103 /* thread_policy */
104
105 typedef struct {
106 mach_msg_header_t req_msgh;
107 mach_ndr_record_t req_ndr;
108 mach_policy_t req_policy;
109 mach_msg_type_number_t req_count;
110 mach_integer_t req_base[0];
111 mach_boolean_t req_setlimit;
112 } mach_thread_policy_request_t;
113
114 typedef struct {
115 mach_msg_header_t rep_msgh;
116 mach_ndr_record_t rep_ndr;
117 mach_kern_return_t rep_retval;
118 mach_msg_trailer_t rep_trailer;
119 } mach_thread_policy_reply_t;
120
121 /* mach_thread_create_running */
122
123 typedef struct {
124 mach_msg_header_t req_msgh;
125 mach_ndr_record_t req_ndr;
126 mach_thread_state_flavor_t req_flavor;
127 mach_msg_type_number_t req_count;
128 mach_natural_t req_state[0];
129 } mach_thread_create_running_request_t;
130
131 typedef struct {
132 mach_msg_header_t rep_msgh;
133 mach_msg_body_t rep_body;
134 mach_msg_port_descriptor_t rep_child_act;
135 mach_msg_trailer_t rep_trailer;
136 } mach_thread_create_running_reply_t;
137
138 /* mach_thread_info */
139
140 typedef struct {
141 mach_msg_header_t req_msgh;
142 mach_ndr_record_t req_ndr;
143 mach_thread_flavor_t req_flavor;
144 mach_msg_type_number_t req_count;
145 } mach_thread_info_request_t;
146
147 typedef struct {
148 mach_msg_header_t rep_msgh;
149 mach_ndr_record_t rep_ndr;
150 mach_kern_return_t rep_retval;
151 mach_msg_type_number_t rep_count;
152 mach_integer_t rep_out[12];
153 mach_msg_trailer_t rep_trailer;
154 } mach_thread_info_reply_t;
155
156 /* thread_get_state */
157
158 typedef struct {
159 mach_msg_header_t req_msgh;
160 mach_ndr_record_t req_ndr;
161 mach_thread_state_flavor_t req_flavor;
162 mach_msg_type_number_t req_count;
163 } mach_thread_get_state_request_t;
164
165 typedef struct {
166 mach_msg_header_t rep_msgh;
167 mach_ndr_record_t rep_ndr;
168 mach_kern_return_t rep_retval;
169 mach_msg_type_number_t rep_count;
170 mach_integer_t rep_state[144];
171 mach_msg_trailer_t rep_trailer;
172 } mach_thread_get_state_reply_t;
173
174 /* mach_thread_set_state */
175
176 typedef struct {
177 mach_msg_header_t req_msgh;
178 mach_ndr_record_t req_ndr;
179 mach_thread_state_flavor_t req_flavor;
180 mach_msg_type_number_t req_count;
181 mach_integer_t req_state[0];
182 } mach_thread_set_state_request_t;
183
184 typedef struct {
185 mach_msg_header_t rep_msgh;
186 mach_ndr_record_t rep_ndr;
187 mach_kern_return_t rep_retval;
188 mach_msg_trailer_t rep_trailer;
189 } mach_thread_set_state_reply_t;
190
191 /* thread_suspend */
192
193 typedef struct {
194 mach_msg_header_t req_msgh;
195 } mach_thread_suspend_request_t;
196
197 typedef struct {
198 mach_msg_header_t rep_msgh;
199 mach_ndr_record_t rep_ndr;
200 mach_kern_return_t rep_retval;
201 mach_msg_trailer_t rep_trailer;
202 } mach_thread_suspend_reply_t;
203
204 /* thread_resume */
205
206 typedef struct {
207 mach_msg_header_t req_msgh;
208 } mach_thread_resume_request_t;
209
210 typedef struct {
211 mach_msg_header_t rep_msgh;
212 mach_ndr_record_t rep_ndr;
213 mach_kern_return_t rep_retval;
214 mach_msg_trailer_t rep_trailer;
215 } mach_thread_resume_reply_t;
216
217 /* thread_abort */
218
219 typedef struct {
220 mach_msg_header_t req_msgh;
221 } mach_thread_abort_request_t;
222
223 typedef struct {
224 mach_msg_header_t rep_msgh;
225 mach_ndr_record_t rep_ndr;
226 mach_kern_return_t rep_retval;
227 mach_msg_trailer_t rep_trailer;
228 } mach_thread_abort_reply_t;
229
230 /* thread_set_policy */
231
232 typedef struct {
233 mach_msg_header_t req_msgh;
234 mach_msg_body_t req_body;
235 mach_msg_port_descriptor_t req_pset;
236 mach_ndr_record_t req_ndr;
237 mach_policy_t req_policy;
238 mach_msg_type_number_t req_base_count;
239 mach_integer_t req_base[0];
240 mach_msg_type_number_t req_limit_count;
241 mach_integer_t req_limit[0];
242 } mach_thread_set_policy_request_t;
243
244 typedef struct {
245 mach_msg_header_t rep_msgh;
246 mach_ndr_record_t rep_ndr;
247 mach_kern_return_t rep_retval;
248 mach_msg_trailer_t rep_trailer;
249 } mach_thread_set_policy_reply_t;
250
251 /* These are machine dependent functions */
252 int mach_thread_get_state_machdep(struct lwp *, int, void *, int *);
253 int mach_thread_set_state_machdep(struct lwp *, int, void *);
254 void mach_create_thread_child(void *);
255
256 #endif /* _MACH_THREAD_H_ */
Cache object: e44b0eec2a7e047afe3a652f17e3cc46
|