--- Gnu-Mach/include/mach/gnumach.defs 2020/09/02 04:45:41 1.1 +++ Gnu-Mach/include/mach/gnumach.defs 2020/09/02 04:52:29 1.1.1.3 @@ -27,6 +27,11 @@ subsystem #include #include +#include + +#ifdef GNUMACH_IMPORTS +GNUMACH_IMPORTS +#endif type vm_cache_statistics_data_t = struct[11] of integer_t; @@ -37,3 +42,97 @@ type vm_cache_statistics_data_t = struct 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); +