• 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
27  *                      will be mapped as nonsecure. Suitable for shared memory.
28  *                      The paired fd must be a "dma_buf".
29  * @TRUSTY_LEND:        Memory will be accessible only to Trusty. On ARM it will
30  *                      be transitioned to "Secure" memory if Trusty is in
31  *                      TrustZone. This transfer kind is suitable for donating
32  *                      video buffers or other similar resources. The paired fd
33  *                      may need to come from a platform-specific allocator for
34  *                      memory that may be transitioned to "Secure".
35  * @TRUSTY_SEND_SECURE: Send memory that is already "Secure". Memory will be
36  *                      accessible only to Trusty. The paired fd may need to
37  *                      come from a platform-specific allocator that returns
38  *                      "Secure" buffers.
39  *
40  * Describes how the user would like the resource in question to be sent to
41  * Trusty. Options may be valid only for certain kinds of fds.
42  */
43 enum transfer_kind {
44     TRUSTY_SHARE = 0,
45     TRUSTY_LEND = 1,
46     TRUSTY_SEND_SECURE = 2,
47 };
48 
49 /**
50  * struct trusty_shm - Describes a transfer of memory to Trusty
51  * @fd:       The fd to transfer
52  * @transfer: How to transfer it - see &enum transfer_kind
53  */
54 struct trusty_shm {
55     __s32 fd;
56     __u32 transfer;
57 };
58 
59 /**
60  * struct tipc_send_msg_req - Request struct for @TIPC_IOC_SEND_MSG
61  * @iov:     Pointer to an array of &struct iovec describing data to be sent
62  * @shm:     Pointer to an array of &struct trusty_shm describing any file
63  *           descriptors to be transferred.
64  * @iov_cnt: Number of elements in the @iov array
65  * @shm_cnt: Number of elements in the @shm array
66  */
67 struct tipc_send_msg_req {
68     __u64 iov;
69     __u64 shm;
70     __u64 iov_cnt;
71     __u64 shm_cnt;
72 };
73 
74 #define TIPC_IOC_MAGIC 'r'
75 #define TIPC_IOC_CONNECT _IOW(TIPC_IOC_MAGIC, 0x80, char*)
76 #define TIPC_IOC_SEND_MSG _IOW(TIPC_IOC_MAGIC, 0x81, struct tipc_send_msg_req)
77 
78 #if defined(CONFIG_COMPAT)
79 #define TIPC_IOC_CONNECT_COMPAT _IOW(TIPC_IOC_MAGIC, 0x80, compat_uptr_t)
80 #endif
81 
82 #endif
83