1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2016-2021, Linaro Limited 4 */ 5 6 #ifndef __OPTEE_RPC_CMD_H 7 #define __OPTEE_RPC_CMD_H 8 9 /* 10 * All RPC is done with a struct optee_msg_arg as bearer of information, 11 * struct optee_msg_arg::arg holds values defined by OPTEE_RPC_CMD_* below. 12 * Only the commands handled by the kernel driver are defined here. 13 * 14 * RPC communication with tee-supplicant is reversed compared to normal 15 * client communication described above. The supplicant receives requests 16 * and sends responses. 17 */ 18 19 /* 20 * Get time 21 * 22 * Returns number of seconds and nano seconds since the Epoch, 23 * 1970-01-01 00:00:00 +0000 (UTC). 24 * 25 * [out] value[0].a Number of seconds 26 * [out] value[0].b Number of nano seconds. 27 */ 28 #define OPTEE_RPC_CMD_GET_TIME 3 29 30 /* 31 * Notification from/to secure world. 32 * 33 * If secure world needs to wait for something, for instance a mutex, it 34 * does a notification wait request instead of spinning in secure world. 35 * Conversely can a synchronous notification can be sent when a secure 36 * world mutex with a thread waiting thread is unlocked. 37 * 38 * This interface can also be used to wait for a asynchronous notification 39 * which instead is sent via a non-secure interrupt. 40 * 41 * Waiting on notification 42 * [in] value[0].a OPTEE_RPC_NOTIFICATION_WAIT 43 * [in] value[0].b notification value 44 * [in] value[0].c timeout in milliseconds or 0 if no timeout 45 * 46 * Sending a synchronous notification 47 * [in] value[0].a OPTEE_RPC_NOTIFICATION_SEND 48 * [in] value[0].b notification value 49 */ 50 #define OPTEE_RPC_CMD_NOTIFICATION 4 51 #define OPTEE_RPC_NOTIFICATION_WAIT 0 52 #define OPTEE_RPC_NOTIFICATION_SEND 1 53 54 /* 55 * Suspend execution 56 * 57 * [in] value[0].a Number of milliseconds to suspend 58 */ 59 #define OPTEE_RPC_CMD_SUSPEND 5 60 61 /* 62 * Allocate a piece of shared memory 63 * 64 * [in] value[0].a Type of memory one of 65 * OPTEE_RPC_SHM_TYPE_* below 66 * [in] value[0].b Requested size 67 * [in] value[0].c Required alignment 68 * [out] memref[0] Buffer 69 */ 70 #define OPTEE_RPC_CMD_SHM_ALLOC 6 71 /* Memory that can be shared with a non-secure user space application */ 72 #define OPTEE_RPC_SHM_TYPE_APPL 0 73 /* Memory only shared with non-secure kernel */ 74 #define OPTEE_RPC_SHM_TYPE_KERNEL 1 75 76 /* 77 * Free shared memory previously allocated with OPTEE_RPC_CMD_SHM_ALLOC 78 * 79 * [in] value[0].a Type of memory one of 80 * OPTEE_RPC_SHM_TYPE_* above 81 * [in] value[0].b Value of shared memory reference or cookie 82 */ 83 #define OPTEE_RPC_CMD_SHM_FREE 7 84 85 /* 86 * Issue master requests (read and write operations) to an I2C chip. 87 * 88 * [in] value[0].a Transfer mode (OPTEE_RPC_I2C_TRANSFER_*) 89 * [in] value[0].b The I2C bus (a.k.a adapter). 90 * 16 bit field. 91 * [in] value[0].c The I2C chip (a.k.a address). 92 * 16 bit field (either 7 or 10 bit effective). 93 * [in] value[1].a The I2C master control flags (ie, 10 bit address). 94 * 16 bit field. 95 * [in/out] memref[2] Buffer used for data transfers. 96 * [out] value[3].a Number of bytes transferred by the REE. 97 */ 98 #define OPTEE_RPC_CMD_I2C_TRANSFER 21 99 100 /* I2C master transfer modes */ 101 #define OPTEE_RPC_I2C_TRANSFER_RD 0 102 #define OPTEE_RPC_I2C_TRANSFER_WR 1 103 104 /* I2C master control flags */ 105 #define OPTEE_RPC_I2C_FLAGS_TEN_BIT BIT(0) 106 107 #endif /*__OPTEE_RPC_CMD_H*/ 108