You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

209 lines
7.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2020. All rights reserved.
* Description: Secure Session Manager API declaration
*/
#ifndef UAPI_SSM_H
#define UAPI_SSM_H
#include "td_type.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Defines the intents in Secure Session Manager 列举SSM中的intent */
typedef enum {
UAPI_SSM_INTENT_WATCH,
UAPI_SSM_INTENT_RECORD,
UAPI_SSM_INTENT_EXPORT,
UAPI_SSM_INTENT_MAX
} uapi_ssm_intent;
/* Defines the buffer ids in Secure Session Manager 定义SSM中的buffer id */
typedef enum {
UAPI_SSM_BUFFER_ID_INVALID = 0,
UAPI_SSM_BUFFER_ID_INTERNAL_BUF_DMX,
UAPI_SSM_BUFFER_ID_INTERNAL_BUF_TSCIPHER,
UAPI_SSM_BUFFER_ID_CIPHER_CENC_BUF,
UAPI_SSM_BUFFER_ID_INTERNAL_BUF_MCIPHER,
UAPI_SSM_BUFFER_ID_VID_RAWLIST_MCU_ONLY,
UAPI_SSM_BUFFER_ID_VID_SEGLIST_MCU_ONLY,
UAPI_SSM_BUFFER_ID_VID_STDCTX_MCU_ONLY,
UAPI_SSM_BUFFER_ID_VID_PICMSG_MCU_ONLY,
UAPI_SSM_BUFFER_ID_VID_SLICEMSG_MCU_ONLY,
UAPI_SSM_BUFFER_ID_VID_METADATA_MCU_ONLY,
UAPI_SSM_BUFFER_ID_VID_SCDRAW_BUF,
UAPI_SSM_BUFFER_ID_VID_SCDSEG_BUF,
UAPI_SSM_BUFFER_ID_VID_SCDMSG,
UAPI_SSM_BUFFER_ID_VID_VDHPMV_BUF,
UAPI_SSM_BUFFER_ID_VID_VDHEXT_BUF_VID_ONLY,
UAPI_SSM_BUFFER_ID_VID_F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uapi_ssm_buffer_id;
/* Defines the input param attribute in Secure Session Manager */
/* CNcomment:定义SSM中作为入参的属性 */
typedef struct {
uapi_ssm_intent intent;
} uapi_ssm_attr;
/* Defines the struct that stores module infomation in Secure Session Manager */
/* CNcomment:定义SSM中存储模块资源信息的结构体 */
typedef struct {
td_handle module_handle;
} uapi_ssm_module_resource;
/* Defines the struct that stores module infomation in Secure Session Manager */
/* CNcomment:定义SSM中存储模块资源信息的结构体 */
typedef struct {
td_handle session_handle;
td_handle buffer_handle;
uapi_ssm_buffer_id buffer_id;
td_handle module_handle;
} uapi_ssm_buffer_attach_info;
/*
Initializes the Secure Session Manager module. CNcomment:初始化SSM模块
Before calling any other api in SSM, you must call this function first.
在调用SSM其他接口之前要求先调用本接口
retval TD_SUCCESS
retval TD_FAILURE open fd fail
*/
td_s32 uapi_ssm_init(td_void);
/*
Deinitializes the Secure Session Manager module. CNcomment:去初始化SSM模块
Before calling this api, you should call uapi_ssm_destroy to destroy all the SSM instance.
在调用SSM去初始化的接口前需要调用uapi_ssm_destroy来销毁所有SSM实例
retval TD_SUCCESS
retval TD_FAILURE cannot deinit ssm
*/
td_s32 uapi_ssm_deinit(td_void);
/*
Create a SSM instance. CNcomment:创建一个SSM实例
This is the only way to set intent,if you unfortunately set a wrong intent,you need to destroy it and create a new one.
调用此接口是设置intent的唯一机会如果设置了错误的intent, 就只能销毁实例重新创建
param[in] session_attr Pointer to create structure for a SSM instance.For details, see the description of
uapi_ssm_attr. 指针类型创建SSM所需信息详细结构体内容请参见uapi_ssm_attr.
param[out] session_handle Pointer to session handle that SSM driver allocates.
指针类型指向SSM驱动分配的session handle.
retval TD_SUCCESS
retval TD_FAILURE
retval SOC_ERR_SSM_NULL_PTR used null pointer
*/
td_s32 uapi_ssm_create(const uapi_ssm_attr *session_attr, td_handle *session_handle);
/*
Destroy a SSM instance by a assigned session handle. 根据指定的session handle来销毁一个SSM实例
param[in] session_handle a SSM handle that you want to destroy.
retval TD_SUCCESS Success CNcomment:成功 CNend
retval TD_FAILURE destroy fail Failure CNcomment:失败 CNend
*/
td_s32 uapi_ssm_destroy(const td_handle session_handle);
/*
Add a module resource to a SSM instance.CNcomment:添加一个模块资源信息到SSM实例中
Module resource include module handle and so on, we have reserved area for extra module info.
模块的资源信息包括模块的handle等结构体内部预留位置拓展用
param[in] session_handle a SSM handle specify the SSM instance to which your module is going to add.
指定想添加到的SSM实例
param[in] resource_info a pointer to a struct that include neccessary infomation during add operation.
一个指向包含添加过程中必须信息的结构体指针
retval TD_SUCCESS Success CNcomment:成功 CNend
retval TD_FAILURE add resource fail Failure CNcomment:失败 CNend
retval SOC_ERR_SSM_NULL_PTR used null pointer
*/
td_s32 uapi_ssm_add_resource(const td_handle session_handle, const uapi_ssm_module_resource *resource_info);
/*
Attach a buffer to a SSM instance. CNcomment:绑定一个buffer到SSM实例中
after alloc memory for a buffer, it should be attached to a specific module(of course it need to follow the policy rule
.Only after that this buffer can bu used. 在为一个buffer分配了内存之后还需要调用此接口来将
这个buffer和模块绑定只有绑定成功后才能正常使用
param[in] buffer_attach_info A pointer to a struct that include neccessary infomation during attach operation.
一个指向包含绑定过程中必须信息的结构体指针
param[out] sercure_info_addr A pointer to a 64bit data that stores the address of secure info,
if buffer is not session belonged, this data feild is 0.
一个指向64位数据的指针存放secure info 的地址.
如果要绑定的buffer不是session belonged 类型那么这个地址为0
retval TD_SUCCESS Success CNcomment:成功 CNend
retval TD_FAILURE Failure CNcomment:失败 CNend
retval SOC_ERR_SSM_NO_MEMORY memcpy attach info fail
retval SOC_ERR_SSM_NULL_PTR used null pointer
*/
td_s32 uapi_ssm_attach_buffer(const uapi_ssm_buffer_attach_info *buffer_attach_info, td_u64 *secure_info_addr);
/*
get the intent from SSM instance. CNcomment:获取指定SSM实例的intent
param[in] session_handle A SSM instance from which you want to get intent .
param[out] intent A pointer to a data field that stores intent type.
一个指向存储获取到的intent类型的数据区域
retval TD_SUCCESS CNcomment:成功 CNend
retval TD_FAILURE CNcomment:失败 CNend
retval SOC_ERR_SSM_NULL_PTR used null pointer
*/
td_s32 uapi_ssm_get_intent(const td_handle session_handle, uapi_ssm_intent *intent);
#ifdef __cplusplus
}
#endif
#endif