1/*
2 * Copyright (c) 2019 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 _MACH_EVENTLINK_TYPES_H_
30#define _MACH_EVENTLINK_TYPES_H_
31
32#include <mach/std_types.h>
33#include <mach/port.h>
34
35__options_decl(kern_clock_id_t, uint32_t, {
36 KERN_CLOCK_MACH_ABSOLUTE_TIME = 1,
37});
38
39__options_decl(mach_eventlink_create_option_t, uint32_t, {
40 MELC_OPTION_NONE = 0,
41 MELC_OPTION_NO_COPYIN = 0x1,
42 MELC_OPTION_WITH_COPYIN = 0x2,
43});
44
45__options_decl(mach_eventlink_associate_option_t, uint32_t, {
46 MELA_OPTION_NONE = 0,
47 MELA_OPTION_ASSOCIATE_ON_WAIT = 0x1,
48});
49
50__options_decl(mach_eventlink_disassociate_option_t, uint32_t, {
51 MELD_OPTION_NONE = 0,
52});
53
54__options_decl(mach_eventlink_signal_wait_option_t, uint32_t, {
55 MELSW_OPTION_NONE = 0,
56 MELSW_OPTION_NO_WAIT = 0x1,
57});
58
59#define EVENTLINK_SIGNAL_COUNT_MASK 0xffffffffffffff
60#define EVENTLINK_SIGNAL_ERROR_MASK 0xff
61#define EVENTLINK_SIGNAL_ERROR_SHIFT 56
62
63#define encode_eventlink_count_and_error(count, error) \
64 (((count) & EVENTLINK_SIGNAL_COUNT_MASK) | ((((uint64_t)error) & EVENTLINK_SIGNAL_ERROR_MASK) << EVENTLINK_SIGNAL_ERROR_SHIFT))
65
66#define decode_eventlink_count_from_retval(retval) \
67 ((retval) & EVENTLINK_SIGNAL_COUNT_MASK)
68
69#define decode_eventlink_error_from_retval(retval) \
70 ((kern_return_t)(((retval) >> EVENTLINK_SIGNAL_ERROR_SHIFT) & EVENTLINK_SIGNAL_ERROR_MASK))
71
72#ifndef KERNEL
73kern_return_t
74mach_eventlink_signal(
75 mach_port_t eventlink_port,
76 uint64_t signal_count);
77
78kern_return_t
79mach_eventlink_wait_until(
80 mach_port_t eventlink_port,
81 uint64_t *count_ptr,
82 mach_eventlink_signal_wait_option_t option,
83 kern_clock_id_t clock_id,
84 uint64_t deadline);
85
86kern_return_t
87mach_eventlink_signal_wait_until(
88 mach_port_t eventlink_port,
89 uint64_t *count_ptr,
90 uint64_t signal_count,
91 mach_eventlink_signal_wait_option_t option,
92 kern_clock_id_t clock_id,
93 uint64_t deadline);
94
95#endif
96
97#endif /* _MACH_EVENTLINK_TYPES_H_ */
98