1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
|
/*
Copyright (C) 2009 Free Software Foundation, Inc.
Written by Zheng Da.
This file is part of the GNU Hurd.
The GNU Hurd is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
The GNU Hurd is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the GNU Hurd; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* This file implements the server-side RPC functions of mach_host. */
#include <stdio.h>
#include <assert.h>
#include <mach.h>
#include <hurd.h>
#include <hurd/ports.h>
#include "util.h"
#include "list.h"
#include "mach_proxy.h"
extern mach_port_t privileged_host_port;
/* Set task priority. */
kern_return_t
S_task_priority (mach_port_t task, int priority, boolean_t change_threads)
{
struct task_info *task_pi;
error_t err;
task_pi = ports_lookup_port (port_bucket, task, task_portclass);
if (task_pi == NULL)
return EOPNOTSUPP;
err = task_priority (task_pi->task_port, priority, change_threads);
debug ("%s", strerror (err));
ports_port_deref (task_pi);
return err;
}
/* Routine processor_set_tasks */
kern_return_t
S_processor_set_tasks (mach_port_t processor_set, task_array_t *task_list,
mach_msg_type_number_t *task_listCnt)
{
error_t err = 0;
mach_port_t *subhurd_tasks = NULL;
int size = 0;
/* no pseudo task port is created for the kernel task. */
int num = 0;
int tot_nbtasks = ports_count_class (task_portclass) + num;
size = tot_nbtasks * sizeof (mach_port_t);
err = vm_allocate (mach_task_self (),
(vm_address_t *) (void *) &subhurd_tasks,
size, 1);
if (err)
goto out;
int get_pseudo_task_port (struct task_info *task_pi)
{
assert (num < tot_nbtasks);
subhurd_tasks[num++] = ports_get_right (task_pi);
return 0;
}
foreach_task (get_pseudo_task_port);
assert (num == tot_nbtasks);
debug ("get %d tasks", tot_nbtasks);
*task_list = subhurd_tasks;
*task_listCnt = tot_nbtasks;
out:
/* I enable the class here,
* so no pseudo task port can be created when I count the number of tasks. */
ports_enable_class (task_portclass);
/* The array will be deallocated after it is sent,
* but the task ports in it don't need to,
* because I only call ports_get_right()
* and the reference count isn't increased. */
return err;
}
/* Get control port for a processor set. */
kern_return_t
S_host_processor_set_priv (mach_port_t host_priv, mach_port_t set_name,
mach_port_t *set, mach_msg_type_name_t *setPoly)
{
extern struct port_class *other_portclass;
struct port_info *pi;
kern_return_t ret = 0;
// TODO create a port for each processor set
// I should create the port for the processor set only once.
ret = ports_create_port (other_portclass, port_bucket,
sizeof (*pi), &pi);
debug ("%s", strerror (ret));
if (ret)
return ret;
*set = ports_get_right (pi);
*setPoly = MACH_MSG_TYPE_MAKE_SEND;
ports_port_deref (pi);
return ret;
}
/* Routine host_reboot */
kern_return_t
S_host_reboot (mach_port_t host_priv, int options)
{
debug ("");
assert (0);
// TODO
return EOPNOTSUPP;
}
/* Routine vm_wire */
kern_return_t
S_vm_wire (mach_port_t host_priv, mach_port_t task,
vm_address_t address, vm_size_t size, vm_prot_t access)
{
debug ("");
assert (0);
// TODO
return EOPNOTSUPP;
}
/* Routine thread_wire */
kern_return_t
S_thread_wire (mach_port_t host_priv, mach_port_t thread, boolean_t wired)
{
debug ("");
assert (0);
// TODO
return EOPNOTSUPP;
}
//////////the request to the host isn't forwarded by the proxy//////////
/* Routine host_processor_sets */
kern_return_t
S_host_processor_sets (mach_port_t host,
processor_set_name_array_t *processor_sets,
mach_msg_type_number_t *processor_setsCnt)
{
debug ("");
assert (0);
// the request to the host isn't forwarded.
return EOPNOTSUPP;
}
/* Routine host_get_time */
kern_return_t
S_host_get_time (mach_port_t host, time_value_t *current_time)
{
debug ("");
assert (0);
// the request to the host isn't forwarded.
return EOPNOTSUPP;
}
/* Routine host_info */
kern_return_t
S_host_info (mach_port_t host, int flavor, host_info_t host_info_out,
mach_msg_type_number_t *host_info_outCnt)
{
debug ("");
assert (0);
// the request to the host isn't forwarded.
return EOPNOTSUPP;
}
/* Get string describing current kernel version. */
kern_return_t
S_host_kernel_version (mach_port_t host, kernel_version_t kernel_version)
{
debug ("");
assert (0);
// the proxy doesn't forward the request to the host port.
return EOPNOTSUPP;
}
///////////////////the RPCs not used by Hurd//////////////////////
/* Get list of processors on this host. */
kern_return_t
S_host_processors (mach_port_t host_priv,
processor_array_t *processor_list,
mach_msg_type_number_t *processor_listCnt)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Start processor. */
kern_return_t
S_processor_start (mach_port_t processor)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Exit processor -- may not be restartable. */
kern_return_t
S_processor_exit (mach_port_t processor)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Get default processor set for host. */
kern_return_t
S_processor_set_default (mach_port_t host, mach_port_t *default_set)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/*
* Create new processor set. Returns real port for manipulations,
* and name port for obtaining information.
*/
kern_return_t
S_processor_set_create (mach_port_t host, mach_port_t *new_set,
mach_port_t *new_name)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Destroy processor set. */
kern_return_t
S_processor_set_destroy (mach_port_t set)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Assign processor to processor set. */
kern_return_t
S_processor_assign (mach_port_t processor, mach_port_t new_set, boolean_t wait)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Get current assignment for thread. */
kern_return_t
S_processor_get_assignment (mach_port_t processor, mach_port_t *assigned_set)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Assign task to processor set. */
kern_return_t
S_task_assign (mach_port_t task, mach_port_t new_set, boolean_t assign_threads)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Assign task to default set. */
kern_return_t
S_task_assign_default (mach_port_t task, boolean_t assign_threads)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Get current assignment for task. */
kern_return_t
S_task_get_assignment (mach_port_t task, mach_port_t *assigned_set)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Set max priority for processor_set. */
kern_return_t
S_processor_set_max_priority (mach_port_t processor_set, int max_priority,
boolean_t change_threads)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Routine processor_set_policy_enable */
kern_return_t
S_processor_set_policy_enable (mach_port_t processor_set, int policy)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Routine processor_set_policy_disable */
kern_return_t
S_processor_set_policy_disable (mach_port_t processor_set, int policy,
boolean_t change_threads)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Routine processor_set_threads */
kern_return_t
S_processor_set_threads (mach_port_t processor_set,
thread_array_t *thread_list,
mach_msg_type_number_t *thread_listCnt)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Routine host_set_time */
kern_return_t
S_host_set_time (mach_port_t host_priv, time_value_t new_time)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Routine host_adjust_time */
kern_return_t
S_host_adjust_time (mach_port_t host_priv, time_value_t new_adjustment,
time_value_t *old_adjustment)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Routine processor_info */
kern_return_t
S_processor_info (mach_port_t processor, int flavor, mach_port_t *host,
processor_info_t processor_info_out,
mach_msg_type_number_t *processor_info_outCnt)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Routine processor_set_info */
kern_return_t
S_processor_set_info (mach_port_t set_name, int flavor, mach_port_t *host,
processor_set_info_t info_out,
mach_msg_type_number_t *info_outCnt)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Routine processor_control */
kern_return_t
S_processor_control (mach_port_t processor, processor_info_t processor_cmd,
mach_msg_type_number_t processor_cmdCnt)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
/* Routine host_get_boot_info */
kern_return_t
S_host_get_boot_info (mach_port_t host_priv, kernel_boot_info_t boot_info)
{
debug ("");
assert (0);
// Hurd currently doesn't use it.
return EOPNOTSUPP;
}
///////////////////it's not a proxy for thread requests///////////////////
/* Assign thread to processor set. */
kern_return_t
S_thread_assign (mach_port_t thread, mach_port_t new_set)
{
debug ("");
assert (0);
return EOPNOTSUPP;
}
/* Assign thread to default set. */
kern_return_t
S_thread_assign_default (mach_port_t thread)
{
debug ("");
assert (0);
return EOPNOTSUPP;
}
/* Get current assignment for thread. */
kern_return_t
S_thread_get_assignment (mach_port_t thread, mach_port_t *assigned_set)
{
debug ("");
assert (0);
return EOPNOTSUPP;
}
/* Set priority for thread. */
kern_return_t S_thread_priority (mach_port_t thread, int priority,
boolean_t set_max)
{
debug ("");
assert (0);
return thread_priority (thread, priority, set_max);
}
/* Set max priority for thread. */
kern_return_t S_thread_max_priority (mach_port_t thread,
mach_port_t processor_set,
int max_priority)
{
debug ("");
assert (0);
return thread_max_priority (thread, processor_set, max_priority);
}
/* Routine thread_depress_abort */
kern_return_t S_thread_depress_abort (mach_port_t thread)
{
debug ("");
assert (0);
return EOPNOTSUPP;
}
/* Set policy for thread */
kern_return_t S_thread_policy (mach_port_t thread, int policy, int data)
{
debug ("");
assert (0);
return EOPNOTSUPP;
}
////////////////////don't support obsolete requests///////////////////////
/* Routine yyy_host_info */
/* obsolete */
kern_return_t
S_yyy_host_info (mach_port_t host, int flavor, host_info_t host_info_out,
mach_msg_type_number_t *host_info_outCnt)
{
debug ("");
assert (0);
return EOPNOTSUPP;
}
/* Routine yyy_processor_info */
/* obsolete */
kern_return_t
S_yyy_processor_info (mach_port_t processor, int flavor, mach_port_t *host,
processor_info_t processor_info_out,
mach_msg_type_number_t *processor_info_outCnt)
{
debug ("");
assert (0);
return EOPNOTSUPP;
}
/* Routine yyy_processor_control */
/* obsolete */
kern_return_t
S_yyy_processor_control (mach_port_t processor,
processor_info_t processor_cmd,
mach_msg_type_number_t processor_cmdCnt)
{
debug ("");
assert (0);
return EOPNOTSUPP;
}
/*
* Get rights to default processor set for host.
* Replaced by host_processor_set_priv.
*/
kern_return_t
S_xxx_processor_set_default_priv (mach_port_t host, mach_port_t *default_set)
{
debug ("");
assert (0);
return EOPNOTSUPP;
}
/* Routine yyy_processor_set_info */
/* obsolete */
kern_return_t
S_yyy_processor_set_info (mach_port_t set_name, int flavor,
mach_port_t *host, processor_set_info_t info_out,
mach_msg_type_number_t *info_outCnt)
{
debug ("");
assert (0);
return EOPNOTSUPP;
}
|