aboutsummaryrefslogtreecommitdiff
path: root/include/trustzone
diff options
context:
space:
mode:
authorMeizu OpenSource <patchwork@meizu.com>2016-08-15 10:19:42 +0800
committerMeizu OpenSource <patchwork@meizu.com>2016-08-15 10:19:42 +0800
commitd2e1446d81725c351dc73a03b397ce043fb18452 (patch)
tree4dbc616b7f92aea39cd697a9084205ddb805e344 /include/trustzone
first commit
Diffstat (limited to 'include/trustzone')
-rw-r--r--include/trustzone/README11
-rw-r--r--include/trustzone/kree/mem.h295
-rw-r--r--include/trustzone/kree/system.h50
-rw-r--r--include/trustzone/kree/tz_irq.h29
-rw-r--r--include/trustzone/kree/tz_mem.h21
-rw-r--r--include/trustzone/kree/tz_mod.h58
-rw-r--r--include/trustzone/kree/tz_pm.h23
-rw-r--r--include/trustzone/tz_cross/hdmi_ta.h21
-rw-r--r--include/trustzone/tz_cross/keyblock.h81
-rw-r--r--include/trustzone/tz_cross/ree_service.h81
-rw-r--r--include/trustzone/tz_cross/ta_dapc.h17
-rw-r--r--include/trustzone/tz_cross/ta_dapc_log.h33
-rw-r--r--include/trustzone/tz_cross/ta_dbg.h15
-rw-r--r--include/trustzone/tz_cross/ta_dcm.h45
-rw-r--r--include/trustzone/tz_cross/ta_ddp.h51
-rw-r--r--include/trustzone/tz_cross/ta_ddp_log.h33
-rw-r--r--include/trustzone/tz_cross/ta_drmkey.h22
-rw-r--r--include/trustzone/tz_cross/ta_emi.h17
-rw-r--r--include/trustzone/tz_cross/ta_gcpu.h18
-rw-r--r--include/trustzone/tz_cross/ta_hacc.h35
-rw-r--r--include/trustzone/tz_cross/ta_hdcp2tx.h42
-rw-r--r--include/trustzone/tz_cross/ta_icnt.h18
-rw-r--r--include/trustzone/tz_cross/ta_irq.h26
-rw-r--r--include/trustzone/tz_cross/ta_logctrl.h21
-rw-r--r--include/trustzone/tz_cross/ta_m4u.h68
-rw-r--r--include/trustzone/tz_cross/ta_mem.h24
-rw-r--r--include/trustzone/tz_cross/ta_modular_drm.h108
-rw-r--r--include/trustzone/tz_cross/ta_mtee_img_prot_inf_gen.h10
-rw-r--r--include/trustzone/tz_cross/ta_ndbg.h20
-rw-r--r--include/trustzone/tz_cross/ta_playready.h97
-rw-r--r--include/trustzone/tz_cross/ta_pm.h26
-rw-r--r--include/trustzone/tz_cross/ta_securetime.h73
-rw-r--r--include/trustzone/tz_cross/ta_system.h20
-rw-r--r--include/trustzone/tz_cross/ta_test.h28
-rw-r--r--include/trustzone/tz_cross/ta_vdec.h18
-rw-r--r--include/trustzone/tz_cross/ta_venc.h23
-rw-r--r--include/trustzone/tz_cross/ta_widevine.h52
-rw-r--r--include/trustzone/tz_cross/trustzone.h165
-rw-r--r--include/trustzone/tz_cross/tz_cmdq.h165
-rw-r--r--include/trustzone/tz_cross/tz_ddp.h58
-rw-r--r--include/trustzone/tz_cross/tz_error_strings.h47
41 files changed, 2065 insertions, 0 deletions
diff --git a/include/trustzone/README b/include/trustzone/README
new file mode 100644
index 000000000..728a7f938
--- /dev/null
+++ b/include/trustzone/README
@@ -0,0 +1,11 @@
+1. If you header files, related to MTEE, are shared between Linux Kernel and User Space
+ those header files should be put in the folders and synced below.
+ 1-1. alps/device/mediatek/mt8127/kernel-headers/trustzone/kree
+ 1-2. alps/kernel-3.10/include/trustzone/kree
+
+2. If your header files should be shared between MTEE and Linux Kernel,
+ those header files should be put in the folders both below.
+ 2-1. alps/kernel-3.10/include/trustzone/tz_cross
+ 2-2. alps/vendor/mediatek/proprietary/trustzone/mtk/include/tz_cross
+
+3. It is noted that head files in Linux Kernel should not include MTK License Disclaimer
diff --git a/include/trustzone/kree/mem.h b/include/trustzone/kree/mem.h
new file mode 100644
index 000000000..a98f00db9
--- /dev/null
+++ b/include/trustzone/kree/mem.h
@@ -0,0 +1,295 @@
+/*
+ * Header files for KREE memory related functions.
+ */
+
+#ifndef __KREE_MEM_H__
+#define __KREE_MEM_H__
+
+#ifdef CONFIG_MTK_IN_HOUSE_TEE_SUPPORT
+
+#include "trustzone/tz_cross/trustzone.h"
+
+
+/// KREE session handle type.
+typedef uint32_t KREE_SESSION_HANDLE;
+
+#define KREE_SESSION_HANDLE_NULL ((KREE_SESSION_HANDLE)0)
+#define KREE_SESSION_HANDLE_FAIL ((KREE_SESSION_HANDLE)-1)
+
+/**
+ * Memory handle define
+ *
+ * Handle is used to communicate with normal world:
+ * 1. Memory information can not expose to normal world. (Major, important!)
+ * 2. Too many informations, and thet can be grouped by handle.
+ *
+ * All kinds of memory use the same handle define.
+ * According to their different purpose, they are redefined to specific name.
+ * Just for easy programming.
+ */
+
+// Shared memory handle define
+typedef uint32_t KREE_SHAREDMEM_HANDLE;
+
+// Secure memory handle define
+typedef uint32_t KREE_SECUREMEM_HANDLE;
+
+// Secure chunk memory handle define
+typedef uint32_t KREE_SECURECM_HANDLE;
+
+// Release Secure chunk memory handle define
+typedef uint32_t KREE_RELEASECM_HANDLE;
+
+/**
+ * Shared memory parameter
+ *
+ * It defines the types for shared memory.
+ *
+ * @param buffer A pointer to shared memory buffer
+ * @param size shared memory size in bytes
+ */
+typedef struct {
+ void* buffer;
+ uint32_t size;
+} KREE_SHAREDMEM_PARAM;
+
+// map_p: 0 = no remap, 1 = remap
+TZ_RESULT kree_register_sharedmem (KREE_SESSION_HANDLE session, KREE_SHAREDMEM_HANDLE *mem_handle,
+ void *start, uint32_t size, void *map_p);
+
+TZ_RESULT kree_unregister_sharedmem (KREE_SESSION_HANDLE session, KREE_SHAREDMEM_HANDLE mem_handle);
+
+/**
+ * Shared memory
+ *
+ * A shared memory is normal memory, which can be seen by Normal world and Secure world.
+ * It is used to create the comminicattion between two worlds.
+ * Currently, zero-copy data transfer is supportted, for simple and efficient design.
+ *
+ * The shared memory lifetime:
+ * 1. CA (Client Application at REE) prepares memory
+ * 2. CA registers it to TEE scope.
+ * 3. A handle is returned. CA can use it to communicate with TEE.
+ * 4. If shared memory is not used, CA unregisters it.
+ * 5. CA frees memory.
+ *
+ * Because it is zero-copy shared memory, the memory characteritics is inherited.
+ * If the shared memory will be used for HW, CA must allocate physical continuous memory.
+ *
+ * Note: Because shared memory can be seen by both Normal and Secure world.
+ * It is a possible weakpoint to bed attacked or leak secure data.
+ *
+ * Note: ONLY support memory allocated by kmalloc!!!
+ */
+
+/**
+ * Register shared memory
+ *
+ * @param session The session handle.
+ * @param shm_handle [out] A pointer to shared memory handle.
+ * @param param A pointer to shared memory parameters.
+ * @return return code.
+ */
+TZ_RESULT KREE_RegisterSharedmem ( KREE_SESSION_HANDLE session,
+ KREE_SHAREDMEM_HANDLE *shm_handle, KREE_SHAREDMEM_PARAM *param);
+
+
+/**
+ * Unregister shared memory
+ *
+ * @param session The session handle.
+ * @param shm_handle The shared memory handle.
+ * @return return code.
+ */
+TZ_RESULT KREE_UnregisterSharedmem (KREE_SESSION_HANDLE session, KREE_SHAREDMEM_HANDLE shm_handle);
+
+/**
+ * Secure memory
+ *
+ * A secure memory can be seen only in Secure world.
+ * Secure memory, here, is defined as external memory (ex: DRAM) protected by trustzone.
+ * It can protect from software attack very well, but can not protect from physical attack, like memory probe.
+ * CA (Client Application at REE) can ask TEE for a secure buffer, then control it:
+ * to reference, or to free...etc.
+ *
+ * Secure memory spec.:
+ * 1. Protected by trustzone (NS = 0).
+ * 2. External memory (ex: external DRAM).
+ * 3. With cache.
+ */
+
+/**
+ * Secure memory allocation
+ *
+ * Allocate one memory.
+ * If memory is allocated successfully, a handle will be provided.
+ *
+ * Memory lifetime:
+ * 1. Allocate memory, and get the handle.
+ * 2. If other process wants to use the same memory, reference it.
+ * 3. If they stop to use it, unreference it.
+ * 4. Free it (by unreference), if it is not used.
+ *
+ * Simple rules:
+ * 1. start by allocate, end by unreference (for free).
+ * 2. start by reference, end by unreference.
+ *
+ * @param session The session handle.
+ * @param mem_handle [out] A pointer to secure memory handle.
+ * @param alignment Memory alignment in bytes.
+ * @param size The size of the buffer to be allocated in bytes.
+ * @return return code.
+ */
+TZ_RESULT KREE_AllocSecuremem (KREE_SESSION_HANDLE session,
+ KREE_SECUREMEM_HANDLE *mem_handle, uint32_t alignment, uint32_t size);
+
+/**
+ * Secure memory reference
+ *
+ * Reference memory.
+ * Referen count will be increased by 1 after reference.
+ *
+ * Reference lifetime:
+ * 1. Reference the memory before using it, if the memory is allocated by other process.
+ * 2. Unreference it if it is not used.
+ *
+ * @param session The session handle.
+ * @param mem_handle The secure memory handle.
+ * @param return return code.
+ */
+TZ_RESULT KREE_ReferenceSecuremem (KREE_SESSION_HANDLE session, KREE_SECUREMEM_HANDLE mem_handle);
+
+/**
+ * Secure memory unreference
+ *
+ * Unreference memory.
+ * Reference count will be decreased by 1 after unreference.
+ * Once reference count is zero, memory will be freed.
+ *
+ * @param session The session handle.
+ * @param mem_handle The secure memory handle.
+ * @param return return code.
+ */
+TZ_RESULT KREE_UnreferenceSecuremem (KREE_SESSION_HANDLE session, KREE_SECUREMEM_HANDLE mem_handle);
+
+/**
+ * Secure chunk memory
+ *
+ * A secure chunk memory can be seen only in Secure world.
+ * It is a kind of secure memory but with difference characteristic:
+ * 1. It is designed and optimized for chunk memory usage.
+ * 2. For future work, it can be released as normal memory for more flexible memory usage.
+ *
+ * Secure chunk memory spec.:
+ * 1. Protected by trustzone (NS = 0).
+ * 2. External memory (ex: external DRAM).
+ * 3. With cache.
+ * 4. For future, it can be released to normal world.
+ */
+
+/**
+ * Secure chunk memory allocation
+ *
+ * Allocate one memory.
+ * If memory is allocated successfully, a handle will be provided.
+ *
+ * Memory lifetime:
+ * 1. Allocate memory, and get the handle.
+ * 2. If other process wants to use the same memory, reference it.
+ * 3. If they stop to use it, unreference it.
+ * 4. Free it (by unreference), if it is not used.
+ *
+ * Simple rules:
+ * 1. start by allocate, end by unreference (for free).
+ * 2. start by reference, end by unreference.
+ *
+ * @param session The session handle.
+ * @param cm_handle [out] A pointer to secure chunk memory handle.
+ * @param alignment Memory alignment in bytes.
+ * @param size The size of the buffer to be allocated in bytes.
+
+ * @return return code.
+ */
+TZ_RESULT KREE_AllocSecurechunkmem (KREE_SESSION_HANDLE session,
+ KREE_SECURECM_HANDLE *cm_handle, uint32_t alignment, uint32_t size);
+
+/**
+ * Secure chunk memory reference
+ *
+ * Reference memory.
+ * Referen count will be increased by 1 after reference.
+ *
+ * Reference lifetime:
+ * 1. Reference the memory before using it, if the memory is allocated by other process.
+ * 2. Unreference it if it is not used.
+ *
+ * @param session The session handle.
+ * @param cm_handle The secure chunk memory handle.
+ * @param return return code.
+ */
+TZ_RESULT KREE_ReferenceSecurechunkmem (KREE_SESSION_HANDLE session, KREE_SECURECM_HANDLE cm_handle);
+
+/**
+ * Secure chunk memory unreference
+ *
+ * Unreference memory.
+ * Reference count will be decreased by 1 after unreference.
+ * Once reference count is zero, memory will be freed.
+ *
+ * @param session The session handle.
+ * @param cm_handle The secure chunk memory handle.
+ * @param return return code.
+ */
+TZ_RESULT KREE_UnreferenceSecurechunkmem (KREE_SESSION_HANDLE session, KREE_SECURECM_HANDLE cm_handle);
+
+/**
+ * Released secure chunk memory Read
+ *
+ * Read release secure chunk memory for normal world usage.
+ *
+ * @param session The session handle.
+ * @param offset offset in bytes.
+ * @param size size in bytes.
+ * @param buffer The pointer to read buffer.
+ * @param return return code.
+ */
+TZ_RESULT KREE_ReadSecurechunkmem (KREE_SESSION_HANDLE session, uint32_t offset, uint32_t size, void *buffer);
+
+/**
+ * Released secure chunk memory Write
+ *
+ * Write release secure chunk memory for normal world usage.
+ *
+ * @param session The session handle.
+ * @param offset offset in bytes.
+ * @param size size in bytes.
+ * @param buffer The pointer to write buffer.
+ * @param return return code.
+ */
+TZ_RESULT KREE_WriteSecurechunkmem (KREE_SESSION_HANDLE session, uint32_t offset, uint32_t size, void *buffer);
+
+/**
+ * Released secure chunk memory get size
+ *
+ * Get released secure chunk memory for normal world usage size.
+ *
+ * @param session The session handle.
+ * @param size [out] The pointer to size in bytes.
+ * @param return return code.
+ */
+TZ_RESULT KREE_GetSecurechunkReleaseSize (KREE_SESSION_HANDLE session, uint32_t *size);
+
+
+/**
+ * Get TEE memory size
+ *
+ * Get the total memory size of trusted execution environment
+ *
+ * @param session The session handle.
+ * @param size [out] The pointer to size in bytes.
+ * @param return return code.
+ */
+TZ_RESULT KREE_GetTEETotalSize (KREE_SESSION_HANDLE session, uint32_t *size);
+
+#endif /* CONFIG_MTK_IN_HOUSE_TEE_SUPPORT */
+#endif /* __KREE_MEM_H__ */
diff --git a/include/trustzone/kree/system.h b/include/trustzone/kree/system.h
new file mode 100644
index 000000000..cf8d2345f
--- /dev/null
+++ b/include/trustzone/kree/system.h
@@ -0,0 +1,50 @@
+/*
+ * Header files for basic KREE functions.
+ */
+
+#ifndef __KREE_H__
+#define __KREE_H__
+
+#ifdef CONFIG_MTK_IN_HOUSE_TEE_SUPPORT
+
+#include "trustzone/tz_cross/trustzone.h"
+
+/// KREE session handle type.
+typedef uint32_t KREE_SESSION_HANDLE;
+
+typedef uint32_t KREE_SHAREDMEM_HANDLE;
+
+
+/* Session Management */
+/**
+ * Create a new TEE sesssion
+ *
+ * @param ta_uuid UUID of the TA to connect to.
+ * @param pHandle Handle for the new session. Return KREE_SESSION_HANDLE_FAIL if fail.
+ * @return return code
+ */
+TZ_RESULT KREE_CreateSession(const char *ta_uuid, KREE_SESSION_HANDLE *pHandle);
+
+/**
+ * Close TEE session
+ *
+ * @param handle Handle for session to close.
+ * @return return code
+ */
+TZ_RESULT KREE_CloseSession(KREE_SESSION_HANDLE handle);
+
+
+/**
+ * Make a TEE service call
+ *
+ * @param handle Session handle to make the call
+ * @param command The command to call.
+ * @param paramTypes Types for the parameters, use TZ_ParamTypes() to consturct.
+ * @param param The parameters to pass to TEE. Maximum 4 params.
+ * @return Return value from TEE service.
+ */
+TZ_RESULT KREE_TeeServiceCall(KREE_SESSION_HANDLE handle, uint32_t command,
+ uint32_t paramTypes, MTEEC_PARAM param[4]);
+
+#endif /* CONFIG_MTK_IN_HOUSE_TEE_SUPPORT */
+#endif /* __KREE_H__ */
diff --git a/include/trustzone/kree/tz_irq.h b/include/trustzone/kree/tz_irq.h
new file mode 100644
index 000000000..7382f3ce4
--- /dev/null
+++ b/include/trustzone/kree/tz_irq.h
@@ -0,0 +1,29 @@
+/*
+ * IRQ/FIQ for TrustZone
+ */
+
+#ifndef __KREE_TZ_IRQ_H__
+#define __KREE_TZ_IRQ_H__
+
+#ifdef CONFIG_MTK_IN_HOUSE_TEE_SUPPORT
+
+void kree_irq_init(void);
+int kree_set_fiq(int irq, unsigned long irq_flags);
+void kree_enable_fiq(int irq);
+void kree_disable_fiq(int irq);
+void kree_query_fiq(int irq, int *enable, int *pending);
+unsigned int kree_fiq_get_intack(void);
+void kree_fiq_eoi(unsigned int iar);
+int kree_raise_softfiq(unsigned int mask, unsigned int irq);
+void kree_irq_mask_all(unsigned int *pmask, unsigned int size);
+void kree_irq_mask_restore(unsigned int *pmask, unsigned int size);
+
+#else
+
+#define kree_set_fiq(irq, irq_flags) -1
+#define kree_enable_fiq(irq)
+#define kree_disable_fiq(irq)
+
+#endif /* CONFIG_MTK_IN_HOUSE_TEE_SUPPORT */
+
+#endif /* __KREE_TZ_IRQ_H__ */
diff --git a/include/trustzone/kree/tz_mem.h b/include/trustzone/kree/tz_mem.h
new file mode 100644
index 000000000..d9f1e9b65
--- /dev/null
+++ b/include/trustzone/kree/tz_mem.h
@@ -0,0 +1,21 @@
+#ifndef __TZ_MEM_H
+#define __TZ_MEM_H
+
+ /*****************************************************************************
+ * MODULE DEFINITION
+ *****************************************************************************/
+#define MODULE_NAME "[MTEE_TZMEM]"
+#define MTEE_TZMEM_TAG "MTEE_TZMEM"
+
+#define IO_NODE_MAJOR_TZMEM 198
+#define IO_NODE_MINOR_TZMEM 0
+#define IO_NODE_NUMBER_TZMEM 1
+
+#define DEV_TZMEM "tzmem"
+
+ /*****************************************************************************
+ * IOCTL DEFINITION
+ *****************************************************************************/
+
+#endif /* end of __TZ_MEM_H */
+
diff --git a/include/trustzone/kree/tz_mod.h b/include/trustzone/kree/tz_mod.h
new file mode 100644
index 000000000..556a194b1
--- /dev/null
+++ b/include/trustzone/kree/tz_mod.h
@@ -0,0 +1,58 @@
+#ifndef TZ_MOD_H
+#define TZ_MOD_H
+
+
+ /*****************************************************************************
+ * MODULE DEFINITION
+ *****************************************************************************/
+#define MODULE_NAME "[MTEE_MOD]"
+#define TZ_DEV_NAME "trustzone"
+#define MAJOR_DEV_NUM 197
+
+ /*****************************************************************************
+ * IOCTL DEFINITION
+ *****************************************************************************/
+#define MTEE_IOC_MAGIC 'T'
+#define MTEE_CMD_OPEN_SESSION _IOWR(MTEE_IOC_MAGIC, 1, struct kree_session_cmd_param)
+#define MTEE_CMD_CLOSE_SESSION _IOWR(MTEE_IOC_MAGIC, 2, struct kree_session_cmd_param)
+#define MTEE_CMD_TEE_SERVICE _IOWR(MTEE_IOC_MAGIC, 3, struct kree_tee_service_cmd_param)
+#define MTEE_CMD_SHM_REG _IOWR(MTEE_IOC_MAGIC, 4, struct kree_tee_service_cmd_param)
+#define MTEE_CMD_SHM_UNREG _IOWR(MTEE_IOC_MAGIC, 5, struct kree_tee_service_cmd_param)
+
+
+#define DEV_IOC_MAXNR (10)
+
+// param for open/close session
+struct kree_session_cmd_param
+{
+ int ret;
+ int handle;
+ void *data;
+};
+
+// param for tee service call
+struct kree_tee_service_cmd_param
+{
+ int ret;
+ int handle;
+ unsigned int command;
+ unsigned int paramTypes;
+ void *param;
+};
+
+// param for shared memory
+struct kree_sharedmemory_cmd_param
+{
+ int ret;
+ uint32_t session;
+ uint32_t mem_handle;
+ uint32_t command;
+ void *buffer;
+ uint32_t size;
+ uint32_t control; // 0 = write, 1 = read only
+};
+
+
+
+#endif /* end of DEVFINO_H */
+
diff --git a/include/trustzone/kree/tz_pm.h b/include/trustzone/kree/tz_pm.h
new file mode 100644
index 000000000..52f0c4066
--- /dev/null
+++ b/include/trustzone/kree/tz_pm.h
@@ -0,0 +1,23 @@
+/*
+ * Power management for TrustZone
+ */
+
+#ifndef __KREE_TZ_PM_H__
+#define __KREE_TZ_PM_H__
+
+#ifdef CONFIG_MTK_IN_HOUSE_TEE_SUPPORT
+
+void kree_pm_init(void);
+void kree_pm_cpu_lowpower(volatile int *ppen_release, int logical_cpuid);
+int kree_pm_cpu_dormant(int mode);
+int kree_pm_device_ops(int state);
+int kree_pm_cpu_dormant_workaround_wake(int workaround_wake);
+
+#else
+
+#define kree_pm_cpu_lowpower(ppen, cpuid)
+#define kree_pm_cpu_dormant(mode) 1
+
+#endif /* CONFIG_MTK_IN_HOUSE_TEE_SUPPORT */
+
+#endif /* __KREE_TZ_PM_H__ */
diff --git a/include/trustzone/tz_cross/hdmi_ta.h b/include/trustzone/tz_cross/hdmi_ta.h
new file mode 100644
index 000000000..dcc4b25ae
--- /dev/null
+++ b/include/trustzone/tz_cross/hdmi_ta.h
@@ -0,0 +1,21 @@
+#ifndef _HDMI_TA_H_
+#define _HDMI_TA_H_
+
+#define TZ_TA_HDMI_NAME "HDMI TA"
+#define TZ_TA_HDMI_UUID "eaf800b0-da1b-11e2-a28f-0800200c9a66"
+
+typedef enum
+{
+ HDMI_TA_WRITE_REG = 0,
+ HDMI_TA_DPI1_WRITE_REG,
+ HDMI_TA_INSTALL_HDCP_KEY,
+ HDMI_TA_LOAD_HDCP_KEY,
+ HDMI_TA_GET_HDCP_AKSV,
+ HDMI_TA_HDCP_ENC_EN,
+ HDMI_TA_HDCP_RST,
+ HDMI_TA_VID_UNMUTE,
+ HDMI_TA_AUD_UNMUTE,
+} HDMI_TA_SERVICE_CMD_T;
+
+
+#endif
diff --git a/include/trustzone/tz_cross/keyblock.h b/include/trustzone/tz_cross/keyblock.h
new file mode 100644
index 000000000..50f241be2
--- /dev/null
+++ b/include/trustzone/tz_cross/keyblock.h
@@ -0,0 +1,81 @@
+#ifndef __KEY_BLOCK_H__
+#define __KEY_BLOCK_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum
+{
+ WIDEVINE_ID = 0,
+ MARLIN_ID,
+ HDCP_1X_TX_ID,
+ HDCP_2X_V1_TX_ID,
+ HDCP_2X_V1_RX_ID,
+ HDCP_2X_V2_TX_ID,
+ HDCP_2X_V2_RX_ID,
+ PLAYREADY_BGROUPCERT_ID,
+ PLAYREADY_ZGPRIV_ID,
+ PLAYREADY_KEYFILE_ID,
+ DRM_KEY_MAX,
+ DRM_SP_EKKB = 0xFFFF
+}
+DRMKeyID;
+
+#define SZ_DRMKEY_ID 4
+#define SZ_DRMKEY_TYPE 4
+#define SZ_DRMKEY_SIZE 4
+#define SZ_DRMKEY_ENC_SIZE 4
+#define SZ_DRMKEY_RESERVED 64
+#define SZ_DRMKEY_HEADER_SIZE (SZ_DRMKEY_ID+SZ_DRMKEY_TYPE+SZ_DRMKEY_SIZE+SZ_DRMKEY_ENC_SIZE+SZ_DRMKEY_RESERVED)
+#define SZ_DRMKEY_SIG 16
+
+//begin of uree using
+
+/*
+[in] keyID Enum DRMKeyID
+[out] oneDrmkeyBlock encrypt DRMBlock
+[out] blockLeng encrypt DRMBlockLength
+
+return 0: OK, others: FAIL
+*/
+int get_encrypt_drmkey ( unsigned int keyID, unsigned char **oneDrmkeyBlock, unsigned int *blockLeng );
+
+int get_clearDrmkey_size( unsigned int keyID, unsigned int *leng);
+
+int free_encrypt_drmkey ( unsigned char *oneEncDrmkeyBlock );
+
+int write_kbo_drmkey(DRMKeyID id,unsigned char* enckey,unsigned int length);
+
+int delete_kbo_drmkey(DRMKeyID id);
+
+int install_KB_OTA_API(unsigned char* buff,unsigned int len);
+
+int query_drmkey ( unsigned int *count, unsigned int *keytype );
+
+//end of uree using
+
+//begin for tee using
+int encrypt_drmkey(DRMKeyID id,unsigned char* clearKey,unsigned int inLength,
+ unsigned char** encKey,unsigned int* outLength);
+
+#if defined(TRUSONIC_TEE_SUPPORT)
+int nw_decrypt_drmkey ( unsigned char *encDrmKeyBlock, unsigned int inLength,
+ unsigned int *outLength, unsigned int *p_decrypt_drmky_buffer_handle);
+int nw_free_drmkey ( unsigned int *p_decrypt_drmky_buffer_handle );
+#endif
+
+int decrypt_drmkey ( unsigned char *encDrmKeyBlock, unsigned int inLength,
+ unsigned char **DrmKey, unsigned int *outLength );
+
+int free_drmkey ( unsigned char *drmkey );
+
+int free_drmkey_safe ( unsigned char *drmkey,int size);
+
+//end for tee using
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __KEY_BLOCK_H__ */
diff --git a/include/trustzone/tz_cross/ree_service.h b/include/trustzone/tz_cross/ree_service.h
new file mode 100644
index 000000000..2f0213415
--- /dev/null
+++ b/include/trustzone/tz_cross/ree_service.h
@@ -0,0 +1,81 @@
+
+/** Commands and value for REE service call */
+/* This is used by TEE internal. Other TA please don't include this */
+
+#ifndef __REE_SERVICE__
+#define __REE_SERVICE__
+
+#define REE_SERVICE_BUFFER_SIZE 128
+
+enum ReeServiceCommand {
+ REE_SERV_NONE = 0,
+ REE_SERV_PUTS, // Print buffer.
+ REE_SERV_USLEEP, // Sleep us
+ REE_SERV_MUTEX_CREATE,
+ REE_SERV_MUTEX_DESTROY,
+ REE_SERV_MUTEX_LOCK,
+ REE_SERV_MUTEX_UNLOCK,
+ REE_SERV_MUTEX_TRYLOCK,
+ REE_SERV_MUTEX_ISLOCK,
+ REE_SERV_SEMAPHORE_CREATE,
+ REE_SERV_SEMAPHORE_DESTROY,
+ REE_SERV_SEMAPHORE_DOWN,
+ REE_SERV_SEMAPHORE_DWNTO, // down with time-out
+ REE_SERV_SEMAPHORE_TRYDWN,
+ REE_SERV_SEMAPHORE_UP,
+#if 0
+ REE_SERV_WAITQ_CREATE,
+ REE_SERV_WAITQ_DESTROY,
+ REE_SERV_WAITQ_WAIT,
+ REE_SERV_WAITQ_WAITTO, // wait with time-out
+ REE_SERV_WAITQ_WAKEUP,
+#endif
+ REE_SERV_REQUEST_IRQ,
+ REE_SERV_ENABLE_IRQ,
+ REE_SERV_ENABLE_CLOCK,
+ REE_SERV_DISABLE_CLOCK,
+ REE_SERV_THREAD_CREATE,
+};
+
+////////// Param structure for commands
+struct ree_service_usleep
+{
+ unsigned int ustime;
+};
+
+
+
+
+#define MTEE_THREAD_NAME_NUM 32
+
+struct REE_THREAD_INFO {
+ uint32_t handle; // trhread handle
+ char name[MTEE_THREAD_NAME_NUM]; // kree side, trhread name
+};
+
+
+#ifndef MTIRQF_NORMAL
+/// Must match the one in tz_private/system.h
+#define MTIRQF_SHARED (1<<0) /// Share with other handlers
+#define MTIRQF_TRIGGER_LOW (1<<1) /// IRQ is triggered by low signal
+#define MTIRQF_TRIGGER_HIGH (1<<2) /// IRQ is triggered by high signal
+#define MTIRQF_TRIGGER_RISING (1<<3) /// IRQ is triggered by rising edge
+#define MTIRQF_TRIGGER_FALLING (1<<4) /// IRQ is triggered by falling edge
+#endif
+
+struct ree_service_irq
+{
+ void *token;
+ unsigned int irq;
+ int enable;
+ unsigned int flags;
+};
+
+struct ree_service_clock
+{
+ unsigned int clk_id;
+ char clk_name[112];
+};
+
+#endif /* __REE_SERVICE__ */
+
diff --git a/include/trustzone/tz_cross/ta_dapc.h b/include/trustzone/tz_cross/ta_dapc.h
new file mode 100644
index 000000000..ba519b781
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_dapc.h
@@ -0,0 +1,17 @@
+#ifndef __TRUSTZONE_TA_DAPC__
+#define __TRUSTZONE_TA_DAPC__
+
+#define TZ_TA_DAPC_UUID "2603779b-b2a6-4f7e-8783-62ab11b383fd"
+
+
+/* Data Structure for DAPC TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Test TA */
+
+
+/* Command for DAPC TA */
+
+#define TZCMD_DAPC_IRQ 0
+#define TZCMD_DAPC_TEST 1
+
+#endif /* __TRUSTZONE_TA_DAPC__ */
diff --git a/include/trustzone/tz_cross/ta_dapc_log.h b/include/trustzone/tz_cross/ta_dapc_log.h
new file mode 100644
index 000000000..fbe1480c5
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_dapc_log.h
@@ -0,0 +1,33 @@
+#ifndef __TRUSTZONE_TA_DAPC_LOG__
+#define __TRUSTZONE_TA_DAPC_LOG__
+
+// for self-defined log output marco
+#ifndef __MTEE_LOG_H__
+#include <tz_private/log.h>
+#endif
+
+// to control the DEBUG level output. define it some where else.
+extern unsigned int g_tee_dbg_log;
+
+// for temporary debugging purpose
+#define MTEE_LOG_CUSTOM_LEVEL MTEE_LOG_LVL_INFO
+
+#define MTEE_LOG_I(args...) \
+do { if ((MTEE_LOG_LVL_INFO) >= MTEE_LOG_BUILD_LEVEL && g_tee_dbg_log > 0) { _MTEE_LOG(MTEE_LOG_LVL_INFO, args); } } while (0)
+
+#define MTEE_LOG_D(args...) \
+do { if ((MTEE_LOG_LVL_DEBUG) >= MTEE_LOG_BUILD_LEVEL && g_tee_dbg_log > 0) { _MTEE_LOG(MTEE_LOG_LVL_DEBUG, args); } } while (0)
+
+#define MTEE_LOG_P(args...) \
+do { if ((MTEE_LOG_LVL_PRINTF) >= MTEE_LOG_BUILD_LEVEL) { _MTEE_LOG(MTEE_LOG_LVL_PRINTF, args); } } while (0)
+
+#define MTEE_LOG_W(args...) \
+do { if ((MTEE_LOG_LVL_WARN) >= MTEE_LOG_BUILD_LEVEL) { _MTEE_LOG(MTEE_LOG_LVL_WARN, args); } } while (0)
+
+#define MTEE_LOG_B(args...) \
+do { if ((MTEE_LOG_LVL_BUG) >= MTEE_LOG_BUILD_LEVEL) { _MTEE_LOG(MTEE_LOG_LVL_BUG, args); } } while (0)
+
+#define MTEE_LOG_A(args...) \
+do { if ((MTEE_LOG_LVL_ASSERT) >= MTEE_LOG_BUILD_LEVEL) { _MTEE_LOG(MTEE_LOG_LVL_ASSERT, args); } } while (0)
+
+#endif /* __TRUSTZONE_TA_DAPC_LOG__ */
diff --git a/include/trustzone/tz_cross/ta_dbg.h b/include/trustzone/tz_cross/ta_dbg.h
new file mode 100644
index 000000000..2f8b89eb0
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_dbg.h
@@ -0,0 +1,15 @@
+/** Commands for TA Debug **/
+
+#ifndef __TRUSTZONE_TA_DBG__
+#define __TRUSTZONE_TA_DBG__
+
+#define TZ_TA_DBG_UUID "42a10730-f349-11e2-a99a-d4856458b228"
+
+// enable secure memory/chunk memory information debug
+#define MTEE_TA_DBG_ENABLE_MEMINFO
+
+/* Command for Debug */
+#define TZCMD_DBG_SECUREMEM_INFO 0
+#define TZCMD_DBG_SECURECM_INFO 1
+
+#endif /* __TRUSTZONE_TA_DBG__ */
diff --git a/include/trustzone/tz_cross/ta_dcm.h b/include/trustzone/tz_cross/ta_dcm.h
new file mode 100644
index 000000000..8ff8bc0c8
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_dcm.h
@@ -0,0 +1,45 @@
+/*
+ DCM TA implementation.
+*/
+
+#ifndef __TRUSTZONE_TA_DCM__
+#define __TRUSTZONE_TA_DCM__
+
+#define TZ_TA_DCM_UUID "b3c1d950-f446-11e2-b778-0800200c9a66"
+
+/* Command for DCM TA */
+#define TZCMD_DCM_ENABLE_DCM 0
+#define TZCMD_DCM_DISABLE_DCM 1
+#define TZCMD_DCM_GET_DCM_STATUS 2
+#define TZCMD_DCM_GET_DCM_OP_STATUS 3
+
+/* Usage */
+/*
+ TZCMD_DCM_ENABLE_DCM
+ Input:
+ param[0].value.a = Type (Type = SMI_DCM)
+
+ TZCMD_DCM_DISABLE_DCM
+ Input:
+ param[0].value.a = Type (Type = SMI_DCM)
+
+ TZCMD_DCM_GET_DCM_STATUS
+ Input:
+ param[0].value.a = Type (Type = SMI_DCM)
+
+ Output:
+ Type = SMI_DCM
+ param[1].value.a = register value for SMI_COMMON_DCM
+ param[1].value.b = register value for SMI_SECURE_DCMCON
+ param[2].value.a = register value for M4U_DCM
+ TZCMD_DCM_GET_DCM_OP_STATUS
+ Input:
+ param[0].value.a = Type (Type = SMI_DCM)
+
+ Output:
+ Type = SMI_DCM
+ param[1].value.a = register value for SMI_SECURE_DCMSET
+ param[1].value.b = register value for SMI_SECURE_DCMCLR
+*/
+
+#endif /* __TRUSTZONE_TA_DCM__ */
diff --git a/include/trustzone/tz_cross/ta_ddp.h b/include/trustzone/tz_cross/ta_ddp.h
new file mode 100644
index 000000000..2efe0a3d7
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_ddp.h
@@ -0,0 +1,51 @@
+#ifndef __TRUSTZONE_TA_DDP__
+#define __TRUSTZONE_TA_DDP__
+
+#define TZ_TA_DDPU_NAME "DDPU TA"
+#define TZ_TA_DDPU_UUID "11d28272-5c14-47a9-9f2b-180dc48ec29f"
+
+/* Data Structure for Test TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Test TA */
+
+/* Command for DDP TA */
+#define TZCMD_DDP_OVL_START 0
+#define TZCMD_DDP_OVL_STOP 1
+#define TZCMD_DDP_OVL_RESET 2
+#define TZCMD_DDP_OVL_ROI 3
+#define TZCMD_DDP_OVL_LAYER_SWITCH 4
+#define TZCMD_DDP_OVL_LAYER_CONFIG 5
+#define TZCMD_DDP_OVL_3D_CONFIG 6
+#define TZCMD_DDP_OVL_LAYER_TDSHP_EN 7
+#define TZCMD_DDP_OVL_TEST 8
+#define TZCMD_DDP_OVL_CONFIG_LAYER_ADDR 9
+#define TZCMD_DDP_OVL_IS_EN 10
+
+/* Data Structure for Test TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Test TA */
+
+/* Command for DDP TA */
+/* rotator control */
+#define TZCMD_DDPU_ROT_ENABLE 0
+#define TZCMD_DDPU_ROT_DISABLE 1
+#define TZCMD_DDPU_ROT_RESET 2
+#define TZCMD_DDPU_ROT_CONFIG 3
+#define TZCMD_DDPU_ROT_CON 4
+#define TZCMD_DDPU_ROT_EXTEND_FUNC 5
+
+/* write dma control */
+#define TZCMD_DDPU_WDMA_START 30
+#define TZCMD_DDPU_WDMA_STOP 31
+#define TZCMD_DDPU_WDMA_RESET 32
+#define TZCMD_DDPU_WDMA_CONFIG 33
+#define TZCMD_DDPU_WDMA_CONFIG_UV 34
+#define TZCMD_DDPU_WDMA_WAIT 35
+#define TZCMD_DDPU_WDMA_EXTEND_FUNC 36
+
+#define TZCMD_DDPU_INTR_CALLBACK 39
+#define TZCMD_DDPU_REGISTER_INTR 40
+
+#define TZCMD_DDPU_SET_DAPC_MODE 50
+
+#endif /* __TRUSTZONE_TA_DDP__ */
diff --git a/include/trustzone/tz_cross/ta_ddp_log.h b/include/trustzone/tz_cross/ta_ddp_log.h
new file mode 100644
index 000000000..74d2dfdb3
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_ddp_log.h
@@ -0,0 +1,33 @@
+#ifndef __TRUSTZONE_TA_DDP_LOG__
+#define __TRUSTZONE_TA_DDP_LOG__
+
+// for self-defined log output marco
+#ifndef __MTEE_LOG_H__
+#include <tz_private/log.h>
+#endif
+
+// to control the DEBUG level output. define it some where else.
+extern unsigned int g_tee_dbg_log;
+
+// for temporary debugging purpose
+#define MTEE_LOG_CUSTOM_LEVEL MTEE_LOG_LVL_INFO
+
+#define MTEE_LOG_I(args...) \
+do { if ((MTEE_LOG_LVL_INFO) >= MTEE_LOG_BUILD_LEVEL && g_tee_dbg_log > 0) { _MTEE_LOG(MTEE_LOG_LVL_INFO, args); } } while (0)
+
+#define MTEE_LOG_D(args...) \
+do { if ((MTEE_LOG_LVL_DEBUG) >= MTEE_LOG_BUILD_LEVEL && g_tee_dbg_log > 0) { _MTEE_LOG(MTEE_LOG_LVL_DEBUG, args); } } while (0)
+
+#define MTEE_LOG_P(args...) \
+do { if ((MTEE_LOG_LVL_PRINTF) >= MTEE_LOG_BUILD_LEVEL) { _MTEE_LOG(MTEE_LOG_LVL_PRINTF, args); } } while (0)
+
+#define MTEE_LOG_W(args...) \
+do { if ((MTEE_LOG_LVL_WARN) >= MTEE_LOG_BUILD_LEVEL) { _MTEE_LOG(MTEE_LOG_LVL_WARN, args); } } while (0)
+
+#define MTEE_LOG_B(args...) \
+do { if ((MTEE_LOG_LVL_BUG) >= MTEE_LOG_BUILD_LEVEL) { _MTEE_LOG(MTEE_LOG_LVL_BUG, args); } } while (0)
+
+#define MTEE_LOG_A(args...) \
+do { if ((MTEE_LOG_LVL_ASSERT) >= MTEE_LOG_BUILD_LEVEL) { _MTEE_LOG(MTEE_LOG_LVL_ASSERT, args); } } while (0)
+
+#endif /* __TRUSTZONE_TA_DDP_LOG__ */
diff --git a/include/trustzone/tz_cross/ta_drmkey.h b/include/trustzone/tz_cross/ta_drmkey.h
new file mode 100644
index 000000000..4917a0855
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_drmkey.h
@@ -0,0 +1,22 @@
+/* An example test TA implementation.
+ */
+
+#ifndef __TRUSTZONE_TA_DRMKEY__
+#define __TRUSTZONE_TA_DRMKEY__
+
+#define TZ_TA_DRMKEY_UUID "989850BF-4663-9DCD-394C-07A45F4633D1"
+
+/* Data Structure for DRMKEY TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Test TA */
+
+/* Command for Test TA */
+#define TZCMD_DRMKEY_INSTALL 0
+#define TZCMD_DRMKEY_QUERY 1
+#define TZCMD_DRMKEY_GEN_EKKB_PUB 2
+#define TZCMD_DRMKEY_GEN_KB_EKKB_EKC 3
+#define TZCMD_DRMKEY_GEN_REENC_EKKB 4
+#define TZCMD_DRMKEY_INIT_ENV 5
+#define TZCMD_DRMKEY_VERIFY_AEK 6
+
+#endif /* __TRUSTZONE_TA_DRMKEY__ */
diff --git a/include/trustzone/tz_cross/ta_emi.h b/include/trustzone/tz_cross/ta_emi.h
new file mode 100644
index 000000000..ac35430ad
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_emi.h
@@ -0,0 +1,17 @@
+#ifndef __TRUSTZONE_TA_EMI__
+#define __TRUSTZONE_TA_EMI__
+
+#define TZ_TA_EMI_UUID "f80dab1a-a33f-4a48-a015-a16845d351f3"
+
+
+/* Data Structure for EMI TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Test TA */
+
+
+/* Command for EMI TA */
+
+#define TZCMD_EMI_REG 0
+#define TZCMD_EMI_CLR 1
+
+#endif /* __TRUSTZONE_TA_EMI__ */
diff --git a/include/trustzone/tz_cross/ta_gcpu.h b/include/trustzone/tz_cross/ta_gcpu.h
new file mode 100644
index 000000000..be0c5e000
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_gcpu.h
@@ -0,0 +1,18 @@
+
+#ifndef __TRUSTZONE_TA_GCPU__
+#define __TRUSTZONE_TA_GCPU__
+
+#define TZ_TA_GCPU_UUID "7b6c51b8-2994-4a32-be68-d840df0281bb"
+
+/* Data Structure for GCPU TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for GCPU TA */
+
+/* Command for GCPU TA */
+#define TZCMD_GCPU_SELFTEST 0
+#define TZCMD_GCPU_SUSPEND 1
+#define TZCMD_GCPU_KERNEL_INIT_DONE 2
+
+
+
+#endif /* __TRUSTZONE_TA_GCPU__ */
diff --git a/include/trustzone/tz_cross/ta_hacc.h b/include/trustzone/tz_cross/ta_hacc.h
new file mode 100644
index 000000000..c12f61bfe
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_hacc.h
@@ -0,0 +1,35 @@
+/* An example test TA implementation.
+ */
+
+#ifndef __TRUSTZONE_SEJ_TA__
+#define __TRUSTZONE_SEJ_TA__
+
+#define TZ_CRYPTO_TA_UUID "0d5fe516-821d-11e2-bdb4-d485645c4311"
+
+/* Data Structure for Test TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Test TA */
+
+/* Command for Test TA */
+#define TZCMD_HACC_INIT 0
+#define TZCMD_HACC_INTERNAL 1
+#define TZCMD_SECURE_ALGO 2
+
+typedef struct _ta_crypto_data_ {
+ unsigned int size;
+ unsigned char bAC;
+ unsigned int user; /* HACC_USER */
+ unsigned char bDoLock;
+ unsigned int aes_type; /* AES_OPS */
+ unsigned char bEn;
+} ta_crypto_data;
+
+typedef struct _ta_secure_algo_data_ {
+ unsigned char direction;
+ unsigned int contentAddr;
+ unsigned int contentLen;
+ unsigned char *customSeed;
+ unsigned char *resText;
+} ta_secure_algo_data;
+
+#endif /* __TRUSTZONE_SEJ_TA_TEST__ */
diff --git a/include/trustzone/tz_cross/ta_hdcp2tx.h b/include/trustzone/tz_cross/ta_hdcp2tx.h
new file mode 100644
index 000000000..df8df1073
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_hdcp2tx.h
@@ -0,0 +1,42 @@
+#ifndef __TRUSTZONE_TA_HDCP_TX__
+#define __TRUSTZONE_TA_HDCP_TX__
+
+#define TZ_TA_HDCP2_TX_UUID "65e64a92-d60e-4d2d-bc38-a0a7ab721112"
+
+/* Data Structure for Test TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Test TA */
+
+/* Command for HDCP2_TX TA */
+#define TZCMD_HDCP2_TX_SET_ENCKEY 0
+#define TZCMD_HDCP2_TX_CHECK_RXID 1
+#define TZCMD_HDCP2_TX_GET_ENC_KM 2
+#define TZCMD_HDCP2_TX_KD_KEY_DEV 3
+#define TZCMD_HDCP2_TX_COMPUTE_H 4
+#define TZCMD_HDCP2_TX_COMPUTE_L 5
+#define TZCMD_HDCP2_TX_GET_ENC_KS 6
+#define TZCMD_HDCP2_TX_SET_PAIR_INFO 7
+#define TZCMD_HDCP2_TX_INIT_AES 8
+#define TZCMD_HDCP2_TX_GET_ENC_DATA 9
+#define TZCMD_HDCP2_TX_GET_PAIR_INFO 10
+#define TZCMD_HDCP2_TX_QUERY_KEY_HAVE_SET 11
+#define TZCMD_HDCP2_TX_VERIFY_SIGNATURE 12
+#define TZCMD_HDCP2_TX_COMPUTE_V 13
+#define TZCMD_HDCP2_TX_COMPUTE_2_2_H 14
+#define TZCMD_HDCP2_TX_COMPUTE_2_12_V 15
+#define TZCMD_HDCP2_TX_COMPUTE_M 16
+#define TZCMD_HDCP2_TX_LOCALITY_CHECK 17
+#define TZCMD_HDCP2_TX_GET_ENC_NATIVE_DATA 18
+#define TZCMD_HDCP2_TX_2_2_KD_KEY_DEV 19
+#define TZCMD_HDCP2_TX_GET_ENC_2_2_KS 20
+
+
+typedef enum HDCP2_TX_KEY_SRC{
+
+ CODED_FACSMILE_KEY = 0,
+ CODED_LICENSE_KEY,
+ DRM_KEY
+} E_HDCP2_TX_KEY_SRC;
+
+#endif /* __TRUSTZONE_TA_VDEC__ */
+
diff --git a/include/trustzone/tz_cross/ta_icnt.h b/include/trustzone/tz_cross/ta_icnt.h
new file mode 100644
index 000000000..dc1dfa4ee
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_icnt.h
@@ -0,0 +1,18 @@
+/* An example test TA implementation.
+ */
+
+#ifndef __TRUSTZONE_TA_INC_CNT__
+#define __TRUSTZONE_TA_INC_CNT__
+
+#define TZ_TA_ICNT_UUID "5bc52d1c-a07b-4373-8cab-d4db3e9eea5c"
+
+/* Data Structure for INC-ONLY CNT TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Test TA */
+
+/* Command for INC-ONLY CNT TA */
+#define TZCMD_ICNT_COUNT 0
+#define TZCMD_ICNT_RATE 1
+
+
+#endif /* __TRUSTZONE_TA_INC_CNT__ */
diff --git a/include/trustzone/tz_cross/ta_irq.h b/include/trustzone/tz_cross/ta_irq.h
new file mode 100644
index 000000000..f40cb592e
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_irq.h
@@ -0,0 +1,26 @@
+/* IRQ/FIQ TA functions
+ */
+
+#ifndef __TRUSTZONE_TA_IRQ__
+#define __TRUSTZONE_TA_IRQ__
+
+#define TZ_TA_IRQ_UUID "0be96652-d723-11e2-b1a4-d485645c4310"
+
+/* Command for IRQ TA */
+#define TZCMD_IRQ_SET_FIQ 0
+#define TZCMD_IRQ_ENABLE_FIQ 1
+#define TZCMD_IRQ_GET_INTACK 2
+#define TZCMD_IRQ_EOI 3
+#define TZCMD_IRQ_TRIGGER_SGI 4
+#define TZCMD_IRQ_MASK_ALL 5
+#define TZCMD_IRQ_MASK_RESTORE 6
+#define TZCMD_IRQ_QUERY_FIQ 7
+
+
+/* TZ Flags for TZCMD_IRQ_SET_FIQ */
+#define TZ_IRQF_EDGE_SENSITIVE 0
+#define TZ_IRQF_LEVEL_SENSITIVE 1
+#define TZ_IRQF_LOW 0
+#define TZ_IRQF_HIGH 2
+
+#endif /* __TRUSTZONE_TA_IRQ__ */
diff --git a/include/trustzone/tz_cross/ta_logctrl.h b/include/trustzone/tz_cross/ta_logctrl.h
new file mode 100644
index 000000000..c7cb91973
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_logctrl.h
@@ -0,0 +1,21 @@
+/* An example test TA implementation.
+ */
+
+#ifndef __TA_LOG_CTRL_H__
+#define __TA_LOG_CTRL_H__
+
+#define TZ_TA_LOG_CTRL_UUID "a80ef6e1-de27-11e2-a28f-0800200c9a66"
+
+/* should match MTEE_LOG_LVL in log.h */
+#define MTEE_LOG_CTRL_LVL_INFO 0x00000000
+#define MTEE_LOG_CTRL_LVL_DEBUG 0x00000001
+#define MTEE_LOG_CTRL_LVL_PRINTF 0x00000002
+#define MTEE_LOG_CTRL_LVL_WARN 0x00000003
+#define MTEE_LOG_CTRL_LVL_BUG 0x00000004
+#define MTEE_LOG_CTRL_LVL_ASSERT 0x00000005
+#define MTEE_LOG_CTRL_LVL_DISABLE 0x0000000f
+
+/* Command for Test TA */
+#define TZCMD_LOG_CTRL_SET_LVL 0
+
+#endif /* __TA_LOG_CTRL_H__ */
diff --git a/include/trustzone/tz_cross/ta_m4u.h b/include/trustzone/tz_cross/ta_m4u.h
new file mode 100644
index 000000000..1770e9a2d
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_m4u.h
@@ -0,0 +1,68 @@
+/* An example test TA implementation.
+ */
+
+#ifndef __TRUSTZONE_TA_M4U__
+#define __TRUSTZONE_TA_M4U__
+
+
+
+#define TZ_TA_M4U_UUID "m4u-smi-mau-spc"
+
+/* Data Structure for Test TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Test TA */
+
+/* Command for Test TA */
+#define M4U_TZCMD_TEST 0
+#define M4U_TZCMD_CONFIG_PORT 66
+#define M4U_TZCMD_REG_BACKUP 67
+#define M4U_TZCMD_REG_RESTORE 68
+#define M4U_TZCMD_ALLOC_MVA_SEC 70
+#define M4U_TZCMD_DEALLOC_MVA_SEC 71
+//====syn nonsec pgt start
+#define M4U_TZCMD_SEC_INIT 72
+#define M4U_TZCMD_MAP_NONSEC_BUF 73
+#define M4U_TZCMD_DEALLOC_MVA_SYNSEC 74
+//====syn nonsec pgt end
+
+#define M4U_TZCMD_SECPGTDUMP 100
+
+
+#if 1 // for m4u whole in tee. mt8135
+#define M4U_TZCMD_INVALID_TLB 75
+#define M4U_TZCMD_HW_INIT 76
+#define M4U_TZCMD_DUMP_REG 77
+#define M4U_TZCMD_WAIT_ISR 78
+#define M4U_TZCMD_INVALID_CHECK 79
+#define M4U_TZCMD_INSERT_SEQ 80
+
+#define M4U_CHECKSELF_VALUE 0x12345678
+
+#define MMU_TOTAL_RS_NR_MT8135 8
+#define M4U_MAIN_TLB_NR_MT8135 48
+
+typedef struct _M4U_ISR_INFO_
+{
+ unsigned int u4Check; // fixed is M4U_CHECKSELF_VALUE
+ unsigned int u4IrqM4uIndex;
+ unsigned int IntrSrc;
+ unsigned int faultMva;
+ unsigned int port_regval;
+ int portID;
+ int larbID;
+
+ unsigned int invalidPA;
+
+ unsigned int rs_va[MMU_TOTAL_RS_NR_MT8135];
+ unsigned int rs_pa[MMU_TOTAL_RS_NR_MT8135];
+ unsigned int rs_st[MMU_TOTAL_RS_NR_MT8135];
+
+ unsigned int main_tags[M4U_MAIN_TLB_NR_MT8135];
+ unsigned int pfh_tags[M4U_MAIN_TLB_NR_MT8135];
+
+ unsigned int main_des[M4U_MAIN_TLB_NR_MT8135];
+ unsigned int pfn_des[M4U_MAIN_TLB_NR_MT8135*4];
+}M4U_ISR_INFO;
+#endif
+
+#endif /* __TRUSTZONE_TA_TEST__ */
diff --git a/include/trustzone/tz_cross/ta_mem.h b/include/trustzone/tz_cross/ta_mem.h
new file mode 100644
index 000000000..c90f66f17
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_mem.h
@@ -0,0 +1,24 @@
+/** Commands for TA memory **/
+
+#ifndef __TRUSTZONE_TA_MEM__
+#define __TRUSTZONE_TA_MEM__
+
+#define TZ_TA_MEM_UUID "4477588a-8476-11e2-ad15-e41f1390d676"
+
+/* Command for Secure Memory Management */
+#define TZCMD_MEM_SHAREDMEM_REG 0
+#define TZCMD_MEM_SHAREDMEM_UNREG 1
+#define TZCMD_MEM_SECUREMEM_ALLOC 2
+#define TZCMD_MEM_SECUREMEM_REF 3
+#define TZCMD_MEM_SECUREMEM_UNREF 4
+#define TZCMD_MEM_SECURECM_ALLOC 5
+#define TZCMD_MEM_SECURECM_REF 6
+#define TZCMD_MEM_SECURECM_UNREF 7
+#define TZCMD_MEM_SECURECM_RELEASE 8
+#define TZCMD_MEM_SECURECM_APPEND 9
+#define TZCMD_MEM_SECURECM_READ 10
+#define TZCMD_MEM_SECURECM_WRITE 11
+#define TZCMD_MEM_SECURECM_RSIZE 12
+#define TZCMD_MEM_TOTAL_SIZE 13
+
+#endif /* __TRUSTZONE_TA_MEM__ */
diff --git a/include/trustzone/tz_cross/ta_modular_drm.h b/include/trustzone/tz_cross/ta_modular_drm.h
new file mode 100644
index 000000000..b8b379e6a
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_modular_drm.h
@@ -0,0 +1,108 @@
+#ifndef __TRUSTZONE_TA_MODULAR_DRM__
+#define __TRUSTZONE_TA_MODULAR_DRM__
+
+#define TZ_TA_MODULAR_DRM_UUID "651d6d29-0cf5-4a0f-b31a-9e8e8cec83a5"
+
+/* Data Structure for Modular DRM TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Modular DRM TA */
+
+/* Command for Modular DRM TA */
+
+#define TZCMD_MODULAR_DRM_Initialize 1
+#define TZCMD_MODULAR_DRM_Terminate 2
+#define TZCMD_MODULAR_DRM_InstallKeybox 3
+#define TZCMD_MODULAR_DRM_GetKeyData 4
+#define TZCMD_MODULAR_DRM_IsKeyboxValid 5
+#define TZCMD_MODULAR_DRM_GetRandom 6
+#define TZCMD_MODULAR_DRM_GetDeviceID 7
+#define TZCMD_MODULAR_DRM_WrapKeybox 8
+#define TZCMD_MODULAR_DRM_OpenSession 9
+#define TZCMD_MODULAR_DRM_CloseSession 10
+#define TZCMD_MODULAR_DRM_DecryptCTR 11
+#define TZCMD_MODULAR_DRM_GenerateDerivedKeys 12
+#define TZCMD_MODULAR_DRM_GenerateSignature 13
+#define TZCMD_MODULAR_DRM_GenerateNonce 14
+#define TZCMD_MODULAR_DRM_LoadKeys 15
+#define TZCMD_MODULAR_DRM_RefreshKeys 16
+#define TZCMD_MODULAR_DRM_SelectKey 17
+#define TZCMD_MODULAR_DRM_RewrapDeviceRSAKey 18
+#define TZCMD_MODULAR_DRM_LoadDeviceRSAKey 19
+#define TZCMD_MODULAR_DRM_GenerateRSASignature 20
+#define TZCMD_MODULAR_DRM_DeriveKeysFromSessionKey 21
+#define TZCMD_MODULAR_DRM_APIVersion 22
+#define TZCMD_MODULAR_DRM_SecurityLevel 23
+#define TZCMD_MODULAR_DRM_Generic_Encrypt 24
+#define TZCMD_MODULAR_DRM_Generic_Decrypt 25
+#define TZCMD_MODULAR_DRM_Generic_Sign 26
+#define TZCMD_MODULAR_DRM_Generic_Verify 27
+#define TZCMD_MODULAR_DRM_GET_RSA_KEY_SIZE 28
+
+
+
+
+
+
+#define TZCMD_MODULAR_DRM_TEST 29
+//Disable or enable debug level log in tee
+#define TZCMD_MODULAR_DRM_SET_DEBUG_LOG 30
+
+
+//added by zhitao yan
+#define TZCMD_MODULAR_DRM_UpdateUsageTable 31
+#define TZCMD_MODULAR_DRM_DeactivateUsageEntry 32
+#define TZCMD_MODULAR_DRM_ReportUsage 33
+#define TZCMD_MODULAR_DRM_DeleteUsageEntry 34
+#define TZCMD_MODULAR_DRM_DeleteUsageTable 35
+//#define TZCMD_MODULAR_DRM_UpdateUsageTable 31
+
+
+
+
+
+
+
+
+typedef enum TEE_MTK_MODULAR_DRM_Crypto_Result
+{
+ TEE_MTK_MODULAR_DRM_Crypto_SUCCESS = 0,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_INIT_FAILED = 1,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_TERMINATE_FAILED = 2,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_OPEN_FAILURE = 3,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_CLOSE_FAILURE = 4,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_ENTER_SECURE_PLAYBACK_FAILED = 5,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_EXIT_SECURE_PLAYBACK_FAILED = 6,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_SHORT_BUFFER = 7,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_NO_DEVICE_KEY = 8,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_NO_ASSET_KEY = 9,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_KEYBOX_INVALID = 10,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_NO_KEYDATA = 11,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_NO_CW = 12,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_DECRYPT_FAILED = 13,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_WRITE_KEYBOX = 14,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_WRAP_KEYBOX = 15,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_BAD_MAGIC = 16,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_BAD_CRC = 17,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_NO_DEVICEID = 18,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_RNG_FAILED = 19,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_RNG_NOT_SUPPORTED = 20,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_SETUP = 21,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_OPEN_SESSION_FAILED = 22,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_CLOSE_SESSION_FAILED = 23,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_INVALID_SESSION = 24,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_NOT_IMPLEMENTED = 25,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_NO_CONTENT_KEY = 26,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_CONTROL_INVALID = 27,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_UNKNOWN_FAILURE = 28,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_INVALID_CONTEXT = 29,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_SIGNATURE_FAILURE = 30,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_TOO_MANY_SESSIONS = 31,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_INVALID_NONCE = 32,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_TOO_MANY_KEYS = 33,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_DEVICE_NOT_RSA_PROVISIONED = 34,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_INVALID_RSA_KEY = 35,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_KEY_EXPIRED = 36,
+ TEE_MTK_MODULAR_DRM_Crypto_ERROR_INSUFFICIENT_RESOURCES = 37,
+} TEE_MTK_MODULAR_DRM_Crypto_Result;
+
+#endif /* __TRUSTZONE_TA_MODULAR_DRM__ */
diff --git a/include/trustzone/tz_cross/ta_mtee_img_prot_inf_gen.h b/include/trustzone/tz_cross/ta_mtee_img_prot_inf_gen.h
new file mode 100644
index 000000000..644b338f0
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_mtee_img_prot_inf_gen.h
@@ -0,0 +1,10 @@
+#ifndef __TA_MTEE_IMG_PROT_INF_GEN_H__
+#define __TA_MTEE_IMG_PROT_INF_GEN_H__
+
+#define TZ_TA_MTEE_IMG_PROT_INF_GEN_UUID "9208af60-b9af-434b-a9c1-9cc76d3f4075"
+
+/* Command for Test TA */
+#define TZCMD_INF1_GEN 0
+
+
+#endif /* __TA_MTEE_IMG_PROT_INF_GEN_H__ */
diff --git a/include/trustzone/tz_cross/ta_ndbg.h b/include/trustzone/tz_cross/ta_ndbg.h
new file mode 100644
index 000000000..6070ef3ad
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_ndbg.h
@@ -0,0 +1,20 @@
+#ifndef __TRUSTZONE_TA_NDBG__
+#define __TRUSTZONE_TA_NDBG__
+
+#define TZ_TA_NDBG_UUID "820b5780-dd5b-11e2-a28f-0800200c9a66"
+
+
+/* Data Structure for NDBG TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Test TA */
+#define NDBG_BAT_ST_SIZE 16
+#define URAN_SIZE 16
+#define NDBG_REE_ENTROPY_SZ (NDBG_BAT_ST_SIZE + URAN_SIZE)
+
+/* Command for DAPC TA */
+
+#define TZCMD_NDBG_INIT 0
+#define TZCMD_NDBG_WAIT_RESEED 1
+#define TZCMD_NDBG_RANDOM 2
+
+#endif /* __TRUSTZONE_TA_NDBG__ */
diff --git a/include/trustzone/tz_cross/ta_playready.h b/include/trustzone/tz_cross/ta_playready.h
new file mode 100644
index 000000000..d2054bfe1
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_playready.h
@@ -0,0 +1,97 @@
+#ifndef __TRUSTZONE_TA_PLAYREADY__
+#define __TRUSTZONE_TA_PLAYREADY__
+
+
+#define TZ_TA_PLAYREADY_UUID "b25bf100-d276-11e2-8b8b-0800200c9a66"
+
+#define PLAYREADY_PROVISIONED_CERT 1
+#define PLAYREADY_PROVISIONED_KEY 2
+#define PLAYREADY_PROVISIONED_CLEAR_KEY 3 // for debug
+
+#define TZ_DRM_UI64EQL 1
+#define TZ_DRM_UI64LES 2
+
+#define TZ_TOKEN_TOKEN 1
+#define TZ_TOKEN_VALUE 2
+#define TZ_VALUE_TOKEN 3
+
+#define SUPPORT_MULTIPLE_INSTANCE 1
+
+#define C_SECONDS_IN_ROLLBACK_GRACE_PERIOD 30
+
+/* Data Structure for Playready TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Playready TA */
+
+/* Command for Playready TA */
+#define TZCMD_PLAYREADY_BASE 0x00000000
+#define TZCMD_PLAYREADY_PROVISIONED_DATA_GET 0x00000001
+#define TZCMD_PLAYREADY_ECCP256_KEYPAIR_GEN 0x00000002
+#define TZCMD_PLAYREADY_ECCP256_KEY_SET 0x00000003
+#define TZCMD_PLAYREADY_ECDSAP256_SIGN 0x00000004
+#define TZCMD_PLAYREADY_ECCP256_DECRYPT 0x00000005
+#define TZCMD_PLAYREADY_OMAC1_KEY_SET 0x00000006
+#define TZCMD_PLAYREADY_OMAC1_VERIFY 0x00000007
+#define TZCMD_PLAYREADY_OMAC1_SIGN 0x00000008
+#define TZCMD_PLAYREADY_COPYBYTE 0x00000009
+#define TZCMD_PLAYREADY_CONTENTKEY_AESCTR_SET 0x0000000a
+#define TZCMD_PLAYREADY_CONTENT_AESCTR_DECRYPT 0x0000000b
+#define TZCMD_PLAYREADY_AESECB_KEY_SET 0x0000000c
+#define TZCMD_PLAYREADY_AESECB_ENCRYPT 0x0000000d
+#define TZCMD_PLAYREADY_AESECB_DECRYPT 0x0000000e
+#define TZCMD_PLAYREADY_GET_KFKEY 0x0000000f
+#define TZCMD_PLAYREADY_AESCBC_KEY_SET 0x00000010
+#define TZCMD_PLAYREADY_AESCBC_ENCRYPT 0x00000011
+#define TZCMD_PLAYREADY_AESCBC_DECRYPT 0x00000012
+#define TZCMD_PLAYREADY_HANDLE_CONTENT_AESCTR_DECRYPT 0x00000013
+#define TZCMD_PLAYREADY_KEYFILE_DECRYPT 0x00000014
+#define TZCMD_PLAYREADY_KEYFILE_ENCRYPT 0x00000015
+#define TZCMD_PLAYREADY_TOKENTIME_COMPARE 0x00000016
+#define TZCMD_PLAYREADY_TOKENTIME_UPDATE 0x00000017
+#define TZCMD_PLAYREADY_MACHINEDATETIME_CHECK 0x00000019
+
+
+typedef struct PLAYREADY_IVDATA {
+ unsigned long long qwInitializationVector;
+ unsigned long long qwBlockOffset;
+ unsigned long bByteOffset;
+} PLAYREADY_IVDATA;
+
+
+typedef struct TZ_PLAYREADY_ENCINFO{
+ char role[100];
+ unsigned int dataSize; //total enc buffer size
+ unsigned int segNum; //trunk number
+ PLAYREADY_IVDATA iv[10]; //IV data for each trunk
+ unsigned int offset[10]; //pointer to an integer array, each element describe clear data size
+ unsigned int length[10]; //pointer to an integer array, each element describe enc data size
+ unsigned int dstHandle; //true : dstData is a handle; false : dstData is a buffer;
+
+}TZ_PLAYREADY_ENCINFO;
+
+#ifdef SUPPORT_MULTIPLE_INSTANCE
+
+#define DRM_AES_KEYSIZE_128 ( 16 ) /* Size ( in bytes ) of a 128 bit key */
+
+/* Now at least two or more process will use ta_playready.c at same time , drm server and media server */
+#define MAX_AESECB_KEYS_INSTANCE 4
+#define MAX_OMAC1_KEYS_INSTANCE 4
+
+typedef struct TZ_PLAYREADY_AESECB_KEYS{
+ uint32_t handle; // tee session handle
+ char aesecbKey[DRM_AES_KEYSIZE_128];
+ uint32_t bProtect;
+ uint32_t bInUse;
+}TZ_PLAYREADY_AESECB_KEYS;
+
+typedef struct TZ_PLAYREADY_OMAC1_KEYS{
+ uint32_t handle; // tee session handle
+ char omac1Key[DRM_AES_KEYSIZE_128];
+ uint32_t bProtect;
+ uint32_t bInUse;
+}TZ_PLAYREADY_OMAC1_KEYS;
+
+#endif
+
+#endif /* __TRUSTZONE_TA_PLAYREADY__ */
+
diff --git a/include/trustzone/tz_cross/ta_pm.h b/include/trustzone/tz_cross/ta_pm.h
new file mode 100644
index 000000000..e5105df04
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_pm.h
@@ -0,0 +1,26 @@
+/* Power management TA functions
+ */
+
+#ifndef __TRUSTZONE_TA_PM__
+#define __TRUSTZONE_TA_PM__
+
+#define TZ_TA_PM_UUID "387389fa-b2cf-11e2-856d-d485645c4310"
+
+/* Command for PM TA */
+
+#define TZCMD_PM_CPU_LOWPOWER 0
+#define TZCMD_PM_CPU_DORMANT 1
+#define TZCMD_PM_DEVICE_OPS 2
+#define TZCMD_PM_CPU_ERRATA_802022_WA 3
+
+enum eMTEE_PM_State
+{
+ MTEE_NONE,
+ MTEE_SUSPEND,
+ MTEE_SUSPEND_LATE,
+ MTEE_RESUME,
+ MTEE_RESUME_EARLY,
+};
+typedef enum eMTEE_PM_State MTEE_PM_State;
+
+#endif /* __TRUSTZONE_TA_PM__ */
diff --git a/include/trustzone/tz_cross/ta_securetime.h b/include/trustzone/tz_cross/ta_securetime.h
new file mode 100644
index 000000000..313c1ef69
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_securetime.h
@@ -0,0 +1,73 @@
+#ifndef __TRUSTZONE_TA_SECURE_TIMER__
+#define __TRUSTZONE_TA_SECURE_TIMER__
+
+
+#define TZ_TA_SECURETIME_UUID "b25bf100-d276-11e2-9c9c-9c9c9c9c9c9c"
+
+
+#define uint64 unsigned long long
+
+#define TZ_SECURETIME_BIRTHDATE 1392967151
+#define TZCMD_SECURETIME_GET_CURRENT_COUNTER 0x00000000 // used for getting encrypted prtime struct to save file when shutdown and suspend or after THREAD_SAVEFILE_VALUE second
+#define TZCMD_SECURETIME_SET_CURRENT_COUNTER 0x00000001 // used for set new playready time using the current rtc counter and encrypted saved prtime struct when resume and bootup
+#define TZCMD_SECURETIME_INC_CURRENT_COUNTER 0x00000002 // used for increase current counter at least PR_TIME_INC_COUNTER secs and no more than PR_TIME_MAX_COUNTER_OFFSET secs
+#define TZCMD_SECURETIME_SET_CURRENT_PRTIME 0x00000003 // used for network time-sync module to sync pr_time
+#define GB_TIME_INC_COUNTER 5
+#define GB_TIME_MAX_COUNTER_OFFSET 8
+
+#define GB_TIME_FILE_BASE 50000
+#define GB_TIME_FILE_ERROR_SIGN (GB_TIME_FILE_BASE + 1)
+#define GB_TIME_FILE_OK_SIGN (GB_TIME_FILE_BASE + 2)
+#define GB_NO_SECURETD_FILE (GB_TIME_FILE_BASE + 3)
+#define GB_TIME_ERROR_SETPRTIME (GB_TIME_FILE_BASE + 4)
+
+#define DRM_UINT64 unsigned long long
+
+
+typedef struct TZ_GB_SECURETIME_INFO{
+volatile unsigned long long hwcounter;
+volatile unsigned long long gb_time;
+char signature[8];
+}TZ_GB_SECURETIME_INFO;
+
+struct TM_GB {
+ int tm_sec; /* seconds */
+ int tm_min; /* minutes */
+ int tm_hour; /* hours */
+ int tm_mday; /* day of the month */
+ int tm_mon; /* month */
+ int tm_year; /* year */
+ int tm_wday; /* day of the week */
+ int tm_yday; /* day in the year */
+ int tm_isdst; /* daylight saving time */
+
+ long int tm_gmtoff; /* Seconds east of UTC. */
+ const char *tm_zone; /* Timezone abbreviation. */
+
+};
+
+//end of SUPPORT_GB_SECURE_CLOCK
+
+typedef struct SECURETIME_IVDATA {
+ unsigned long long qwInitializationVector;
+ unsigned long long qwBlockOffset;
+ unsigned long bByteOffset;
+} SECURETIME_IVDATA;
+
+
+typedef struct TZ_SECURETIME_ENCINFO{
+ char role[100];
+ unsigned int dataSize; //total enc buffer size
+ unsigned int segNum; //trunk number
+ SECURETIME_IVDATA iv[10]; //IV data for each trunk
+ unsigned int offset[10]; //pointer to an integer array, each element describe clear data size
+ unsigned int length[10]; //pointer to an integer array, each element describe enc data size
+ unsigned int dstHandle; //true : dstData is a handle; false : dstData is a buffer;
+
+}TZ_SECURETIME_ENCINFO;
+
+//unsigned long long GetTee_SecureTime(); //only be userd in tee, in user or kernel, should call the tee_service call
+
+
+#endif /* __TRUSTZONE_TA_PLAYREADY__ */
+
diff --git a/include/trustzone/tz_cross/ta_system.h b/include/trustzone/tz_cross/ta_system.h
new file mode 100644
index 000000000..8696d530c
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_system.h
@@ -0,0 +1,20 @@
+/** Commands for TA SYSTEM **/
+
+#ifndef __TRUSTZONE_TA_SYSTEM__
+#define __TRUSTZONE_TA_SYSTEM__
+
+/// Special handle for system connect.
+/// NOTE: Handle manager guarantee normal handle will have bit31=0.
+#define MTEE_SESSION_HANDLE_SYSTEM 0xFFFF1234
+
+
+
+/* Session Management */
+#define TZCMD_SYS_INIT 0
+#define TZCMD_SYS_SESSION_CREATE 1
+#define TZCMD_SYS_SESSION_CLOSE 2
+#define TZCMD_SYS_IRQ 3
+#define TZCMD_SYS_THREAD_CREATE 4
+
+
+#endif /* __TRUSTZONE_TA_SYSTEM__ */
diff --git a/include/trustzone/tz_cross/ta_test.h b/include/trustzone/tz_cross/ta_test.h
new file mode 100644
index 000000000..f8d8aa6c1
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_test.h
@@ -0,0 +1,28 @@
+/* An example test TA implementation.
+ */
+
+#ifndef __TRUSTZONE_TA_TEST__
+#define __TRUSTZONE_TA_TEST__
+
+#define TZ_TA_TEST_UUID "0d5fe516-821d-11e2-bdb4-d485645c4310"
+
+/* Data Structure for Test TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Test TA */
+
+/* Command for Test TA */
+#define TZCMD_TEST_ADD 0
+#define TZCMD_TEST_MUL 1
+#define TZCMD_TEST_ADD_MEM 2
+#define TZCMD_TEST_DO_A 3
+#define TZCMD_TEST_DO_B 4
+#define TZCMD_TEST_SLEEP 5
+#define TZCMD_TEST_DELAY 6
+#define TZCMD_TEST_DO_C 7
+#define TZCMD_TEST_DO_D 8
+#define TZCMD_TEST_SECUREFUNC 9
+#define TZCMD_TEST_CP_SBUF2NBUF 10
+#define TZCMD_TEST_CP_NBUF2SBUF 11
+#define TZCMD_TEST_THREAD 12
+
+#endif /* __TRUSTZONE_TA_TEST__ */
diff --git a/include/trustzone/tz_cross/ta_vdec.h b/include/trustzone/tz_cross/ta_vdec.h
new file mode 100644
index 000000000..57af41572
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_vdec.h
@@ -0,0 +1,18 @@
+#ifndef __TRUSTZONE_TA_VDEC__
+#define __TRUSTZONE_TA_VDEC__
+
+#define TZ_TA_VDEC_UUID "ff33a6e0-8635-11e2-9e96-0800200c9a66"
+
+#define UT_ENABLE 0
+#define DONT_USE_BS_VA 1 // for VP path integration set to 1, for mfv_ut set to 0
+#define USE_MTEE_M4U
+#define USE_MTEE_DAPC
+
+
+/* Command for VDEC TA */
+#define TZCMD_VDEC_AVC_INIT 0
+#define TZCMD_VDEC_AVC_DECODE 1
+#define TZCMD_VDEC_AVC_DEINIT 2
+
+#define TZCMD_VDEC_TEST 100
+#endif /* __TRUSTZONE_TA_VDEC__ */
diff --git a/include/trustzone/tz_cross/ta_venc.h b/include/trustzone/tz_cross/ta_venc.h
new file mode 100644
index 000000000..0ea27c6fc
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_venc.h
@@ -0,0 +1,23 @@
+#ifndef __TRUSTZONE_TA_VENC__
+#define __TRUSTZONE_TA_VENC__
+
+#define TZ_TA_VENC_UUID "e7305aca-375e-4f69-ac6b-ba9d3c9a1f97"
+
+//#define UT_ENABLE 0
+//#define DONT_USE_BS_VA 1 // for VP path integration set to 1, for mfv_ut set to 0
+//#define USE_MTEE_M4U
+//#define USE_MTEE_DAPC
+
+
+/* Command for VENC TA */
+#define TZCMD_VENC_AVC_INIT 0
+#define TZCMD_VENC_AVC_ENCODE 1
+#define TZCMD_VENC_AVC_ENCODE_NS 2
+#define TZCMD_VENC_AVC_DEINIT 3
+#define TZCMD_VENC_AVC_ALLOC_WORK_BUF 4
+#define TZCMD_VENC_AVC_FREE_WORK_BUF 5
+#define TZCMD_VENC_AVC_SHARE_WORK_BUF 6
+#define TZCMD_VENC_AVC_COPY_WORK_BUF 7
+
+#define TZCMD_VENC_TEST 100
+#endif /* __TRUSTZONE_TA_VENC__ */
diff --git a/include/trustzone/tz_cross/ta_widevine.h b/include/trustzone/tz_cross/ta_widevine.h
new file mode 100644
index 000000000..1cf6e62d2
--- /dev/null
+++ b/include/trustzone/tz_cross/ta_widevine.h
@@ -0,0 +1,52 @@
+#ifndef __TRUSTZONE_TA_WIDEVINE__
+#define __TRUSTZONE_TA_WIDEVINE__
+
+#define TZ_TA_WIDEVINE_UUID "ff33a6e0-8635-11e2-9e96-0800200c9a00"
+
+/* Data Structure for Widevine TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Widevine TA */
+
+/* Command for Widevine TA */
+
+#define TZCMD_WIDEVINE_INIT 1
+#define TZCMD_WIDEVINE_TERMINATE 2
+#define TZCMD_WIDEVINE_SET_ENTITLEMENT_KEY 3
+#define TZCMD_WIDEVINE_DEVICE_CONTROL 4
+#define TZCMD_WIDEVINE_DECRYPT_VIDEO 5
+#define TZCMD_WIDEVINE_DECRYPT_AUDIO 6
+#define TZCMD_WIDEVINE_INSTALL_KEYBOX 7
+#define TZCMD_WIDEVINE_IS_KEYBOX_VALID 8
+#define TZCMD_WIDEVINE_GET_DEVICE_ID 9
+#define TZCMD_WIDEVINE_GET_KEY_DATA 10
+#define TZCMD_WIDEVINE_RANDOM 11
+#define TZCMD_WIDEVINE_TEST 12
+#define TZCMD_WIDEVINE_READ_NAL 13
+//Disable or enable debug level log in tee
+#define TZCMD_WIDEVINE_SET_DEBUG_LOG 14
+
+typedef enum TEE_MTK_CryptoResult
+{
+ TEE_MTK_Crypto_SUCCESS = 0,
+ TEE_MTK_Crypto_ERROR_INIT_FAILED,
+ TEE_MTK_Crypto_ERROR_TERMINATE_FAILED,
+ TEE_MTK_Crypto_ERROR_ENTER_SECURE_PLAYBACK_FAILED,
+ TEE_MTK_Crypto_ERROR_EXIT_SECURE_PLAYBACK_FAILED,
+ TEE_MTK_Crypto_ERROR_SHORT_BUFFER,
+ TEE_MTK_Crypto_ERROR_NO_DEVICE_KEY,
+ TEE_MTK_Crypto_ERROR_NO_ASSET_KEY,
+ TEE_MTK_Crypto_ERROR_KEYBOX_INVALID,
+ TEE_MTK_Crypto_ERROR_NO_KEYDATA,
+ TEE_MTK_Crypto_ERROR_NO_CW,
+ TEE_MTK_Crypto_ERROR_DECRYPT_FAILED,
+ TEE_MTK_Crypto_ERROR_WRITE_KEYBOX,
+ TEE_MTK_Crypto_ERROR_WRAP_KEYBOX,
+ TEE_MTK_Crypto_ERROR_BAD_MAGIC,
+ TEE_MTK_Crypto_ERROR_BAD_CRC,
+ TEE_MTK_Crypto_ERROR_NO_DEVICEID,
+ TEE_MTK_Crypto_ERROR_RNG_FAILED,
+ TEE_MTK_Crypto_ERROR_RNG_NOT_SUPPORTED,
+ TEE_MTK_Crypto_ERROR_SETUP,
+ TEE_MTK_Crypto_LEFT_NAL
+} TEE_MTK_CryptoResult;
+#endif /* __TRUSTZONE_TA_WIDEVINE__ */
diff --git a/include/trustzone/tz_cross/trustzone.h b/include/trustzone/tz_cross/trustzone.h
new file mode 100644
index 000000000..9d49b821b
--- /dev/null
+++ b/include/trustzone/tz_cross/trustzone.h
@@ -0,0 +1,165 @@
+/*
+ * Basic Data Types & function for common TZ.
+ */
+
+#ifndef __REE_TRUSTZONE_H__
+#define __REE_TRUSTZONE_H__
+
+#ifdef __KERNEL__
+#include <linux/types.h>
+#else
+#include <stdint.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Temp memory reference paramter define
+ * The parameter pass by copying data. The size limit for temp memory
+ * parameter is 4KB.
+ *
+ * @param buffer A pointer to the buffer.
+ * @param size Buffer size in bytes.
+ */
+typedef struct {
+ void *buffer;
+ uint32_t size;
+} MTEEC_MEM;
+
+/**
+ * Registed shared memory paramter define
+ *
+ * @param handle memory handle.
+ * @param offset Offset size in bytes. The shared memory is used based
+ * on this offset.
+ * @param size Buffer size in bytes.
+ */
+typedef struct {
+ uint32_t handle;
+ uint32_t offset;
+ uint32_t size;
+} MTEEC_MEMREF;
+
+/**
+ * Registed shared memory paramter define
+ *
+ * @param a Implementation defined value.
+ * @param b Implementation defined value.
+ */
+typedef struct {
+ uint32_t a;
+ uint32_t b;
+} MTEEC_VALUE;
+
+/**
+ * Paramter define
+ *
+ * @param mem Parameter for temp memory reference. Parameter types are TZPT_MEM_XXX.
+ * @param memref Parameter for registed shared memory or allocated secure memory.
+ * Parameter types are TZPT_MEMREF_XXX.
+ * @param value Parameter for value. Parameter types are TZPT_VALUE_XXX.
+ */
+typedef union {
+ MTEEC_MEM mem;
+ MTEEC_MEMREF memref;
+ MTEEC_VALUE value;
+} MTEEC_PARAM;
+
+/**
+ * Parameter type define
+ *
+ * @see TZ_PARAM_TYPES
+ */
+typedef enum
+{
+ TZPT_NONE = 0,
+ TZPT_VALUE_INPUT = 1,
+ TZPT_VALUE_OUTPUT = 2,
+ TZPT_VALUE_INOUT = 3,
+ TZPT_MEM_INPUT = 4,
+ TZPT_MEM_OUTPUT = 5,
+ TZPT_MEM_INOUT = 6,
+ TZPT_MEMREF_INPUT = 7,
+ TZPT_MEMREF_OUTPUT = 8,
+ TZPT_MEMREF_INOUT = 9,
+} TZ_PARAM_TYPES;
+
+
+/// Macros to build parameter types for ?REE_TeeServiceCall
+/// @see TZ_ParamTypes
+#define TZ_ParamTypes1(t1) TZ_ParamTypes(t1, TZPT_NONE, TZPT_NONE, TZPT_NONE)
+#define TZ_ParamTypes2(t1,t2) TZ_ParamTypes(t1, t2, TZPT_NONE, TZPT_NONE)
+#define TZ_ParamTypes3(t1,t2,t3) TZ_ParamTypes(t1, t2, t3, TZPT_NONE)
+#define TZ_ParamTypes4(t1,t2,t3,t4) TZ_ParamTypes(t1, t2, t3, t4)
+
+/**
+ * Macros to build parameter types for ?REE_TeeServiceCall
+ *
+ * @see KREE_TeeServiceCall
+ * @see UREE_TeeServiceCall
+ * @param t1 types for param[0]
+ * @param t2 types for param[1]
+ * @param t3 types for param[2]
+ * @param t4 types for param[3]
+ * @return value for paramTypes.
+ */
+static inline uint32_t TZ_ParamTypes(TZ_PARAM_TYPES t1, TZ_PARAM_TYPES t2,
+ TZ_PARAM_TYPES t3, TZ_PARAM_TYPES t4)
+{
+ return (TZ_PARAM_TYPES)(t1 | (t2 << 8) | (t3 << 16) | (t4 << 24));
+}
+
+/*
+ * Get TZ_PARAM_TYPES for a parameter.
+ *
+ * @param paramTypes paramTypes packed by TZ_ParamTypes.
+ * @param num Which parameter types to get.
+ */
+static inline TZ_PARAM_TYPES TZ_GetParamTypes(uint32_t paramTypes, int num)
+{
+ return (TZ_PARAM_TYPES)((paramTypes >> (8*num)) & 0xff);
+}
+
+/**
+ * Return code
+ *
+ * This global return code is used for both REE and TEE.
+ * Implementation-Defined 0x00000001 - 0xFFFEFFFF
+ * Reserved for Future Use 0xFFFF0011 V 0xFFFFFFFF
+ *
+ * @see TZ_RESULT
+ */
+#define TZ_RESULT_SUCCESS 0x00000000 // The operation was successful.
+#define TZ_RESULT_ERROR_GENERIC 0xFFFF0000 // Non-specific cause.
+#define TZ_RESULT_ERROR_ACCESS_DENIED 0xFFFF0001 // Access privileges are not sufficient.
+#define TZ_RESULT_ERROR_CANCEL 0xFFFF0002 // The operation was cancelled.
+#define TZ_RESULT_ERROR_ACCESS_CONFLICT 0xFFFF0003 // Concurrent accesses caused conflict.
+#define TZ_RESULT_ERROR_EXCESS_DATA 0xFFFF0004 // Too much data for the requested operation was passed.
+#define TZ_RESULT_ERROR_BAD_FORMAT 0xFFFF0005 // Input data was of invalid format.
+#define TZ_RESULT_ERROR_BAD_PARAMETERS 0xFFFF0006 // Input parameters were invalid.
+#define TZ_RESULT_ERROR_BAD_STATE 0xFFFF0007 // Operation is not valid in the current state.
+#define TZ_RESULT_ERROR_ITEM_NOT_FOUND 0xFFFF0008 // The requested data item is not found.
+#define TZ_RESULT_ERROR_NOT_IMPLEMENTED 0xFFFF0009 // The requested operation should exist but is not yet implemented.
+#define TZ_RESULT_ERROR_NOT_SUPPORTED 0xFFFF000A // The requested operation is valid but is not supported in this Implementation.
+#define TZ_RESULT_ERROR_NO_DATA 0xFFFF000B // Expected data was missing.
+#define TZ_RESULT_ERROR_OUT_OF_MEMORY 0xFFFF000C // System ran out of resources.
+#define TZ_RESULT_ERROR_BUSY 0xFFFF000D // The system is busy working on something else.
+#define TZ_RESULT_ERROR_COMMUNICATION 0xFFFF000E // Communication with a remote party failed.
+#define TZ_RESULT_ERROR_SECURITY 0xFFFF000F // A security fault was detected.
+#define TZ_RESULT_ERROR_SHORT_BUFFER 0xFFFF0010 // The supplied buffer is too short for the generated output.
+#define TZ_RESULT_ERROR_INVALID_HANDLE 0xFFFF0011 // The handle is invalid.
+
+typedef int TZ_RESULT;
+
+/**
+ * Return a human readable error string.
+ */
+const char *TZ_GetErrorString(TZ_RESULT res);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __REE_TRUSTZONE_H__ */
diff --git a/include/trustzone/tz_cross/tz_cmdq.h b/include/trustzone/tz_cross/tz_cmdq.h
new file mode 100644
index 000000000..ff7af487b
--- /dev/null
+++ b/include/trustzone/tz_cross/tz_cmdq.h
@@ -0,0 +1,165 @@
+#ifndef __TRUSTZONE_TZ_CMDQ__
+#define __TRUSTZONE_TZ_CMDQ__
+
+#include "trustzone.h"
+
+#ifdef __KERNEL__
+#else
+#include "types.h"
+#endif
+
+#define TZ_TA_CMDQ_NAME "CMDQ_TA"
+#define TZ_TA_CMDQ_UUID "tz_ta_cmdq_uuid_mt8127_svp"
+
+/* Data Structure for CMDQ TA */
+/* You should define data structure used both in REE/TEE here
+ */
+
+#define CMDQ_MAX_BLOCK_SIZE (32 * 1024)
+
+#define CMDQ_IWC_MAX_CMD_LENGTH (32 * 1024 / 4)
+
+#define CMDQ_IWC_MAX_ADDR_LIST_LENGTH (12)
+#define CMDQ_IWC_MAX_PORT_LIST_LENGTH (5)
+
+
+typedef struct
+{
+ uint32_t instrIndex; // _d, indicate x-th instruction
+ uint32_t baseHandle; // _h, secure handle
+ uint32_t offset; // _b, buffser offset to secure handle
+
+ // mva config
+ bool isMVA;
+ uint32_t size;
+ uint32_t port;
+} iwcCmdqAddrMetadata_t;
+
+
+typedef struct
+{
+ uint32_t port;
+ bool useMVA;
+} iwcCmdqPortMetadata_t;
+
+
+typedef struct {
+ uint32_t logLevel;
+} iwcCmdqDebugConfig_t;
+
+
+typedef struct {
+ uint32_t addrListLength;
+ uint32_t portListLength;
+ iwcCmdqAddrMetadata_t addrList[CMDQ_IWC_MAX_ADDR_LIST_LENGTH];
+ iwcCmdqPortMetadata_t portList[CMDQ_IWC_MAX_PORT_LIST_LENGTH];
+ iwcCmdqDebugConfig_t debug;
+}iwcCmdqMetadata_t;
+
+//
+// linex kernel and mobicore has their own MMU tables,
+// the latter's is used to map world shared memory and physical address
+// so mobicore dose not understand linux virtual address mapping.
+//
+// if we want to transact a large buffer in TCI/DCI, there are 2 method (both need 1 copy):
+// 1. use mc_map, to map normal world buffer to WSM, and pass secure_virt_addr in TCI/DCI buffer
+// note mc_map implies a memcopy to copy content from normal world to WSM
+// 2. declare a fixed lenth array in TCI/DCI struct, and its size must be < 1M
+//
+typedef struct {
+ union
+ {
+ uint32_t cmd; // [IN] command id
+ int32_t rsp; // [OUT] 0 for success, < 0 for error
+ };
+
+ uint32_t thread;
+ uint32_t scenario;
+ uint32_t priority;
+ uint32_t engineFlag;
+ uint32_t pVABase[CMDQ_IWC_MAX_CMD_LENGTH];
+ uint32_t blockSize;
+
+ iwcCmdqMetadata_t metadata;
+} iwcCmdqMessage_t, *iwcCmdqMessage_ptr;
+
+
+typedef struct {
+ uint32_t commandId;
+ uint32_t phy_addr;
+ uint32_t size;
+ uint32_t alignment;
+ uint32_t refcount;
+ uint32_t handle;
+} tlApimem_t, *tlApimem_ptr;
+
+#define QUERY_MAX_LEN 8
+
+
+
+// CMDQ secure engine
+// the engine id should be same as the normal CMDQ
+typedef enum CMDQ_ENG_SEC_ENUM
+{
+ // CAM
+ CMDQ_ENG_SEC_ISP_IMGI = 0,
+ CMDQ_ENG_SEC_ISP_IMGO = 1,
+ CMDQ_ENG_SEC_ISP_IMG2O = 2,
+
+ // MDP
+ CMDQ_ENG_SEC_MDP_RDMA0 = 3,
+ CMDQ_ENG_SEC_MDP_CAMIN = 4,
+ CMDQ_ENG_SEC_MDP_SCL0 = 5,
+ CMDQ_ENG_SEC_MDP_SCL1 = 6,
+ CMDQ_ENG_SEC_MDP_TDSHP = 7,
+ CMDQ_ENG_SEC_MDP_WROT = 8,
+ CMDQ_ENG_SEC_MDP_WDMA1 = 9,
+
+ CMDQ_ENG_SEC_LSCI = 10,
+ CMDQ_ENG_SEC_CMDQ = 11,
+
+ CMDQ_ENG_SEC_ISP_Total = 12,
+}CMDQ_ENG_SEC_ENUM;
+
+
+//
+// ERROR code number (ERRNO)
+// note the error result returns negative value, i.e, -(ERRNO)
+//
+#define CMDQ_ERR_NOMEM (12) // out of memory
+#define CMDQ_ERR_FAULT (14) // bad address
+
+#define CMDQ_ERR_ADDR_CONVERT_HANDLE_2_PA (1000)
+#define CMDQ_ERR_ADDR_CONVER_PA (1200)
+#define CMDQ_ERR_ADDR_CONVERT_ALLOC_MVA (1100)
+#define CMDQ_ERR_ADDR_CONVERT_FREE_MVA (1200)
+#define CMDQ_ERR_PORT_CONFIG (1300)
+
+#define CMDQ_TZ_ERR_UNKNOWN_IWC_CMD (5000)
+
+#define CMDQ_ERR_TZ_IPC_EXECUTE_SESSION (5001)
+#define CMDQ_ERR_TZ_IPC_CLOSE_SESSION (5002)
+#define CMDQ_ERR_TZ_EXEC_FAILED (5003)
+
+
+
+/* Command for CMDQ TA */
+#define TZCMD_CMDQ_SUBMIT_TASK (1)
+#define TZCMD_CMDQ_RES_RELEASE (2)
+
+#define TZCMD_CMDQ_TEST_HELLO (4000)
+#define TZCMD_CMDQ_TEST_DUMMY (4001)
+#define TZCMD_CMDQ_TEST_SMI_DUMP (4002)
+#define TZCMD_CMDQ_DEBUG_SW_COPY (4003)
+#define TZCMD_CMDQ_TRAP_DR_INFINITELY (4004)
+#define TZCMD_CMDQ_DUMP (4005)
+#define TZCMD_CMDQ_TEST_TASK_IWC (4006)
+
+
+/**
+ * Termination codes
+ */
+#define EXIT_ERROR ((uint32_t)(-1))
+
+
+#endif /* __TRUSTZONE_TZ_CMDQ__ */
diff --git a/include/trustzone/tz_cross/tz_ddp.h b/include/trustzone/tz_cross/tz_ddp.h
new file mode 100644
index 000000000..a3fa49bcc
--- /dev/null
+++ b/include/trustzone/tz_cross/tz_ddp.h
@@ -0,0 +1,58 @@
+#ifndef __TRUSTZONE_TZ_DDP__
+#define __TRUSTZONE_TZ_DDP__
+
+#define TZ_TA_DDP_NAME "DDP TA"
+#define TZ_TA_DDP_UUID "dd7b73bc-0244-4072-b541-c9a53d8fbf5b"
+
+/* Data Structure for Test TA */
+/* You should define data structure used both in REE/TEE here
+ N/A for Test TA */
+
+/* Command for DDP TA */
+#define TZCMD_DDP_OVL_START 0
+#define TZCMD_DDP_OVL_STOP 1
+#define TZCMD_DDP_OVL_RESET 2
+#define TZCMD_DDP_OVL_ROI 3
+#define TZCMD_DDP_OVL_LAYER_SWITCH 4
+#define TZCMD_DDP_OVL_LAYER_CONFIG 5
+#define TZCMD_DDP_OVL_3D_CONFIG 6
+#define TZCMD_DDP_OVL_LAYER_TDSHP_EN 7
+#define TZCMD_DDP_OVL_TEST 8
+#define TZCMD_DDP_OVL_CONFIG_LAYER_ADDR 9
+#define TZCMD_DDP_OVL_IS_EN 10
+
+#define TZCMD_DDP_OVL_ALLOC_MVA 11
+#define TZCMD_DDP_OVL_DEALLOC_MVA 12
+
+#define TZCMD_DDP_SECURE_MVA_MAP 13
+#define TZCMD_DDP_SECURE_MVA_UNMAP 14
+
+#define TZCMD_DDP_INTR_CALLBACK 15
+#define TZCMD_DDP_REGISTER_INTR 16
+
+#define TZCMD_DDP_OVL_BACKUP_REG 17
+#define TZCMD_DDP_OVL_RESTORE_REG 18
+
+#define TZCMD_DDP_WDMA_BACKUP_REG 19
+#define TZCMD_DDP_WDMA_RESTORE_REG 20
+
+#define TZCMD_DDP_DUMP_REG 30
+#define TZCMD_DDP_SET_SECURE_MODE 31
+
+#define TZCMD_DDP_SET_DEBUG_LOG 40
+
+#define TZCMD_DDP_SET_DAPC_MODE 50
+
+#define TZCMD_DDP_WDMA_CONFIG 60
+#define TZCMD_DDP_WDMA_INTEN 61
+#define TZCMD_DDP_WDMA_INTSTA 62
+#define TZCMD_DDP_WDMA_START 63
+#define TZCMD_DDP_WDMA_STOP 64
+#define TZCMD_DDP_WDMA_RST 65
+#define TZCMD_DDP_WDMA1_CONFIG_UV 66
+
+
+#define TZCMD_DDP_RDMA_ADDR_CONFIG 70
+
+#define TZCMD_DDP_RDMA1_ADDR_CONFIG 71
+#endif /* __TRUSTZONE_TZ_DDP__ */
diff --git a/include/trustzone/tz_cross/tz_error_strings.h b/include/trustzone/tz_cross/tz_error_strings.h
new file mode 100644
index 000000000..e991a22bf
--- /dev/null
+++ b/include/trustzone/tz_cross/tz_error_strings.h
@@ -0,0 +1,47 @@
+/*
+ * Helper to implement TZ_GetErrorString in MTEE/KREE/UREE
+ * Please don't include this.
+ */
+
+#ifndef __TZ_ERROR_STRINGS__
+#define __TZ_ERROR_STRINGS__
+
+static const char *TZ_ErrorStrings[] = {
+ "The operation was successful.",
+ "Non-specific cause.",
+ "Access privileges are not sufficient.",
+ "The operation was cancelled.",
+ "Concurrent accesses caused conflict.",
+ "Too much data for the requested operation was passed.",
+ "Input data was of invalid format.",
+ "Input parameters were invalid.",
+ "Operation is not valid in the current state.",
+ "The requested data item is not found.",
+ "The requested operation should exist but is not yet implemented.",
+ "The requested operation is valid but is not supported in this Implementation.",
+ "Expected data was missing.",
+ "System ran out of resources.",
+ "The system is busy working on something else.",
+ "Communication with a remote party failed.",
+ "A security fault was detected.",
+ "The supplied buffer is too short for the generated output.",
+ "The handle is invalid.",
+ "Unknown error.",
+};
+#define TZ_ErrorStrings_num (sizeof(TZ_ErrorStrings)/sizeof(TZ_ErrorStrings[0]))
+
+
+static const char *_TZ_GetErrorString(TZ_RESULT res)
+{
+ unsigned int num;
+
+ if (res == 0)
+ return TZ_ErrorStrings[0];
+
+ num = ((unsigned int)res & 0xffff) + 1;
+ if (num > (TZ_ErrorStrings_num-1))
+ num = TZ_ErrorStrings_num-1;
+ return TZ_ErrorStrings[num];
+}
+
+#endif /* __TZ_ERROR_STRINGS__ */