| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2015, Linaro Limited |
|---|
| 3 | | - * |
|---|
| 4 | | - * This software is licensed under the terms of the GNU General Public |
|---|
| 5 | | - * License version 2, as published by the Free Software Foundation, and |
|---|
| 6 | | - * may be copied, distributed, and modified under those terms. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | | - * GNU General Public License for more details. |
|---|
| 12 | | - * |
|---|
| 13 | 4 | */ |
|---|
| 14 | 5 | |
|---|
| 15 | 6 | #ifndef OPTEE_PRIVATE_H |
|---|
| .. | .. |
|---|
| 26 | 17 | /* Some Global Platform error codes used in this driver */ |
|---|
| 27 | 18 | #define TEEC_SUCCESS 0x00000000 |
|---|
| 28 | 19 | #define TEEC_ERROR_BAD_PARAMETERS 0xFFFF0006 |
|---|
| 20 | +#define TEEC_ERROR_NOT_SUPPORTED 0xFFFF000A |
|---|
| 29 | 21 | #define TEEC_ERROR_COMMUNICATION 0xFFFF000E |
|---|
| 30 | 22 | #define TEEC_ERROR_OUT_OF_MEMORY 0xFFFF000C |
|---|
| 23 | +#define TEEC_ERROR_SHORT_BUFFER 0xFFFF0010 |
|---|
| 31 | 24 | |
|---|
| 32 | 25 | #define TEEC_ORIGIN_COMMS 0x00000002 |
|---|
| 33 | 26 | |
|---|
| .. | .. |
|---|
| 77 | 70 | * struct optee - main service struct |
|---|
| 78 | 71 | * @supp_teedev: supplicant device |
|---|
| 79 | 72 | * @teedev: client device |
|---|
| 73 | + * @ctx: driver internal TEE context |
|---|
| 80 | 74 | * @invoke_fn: function to issue smc or hvc |
|---|
| 81 | 75 | * @call_queue: queue of threads waiting to call @invoke_fn |
|---|
| 82 | 76 | * @wait_queue: queue of threads from secure world waiting for a |
|---|
| .. | .. |
|---|
| 86 | 80 | * @memremaped_shm virtual address of memory in shared memory pool |
|---|
| 87 | 81 | * @sec_caps: secure world capabilities defined by |
|---|
| 88 | 82 | * OPTEE_SMC_SEC_CAP_* in optee_smc.h |
|---|
| 83 | + * @scan_bus_done flag if device registation was already done. |
|---|
| 84 | + * @scan_bus_wq workqueue to scan optee bus and register optee drivers |
|---|
| 85 | + * @scan_bus_work workq to scan optee bus and register optee drivers |
|---|
| 89 | 86 | */ |
|---|
| 90 | 87 | struct optee { |
|---|
| 91 | 88 | struct tee_device *supp_teedev; |
|---|
| 92 | 89 | struct tee_device *teedev; |
|---|
| 93 | 90 | optee_invoke_fn *invoke_fn; |
|---|
| 91 | + struct tee_context *ctx; |
|---|
| 94 | 92 | struct optee_call_queue call_queue; |
|---|
| 95 | 93 | struct optee_wait_queue wait_queue; |
|---|
| 96 | 94 | struct optee_supp supp; |
|---|
| 97 | 95 | struct tee_shm_pool *pool; |
|---|
| 98 | 96 | void *memremaped_shm; |
|---|
| 99 | 97 | u32 sec_caps; |
|---|
| 98 | + bool scan_bus_done; |
|---|
| 99 | + struct workqueue_struct *scan_bus_wq; |
|---|
| 100 | + struct work_struct scan_bus_work; |
|---|
| 100 | 101 | }; |
|---|
| 101 | 102 | |
|---|
| 102 | 103 | struct optee_session { |
|---|
| .. | .. |
|---|
| 182 | 183 | void optee_fill_pages_list(u64 *dst, struct page **pages, int num_pages, |
|---|
| 183 | 184 | size_t page_offset); |
|---|
| 184 | 185 | |
|---|
| 186 | +#define PTA_CMD_GET_DEVICES 0x0 |
|---|
| 187 | +#define PTA_CMD_GET_DEVICES_SUPP 0x1 |
|---|
| 188 | +int optee_enumerate_devices(u32 func); |
|---|
| 189 | +void optee_unregister_devices(void); |
|---|
| 190 | + |
|---|
| 185 | 191 | /* |
|---|
| 186 | 192 | * Small helpers |
|---|
| 187 | 193 | */ |
|---|