1 /* 2 * Copyright (C) 2022 Huawei Technologies Co., Ltd. 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 #ifndef TEE_DRIVER_MODULE_H 13 #define TEE_DRIVER_MODULE_H 14 #include <stdint.h> 15 #include <tee_defines.h> 16 17 #define DRV_NAME_MAX_LEN 32U 18 #define DRV_RESERVED_NUM 8U 19 20 struct drv_data { 21 int32_t fd; /* unique label which alloced by driver framework */ 22 uint32_t taskid; /* caller taskid */ 23 void *private_data; /* the private data associated with this fd */ 24 struct tee_uuid uuid; /* caller uuid */ 25 }; 26 27 typedef int32_t (*init_func)(void); 28 29 typedef int32_t (*suspned_func)(void); 30 typedef int32_t (*resume_func)(void); 31 32 typedef int64_t (*ioctl_func)(struct drv_data *drv, uint32_t cmd, unsigned long args, uint32_t args_len); 33 typedef int64_t (*open_func)(struct drv_data *drv, unsigned long args, uint32_t args_len); 34 typedef int64_t (*close_func)(struct drv_data *drv); 35 36 struct tee_driver_module { 37 init_func init; 38 ioctl_func ioctl; 39 open_func open; 40 close_func close; 41 suspned_func suspend; 42 resume_func resume; 43 suspned_func suspend_s4; 44 resume_func resume_s4; 45 uint64_t reserved[DRV_RESERVED_NUM]; /* has not used, just reserved */ 46 }; 47 48 #define tee_driver_declare(name, init, open, ioctl, close, suspend, resume, suspend_s4, resume_s4) \ 49 __attribute__((visibility("default"))) const struct tee_driver_module g_driver_##name = { \ 50 init, ioctl, open, close, suspend, resume, suspend_s4, resume_s4, {0} } 51 52 #endif /* TEE_DRIVER_MODULE_H */ 53