1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2020-2022, Arm Limited
4  */
5 
6 #ifndef __ARM_FFA_USER_H
7 #define __ARM_FFA_USER_H
8 
9 #include <linux/ioctl.h>
10 #include <linux/types.h>
11 
12 #define FFA_IOC_MAGIC	0xf0
13 #define FFA_IOC_BASE	0
14 
15 /**
16  * struct ffa_ioctl_ep_desc - Query endpoint ID
17  * @uuid_ptr:	[in] Pointer to queried UUID. Format must be an RFC 4122 string,
18  * 		i.e. "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee".
19  * @id:		[out] 16-bit ID of endpoint.
20  */
21 struct ffa_ioctl_ep_desc {
22 	__u64 uuid_ptr;
23 	__u16 id;
24 };
25 #define FFA_IOC_GET_PART_ID	_IOWR(FFA_IOC_MAGIC, FFA_IOC_BASE + 0, \
26 				      struct ffa_ioctl_ep_desc)
27 
28 /**
29  * struct ffa_ioctl_msg_args - Send direct message request
30  * @args:	[in/out] Arguments of FFA_MSG_SEND_DIRECT_REQ (w3-w7). If the
31  * 		response is FFA_MSG_SEND_DIRECT_RESP, the received arguments are
32  * 		returned in this field.
33  * @dst_id:	[in] 16-bit ID of destination endpoint.
34  */
35 struct ffa_ioctl_msg_args {
36 	__u32 args[5];
37 	__u16 dst_id;
38 };
39 #define FFA_IOC_MSG_SEND	_IOWR(FFA_IOC_MAGIC, FFA_IOC_BASE + 1, \
40 				      struct ffa_ioctl_msg_args)
41 
42 /**
43  * struct ffa_ioctl_shm_desc - Share/reclaim memory region
44  * @handle:	[in/out] Handle assigned by the SPM. Output when used with
45  * 		FFA_IOC_SHM_INIT, input when used with FFA_IOC_SHM_DEINIT.
46  * @size:	[in/out] In: the required size of region in bytes. Out: the
47  * 		actual region size allocated by the kernel. Unused on reclaim.
48  * @dst_id:	[in] 16-bit ID of destination endpoint. Unused on reclaim.
49  */
50 struct ffa_ioctl_shm_desc {
51 	__u64 handle;
52 	__u64 size;
53 	__u16 dst_id;
54 };
55 #define FFA_IOC_SHM_INIT	_IOWR(FFA_IOC_MAGIC, FFA_IOC_BASE + 2, \
56 				      struct ffa_ioctl_shm_desc)
57 
58 #define FFA_IOC_SHM_DEINIT	_IOW(FFA_IOC_MAGIC, FFA_IOC_BASE + 3, \
59 				     struct ffa_ioctl_shm_desc)
60 
61 /**
62  * struct ffa_ioctl_buf_desc - Read/write shared memory region
63  * @handle:	[in] Handle of the memory region.
64  * @buf_ptr:	[in] Pointer to user space buffer. Data is copied from/to this
65  * 		buffer to/from the memory region shared with the given endpoint.
66  * @buf_len:	[in] Length of read/write in bytes.
67  */
68 struct ffa_ioctl_buf_desc {
69 	__u64 handle;
70 	__u64 buf_ptr;
71 	__u64 buf_len;
72 };
73 #define FFA_IOC_SHM_READ	_IOW(FFA_IOC_MAGIC, FFA_IOC_BASE + 4, \
74 				     struct ffa_ioctl_buf_desc)
75 
76 #define FFA_IOC_SHM_WRITE	_IOW(FFA_IOC_MAGIC, FFA_IOC_BASE + 5, \
77 				     struct ffa_ioctl_buf_desc)
78 
79 #endif /* __ARM_FFA_USER_H */
80