diff options
| author | Gerrit Code Review <gerrit2@nvidia.com> | 2018-08-10 09:53:36 -0400 |
|---|---|---|
| committer | Gerrit Code Review <gerrit2@nvidia.com> | 2018-08-10 09:53:36 -0400 |
| commit | 1794f2c43e09e80f2dd5961811d3f7318a7f3609 (patch) | |
| tree | 54f0c544f1290444fd0870655394ee602bc50d34 /include/linux | |
| parent | 5eacad37f31658aa672f52d955cb5e3ca7b173d7 (diff) | |
| parent | e0babe691ca6dd3ce6f68e80b9f699f0c438f78a (diff) | |
Merge "Merge remote-tracking branch 'origin/dev/swolfe_trustyporting_kernel-nvidia_20180728' into HEAD" into dev-kernel
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/trusty/sm_err.h | 45 | ||||
| -rw-r--r-- | include/linux/trusty/smcall.h | 138 | ||||
| -rw-r--r-- | include/linux/trusty/trusty.h | 105 | ||||
| -rw-r--r-- | include/linux/trusty/trusty_ipc.h | 122 |
4 files changed, 410 insertions, 0 deletions
diff --git a/include/linux/trusty/sm_err.h b/include/linux/trusty/sm_err.h new file mode 100644 index 000000000..fb6f3794d --- /dev/null +++ b/include/linux/trusty/sm_err.h | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2013 Google Inc. All rights reserved | ||
| 3 | * Copyright (c) 2017 NVIDIA CORPORATION. All rights reserved. | ||
| 4 | * | ||
| 5 | * Permission is hereby granted, free of charge, to any person obtaining | ||
| 6 | * a copy of this software and associated documentation files | ||
| 7 | * (the "Software"), to deal in the Software without restriction, | ||
| 8 | * including without limitation the rights to use, copy, modify, merge, | ||
| 9 | * publish, distribute, sublicense, and/or sell copies of the Software, | ||
| 10 | * and to permit persons to whom the Software is furnished to do so, | ||
| 11 | * subject to the following conditions: | ||
| 12 | * | ||
| 13 | * The above copyright notice and this permission notice shall be | ||
| 14 | * included in all copies or substantial portions of the Software. | ||
| 15 | * | ||
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| 19 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
| 20 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| 21 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
| 22 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 23 | */ | ||
| 24 | #ifndef __LINUX_TRUSTY_SM_ERR_H | ||
| 25 | #define __LINUX_TRUSTY_SM_ERR_H | ||
| 26 | |||
| 27 | /* Errors from the secure monitor */ | ||
| 28 | #define SM_ERR_UNDEFINED_SMC 0xFFFFFFFF /* Unknown SMC (defined by ARM DEN 0028A(0.9.0) */ | ||
| 29 | #define SM_ERR_INVALID_PARAMETERS -2 | ||
| 30 | #define SM_ERR_INTERRUPTED -3 /* Got interrupted. Call back with restart SMC */ | ||
| 31 | #define SM_ERR_UNEXPECTED_RESTART -4 /* Got an restart SMC when we didn't expect it */ | ||
| 32 | #define SM_ERR_BUSY -5 /* Temporarily busy. Call back with original args */ | ||
| 33 | #define SM_ERR_INTERLEAVED_SMC -6 /* Got a trusted_service SMC when a restart SMC is required */ | ||
| 34 | #define SM_ERR_INTERNAL_FAILURE -7 /* Unknown error */ | ||
| 35 | #define SM_ERR_NOT_SUPPORTED -8 | ||
| 36 | #define SM_ERR_NOT_ALLOWED -9 /* SMC call not allowed */ | ||
| 37 | #define SM_ERR_END_OF_INPUT -10 | ||
| 38 | #define SM_ERR_PANIC -11 /* Secure OS crashed */ | ||
| 39 | #define SM_ERR_FIQ_INTERRUPTED -12 /* Got interrupted by FIQ. Call back with SMC_SC_RESTART_FIQ on same CPU */ | ||
| 40 | #define SM_ERR_CPU_IDLE -13 /* SMC call waiting for another CPU */ | ||
| 41 | #define SM_ERR_NOP_INTERRUPTED -14 /* Got interrupted. Call back with new SMC_SC_NOP */ | ||
| 42 | #define SM_ERR_NOP_DONE -15 /* Cpu idle after SMC_SC_NOP (not an error) */ | ||
| 43 | #define SM_ERR_NOP_RETRY -16 /* Retry the previous NOP smc as the first may not have reached TOS */ | ||
| 44 | |||
| 45 | #endif | ||
diff --git a/include/linux/trusty/smcall.h b/include/linux/trusty/smcall.h new file mode 100644 index 000000000..b11cf2ea9 --- /dev/null +++ b/include/linux/trusty/smcall.h | |||
| @@ -0,0 +1,138 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2013-2014 Google Inc. All rights reserved | ||
| 3 | * | ||
| 4 | * Permission is hereby granted, free of charge, to any person obtaining | ||
| 5 | * a copy of this software and associated documentation files | ||
| 6 | * (the "Software"), to deal in the Software without restriction, | ||
| 7 | * including without limitation the rights to use, copy, modify, merge, | ||
| 8 | * publish, distribute, sublicense, and/or sell copies of the Software, | ||
| 9 | * and to permit persons to whom the Software is furnished to do so, | ||
| 10 | * subject to the following conditions: | ||
| 11 | * | ||
| 12 | * The above copyright notice and this permission notice shall be | ||
| 13 | * included in all copies or substantial portions of the Software. | ||
| 14 | * | ||
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
| 19 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| 20 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
| 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 22 | */ | ||
| 23 | #ifndef __LINUX_TRUSTY_SMCALL_H | ||
| 24 | #define __LINUX_TRUSTY_SMCALL_H | ||
| 25 | |||
| 26 | #define SMC_NUM_ENTITIES 64 | ||
| 27 | #define SMC_NUM_ARGS 4 | ||
| 28 | #define SMC_NUM_PARAMS (SMC_NUM_ARGS - 1) | ||
| 29 | |||
| 30 | #define SMC_IS_FASTCALL(smc_nr) ((smc_nr) & 0x80000000) | ||
| 31 | #define SMC_IS_SMC64(smc_nr) ((smc_nr) & 0x40000000) | ||
| 32 | #define SMC_ENTITY(smc_nr) (((smc_nr) & 0x3F000000) >> 24) | ||
| 33 | #define SMC_FUNCTION(smc_nr) ((smc_nr) & 0x0000FFFF) | ||
| 34 | |||
| 35 | #define SMC_NR(entity, fn, fastcall, smc64) ((((fastcall) & 0x1) << 31) | \ | ||
| 36 | (((smc64) & 0x1) << 30) | \ | ||
| 37 | (((entity) & 0x3F) << 24) | \ | ||
| 38 | ((fn) & 0xFFFF) \ | ||
| 39 | ) | ||
| 40 | |||
| 41 | #define SMC_FASTCALL_NR(entity, fn) SMC_NR((entity), (fn), 1, 0) | ||
| 42 | #define SMC_STDCALL_NR(entity, fn) SMC_NR((entity), (fn), 0, 0) | ||
| 43 | #define SMC_FASTCALL64_NR(entity, fn) SMC_NR((entity), (fn), 1, 1) | ||
| 44 | #define SMC_STDCALL64_NR(entity, fn) SMC_NR((entity), (fn), 0, 1) | ||
| 45 | |||
| 46 | #define SMC_ENTITY_ARCH 0 /* ARM Architecture calls */ | ||
| 47 | #define SMC_ENTITY_CPU 1 /* CPU Service calls */ | ||
| 48 | #define SMC_ENTITY_SIP 2 /* SIP Service calls */ | ||
| 49 | #define SMC_ENTITY_OEM 3 /* OEM Service calls */ | ||
| 50 | #define SMC_ENTITY_STD 4 /* Standard Service calls */ | ||
| 51 | #define SMC_ENTITY_RESERVED 5 /* Reserved for future use */ | ||
| 52 | #define SMC_ENTITY_TRUSTED_APP 48 /* Trusted Application calls */ | ||
| 53 | #define SMC_ENTITY_TRUSTED_OS 50 /* Trusted OS calls */ | ||
| 54 | #define SMC_ENTITY_LOGGING 51 /* Used for secure -> nonsecure logging */ | ||
| 55 | #define SMC_ENTITY_GUEST_RESET 52 /* Notify Trusted OS */ | ||
| 56 | /* about guest reset */ | ||
| 57 | #define SMC_ENTITY_SECURE_MONITOR 60 /* Trusted OS calls internal to secure monitor */ | ||
| 58 | |||
| 59 | /* FC = Fast call, SC = Standard call */ | ||
| 60 | #define SMC_SC_RESTART_LAST SMC_STDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0) | ||
| 61 | #define SMC_SC_LOCKED_NOP SMC_STDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1) | ||
| 62 | |||
| 63 | /** | ||
| 64 | * SMC_SC_RESTART_FIQ - Re-enter trusty after it was interrupted by an fiq | ||
| 65 | * | ||
| 66 | * No arguments, no return value. | ||
| 67 | * | ||
| 68 | * Re-enter trusty after returning to ns to process an fiq. Must be called iff | ||
| 69 | * trusty returns SM_ERR_FIQ_INTERRUPTED. | ||
| 70 | * | ||
| 71 | * Enable by selecting api version TRUSTY_API_VERSION_RESTART_FIQ (1) or later. | ||
| 72 | */ | ||
| 73 | #define SMC_SC_RESTART_FIQ SMC_STDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 2) | ||
| 74 | |||
| 75 | /** | ||
| 76 | * SMC_SC_NOP - Enter trusty to run pending work. | ||
| 77 | * | ||
| 78 | * No arguments. | ||
| 79 | * | ||
| 80 | * Returns SM_ERR_NOP_INTERRUPTED or SM_ERR_NOP_DONE. | ||
| 81 | * If SM_ERR_NOP_INTERRUPTED is returned, the call must be repeated. | ||
| 82 | * | ||
| 83 | * Enable by selecting api version TRUSTY_API_VERSION_SMP (2) or later. | ||
| 84 | */ | ||
| 85 | #define SMC_SC_NOP SMC_STDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 3) | ||
| 86 | |||
| 87 | /* | ||
| 88 | * Return from secure os to non-secure os with return value in r1 | ||
| 89 | */ | ||
| 90 | #define SMC_SC_NS_RETURN SMC_STDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0) | ||
| 91 | |||
| 92 | #define SMC_FC_RESERVED SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0) | ||
| 93 | #define SMC_FC_FIQ_EXIT SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1) | ||
| 94 | #define SMC_FC_REQUEST_FIQ SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 2) | ||
| 95 | #define SMC_FC_GET_NEXT_IRQ SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 3) | ||
| 96 | #define SMC_FC_FIQ_ENTER SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 4) | ||
| 97 | |||
| 98 | #define SMC_FC64_SET_FIQ_HANDLER SMC_FASTCALL64_NR(SMC_ENTITY_SECURE_MONITOR, 5) | ||
| 99 | #define SMC_FC64_GET_FIQ_REGS SMC_FASTCALL64_NR (SMC_ENTITY_SECURE_MONITOR, 6) | ||
| 100 | |||
| 101 | #define SMC_FC_CPU_SUSPEND SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 7) | ||
| 102 | #define SMC_FC_CPU_RESUME SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 8) | ||
| 103 | |||
| 104 | #define SMC_FC_AARCH_SWITCH SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 9) | ||
| 105 | #define SMC_FC_GET_VERSION_STR SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 10) | ||
| 106 | |||
| 107 | /** | ||
| 108 | * SMC_FC_API_VERSION - Find and select supported API version. | ||
| 109 | * | ||
| 110 | * @r1: Version supported by client. | ||
| 111 | * | ||
| 112 | * Returns version supported by trusty. | ||
| 113 | * | ||
| 114 | * If multiple versions are supported, the client should start by calling | ||
| 115 | * SMC_FC_API_VERSION with the largest version it supports. Trusty will then | ||
| 116 | * return a version it supports. If the client does not support the version | ||
| 117 | * returned by trusty and the version returned is less than the version | ||
| 118 | * requested, repeat the call with the largest supported version less than the | ||
| 119 | * last returned version. | ||
| 120 | * | ||
| 121 | * This call must be made before any calls that are affected by the api version. | ||
| 122 | */ | ||
| 123 | #define TRUSTY_API_VERSION_RESTART_FIQ (1) | ||
| 124 | #define TRUSTY_API_VERSION_SMP (2) | ||
| 125 | #define TRUSTY_API_VERSION_SMP_NOP (3) | ||
| 126 | #define TRUSTY_API_VERSION_CURRENT (3) | ||
| 127 | #define SMC_FC_API_VERSION SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 11) | ||
| 128 | |||
| 129 | /* TRUSTED_OS entity calls */ | ||
| 130 | #define SMC_SC_VIRTIO_GET_DESCR SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 20) | ||
| 131 | #define SMC_SC_VIRTIO_START SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 21) | ||
| 132 | #define SMC_SC_VIRTIO_STOP SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 22) | ||
| 133 | |||
| 134 | #define SMC_SC_VDEV_RESET SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 23) | ||
| 135 | #define SMC_SC_VDEV_KICK_VQ SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 24) | ||
| 136 | #define SMC_NC_VDEV_KICK_VQ SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 25) | ||
| 137 | |||
| 138 | #endif /* __LINUX_TRUSTY_SMCALL_H */ | ||
diff --git a/include/linux/trusty/trusty.h b/include/linux/trusty/trusty.h new file mode 100644 index 000000000..096608e24 --- /dev/null +++ b/include/linux/trusty/trusty.h | |||
| @@ -0,0 +1,105 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2013 Google, Inc. | ||
| 3 | * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. | ||
| 4 | * | ||
| 5 | * This software is licensed under the terms of the GNU General Public | ||
| 6 | * License version 2, as published by the Free Software Foundation, and | ||
| 7 | * may be copied, distributed, and modified under those terms. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | */ | ||
| 15 | #ifndef __LINUX_TRUSTY_TRUSTY_H | ||
| 16 | #define __LINUX_TRUSTY_TRUSTY_H | ||
| 17 | |||
| 18 | #include <linux/kernel.h> | ||
| 19 | #include <linux/trusty/sm_err.h> | ||
| 20 | #include <linux/device.h> | ||
| 21 | #include <linux/pagemap.h> | ||
| 22 | #include <linux/tegra-soc.h> | ||
| 23 | |||
| 24 | enum { | ||
| 25 | TRUSTY_DEV_UNINIT = -1, | ||
| 26 | |||
| 27 | TRUSTY_DEV_DISABLED = 0, | ||
| 28 | TRUSTY_DEV_ENABLED | ||
| 29 | }; | ||
| 30 | |||
| 31 | #if IS_ENABLED(CONFIG_TRUSTY) | ||
| 32 | s32 trusty_std_call32(struct device *dev, u32 smcnr, u32 a0, u32 a1, u32 a2); | ||
| 33 | s32 trusty_fast_call32(struct device *dev, u32 smcnr, u32 a0, u32 a1, u32 a2); | ||
| 34 | #ifdef CONFIG_64BIT | ||
| 35 | s64 trusty_fast_call64(struct device *dev, u64 smcnr, u64 a0, u64 a1, u64 a2); | ||
| 36 | #endif | ||
| 37 | int hyp_ipa_translate(uint64_t *ipa); | ||
| 38 | #else | ||
| 39 | static inline s32 trusty_std_call32(struct device *dev, u32 smcnr, | ||
| 40 | u32 a0, u32 a1, u32 a2) | ||
| 41 | { | ||
| 42 | return SM_ERR_UNDEFINED_SMC; | ||
| 43 | } | ||
| 44 | static inline s32 trusty_fast_call32(struct device *dev, u32 smcnr, | ||
| 45 | u32 a0, u32 a1, u32 a2) | ||
| 46 | { | ||
| 47 | return SM_ERR_UNDEFINED_SMC; | ||
| 48 | } | ||
| 49 | #ifdef CONFIG_64BIT | ||
| 50 | static inline s64 trusty_fast_call64(struct device *dev, | ||
| 51 | u64 smcnr, u64 a0, u64 a1, u64 a2) | ||
| 52 | { | ||
| 53 | return SM_ERR_UNDEFINED_SMC; | ||
| 54 | } | ||
| 55 | #endif | ||
| 56 | #endif | ||
| 57 | |||
| 58 | struct notifier_block; | ||
| 59 | enum { | ||
| 60 | TRUSTY_CALL_PREPARE, | ||
| 61 | TRUSTY_CALL_RETURNED, | ||
| 62 | #ifdef CONFIG_TEGRA_VIRTUALIZATION | ||
| 63 | TRUSTY_CALL_VQ_POLLING, | ||
| 64 | #endif | ||
| 65 | }; | ||
| 66 | int trusty_call_notifier_register(struct device *dev, | ||
| 67 | struct notifier_block *n); | ||
| 68 | int trusty_call_notifier_unregister(struct device *dev, | ||
| 69 | struct notifier_block *n); | ||
| 70 | int trusty_panic_notifier_register(struct device *dev, | ||
| 71 | struct notifier_block *n); | ||
| 72 | int trusty_panic_notifier_unregister(struct device *dev, | ||
| 73 | struct notifier_block *n); | ||
| 74 | const char *trusty_version_str_get(struct device *dev); | ||
| 75 | u32 trusty_get_api_version(struct device *dev); | ||
| 76 | |||
| 77 | struct ns_mem_page_info { | ||
| 78 | uint64_t attr; | ||
| 79 | }; | ||
| 80 | |||
| 81 | int trusty_encode_page_info(struct ns_mem_page_info *inf, | ||
| 82 | struct page *page, pgprot_t pgprot); | ||
| 83 | |||
| 84 | int trusty_call32_mem_buf(struct device *dev, u32 smcnr, | ||
| 85 | struct page *page, u32 size, | ||
| 86 | pgprot_t pgprot); | ||
| 87 | |||
| 88 | struct trusty_nop { | ||
| 89 | struct list_head node; | ||
| 90 | u32 args[3]; | ||
| 91 | }; | ||
| 92 | |||
| 93 | static inline void trusty_nop_init(struct trusty_nop *nop, | ||
| 94 | u32 arg0, u32 arg1, u32 arg2) { | ||
| 95 | INIT_LIST_HEAD(&nop->node); | ||
| 96 | nop->args[0] = arg0; | ||
| 97 | nop->args[1] = arg1; | ||
| 98 | nop->args[2] = arg2; | ||
| 99 | } | ||
| 100 | |||
| 101 | void trusty_enqueue_nop(struct device *dev, struct trusty_nop *nop); | ||
| 102 | void trusty_dequeue_nop(struct device *dev, struct trusty_nop *nop); | ||
| 103 | int is_trusty_dev_enabled(void); | ||
| 104 | |||
| 105 | #endif | ||
diff --git a/include/linux/trusty/trusty_ipc.h b/include/linux/trusty/trusty_ipc.h new file mode 100644 index 000000000..e76e252e4 --- /dev/null +++ b/include/linux/trusty/trusty_ipc.h | |||
| @@ -0,0 +1,122 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2015 Google, Inc. | ||
| 3 | * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. | ||
| 4 | * | ||
| 5 | * This software is licensed under the terms of the GNU General Public | ||
| 6 | * License version 2, as published by the Free Software Foundation, and | ||
| 7 | * may be copied, distributed, and modified under those terms. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | */ | ||
| 15 | #ifndef __LINUX_TRUSTY_TRUSTY_IPC_H | ||
| 16 | #define __LINUX_TRUSTY_TRUSTY_IPC_H | ||
| 17 | |||
| 18 | /* | ||
| 19 | * Errnos below must be in sync with the corresponding errnos | ||
| 20 | * defined in 3rdparty/trusty/external/lk/include/err.h | ||
| 21 | */ | ||
| 22 | #define NO_ERROR (0) | ||
| 23 | #define ERR_NOT_FOUND (-2) | ||
| 24 | |||
| 25 | struct tipc_chan; | ||
| 26 | |||
| 27 | struct tipc_msg_buf { | ||
| 28 | void *buf_va; | ||
| 29 | phys_addr_t buf_pa; | ||
| 30 | size_t buf_sz; | ||
| 31 | size_t wpos; | ||
| 32 | size_t rpos; | ||
| 33 | struct list_head node; | ||
| 34 | }; | ||
| 35 | |||
| 36 | enum tipc_chan_event { | ||
| 37 | TIPC_CHANNEL_CONNECTED = 1, | ||
| 38 | TIPC_CHANNEL_DISCONNECTED, | ||
| 39 | TIPC_CHANNEL_SHUTDOWN, | ||
| 40 | TIPC_CHANNEL_NOT_FOUND, | ||
| 41 | }; | ||
| 42 | |||
| 43 | struct tipc_chan_ops { | ||
| 44 | void (*handle_event)(void *cb_arg, int event); | ||
| 45 | struct tipc_msg_buf *(*handle_msg)(void *cb_arg, | ||
| 46 | struct tipc_msg_buf *mb); | ||
| 47 | void (*handle_release)(void *cb_arg); | ||
| 48 | }; | ||
| 49 | |||
| 50 | struct tipc_chan *tipc_create_channel(struct device *dev, | ||
| 51 | const struct tipc_chan_ops *ops, | ||
| 52 | void *cb_arg); | ||
| 53 | |||
| 54 | int tipc_chan_connect(struct tipc_chan *chan, const char *port); | ||
| 55 | |||
| 56 | int tipc_chan_queue_msg(struct tipc_chan *chan, struct tipc_msg_buf *mb); | ||
| 57 | |||
| 58 | int tipc_chan_shutdown(struct tipc_chan *chan); | ||
| 59 | |||
| 60 | void tipc_chan_destroy(struct tipc_chan *chan); | ||
| 61 | |||
| 62 | struct tipc_msg_buf *tipc_chan_get_rxbuf(struct tipc_chan *chan); | ||
| 63 | |||
| 64 | void tipc_chan_put_rxbuf(struct tipc_chan *chan, struct tipc_msg_buf *mb); | ||
| 65 | |||
| 66 | struct tipc_msg_buf * | ||
| 67 | tipc_chan_get_txbuf_timeout(struct tipc_chan *chan, long timeout); | ||
| 68 | |||
| 69 | void tipc_chan_put_txbuf(struct tipc_chan *chan, struct tipc_msg_buf *mb); | ||
| 70 | |||
| 71 | static inline size_t mb_avail_space(struct tipc_msg_buf *mb) | ||
| 72 | { | ||
| 73 | return mb->buf_sz - mb->wpos; | ||
| 74 | } | ||
| 75 | |||
| 76 | static inline size_t mb_avail_data(struct tipc_msg_buf *mb) | ||
| 77 | { | ||
| 78 | return mb->wpos - mb->rpos; | ||
| 79 | } | ||
| 80 | |||
| 81 | static inline void *mb_put_data(struct tipc_msg_buf *mb, size_t len) | ||
| 82 | { | ||
| 83 | void *pos = (u8 *)mb->buf_va + mb->wpos; | ||
| 84 | BUG_ON(mb->wpos + len > mb->buf_sz); | ||
| 85 | mb->wpos += len; | ||
| 86 | return pos; | ||
| 87 | } | ||
| 88 | |||
| 89 | static inline void *mb_get_data(struct tipc_msg_buf *mb, size_t len) | ||
| 90 | { | ||
| 91 | void *pos = (u8 *)mb->buf_va + mb->rpos; | ||
| 92 | BUG_ON(mb->rpos + len > mb->wpos); | ||
| 93 | mb->rpos += len; | ||
| 94 | return pos; | ||
| 95 | } | ||
| 96 | |||
| 97 | /* OTE-TIPC wrapper APIs*/ | ||
| 98 | /* | ||
| 99 | * te_open_trusted_session - Establishes the session with TA | ||
| 100 | * @name(in): name of the TA to connect to. | ||
| 101 | * @ctx(out): pointer to the private data associated to the open session | ||
| 102 | * Returns 0 on Success else error code. | ||
| 103 | */ | ||
| 104 | int te_open_trusted_session(char *name, void **ctx); | ||
| 105 | /* | ||
| 106 | * te_close_trusted_session - Closes the session established | ||
| 107 | * @ctx: ctx returned by open session | ||
| 108 | */ | ||
| 109 | void te_close_trusted_session(void *ctx); | ||
| 110 | /* | ||
| 111 | * te_launch_trusted_oper - Communicate with TA to perform any operation | ||
| 112 | * @buf: Buffer to sent to secure world. | ||
| 113 | * @buf_len: length of the buffer. | ||
| 114 | * @ta_cmd: command to sent to secure world. | ||
| 115 | * @ctx: ctx returned by open session. | ||
| 116 | * Returns 0 on Success else error code. | ||
| 117 | */ | ||
| 118 | int te_launch_trusted_oper(void *buf, size_t buf_len, uint32_t ta_cmd, | ||
| 119 | void *ctx); | ||
| 120 | |||
| 121 | #endif /* __LINUX_TRUSTY_TRUSTY_IPC_H */ | ||
| 122 | |||
