xref: /freebsd/sys/dev/ntsync/ntsync.h (revision 73e0d6b44038d1c7764c5013a54ae17a8f680a69)
1 /*
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright 2026 The FreeBSD Foundation
5  *
6  * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
7  * under sponsorship from the FreeBSD Foundation.
8  */
9 
10 #ifndef __DEV_NTSYNC_H__
11 #define	__DEV_NTSYNC_H__
12 
13 #include <sys/types.h>
14 #include <sys/ioccom.h>
15 
16 struct ntsync_sem_args {
17 	uint32_t count;
18 	uint32_t max;
19 };
20 
21 struct ntsync_mutex_args {
22 	uint32_t owner;
23 	uint32_t count;
24 };
25 
26 struct ntsync_event_args {
27 	uint32_t manual;
28 	uint32_t signaled;
29 };
30 
31 struct ntsync_wait_args {
32 	uint64_t timeout;
33 	uint64_t objs;
34 	uint32_t count;
35 	uint32_t index;
36 	uint32_t flags;
37 	uint32_t owner;
38 	uint32_t alert;
39 	uint32_t pad;
40 };
41 
42 #define	NTSYNC_WAIT_REALTIME	0x00000001
43 
44 #define	NTSYNC_MAX_WAIT_COUNT	64
45 
46 /*
47  * 'sp' means that the ioctl is special, it might return both error
48  * and copy out parameters.  See ntsync_ioctl_copyout().
49  */
50 
51 #define	NTSYNC_IOC_CREATE_SEM	_IOW('n', 1, struct ntsync_sem_args)
52 #define	NTSYNC_IOC_CREATE_MUTEX	_IOW('n', 2, struct ntsync_mutex_args)
53 #define	NTSYNC_IOC_CREATE_EVENT	_IOW('n', 3, struct ntsync_event_args)
54 #define	NTSYNC_IOC_SEM_RELEASE	_IOWR('n', 4, uint32_t)
55 #define	NTSYNC_IOC_MUTEX_UNLOCK	_IOWR('n', 5, struct ntsync_mutex_args)
56 #define	NTSYNC_IOC_EVENT_SET	_IOR('n', 6, uint32_t)
57 #define	NTSYNC_IOC_EVENT_RESET	_IOR('n', 7, uint32_t)
58 #define	NTSYNC_IOC_EVENT_PULSE	_IOR('n', 8, uint32_t)
59 #define	NTSYNC_IOC_SEM_READ	_IOR('n', 9, struct ntsync_sem_args)
60 #define	NTSYNC_IOC_MUTEX_READ	_IO('n', 10) /* sp */
61 #define	NTSYNC_IOC_EVENT_READ	_IOR('n', 11, struct ntsync_event_args)
62 #define	NTSYNC_IOC_MUTEX_KILL	_IOW('n', 12, uint32_t)
63 #define	NTSYNC_IOC_WAIT_ANY	_IOW('n', 13, struct ntsync_wait_args) /* sp */
64 #define	NTSYNC_IOC_WAIT_ALL	_IOW('n', 14, struct ntsync_wait_args) /* sp */
65 
66 #endif
67