• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _UAPI_LINUX_TRUSTY_IPC_H_
18 #define _UAPI_LINUX_TRUSTY_IPC_H_
19 
20 #include <linux/ioctl.h>
21 #include <linux/types.h>
22 #include <linux/uio.h>
23 
24 /**
25  * enum transfer_kind - How to send an fd to Trusty
26  * @TRUSTY_SHARE: Memory will be accessible by Linux and Trusty. On ARM it will
27  *                be mapped as nonsecure. Suitable for shared memory. The paired
28  *                fd must be a "memfd".
29  * @TRUSTY_LEND:  Memory will be accessible only to Trusty. On ARM it will be
30  *                transitioned to "Secure" memory if Trusty is in TrustZone.
31  *                This transfer kind is suitable for donating video buffers or
32  *                other similar resources. The paired fd may need to come from a
33  *                platform-specific allocator for memory that may be
34  *                transitioned to "Secure".
35  *
36  * Describes how the user would like the resource in question to be sent to
37  * Trusty. Options may be valid only for certain kinds of fds.
38  */
39 enum transfer_kind {
40     TRUSTY_SHARE = 0,
41     TRUSTY_LEND = 1,
42 };
43 
44 /**
45  * struct trusty_shm - Describes a transfer of memory to Trusty
46  * @fd:       The fd to transfer
47  * @transfer: How to transfer it - see &enum transfer_kind
48  */
49 struct trusty_shm {
50     __s32 fd;
51     __u32 transfer;
52 };
53 
54 /**
55  * struct tipc_send_msg_req - Request struct for @TIPC_IOC_SEND_MSG
56  * @iov:     Pointer to an array of &struct iovec describing data to be sent
57  * @shm:     Pointer to an array of &struct trusty_shm describing any file
58  *           descriptors to be transferred.
59  * @iov_cnt: Number of elements in the @iov array
60  * @shm_cnt: Number of elements in the @shm array
61  */
62 struct tipc_send_msg_req {
63     __u64 iov;
64     __u64 shm;
65     __u64 iov_cnt;
66     __u64 shm_cnt;
67 };
68 
69 #define TIPC_IOC_MAGIC 'r'
70 #define TIPC_IOC_CONNECT _IOW(TIPC_IOC_MAGIC, 0x80, char*)
71 #define TIPC_IOC_SEND_MSG _IOW(TIPC_IOC_MAGIC, 0x81, struct tipc_send_msg_req)
72 
73 #if defined(CONFIG_COMPAT)
74 #define TIPC_IOC_CONNECT_COMPAT _IOW(TIPC_IOC_MAGIC, 0x80, compat_uptr_t)
75 #endif
76 
77 #endif
78