Initial commit: Linux kernel 4.19 for Unplugged OS

This commit is contained in:
ziv committed 2025-10-06 13:52:42 +00:00
commit d30235b04c
80519 files changed
+35800681

No files matched your search

@@ -0,0 +1,113 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef __TZ_TEEI_H__
#define __TZ_TEEI_H__
#define socket_buffer_size 2048
#define ARGS_BLOCK_SIZE 1024
struct sockaddr {
unsigned short sa_family;
char sa_data[14];
};
struct in_addr {
unsigned long s_addr; /* that¡¦s a 32-bit long, or 4 bytes */
};
struct sockaddr_in {
short int sin_family;
unsigned short int sin_port;
struct in_addr sin_addr;
unsigned char sin_zero[8];
};
struct TEEI_socket_command {
int func;
int cmd_size;
union func_arg {
char raw[ARGS_BLOCK_SIZE];
struct func_socket {
int af;
int type;
int protocol;
} func_socket_args;
struct func_connect {
int sockfd;
struct sockaddr ob_addr;
int addrlen;
} func_connect_args;
struct func_bind {
int sockfd;
struct sockaddr ob_addr;
int addrlen;
} func_bind_args;
struct func_listen {
int sockfd;
int backlog;
} func_listen_args;
struct func_accept {
int sockfd;
struct sockaddr ob_addr;
int addrlen;
} func_accept_args;
struct func_send {
int sockfd;
void *buf;
int len;
int flags;
} func_send_args;
#define func_recv func_send
#define func_recv_args func_send_args
#define func_recv_send func_send
#define func_recv_send_args func_send_args
struct func_close {
int sockfd;
} func_close_args;
struct func_inet_addr {
char ip_addr[17];
} func_inet_addr_args;
struct func_htons {
unsigned short portnum;
} func_htons_args;
struct func_setsockopt {
int fd;
int level;
int optname;
struct timeval;
int optlen;
} func_setsockopt_args;
} args;
};
union TEEI_socket_response_type {
int value;
uint32_t addr;
bool hasError;
unsigned short portnum;
unsigned int transSize;
struct response_func_recv {
void *buf;
unsigned int size;
} recv;
};
#endif /* __TZ_TEEI_H_ */
@@ -0,0 +1,39 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef BACKWARD_DRIVER_H
#define BACKWARD_DRIVER_H
#include <linux/types.h>
#include "teei_common.h"
#define TEEI_BDRV_TYPE (0x10)
#define TEEI_LOAD_IMG_TYPE (0x20)
struct bdrv_work_struct {
unsigned long long bdrv_work_type;
void *param_p;
struct list_head c_link;
};
extern struct service_handler reetime;
extern struct service_handler vfs_handler;
extern unsigned char *daulOS_VFS_share_mem;
int notify_vfs_handle(void);
int wait_for_vfs_done(void);
int init_all_service_handlers(void);
int vfs_thread_function(unsigned long virt_addr,
unsigned long para_vaddr, unsigned long buff_vaddr);
int init_bdrv_comp_fn(void);
void teei_notify_bdrv_fn(void);
int teei_bdrv_fn(void *work);
#endif /* end of BACKWARD_DRIVER_H */
@@ -0,0 +1,27 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef IRQ_REGISTER_H
#define IRQ_REGISTER_H
#define SCHED_ENT_CNT 10
struct load_soter_entry {
unsigned long vfs_addr;
struct work_struct work;
};
int register_ut_irq_handler(int irq);
int register_switch_irq_handler(void);
void load_func(struct work_struct *entry);
void work_func(struct work_struct *entry);
void secondary_load_func(void);
int teei_smc(unsigned long long smc_id, unsigned long long p1,
unsigned long long p2, unsigned long long p3);
#endif /* end of IRQ_REGISTER_H */
@@ -0,0 +1,45 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef NOTIFY_QUEUE_H
#define NOTIFY_QUEUE_H
#include <linux/types.h>
struct NQ_head {
unsigned long long nq_type;
unsigned long long max_count;
unsigned long long put_index;
unsigned long long reserve[5];
};
struct NQ_entry {
unsigned long long cmd_ID;
unsigned long long sub_cmd_ID;
unsigned long long block_p;
unsigned long long param[5];
};
int add_nq_entry(unsigned long long cmd_ID, unsigned long long sub_cnd_ID,
unsigned long long block_p, unsigned long long p0,
unsigned long long p1, unsigned long long p2);
int add_bdrv_nq_entry(unsigned long long cmd_ID, unsigned long long sub_cnd_ID,
unsigned long long block_p, unsigned long long p0,
unsigned long long p1, unsigned long long p2);
struct NQ_entry *get_nq_entry(void);
int create_nq_buffer(void);
int set_soter_version(void);
void secondary_init_cmdbuf(void *info);
int show_t_nt_queue(void);
extern unsigned long long switch_input_index;
extern unsigned long long switch_output_index;
#endif /* end of NOTIFY_QUEUE_H */
@@ -0,0 +1,144 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef SMC_CALL_H_
#define SMC_CALL_H_
#include <teei_secure_api.h>
#include <linux/arm-smccc.h>
/*This field id is fixed by arm*/
#define ID_FIELD_F_FAST_SMC_CALL 1
#define ID_FIELD_F_STANDARD_SMC_CALL 0
#define ID_FIELD_W_64 1
#define ID_FIELD_W_32 0
#define ID_FIELD_T_ARM_SERVICE 0
#define ID_FIELD_T_CPU_SERVICE 1
#define ID_FIELD_T_SIP_SERVICE 2
#define ID_FIELD_T_OEM_SERVICE 3
#define ID_FIELD_T_STANDARD_SERVICE 4
/*TA Call 48-49*/
#define ID_FIELD_T_TA_SERVICE0 48
#define ID_FIELD_T_TA_SERVICE1 49
/*TOS Call 50-63*/
#define ID_FIELD_T_TRUSTED_OS_SERVICE0 50
#define ID_FIELD_T_TRUSTED_OS_SERVICE1 51
#define ID_FIELD_T_TRUSTED_OS_SERVICE2 52
#define ID_FIELD_T_TRUSTED_OS_SERVICE3 53
#define MAKE_SMC_CALL_ID(F, W, T, FN) (((F)<<31)|((W)<<30)|((T)<<24)|(FN))
#define SMC_CALL_RTC_OK 0x0
#define SMC_CALL_RTC_UNKNOWN_FUN 0xFFFFFFFF
#define SMC_CALL_RTC_MONITOR_NOT_READY 0xFFFFFFFE
#define SMC_CALL_INTERRUPTED_IRQ 0x54
#define SMC_CALL_DONE 0x45
#define N_GET_T_FP_DEVICE_ID \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_64, ID_FIELD_T_TRUSTED_OS_SERVICE2, 11)
/*Child type command type for soter to recognize*/
#define N_ACK_T_INVOKE_DRV_CMD \
MAKE_SMC_CALL_ID(ID_FIELD_F_STANDARD_SMC_CALL, \
ID_FIELD_W_64, ID_FIELD_T_TRUSTED_OS_SERVICE3, 5)
#define N_INVOKE_T_LOAD_TEE_CMD \
MAKE_SMC_CALL_ID(ID_FIELD_F_STANDARD_SMC_CALL, \
ID_FIELD_W_64, ID_FIELD_T_TRUSTED_OS_SERVICE3, 6)
#define N_INVOKE_T_NQ_CMD \
MAKE_SMC_CALL_ID(ID_FIELD_F_STANDARD_SMC_CALL, \
ID_FIELD_W_64, ID_FIELD_T_TRUSTED_OS_SERVICE3, 2)
/*For non-secure side Fast Call*/
#define N_SWITCH_TO_T_OS_STAGE2 \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 0)
#define N_GET_PARAM_IN \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 1)
#define N_INIT_T_FC_BUF \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 2)
#define N_INVOKE_T_FAST_CALL \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 3)
#define NT_DUMP_STATE \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 4)
#define N_ACK_T_FOREGROUND \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 5)
#define N_ACK_T_BACKSTAGE \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 6)
#define N_INIT_T_BOOT_STAGE1 \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 7)
#define N_SWITCH_CORE \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 8)
#define N_GET_NON_IRQ_NUM \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 9)
#define N_GET_SE_OS_STATE \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 10)
#define N_GET_T_FP_DEVICE_ID_32 \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 11)
#define N_ADD_TRIGGER_IRQ_COUNT \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 12)
#define N_GET_RESERVED_MEM_SIZE \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 13)
#define N_GET_RESERVED_MEM_PADDR \
MAKE_SMC_CALL_ID(ID_FIELD_F_FAST_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE2, 14)
/*For non-secure side Standard Call*/
#define NT_SCHED_T \
MAKE_SMC_CALL_ID(ID_FIELD_F_STANDARD_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE3, 0)
#define N_INVOKE_T_SYS_CTL \
MAKE_SMC_CALL_ID(ID_FIELD_F_STANDARD_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE3, 1)
#define N_INVOKE_T_NQ \
MAKE_SMC_CALL_ID(ID_FIELD_F_STANDARD_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE3, 2)
#define N_INVOKE_T_DRV \
MAKE_SMC_CALL_ID(ID_FIELD_F_STANDARD_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE3, 3)
#define N_RAISE_T_EVENT \
MAKE_SMC_CALL_ID(ID_FIELD_F_STANDARD_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE3, 4)
#define N_ACK_T_INVOKE_DRV \
MAKE_SMC_CALL_ID(ID_FIELD_F_STANDARD_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE3, 5)
#define N_INVOKE_T_LOAD_TEE \
MAKE_SMC_CALL_ID(ID_FIELD_F_STANDARD_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE3, 6)
#define N_ACK_T_LOAD_IMG \
MAKE_SMC_CALL_ID(ID_FIELD_F_STANDARD_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE3, 7)
#define NT_SCHED_T_FIQ \
MAKE_SMC_CALL_ID(ID_FIELD_F_STANDARD_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE3, 8)
#define NT_CANCEL_T_TUI \
MAKE_SMC_CALL_ID(ID_FIELD_F_STANDARD_SMC_CALL, \
ID_FIELD_W_32, ID_FIELD_T_TRUSTED_OS_SERVICE3, 9)
static inline void get_t_device_id(uint64_t *p0)
{
struct arm_smccc_res res;
arm_smccc_smc(N_GET_T_FP_DEVICE_ID_32, 0, 0, 0,
0, 0, 0, 0, &res);
*p0 = res.a0;
}
#endif /* SMC_CALL_H_ */
@@ -0,0 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef SCHED_STATUS_H
#define SCHED_STATUS_H
#define GLSCH_NONE (0x00)
#define GLSCH_LOW (0x01)
#define GLSCH_HIGH (0x02)
#define GLSCH_NEG (0x03)
#define GLSCH_FOR_SOTER (0x04)
#endif /* end of SCHED_STATUS_H */
@@ -0,0 +1,48 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef __TEEI_SMC_ID_H__
#define __TEEI_SMC_ID_H__
/* SMC Identifiers for non-secure world functions */
#define CALL_TRUSTZONE_API 0x1
#if defined(CONFIG_S5PV310_BOARD) || defined(CONFIG_MVV4412_BOARD)
/* Based arch/arm/mach-exynos/include/mach/smc.h */
#define SMC_CMD_INIT (-1)
#define SMC_CMD_INFO (-2)
/* For Power Management */
#define SMC_CMD_SLEEP (-3)
#define SMC_CMD_CPU1BOOT (-4)
#define SMC_CMD_CPU0AFTR (-5)
/* For CP15 Access */
#define SMC_CMD_C15RESUME (-11)
/* For L2 Cache Access */
#define SMC_CMD_L2X0CTRL (-21)
#define SMC_CMD_L2X0SETUP1 (-22)
#define SMC_CMD_L2X0SETUP2 (-23)
#define SMC_CMD_L2X0INVALL (-24)
#define SMC_CMD_L2X0DEBUG (-25)
#define SMC_CMD_L2X0FLUSHALL (-26)
#define SMC_CMD_L2X0CLEANALL (-27)
#define SMC_CMD_L2X0FLUSHRANGE (-28)
/* For Framebuffer */
#define SMC_CMD_INIT_SECURE_WINDOW (-29)
#define SMC_CP15_REG (-102)
#define SMC_CP15_AUX_CTRL 0x1
#define SMC_CP15_L2_PREFETCH 0x2
#define SMC_CACHE_CTRL 0x3
#endif
#ifdef CONFIG_ZYNQ7_BOARD
#define SMC_CMD_CPU1BOOT (-4)
#define SMC_CMD_SECURE_READ (-30)
#define SMC_CMD_SECURE_WRITE (-31)
#endif
#endif /* __TEEI_SMC_ID__ */
@@ -0,0 +1,28 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef SWITCH_QUEUE_H
#define SWITCH_QUEUE_H
struct task_entry_struct {
unsigned long long work_type;
unsigned long long x0;
unsigned long long x1;
unsigned long long x2;
unsigned long long x3;
struct list_head c_link;
};
int add_work_entry(unsigned long long work_type, unsigned long long x0,
unsigned long long x1, unsigned long long x2,
unsigned long long x3);
int teei_notify_switch_fn(void);
int init_teei_switch_comp(void);
int teei_switch_fn(void *work);
#endif /* end of SWITCH_QUEUE_H */
@@ -0,0 +1,13 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef __TEEI_SYS_FS_H__
#define __TEEI_SYS_FS_H__
int init_sysfs(struct platform_device *pdev);
void remove_sysfs(struct platform_device *pdev);
#endif
@@ -0,0 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef TEEI_CANCEL_CMD_H
#define TEEI_CANCEL_CMD_H
extern unsigned long cancel_message_buff;
extern struct semaphore fp_lock;
unsigned long create_cancel_fdrv(int buff_size);
int send_cancel_command(unsigned long share_memory_size);
#endif /* end of TEEI_CANCEL_CMD_H */
@@ -0,0 +1,126 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef __TEEI_CLIENT_H_
#define __TEEI_CLIENT_H_
#include <tee_client_api.h>
#include <teei_ioc.h>
#define TEEI_CLIENT_FULL_PATH_DEV_NAME "/dev/teei_client"
#define TEEI_CLIENT_DEV "teei_client"
/** IOCTL request */
/**
* @brief Encode command structure
*/
struct teei_client_encode_cmd {
unsigned int len;
unsigned long long data;
int offset;
int flags;
int param_type;
int encode_id;
int session_id;
unsigned int cmd_id;
int value_flag;
int param_pos;
int param_pos_type;
int return_value;
int return_origin;
};
/**
* @brief Session details structure
*/
struct ser_ses_id {
/* int service_id; */
int session_id;
struct TEEC_UUID uuid;
int return_value;
int return_origin;
int paramtype;
int params[8];
};
/**
* @brief Session details structure
*/
struct user_ses_init {
int session_id;
};
struct ctx_data {
char name[255]; /* context name */
int ctx_ret; /* context return */
};
/**
* @brief Shared memory information for the session
*/
struct teei_session_shared_mem_info {
/* unsigned long service_id; */
unsigned int session_id;
u64 user_mem_addr;
};
/**
* @brief Shared memory used for smc processing
*/
struct teei_smc_cdata {
int cmd_addr;
int size;
int valid_flag;
int ret_val;
};
/* For general service */
#define TEEI_CLIENT_IOCTL_SEND_CMD_REQ \
_IOWR(TEEI_CLIENT_IOC_MAGIC, 3, struct teei_client_encode_cmd)
#define TEEI_CLIENT_IOCTL_SES_OPEN_REQ \
_IOW(TEEI_CLIENT_IOC_MAGIC, 4, struct ser_ses_id)
#define TEEI_CLIENT_IOCTL_SES_CLOSE_REQ \
_IOWR(TEEI_CLIENT_IOC_MAGIC, 5, struct ser_ses_id)
#define TEEI_CLIENT_IOCTL_SHR_MEM_FREE_REQ \
_IOWR(TEEI_CLIENT_IOC_MAGIC, 6, struct teei_session_shared_mem_info)
#define TEEI_CLIENT_IOCTL_ENC_UINT32 \
_IOWR(TEEI_CLIENT_IOC_MAGIC, 7, struct teei_client_encode_cmd)
#define TEEI_CLIENT_IOCTL_ENC_ARRAY \
_IOWR(TEEI_CLIENT_IOC_MAGIC, 8, struct teei_client_encode_cmd)
#define TEEI_CLIENT_IOCTL_ENC_ARRAY_SPACE \
_IOWR(TEEI_CLIENT_IOC_MAGIC, 9, struct teei_client_encode_cmd)
#define TEEI_CLIENT_IOCTL_ENC_MEM_REF \
_IOWR(TEEI_CLIENT_IOC_MAGIC, 10, struct teei_client_encode_cmd)
#define TEEI_CLIENT_IOCTL_DEC_UINT32 \
_IOWR(TEEI_CLIENT_IOC_MAGIC, 11, struct teei_client_encode_cmd)
#define TEEI_CLIENT_IOCTL_DEC_ARRAY_SPACE \
_IOWR(TEEI_CLIENT_IOC_MAGIC, 12, struct teei_client_encode_cmd)
#define TEEI_CLIENT_IOCTL_OPERATION_RELEASE \
_IOWR(TEEI_CLIENT_IOC_MAGIC, 13, struct teei_client_encode_cmd)
#define TEEI_CLIENT_IOCTL_SHR_MEM_ALLOCATE_REQ \
_IOWR(TEEI_CLIENT_IOC_MAGIC, 14, struct teei_session_shared_mem_info)
#define TEEI_CLIENT_IOCTL_GET_DECODE_TYPE \
_IOWR(TEEI_CLIENT_IOC_MAGIC, 15, struct teei_client_encode_cmd)
/* add by lodovico */
#define TEEI_CLIENT_IOCTL_INITCONTEXT_REQ \
_IOW(TEEI_CLIENT_IOC_MAGIC, 16, struct ctx_data)
#define TEEI_CLIENT_IOCTL_CLOSECONTEXT_REQ \
_IOW(TEEI_CLIENT_IOC_MAGIC, 17, struct ctx_data)
/* add end */
#define TEEI_CLIENT_IOCTL_SES_INIT_REQ \
_IOW(TEEI_CLIENT_IOC_MAGIC, 18, struct user_ses_init)
#define TEEI_GET_TEEI_CONFIG_STAT \
_IOW(TEEI_CLIENT_IOC_MAGIC, 0x1001, struct ctx_data)
#define TEEI_CANCEL_COMMAND \
_IOW(TEEI_CLIENT_IOC_MAGIC, 0x1002, struct ctx_data)
#endif /* __TEEI_CLIENT_H_ */
@@ -0,0 +1,78 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef __TEEI_CLIENT_MAIN_H__
#define __TEEI_CLIENT_MAIN_H__
#include <linux/suspend.h>
#include <teei_ioc.h>
#include "teei_smc_struct.h"
#include "teei_client.h"
/* #define UT_DEBUG */
#define CANCEL_BUFF_SIZE (4096)
#define TEEI_CONFIG_FULL_PATH_DEV_NAME "/dev/teei_config"
#define TEEI_CONFIG_DEV "teei_config"
#define MIN_BC_NUM (4)
#define MAX_LC_NUM (3)
#define TEEI_CPU_0
#define TEEI_TA 0x01
#define TEEI_DRV 0x00
enum {
TZ_CALL_PREPARE,
TZ_CALL_RETURNED,
};
struct tz_driver_state {
struct mutex smc_lock;
struct atomic_notifier_head notifier;
struct platform_device *tz_log_pdev;
};
struct tz_driver_state *get_tz_drv_state(void);
extern unsigned int soter_error_flag;
extern struct workqueue_struct *secure_wq;
extern struct semaphore boot_sema;
extern struct smc_call_struct smc_call_entry;
extern unsigned long boot_vfs_addr;
extern unsigned long boot_soter_flag;
extern int keymaster_call_flag;
extern struct completion boot_decryto_lock;
extern struct task_struct *teei_switch_task;
extern struct kthread_worker ut_fastcall_worker;
extern unsigned long spi_ready_flag;
extern struct list_head g_block_link;
int get_current_cpuid(void);
void *tz_malloc_shared_mem(size_t size, int flags);
void tz_free_shared_mem(void *addr, size_t size);
void *tz_malloc(size_t size, int flags);
int handle_switch_core(int cpu);
int is_teei_ready(void);
int teei_new_capi_init(void);
int handle_new_capi_call(void *args);
int tz_load_drv_by_str(const char *buf);
int tz_load_ta_by_str(const char *buf);
int teei_handle_move_core(int cpu);
int teei_move_cpu_context(int target_cpu_id, int original_cpu_id);
void teei_cpus_read_lock(void);
void teei_cpus_read_unlock(void);
void teei_cpus_write_lock(void);
void teei_cpus_write_unlock(void);
int teei_set_switch_pri(unsigned long policy);
#endif /* __TEEI_CLIENT_MAIN_H__ */
@@ -0,0 +1,22 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef TEEI_CLIENT_TRANSFER_DATA_H
#define TEEI_CLIENT_TRANSFER_DATA_H
#include <tee_client_api.h>
#include <teei_secure_api.h>
int ut_pf_gp_initialize_context(struct TEEC_Context *context);
int ut_pf_gp_finalize_context(struct TEEC_Context *context);
int ut_pf_gp_transfer_data(struct TEEC_Context *context, struct TEEC_UUID *uuid,
unsigned int command, void *buffer, unsigned long size);
int ut_pf_gp_transfer_user_data(struct TEEC_Context *context,
struct TEEC_UUID *uuid,
unsigned int command, void *buffer, unsigned long size);
#endif /* end of TEEI_CLIENT_TRANSFER_DATA_H */
@@ -0,0 +1,183 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef __TEEI_COMMON_H_
#define __TEEI_COMMON_H_
#include <linux/types.h>
#include <notify_queue.h>
//#include <mt-plat/met_drv.h>
#define TEEI_MAX_REQ_PARAMS 12
#define TEEI_MAX_RES_PARAMS 8
#define TEEI_1K_SIZE 1024
/**
* @brief Command status
*/
enum teei_cmd_status {
TEEI_STATUS_INCOMPLETE = 0,
TEEI_STATUS_COMPLETE,
TEEI_STATUS_MAX = 0x7FFFFFFF
};
/**
* @brief Parameters type
*/
enum teeic_param_type {
TEEIC_PARAM_IN = 0,
TEEIC_PARAM_OUT
};
/**
* @brief Shared memory for Notification
*/
struct teeic_notify_data {
int dev_file_id;
int service_id;
int client_pid;
int session_id;
int enc_id;
};
enum teeic_param_value {
TEEIC_PARAM_A = 0,
TEEIC_PARAM_B
};
enum teeic_param_pos {
TEEIC_PARAM_1ST = 0,
TEEIC_PARAM_2ND,
TEEIC_PARAM_3TD,
TEEIC_PARAM_4TH
};
/**
* @brief Metadata used for encoding/decoding
*/
struct teei_encode_meta {
int type;
int len; /* data length */
unsigned long long usr_addr; /* data address in user space */
int ret_len; /* return sizeof data */
int value_flag; /* value of a or b */
int param_pos; /* param order */
int param_pos_type; /* param type */
};
/**
* @brief SMC command structure
*/
#pragma pack(1)
struct teei_smc_cmd {
u32 teei_cmd_type;
u32 id;
u32 context;
u32 enc_id;
u32 src_id;
u32 src_context;
u32 req_buf_len;
u32 resp_buf_len;
u32 ret_resp_buf_len;
u32 info_buf_len;
u32 cmd_status;
u64 req_buf_phys;
u64 resp_buf_phys;
u64 meta_data_phys;
u64 info_buf_phys;
u32 dev_file_id;
u32 error_code;
u64 teei_sema;
};
#pragma pack()
struct message_head {
unsigned int invalid_flag;
unsigned int message_type;
unsigned int child_type;
unsigned int param_length;
};
struct fdrv_message_head {
unsigned int driver_type;
unsigned int fdrv_param_length;
};
#pragma pack(1)
struct create_fdrv_struct {
u32 fdrv_type;
u64 fdrv_phy_addr;
u32 fdrv_size;
};
#pragma pack()
struct ack_fast_call_struct {
int retVal;
};
struct fdrv_call_struct {
int fdrv_call_type;
int fdrv_call_buff_size;
int retVal;
};
struct service_handler {
unsigned int sysno;
void *param_buf;
unsigned int size;
long (*init)(struct service_handler *handler);
void (*deinit)(struct service_handler *handler);
int (*handle)(struct NQ_entry *handler);
};
/* [KTRACE] Begin-End */
#ifdef CONFIG_MICROTRUST_TZ_DRIVER_MTK_TRACING
#define KATRACE_MESSAGE_LENGTH 1024
#define BEGINED_PID (current->tgid)
static inline void tracing_mark_write(const char *buf)
{
TRACE_PUTS(buf);
}
#define WRITE_MSG(format, pid, name) { \
char buf[KATRACE_MESSAGE_LENGTH]; \
int len = snprintf(buf, sizeof(buf), format, pid, name); \
if (len >= (int) sizeof(buf)) { \
int name_len = strlen(name) - (len - sizeof(buf)) - 1; \
len = snprintf(buf, sizeof(buf), "B|%d|%.*s", BEGINED_PID, \
name_len, name); \
} \
tracing_mark_write(buf); \
}
#define KATRACE_BEGIN(name) katrace_begin_body(name)
static inline void katrace_begin_body(const char *name)
{
WRITE_MSG("B|%d|%s", BEGINED_PID, name);
}
#define KATRACE_END(name) katrace_end(name)
static inline void katrace_end(const char *name)
{
WRITE_MSG("E|%d|%s", BEGINED_PID, name);
}
#else
#define KATRACE_BEGIN(name) \
do { \
} while (0)
#define KATRACE_END(name) \
do { \
} while (0)
#endif
#endif /* __TEEI_COMMON_H_ */
@@ -0,0 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef SW_COMMON_TYPES_H
#define SW_COMMON_TYPES_H
#define size_t (unsigned long)
#endif
@@ -0,0 +1,40 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef __TEEI_DEBUG_H_
#define __TEEI_DEBUG_H_
/* #define TEEI_DEBUG */
/* #define TEEI_INFO */
#undef TDEBUG
#undef TINFO
#undef TERR
#define TZDebug(fmt, args...) \
pr_info("\033[;34m[TZDriver]"fmt"\033[0m\n", ##args)
#ifdef TEEI_DEBUG
/*
* #define TDEBUG(fmt, args...) pr_info("%s(%i, %s): " fmt "\n", \
* __func__, current->pid, current->comm, ##args)
*/
#define TDEBUG(fmt, args...) pr_info("tz driver"fmt"\n", ##args)
#else
#define TDEBUG(fmt, args...)
#endif
#ifdef TEEI_INFO
#define TINFO(fmt, args...) pr_info("%s(%i, %s): " fmt "\n", \
__func__, current->pid, current->comm, ##args)
#else
#define TINFO(fmt, args...)
#endif
#define TERR(fmt, args...) pr_notice("%s(%i, %s): " fmt "\n", \
__func__, current->pid, current->comm, ##args)
#endif
@@ -0,0 +1,13 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef TEEI_FP_H
#define TEEI_FP_H
extern struct TEEC_UUID uuid_fp;
#endif /* end of TEEI_FP_H */
@@ -0,0 +1,170 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef __TEEI_ID_H_
#define __TEEI_ID_H_
#include <asm/cacheflush.h>
#define SMC_ENOMEM 7
#define SMC_EOPNOTSUPP 6
#define SMC_EINVAL_ADDR 5
#define SMC_EINVAL_ARG 4
#define SMC_ERROR 3
#define SMC_INTERRUPTED 2
#define SMC_PENDING 1
#define SMC_SUCCESS 0
/*extern void __flush_dcache_area(void *addr, size_t len);*/
extern unsigned long boot_soter_flag;
#define START_STATUS (0)
/**
* @brief Encoding data type
*/
enum teei_enc_data_type {
TEEI_ENC_INVALID_TYPE = 0,
TEEI_ENC_UINT32,
TEEI_ENC_ARRAY,
TEEI_MEM_REF,
TEEI_SECURE_MEM_REF
};
/**
* @brief Command ID's for global service
*/
enum _global_cmd_id {
TEEI_GLOBAL_CMD_ID_INVALID = 0x0,
TEEI_GLOBAL_CMD_ID_BOOT_ACK,
/* add by lodovico */
TEEI_GLOBAL_CMD_ID_INIT_CONTEXT,
/* add end */
TEEI_GLOBAL_CMD_ID_OPEN_SESSION,
TEEI_GLOBAL_CMD_ID_CLOSE_SESSION,
TEEI_GLOBAL_CMD_ID_RESUME_ASYNC_TASK,
TEEI_GLOBAL_CMD_ID_UNKNOWN = 0x7FFFFFFE,
TEEI_GLOBAL_CMD_ID_MAX = 0x7FFFFFFF
};
/* add by lodovico */
/* void printff(); */
int service_smc_call(u32 teei_cmd_type, u32 dev_file_id, u32 svc_id,
u32 cmd_id, u32 context, u32 enc_id,
const void *cmd_buf,
size_t cmd_len,
void *resp_buf,
size_t resp_len,
const void *meta_data,
int *ret_resp_len,
void *wq,
void *arg_lock, int *error_code);
enum teei_cmd_type {
TEEI_CMD_TYPE_INVALID = 0x0,
TEEI_CMD_TYPE_SOCKET_INIT,
TEEI_CMD_TYPE_INITIALIZE_CONTEXT,
TEEI_CMD_TYPE_FINALIZE_CONTEXT,
TEEI_CMD_TYPE_OPEN_SESSION,
TEEI_CMD_TYPE_CLOSE_SESSION,
TEEI_CMD_TYPE_INVOKE_COMMAND,
TEEI_CMD_TYPE_UNKNOWN = 0x7FFFFFFE,
TEEI_CMD_TYPE_MAX = 0x7FFFFFFF
};
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
#define Cache_line_size 32
/****************************************************************
* @brief:
* Flush_Dcache_By_Area
* @param:
* start - mva start
* end - mva end
* @return:
* ***************************************************************/
static inline void Flush_Dcache_By_Area(unsigned long start, unsigned long end)
{
if (boot_soter_flag == START_STATUS) {
#ifdef CONFIG_ARM64
__flush_dcache_area((void *)start, (end - start));
#else
__cpuc_flush_dcache_area((void *)start, (end - start));
#endif
}
}
/******************************************************************
* @brief:
* Invalidate_Dcache_By_Area
* @param:
* start - mva start
* end - mva end
* @return:
* *****************************************************************/
static inline void __Invalidate_Dcache_By_Area(unsigned long start,
unsigned long end)
{
#ifdef CONFIG_ARM64
uint64_t temp[2];
temp[0] = start;
temp[1] = end;
__asm__ volatile(
"ldr x0, [%[temp], #0]\n\t"
"ldr x1, [%[temp], #8]\n\t"
"mrs x3, ctr_el0\n\t"
"ubfm x3, x3, #16, #19\n\t"
"mov x2, #4\n\t"
"lsl x2, x2, x3\n\t"
"dsb sy\n\t"
"sub x3, x2, #1\n\t"
"bic x0, x0, x3\n\t"
/* invalidate D line / unified line */
"1: dc ivac, x0\n\t"
"add x0, x0, x2\n\t"
"cmp x0, x1\n\t"
"b.lo 1b\n\t"
"dsb sy\n\t"
: :
[temp] "r" (temp)
: "x0", "x1", "x2", "x3", "memory");
#else
__asm__ __volatile__ ("dsb" : : : "memory"); /* dsb */
__asm__ __volatile__ (
/* Invalidate Data Cache Line (using MVA) Register */
"1: mcr p15, 0, %[i], c7, c6, 1\n"
" add %[i], %[i], %[clsz]\n"
" cmp %[i], %[end]\n"
" blo 1b\n"
:
[i] "=&r" (start)
: "0" ((unsigned long)start & (~(Cache_line_size - 1))),
[end] "r" (end),
[clsz] "i" (Cache_line_size)
: "memory");
/* invalidate btc */
asm volatile ("mcr p15, 0, %0, c7, c5, 0" : : "r" (0) : "memory");
__asm__ __volatile__ ("dsb" : : : "memory"); /* dsb */
#endif
}
static inline void Invalidate_Dcache_By_Area(unsigned long start,
unsigned long end)
{
if (boot_soter_flag == START_STATUS)
__Invalidate_Dcache_By_Area(start, end);
}
/* add end */
#endif /* __OPEN_OTZ_ID_H_ */
@@ -0,0 +1,14 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef TEEI_KEYMASTER_H
#define TEEI_KEYMASTER_H
extern struct semaphore keymaster_api_lock;
int send_keymaster_command(void *buffer, unsigned long size);
#endif /* end of TEEI_KEYMASTER_H */
@@ -0,0 +1,164 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef __LIB_LIST_H__
#define __LIB_LIST_H__
#define LIST_POISON_PREV 0xDEADBEEF
#define LIST_POISON_NEXT 0xFADEBABE
/**
* @brief
*/
struct list {
struct list *next, *prev;
};
#define INIT_HEAD(__lname) { &(__lname), &(__lname) }
#define LIST_HEAD(_lname) struct list _lname = INIT_HEAD(_lname)
#define INIT_LIST_HEAD(ptr) do { \
(ptr)->next = ptr; (ptr)->prev = ptr; \
} while (0)
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
#define list_for_each(curr, head) \
for (curr = (head)->next; curr != head; curr = (curr)->next)
#define list_for_each_entry(ptr, head, member) \
for (ptr = list_entry((head)->next, typeof(*ptr), member); \
&ptr->member != (head); \
ptr = list_entry(ptr->member.next, typeof(*ptr), member))
/**
* list_for_each_entry_safe - iterate over list of given type
* safe against removal of list entry
* @param pos: the type * to use as a loop cursor.
* @param n: another type * to use as temporary storage
* @param head: the head for your list.
* @param member: the name of the list_struct within the struct.
*/
#define list_for_each_entry_safe(pos, n, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member), \
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.next, typeof(*n), member))
/**
* @brief
*
* @param prev
* @param next
* @param new
*/
static inline void __list_add(struct list *prev,
struct list *next, struct list *new)
{
new->prev = prev;
new->next = next;
prev->next = new;
next->prev = new;
}
/**
* @brief
* Adds the new node after the given head.
* @param head: List head after which the "new" node should be added.
* @param new: New node that needs to be added to list.
* @note Please note that new node is added after the head.
*/
static inline void list_add(struct list *head, struct list *new)
{
__list_add(head, head->next, new);
}
/**
* Adds a node at the tail where tnode points to tail node.
* @param tnode: The current tail node.
* @param new: The new node to be added before tail.
* @note: Please note that new node is added before tail node.
*/
static inline void list_add_tail(struct list *tnode, struct list *new)
{
__list_add(tnode->prev, tnode, new);
}
/**
* @brief
*
* @param node
* @param prev
* @param next
*/
static inline void __list_del(struct list *node,
struct list *prev, struct list *next)
{
prev->next = node->next;
next->prev = node->prev;
node->next = (void *)LIST_POISON_NEXT;
node->prev = (void *)LIST_POISON_PREV;
}
/**
* @brief
* Deletes a given node from list.
* @param node: Node to be deleted.
*
* @param node
*/
static inline void list_del(struct list *node)
{
__list_del(node, node->prev, node->next);
}
/**
* @brief
*
* @param head
*
* @return
*/
static inline struct list *list_pop_tail(struct list *head)
{
struct list *dnode = head->prev;
list_del(head->prev);
return dnode;
}
/**
* @brief
*
* @param head
*
* @return
*/
static inline struct list *list_pop(struct list *head)
{
struct list *dnode = head->next;
list_del(head->next);
return dnode;
}
/**
* @brief
*
* @param head
*
* @return
*/
static inline int list_empty(struct list *head)
{
if (head->next == head)
return 1;
else
return 0;
}
#endif /* __LIB_LIST_H__ */
@@ -0,0 +1,13 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef TEEI_LOG_H
#define TEEI_LOG_H
#define LOG_BUF_LEN (256 * 1024)
#endif /* TEEI_LOG_H */
@@ -0,0 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef TEEI_SMC_CALL_H
#define TEEI_SMC_CALL_H
#include <linux/semaphore.h>
#endif /* end of TEEI_SMC_CALL_H */
@@ -0,0 +1,68 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef __TEEI_SMC_STRUCT_H__
#define __TEEI_SMC_STRUCT_H__
#include <linux/semaphore.h>
#define TEE_NAME_SIZE (255)
struct teei_encode {
struct list_head head;
int encode_id;
void *ker_req_data_addr;
void *ker_res_data_addr;
u32 enc_req_offset;
u32 enc_res_offset;
u32 enc_req_pos;
u32 enc_res_pos;
u32 dec_res_pos;
u32 dec_offset;
struct teei_encode_meta *meta;
};
struct teei_shared_mem {
struct list_head head;
struct list_head s_head;
void *index;
void *k_addr;
void *u_addr;
u32 len;
};
struct teei_context {
/* ID */
unsigned long cont_id;
/* Name */
char tee_name[TEE_NAME_SIZE];
/* session counter */
unsigned long sess_cnt;
/* share memory counter */
unsigned long shared_mem_cnt;
/* link list for teei_context */
struct list_head link;
/* link list for the sessions of this context */
struct list_head sess_link;
/* link list for the share memory of this context */
struct list_head shared_mem_list;
struct semaphore cont_lock;
};
struct teei_session {
/* ID */
int sess_id;
/* the teei_context pointer of this session */
struct teei_context *parent_cont;
/* link list for teei_session */
struct list_head link;
/* link list for the encode of this session */
struct list_head encode_list;
/* link list for the share memory of this session */
struct list_head shared_mem_list;
};
#endif
@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef TEEI_TASK_LINK_H
#define TEEI_TASK_LINK_H
int teei_init_task_link(void);
int teei_add_to_task_link(struct list_head *entry);
struct task_entry_struct *teei_get_task_from_link(void);
int is_teei_task_link_empty(void);
int teei_add_to_bdrv_link(struct list_head *entry);
struct bdrv_work_struct *teei_get_bdrv_from_link(void);
#endif /* end of TEEI_TASK_LINK_H */
@@ -0,0 +1,27 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef TZ_SERVICE_H
#define TZ_SERVICE_H
#ifdef VFS_RDWR_SEM
extern struct semaphore VFS_rd_sem;
extern struct semaphore VFS_wr_sem;
#else
extern struct completion VFS_rd_comp;
extern struct completion VFS_wr_comp;
#endif
int wait_for_service_done(void);
int register_switch_irq_handler(void);
int teei_service_init(void);
void set_sch_nq_cmd(void);
void set_sch_load_img_cmd(void);
long create_cmd_buff(void);
void set_cancel_command(unsigned long memory_size);
#endif
@@ -0,0 +1,90 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef _UT_DRV_H_
#define _UT_DRV_H_
#include <tee_client_api.h>
struct ut_drv_entry {
struct TEEC_UUID uuid;
struct TEEC_Session session;
uint32_t driver_id;
struct list_head list;
};
struct param_get_drv_id {
unsigned long dummy;
};
struct param_reg_dci_buf {
uint64_t phy_addr;
uint32_t buf_size;
};
struct param_notify_from_ree {
unsigned long data;
uint32_t cmd;
};
struct param_drv_open {
unsigned long data;
};
struct param_drv_ioctl {
unsigned long data;
uint32_t cmd;
};
struct param_drv_close {
unsigned long dummy;
};
struct ut_drv_param {
uint32_t cmd_id;
union {
struct param_get_drv_id get_drv_id;
struct param_reg_dci_buf reg_dci_buf;
struct param_notify_from_ree notify_from_ree;
struct param_drv_open drv_open;
struct param_drv_ioctl drv_ioctl;
struct param_drv_close drv_close;
} u;
};
enum {
UT_DRV_GET_DRIVER_ID,
UT_DRV_REGISTER_DCI_BUFFER,
UT_DRV_FREE_DCI_BUFFER,
UT_DRV_NOTIFY_FROM_REE,
UT_DRV_OPEN,
UT_DRV_IOCTL,
UT_DRV_CLOSE,
};
static inline void prepare_params(struct TEEC_Operation *op,
void *data, size_t size)
{
op->params[0].tmpref.buffer = data;
op->params[0].tmpref.size = size;
op->params[1].value.a = 0;
op->paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
TEEC_VALUE_OUTPUT,
TEEC_NONE,
TEEC_NONE);
}
static inline uint32_t get_result(struct TEEC_Operation *op)
{
return op->params[1].value.a;
}
struct ut_drv_entry *find_ut_drv_entry_by_uuid(struct TEEC_UUID *uuid);
struct ut_drv_entry *find_ut_drv_entry_by_driver_id(uint32_t driver_id);
#endif
@@ -0,0 +1,23 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef UTDRIVER_IRQ_H
#define UTDRIVER_IRQ_H
#define LOAD_IMG_IRQ (281)
#define SWITCH_IRQ (282)
#define BOOT_IRQ (283)
#define SCHED_IRQ (284)
#define SOTER_IRQ (285)
#define FP_ACK_IRQ (287)
#define BDRV_IRQ (278)
#define TEEI_LOG_IRQ (277)
#define SOTER_ERROR_IRQ (276)
#define UT_DRV_IRQ (284)
#endif /* end if UTDRIVER_IRQ_H */
@@ -0,0 +1,59 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef UTDRIVER_MACRO_H
#define UTDRIVER_MACRO_H
/* define TEEI_MUTIL_TA_DEBUG */
#define START_STATUS (0)
#define END_STATUS (1)
#define VFS_SIZE (0x80000)
#define VDRV_MAX_SIZE (0x80000)
#define KEYMASTER_BUFF_SIZE (512 * 1024)
/* Command ID in the notify queue entry */
#define TEEI_CREAT_FDRV (0x40)
#define TEEI_CREAT_BDRV (0x41)
#define TEEI_LOAD_TEE (0x42)
#define NEW_CAPI_CALL (0x43)
#define TEEI_BDRV_CALL (0x44)
#define TEEI_FDRV_CALL (0x45)
#define TEEI_SCHED_CALL (0x46)
#define TEEI_MODIFY_TEE_CONFIG (0x47)
/* Command ID in the notify queue entry END */
/* Switch function ID */
#define SMC_CALL_TYPE (0x10)
#define SWITCH_CORE_TYPE (0x11)
/* Switch function ID END */
#define VFS_SYS_NO 0x08
#define REETIME_SYS_NO 0x07
#define SCHED_SYS_NO 0x09
#define CANCEL_SYS_NO (110)
#define MAX_BUFF_SIZE (0x2000)
#define NQ_SIZE (0x1000)
#define NQ_BUFF_SIZE (0x1000)
#define NQ_BLOCK_SIZE (64)
#define BLOCK_MAX_COUNT (NQ_BUFF_SIZE / NQ_BLOCK_SIZE - 1)
#define CTL_BUFF_SIZE (0x1000)
#define MESSAGE_LENGTH (0x1000)
#define MESSAGE_SIZE (0x1000)
/* #define DYNAMIC_SET_PRIORITY */
#endif /* end of UTDRIVER_MACRO_H */
@@ -0,0 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef __UTOS_VERSION_H__
#define __UTOS_VERSION_H__
#define UTOS_VERSION "tag.base.dbg.2.5.3"
#endif
@@ -0,0 +1,40 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2015-2019, MICROTRUST Incorporated
* All Rights Reserved.
*
*/
#ifndef __UT_TUI_H_
#define __UT_TUI_H_
#include <linux/suspend.h>
enum disp_pwm_id_t {
DISP_PWM0 = 0x1,
DISP_PWM1 = 0x2,
DISP_PWM_ALL = (DISP_PWM0 | DISP_PWM1)
};
#define disp_pwm_id_t enum disp_pwm_id_t
extern int mtkfb_set_backlight_level(unsigned int level);
extern int disp_pwm_set_backlight(disp_pwm_id_t id, int level_1024);
extern void disp_aal_notify_backlight_changed(int bl_1024);
extern void ut_down_low(struct semaphore *sema);
extern int enter_tui_flag;
extern int power_down_flag;
extern unsigned long tui_display_message_buff;
extern unsigned long tui_notice_message_buff;
extern struct semaphore tui_notify_sema;
int try_send_tui_command(void);
int send_tui_display_command(unsigned long share_memory_size);
int send_tui_notice_command(unsigned long share_memory_size);
unsigned long create_tui_buff(int buff_size, unsigned int fdrv_type);
int wait_for_power_down(void);
int tui_notify_reboot(struct notifier_block *this, unsigned long code, void *x);
int __send_tui_display_command(unsigned long share_memory_size);
int __send_tui_notice_command(unsigned long share_memory_size);
#endif /* end of __UT_TUI_H_ */