Exemplo n.º 1
0
static int package_cmd(
		struct te_request * request, 
		struct te_oper_param  *param, 
		cmd_t *cmd
		)
{
	unsigned int i =0 ;
	__command_dump(cmd);

	sst_memset(request,0, sizeof(*request))	;
	sst_memset(param,0, sizeof(*param))	;

	request->type = TEE_SMC_SST_COMMAND ; 
	request->params = param ;

	request->params_size = 3 ; 

	request->params->index = i =0 ;
	param[0].type =  (uint32_t)TE_PARAM_TYPE_MEM_RW;
	param[0].u.Mem.base = cmd;
	param[0].u.Mem.phys =(void *)virt_to_phys(cmd);
	param[0].u.Mem.len= sizeof(*cmd);

	i ++;
	sst_memset(&param[i],0, sizeof(*param));
	param[i].index = i ;
	if( cmd->cmd_buf != NULL ){
		sst_memcpy(align_cmd_buf, cmd->cmd_buf,cmd->cmd_buf_len );
		param[i].type = TE_PARAM_TYPE_MEM_RO;
		param[i].u.Mem.base = align_cmd_buf;
		param[i].u.Mem.phys = (void *)virt_to_phys(align_cmd_buf);
		param[i].u.Mem.len= cmd->cmd_buf_len;

	}

	i ++;
	sst_memset(&param[i],0, sizeof(*param));
	param[i].index = i ;
	if( cmd->resp_buf != NULL ){
		param[i].type = (uint32_t)TE_PARAM_TYPE_MEM_RW;
		param[i].u.Mem.base = align_resp_buf;
		param[i].u.Mem.phys =(void *)virt_to_phys(align_resp_buf);
		param[i].u.Mem.len= cmd->resp_buf_len;
	}

	__request_dump(request);
	for(i =0 ;i< 3; i++)
		__param_dump(&param[i]);

	return 0;
}
Exemplo n.º 2
0
static int package_cmd(
		struct te_request * request, 
		struct te_oper_param  *param, 
		cmd_t *cmd
		)
{
	unsigned int i =0 ;

	__command_dump(cmd);

	char *cmd_buf, 
		 *resp_buf ;

	if(!align_cmd_buf || !align_resp_buf ){
		cmd_buf = malloc(SZ_8K);	
		resp_buf = malloc(SZ_8K);
		if(!cmd_buf || !resp_buf){
			printf("smc load sst out of memory\n");
			return -1 ;
		}

		align_cmd_buf = (char *)ALIGN_BUF((unsigned int)cmd_buf, SZ_4K ) ;
		align_resp_buf= (char *)ALIGN_BUF((unsigned int)resp_buf,SZ_4K) ;
	}


	memset(request,0, sizeof(*request))	;
	memset(param,0, sizeof(*param))	;

	request->type = TEE_SMC_SST_COMMAND ; 
	request->params = param ;
	request->params_size = 3 ; 
	request->params->index = i =0 ;

	param[0].type =  (uint32_t)TE_PARAM_TYPE_MEM_RW;
	param[0].u.Mem.base = cmd;
	param[0].u.Mem.phys =(void *)virt_to_phys(cmd);
	param[0].u.Mem.len= sizeof(*cmd);

	i ++;
	memset(&param[i],0, sizeof(*param));
	param[i].index = i ;
	if( cmd->cmd_buf != NULL ){
		memcpy(align_cmd_buf, cmd->cmd_buf,cmd->cmd_buf_len );
		param[i].type = TE_PARAM_TYPE_MEM_RO;
		param[i].u.Mem.base = align_cmd_buf;
		param[i].u.Mem.phys = (void *)virt_to_phys(align_cmd_buf);
		param[i].u.Mem.len= cmd->cmd_buf_len;

	}

	i ++;
	memset(&param[i],0, sizeof(*param));
	param[i].index = i ;
	if( cmd->resp_buf != NULL ){
		param[i].type = (uint32_t)TE_PARAM_TYPE_MEM_RW;
		param[i].u.Mem.base = align_resp_buf;
		param[i].u.Mem.phys =(void *)virt_to_phys(align_resp_buf);
		param[i].u.Mem.len= cmd->resp_buf_len;
	}

	__request_dump(request);
	for(i =0 ;i< 3; i++)
		__param_dump(&param[i]);

	return 0;
}