summaryrefslogtreecommitdiff
path: root/include/mach/gnumach.defs
blob: b484accc001f635a7b0c1c5d57878091c95ceafe (plain)
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
/*
 * Copyright (C) 2012 Free Software Foundation
 *
 * This program 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 of the License, or
 * (at your option) any later version.
 *
 * This program 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 this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

subsystem
#if	KERNEL_SERVER
	  KernelServer
#endif	/* KERNEL_SERVER */
#if	KERNEL_USER
	  KernelUser
#endif	/* KERNEL_USER */
		       gnumach 4200;

#include <mach/std_types.defs>
#include <mach/mach_types.defs>
#include <mach_debug/mach_debug_types.defs>

#ifdef	GNUMACH_IMPORTS
GNUMACH_IMPORTS
#endif

type vm_cache_statistics_data_t = struct[11] of integer_t;

type vm_wire_t = int;

/*
 * Return page cache statistics for the host on which the target task
 * resides.
 */
routine vm_cache_statistics(
		target_task	: vm_task_t;
	out	vm_cache_stats	: vm_cache_statistics_data_t);

/*
 * Terminate a thread and release rights and memory.
 *
 * Intended to be used by threading libraries to provide a clean way for
 * threads to terminate themselves. The resources a thread wouldn't be able
 * to release without this call when terminating itself are its
 * last reference to its kernel port, its reply port, and its stack.
 *
 * This call is semantically equivalent to :
 *  - mach_port_deallocate(task, thread_name);
 *  - if (reply_port != MACH_PORT_NULL)
 *      mach_port_destroy(task, reply_port);
 *  - if ((address != 0) || (size != 0))
 *      vm_deallocate(task, address, size)
 *  - thread_terminate(thread)
 *
 * Implemented as a simple routine so a reply port isn't required.
 */
simpleroutine thread_terminate_release(
		thread		: thread_t;
		task		: task_t;
		thread_name	: mach_port_name_t;
		reply_port	: mach_port_name_t;
		address		: vm_address_t;
		size		: vm_size_t);

/*
 *	Set the name of task TASK to NAME.  This is a debugging aid.
 *	NAME will be used in error messages printed by the kernel.
 */
simpleroutine task_set_name(
		task	: task_t;
		name	: kernel_debug_name_t);

/*
 * Register a port to which a notification about newly created tasks
 * are sent.
 */
routine register_new_task_notification(
		host_priv	: host_priv_t;
		notification	: mach_port_send_t);

/* Test that the contents of ADDR are equal to the 32-bit integer VAL1.
 * If they are not, return immediately, otherwise, block until a
 * matching 'gsync_wake' is done on the same address. FLAGS is used
 * to control how the thread waits, and may be composed of:
 * - GSYNC_SHARED: The address may be shared among tasks. If this
     bit is not set, the address is assumed to be task-local.
 * - GSYNC_QUAD: Additionally check that the adjacent 32-bit word
     following ADDR matches the value VAL2.
 * - GSYNC_TIMED: The call only blocks for MSEC milliseconds. */
routine gsync_wait(
  task : task_t;
  addr : vm_offset_t;
  val1 : unsigned;
  val2 : unsigned;
  msec : natural_t;
  flags : int);

/* Wake up threads waiting on the address ADDR. Much like with
 * 'gsync_wait', the parameter FLAGS controls how it is done. In this
 * case, it may be composed of the following:
 * - GSYNC_SHARED: Same as with 'gsync_wait'.
 * - GSYNC_BROADCAST: Wake up every thread waiting on the address. If
 *   this flag is not set, the call wakes (at most) 1 thread.
 * - GSYNC_MUTATE: Before waking any potential waiting threads, set the
 *   contents of ADDR to VAL.
 *
 * This RPC is implemented as a simple routine for efficiency reasons,
 * and because the return value rarely matters. */
simpleroutine gsync_wake(
  task : task_t;
  addr : vm_offset_t;
  val : unsigned;
  flags : int);

/* Arrange for threads waiting on address SRC_ADDR to instead
 * wait on address DST_ADDR. If WAKE_ONE is true, additionally
 * wake one of the threads waiting on SRC_ADDR. For this function,
 * the parameter flags may be a combination of:
 * - GSYNC_SHARED: Just like with 'gsync_wait' and 'gsync_wake'.
 * - GSYNC_BROADCAST: Move all the threads waiting on SRC_ADDR. If
     this flag is not set, the call moves (at most) 1 thread.
 *
 * This RPC is also a simple routine, and for the same reasons as
 * with 'gsync_wake'. */
simpleroutine gsync_requeue(
  task : task_t;
  src_addr : vm_offset_t;
  dst_addr : vm_offset_t;
  wake_one : boolean_t;
  flags : int);

/*
 * If the VM_WIRE_CURRENT flag is passed, specify that the entire
 * virtual address space of the target task must not cause page faults.
 *
 * If the VM_WIRE_FUTURE flag is passed, automatically wire new
 * mappings in the address space of the target task.
 *
 * If the flags are empty (VM_WIRE_NONE), unwire all mappings.
 */
routine	vm_wire_all(
		host		: mach_port_t;
		task		: vm_task_t;
		flags		: vm_wire_t);