/* *********************
 * set params in ntw
 * *********************/
tee_stat_t tee_msgm_set_params(tee_msgm_t msgm, tee_msg_op_info_t *params)
{
	tee_msgm_ntw_struct *ntw_handle = NULL;
	tee_stat_t set_params_stat = TEEC_SUCCESS;
	uint32_t times = PARAM_NUMBERS, idx = 0, type = TEEC_NONE;

	OSA_ASSERT((msgm && params));
	ntw_handle = (tee_msgm_ntw_struct *) msgm;
	OSA_ASSERT(IS_MAGIC_VALID(ntw_handle->magic));
	while (times--) {
		type = TEEC_PARAM_TYPE_GET(params->paramTypes, idx);
		if (!IS_PARAMTYPES_TYPE_VALID(type)) {
			TZDD_DBG("tee_msgm_set_params: bad paramsTypes\n");
			return TEEC_ERROR_BAD_PARAMETERS;
		}
		if (IS_TYPE_MEMREF(type)) {
			if (!IS_NTW_MEM_FLAG_VALID(params->params[idx].memref.parent->flags)) {
				TZDD_DBG("tee_msgm_set_params: un-compatible arg\n");
				return TEEC_ERROR_BAD_PARAMETERS;
			}
		}
		idx++;
	}
	set_params_stat = set_params(msgm, params);
	return set_params_stat;
}
Esempio n. 2
0
/******************************************************************************
*
* Name: nci_data_create
*
* Description: NCI DATA main module initialization. Called by nci_create.
*			  Allocate memory and initialize parameters.
*			  Register notification callbacks.
*			  Register all connections to separate queues in OSA.
*
* Input: 	h_nci - handle to NCI object
*		h_osa - handle to OSA object
*		f_rx_ind_cb -callback function to be called when receiving data per connection
*		f_tx_done_cb -callback function to be called when packet transferring (to NFCC) is completed (when transport send function is done)
*		h_data_cb - handle for the NCI received Data and transmission complete indication callbacks
*
* Output: None
*
* Return: handle to created data main object
*
*******************************************************************************/
nfc_handle_t nci_data_create(nfc_handle_t h_nci, nfc_handle_t h_osa, data_cb_f f_rx_ind_cb, data_cb_f f_tx_done_cb, nfc_handle_t h_data_cb)
{
	nfc_u32 i;
	struct nci_data_context *p_ctx = (struct nci_data_context *)osa_mem_alloc(sizeof(struct nci_data_context));
	OSA_ASSERT(p_ctx);

	p_ctx->h_nci = h_nci;
	p_ctx->h_osa = h_osa;
	p_ctx->f_rx_ind_cb = f_rx_ind_cb;
	p_ctx->f_tx_done_cb = f_tx_done_cb;
	p_ctx->h_data_cb = h_data_cb;
	p_ctx->max_logical_connections = 0;

	/* register to relevent notifications */
	nci_register_ntf_cb(p_ctx->h_nci, E_NCI_NTF_CORE_CONN_CREDITS, static_conn_credit_ntf, p_ctx);
	nci_register_ntf_cb(p_ctx->h_nci, E_NCI_NTF_RF_ACTIVATE, static_activate_ntf, p_ctx);
	nci_register_ntf_cb(p_ctx->h_nci, E_NCI_NTF_RF_DEACTIVATE, static_deactivate_ntf, p_ctx);
	nci_register_ntf_cb(p_ctx->h_nci, E_NCI_NTF_CORE_CONN_CLOSE, static_conn_close_ntf, p_ctx);

	p_ctx->p_conn_tbl = (struct nci_conn *)osa_mem_alloc(MAX_LOGICAL_CONNS * sizeof(struct nci_conn));
	OSA_ASSERT(p_ctx->p_conn_tbl);

	for(i=0; i<MAX_LOGICAL_CONNS; i++)
	{
		osa_taskq_register(p_ctx->h_osa, (nfc_u8)(E_NCI_Q_DATA+i), nci_data_cb, p_ctx->h_nci, 0);
		p_ctx->p_conn_tbl[i].instance = 0;
		p_ctx->p_conn_tbl[i].b_active_conn = NCI_CONNECTION_DISABLED;
		p_ctx->p_conn_tbl[i].h_rx_fragments = NULL;
	}
	return p_ctx;
}
Esempio n. 3
0
/******************************************************************************
*
* Name: action_evt_core_set_config_rsp_ok
*
* Description: Called by NCI core when event EVT_CORE_SET_CONFIG_RSP_OK occurs.
*
* Input: 	h_rf_mgmt - handle to RF main object
*		curr_state - event to handle
*
* Output: None
*
* Return: Next state in SM according to current state and event
*
*******************************************************************************/
nfc_u32 action_evt_core_set_config_rsp_ok(nfc_handle_t h_rf_mgmt, nfc_u32 curr_state)
{
	struct ncix_rf_mgmt *p_rf_mgmt = (struct ncix_rf_mgmt *)h_rf_mgmt;
	nci_status_e status = NCI_STATUS_OK;
		nfc_u32 next_state = curr_state;

	switch(curr_state)
	{
		case E_STATE_WAIT_4_CORE_SET_CONFIG_RSP:
		{
			//sanity check - we are not supposed to get here if c or r = 0
			if((p_rf_mgmt->card_proto_mask != 0) || (p_rf_mgmt->reader_proto_mask != 0))
			{
				status = static_send_discover(p_rf_mgmt);
				next_state = E_STATE_ACTIVATING;
			}
			else
			{
				OSA_ASSERT(0);
			}

			break;
		}

		default:
		{
			OSA_ASSERT(0);
		}
	}

	return 	next_state;
}
Esempio n. 4
0
/******************************************************************************
*
* Name: nci_data_create
*
* Description: NCI DATA main module initialization. Called by nci_create.
*			  Allocate memory and initialize parameters.
*			  Register notification callbacks.
*			  Register all connections to separate queues in OSA.
*
* Input: 	h_nci - handle to NCI object
*		h_osa - handle to OSA object
*		f_rx_ind_cb -callback function to be called when receiving data per connection
*		f_tx_done_cb -callback function to be called when packet transferring (to NFCC) is completed (when transport send function is done)
*		h_data_cb - handle for the NCI received Data and transmission complete indication callbacks
*
* Output: None
*
* Return: handle to created data main object
*
*******************************************************************************/
nfc_handle_t nci_data_create(nfc_handle_t h_nci, nfc_handle_t h_osa, data_cb_f f_rx_ind_cb, data_cb_f f_tx_done_cb, nfc_handle_t h_data_cb)
{
	nfc_u8 i;
	struct nci_data_context *p_ctx = (struct nci_data_context *)osa_mem_alloc(sizeof(struct nci_data_context));
	OSA_ASSERT(p_ctx);

	osa_report(INFORMATION, ("DATA nci_data_create"));

	p_ctx->h_nci = h_nci;
	p_ctx->h_osa = h_osa;
	p_ctx->f_rx_ind_cb = f_rx_ind_cb;
	p_ctx->f_tx_done_cb = f_tx_done_cb;
	p_ctx->h_data_cb = h_data_cb;
	p_ctx->max_logical_connections = 0;

	p_ctx->p_conn_tbl = (struct nci_conn *)osa_mem_alloc(MAX_LOGICAL_CONNS * sizeof(struct nci_conn));
	OSA_ASSERT(p_ctx->p_conn_tbl);

	for(i=0; i<MAX_LOGICAL_CONNS; i++)
	{
		osa_taskq_register(p_ctx->h_osa, (nfc_u8)(E_NCI_Q_DATA+i), nci_data_cb, p_ctx->h_nci, 0);
		p_ctx->p_conn_tbl[i].instance = 0;
		p_ctx->p_conn_tbl[i].b_active_conn = NCI_CONNECTION_DISABLED;
		p_ctx->p_conn_tbl[i].h_rx_fragments = NULL;
		p_ctx->p_conn_tbl[i].h_tx_timer = NULL;
		p_ctx->p_conn_tbl[i].conn_id = i;
		p_ctx->p_conn_tbl[i].p_owner = p_ctx;
	}
	return p_ctx;
}
Esempio n. 5
0
void osa_list_add_tail(struct osa_list *entry, struct osa_list *head)
{
	OSA_ASSERT(entry);
	OSA_ASSERT(head);

	entry->next = head;
	entry->prev = head->prev;
	head->prev->next = entry;
	head->prev = entry;
}
/* **********************
 * update_params in ntw
 * **********************/
tee_stat_t tee_msgm_update_params(tee_msgm_t msgm, tee_msg_op_info_t *params)
{
	tee_msgm_ntw_struct *ntw_handle = NULL;
	tee_stat_t update_params_stat = TEEC_SUCCESS;

	OSA_ASSERT((msgm && params));
	ntw_handle = (tee_msgm_ntw_struct *) msgm;
	OSA_ASSERT(IS_MAGIC_VALID(ntw_handle->magic));

	update_params_stat = update_params(msgm, params);
	return update_params_stat;
}
/* ****************
 * set ret in ntw
 * ****************/
tee_stat_t tee_msgm_set_ret(tee_msgm_t msgm, void *arg)
{
	tee_msgm_ntw_struct *ntw_handle = NULL;
	tee_stat_t set_ret_stat = TEEC_SUCCESS;

	OSA_ASSERT((arg && msgm));
	ntw_handle = (tee_msgm_ntw_struct *) msgm;
	OSA_ASSERT(IS_MAGIC_VALID(ntw_handle->magic));

	set_ret_stat = ntw_handle->op->set_ret(msgm, arg);
	return set_ret_stat;
}
/* ******************************
 * will not destroy the msg buf
 * *******************************/
void tee_msgm_destroy_inst(tee_msgm_t msgm)
{
	tee_msgm_ntw_struct *ntw_handle = NULL;

	OSA_ASSERT(msgm);
	ntw_handle = (tee_msgm_ntw_struct *) msgm;
	OSA_ASSERT(IS_MAGIC_VALID(ntw_handle->magic));
	CLEANUP_MAGIC(ntw_handle->magic);
	osa_kmem_free(ntw_handle);
	ntw_handle = NULL;
	return;
}
/* *****************
 * get ret in ntw
 * *****************/
tee_stat_t tee_msgm_get_ret(tee_msgm_t msgm, void *arg)
{
	tee_msgm_ntw_struct *ntw_handle = NULL;
	tee_stat_t get_ret_stat = TEEC_SUCCESS;

	OSA_ASSERT(msgm);
	ntw_handle = (tee_msgm_ntw_struct *) msgm;
	OSA_ASSERT(IS_MAGIC_VALID(ntw_handle->magic));

	if (NULL != arg)
		get_ret_stat = ntw_handle->op->get_ret(msgm, arg);

	return get_ret_stat;
}
Esempio n. 10
0
/******************************************************************************
*
* Name: action_evt_enable_c
*
* Description: Called by NCI core when event EVT_ENABLE_C occurs.
*
* Input: 	h_rf_mgmt - handle to RF Management object
*		curr_state - event to handle
*
* Output: None
*
* Return: Next state in SM according to current state and event
*
*******************************************************************************/
nfc_u32 action_evt_enable_c(nfc_handle_t h_rf_mgmt, nfc_u32 curr_state)
{
	struct ncix_rf_mgmt *p_rf_mgmt = (struct ncix_rf_mgmt *)h_rf_mgmt;
	nci_status_e status = NCI_STATUS_OK;
	nci_cmd_param_u	cmd;
	nfc_u32 next_state = curr_state;

	switch(curr_state)
	{
		case E_STATE_IDLE:
		{
			//sanity check - we are not supposed to get here if c or r = 0
			if((p_rf_mgmt->card_proto_mask != 0) || (p_rf_mgmt->reader_proto_mask != 0))
			{
				if(p_rf_mgmt->card_proto_mask != 0)
				{
					status = static_send_core_set_config(p_rf_mgmt);
					next_state = E_STATE_WAIT_4_CORE_SET_CONFIG_RSP;
				}
				else
				{
					status = static_send_discover(p_rf_mgmt);
					next_state = E_STATE_ACTIVATING;
				}
			}
			else
			{
				OSA_ASSERT(0);
			}

			break;
		}
		case E_STATE_ACTIVE:
		{
			cmd.deactivate.type = NCI_DEACTIVATE_TYPE_IDLE_MODE;
			status = nci_send_cmd(p_rf_mgmt->h_nci, NCI_OPCODE_RF_DEACTIVATE_CMD, &cmd, NULL, 0, NULL, NULL);
			next_state = E_STATE_DE_ACTIVATING;
			break;
		}

		default:
		{
			OSA_ASSERT(0);
		}
	}

	return 	next_state;
}
Esempio n. 11
0
/******************************************************************************
*
* Name: nci_create
*
* Description: Create NCI module - this will involve only SW init (context allocation, callbacks registration)
 * and registration of callback for incoming data. Returns handle to created NCI object
*
* Input: 	h_caller - caller handle (to be used with data rx and tx callbacks)
* 		h_osa - os context
*		f_rx_ind_cb - rx indication callback (for received data packets)
*		f_tx_done_cb - to be called when packet transferring (to NFCC) is completed (when transport send function is done)
*
* Output: None
*
* Return: Success - handle to created NCI object
*		  Failure - NULL
*
*******************************************************************************/
nfc_handle_t nci_create(nfc_handle_t h_data_cb,
					nfc_handle_t h_osa,
					data_cb_f f_rx_ind_cb,
					data_cb_f f_tx_done_cb)
{
	struct nci_context *p_nci = (struct nci_context*)osa_mem_alloc(sizeof(struct nci_context));
	OSA_ASSERT(p_nci);
	osa_mem_zero(p_nci, sizeof(struct nci_context));

	if(p_nci)
	{
		p_nci->h_osa = h_osa;
		p_nci->cmd_timeout = NCI_COMMAND_TIMEOUT; /* default is 1 second watchdog */
		p_nci->h_ncidev = NULL;

		p_nci->h_ncix = ncix_create(p_nci, h_osa);
		p_nci->h_data = nci_data_create(p_nci, h_osa, f_rx_ind_cb, f_tx_done_cb, h_data_cb);
		p_nci->h_nci_rf_sm = nci_rf_sm_create(p_nci);
	}

	gIsNCIActive = NFC_TRUE;

	osa_report(INFORMATION, ("NCI create 0x%x", p_nci));

	return (nfc_handle_t)p_nci;
}
Esempio n. 12
0
void osa_list_del(struct osa_list *entry)
{
	OSA_ASSERT(entry);

	entry->prev->next = entry->next;
	entry->next->prev = entry->prev;
}
Esempio n. 13
0
/******************************************************************************
*
* Name: nci_unregister_ntf_cb
*
* Description: Un-Register a callback to specific notification
*
* Input: 	h_nci -handle to NCI object
*		ntf_id - Notification id from nci_ntf_e enum
*		f_ntf_cb - callback function to be invoked upon notification reception
*
* Output: None
*
* Return: None
*
*******************************************************************************/
void nci_unregister_ntf_cb(nfc_handle_t h_nci, nci_ntf_e ntf_id,
						 ntf_cb_f f_ntf_cb)
{
	struct nci_context *p_nci = (struct nci_context*)h_nci;
	struct nci_ntf *p_prev = 0;
	struct nci_ntf *p_ntf = p_nci->p_ntf_tbl[ntf_id];

	while(p_ntf)
	{
		if(p_ntf->f_ntf_cb == f_ntf_cb)
		{
			if(p_prev)
			{
				p_prev->p_next = p_ntf->p_next;
			}
			else
			{
				p_nci->p_ntf_tbl[ntf_id] = p_ntf->p_next;
			}
			osa_mem_free(p_ntf);
			return;
		}

		p_prev = p_ntf;
		p_ntf = p_ntf->p_next;
	}
	OSA_ASSERT(0);
}
Esempio n. 14
0
/******************************************************************************
*
* Name: nci_data_receive
*
* Description: Function is called (by nci_rx_cb) when receiving fragment data packet.
*			  The fragment is added to a data connection's frgament queue.
*			  If this is the last fragment than memory is allocated, all fragments are
*			  reassembed and copied to it and it's passed to higher level by calling callback routine.
*			  Allocated memory is freed.
*
* Input: 	h_data - handle to NCI DATA context object
*		conn_id - Connection ID
*		p_buff - buffer containing fragment data received
*		b_last_fragment -If not 0 than it's last fragment
*
* Output: None
*
* Return: None
*
*******************************************************************************/
void nci_data_receive (nfc_handle_t h_data, nfc_u8 conn_id, struct nci_buff *p_buff, nfc_u8 b_last_fragment)
{
	struct nci_data_context *p_ctx = (struct nci_data_context *)h_data;
	struct nci_conn *p_conn = &p_ctx->p_conn_tbl[conn_id];
	nfc_u32 pending_rx_length;
	nfc_u8 *p_rx_data;

	/* Append incoming buffer to Rx_buff and increment bytes counter*/
	pending_rx_length = static_add_rx_fragment(p_ctx, conn_id, p_buff);

	/* for the last fragment - serialize (copy) fragments into single buffer and send to user */
	if(b_last_fragment)
	{
		if(0 != p_conn->h_tx_timer)
		{
			osa_timer_stop(p_conn->h_tx_timer);
			p_conn->h_tx_timer = NULL;
		}

		p_rx_data = (nfc_u8 *)osa_mem_alloc(pending_rx_length);
		OSA_ASSERT(p_rx_data);
		static_get_rx_packet(p_ctx, conn_id, p_rx_data);
		p_ctx->f_rx_ind_cb(p_ctx->h_data_cb, conn_id, p_rx_data, pending_rx_length, NCI_STATUS_OK);
		osa_mem_free(p_rx_data);
	}
}
Esempio n. 15
0
/******************************************************************************
*
* Name: action_evt_disable_c
*
* Description: Called by NCI core when event EVT_DISABLE_C occurs.
*
* Input: 	h_rf_mgmt - handle to RF Management object
*		curr_state - event to handle
*
* Output: None
*
* Return: Next state in SM according to current state and event
*
*******************************************************************************/
nfc_u32 action_evt_disable_c(nfc_handle_t h_rf_mgmt, nfc_u32 curr_state)
{
	struct ncix_rf_mgmt *p_rf_mgmt = (struct ncix_rf_mgmt *)h_rf_mgmt;
	nci_status_e status = NCI_STATUS_OK;
	nci_cmd_param_u	cmd;
	nfc_u32 next_state = curr_state;

	p_rf_mgmt->card_proto_mask = 0;
	p_rf_mgmt->reader_proto_mask = 0;

	switch(curr_state)
	{
		case E_STATE_IDLE:
			{
				ncix_op_complete(p_rf_mgmt->h_ncix, NCI_STATUS_OK);
				next_state = E_STATE_IDLE;
				break;
			}
		case E_STATE_ACTIVE:
		{
			cmd.deactivate.type = NCI_DEACTIVATE_TYPE_IDLE_MODE;
			status = nci_send_cmd(p_rf_mgmt->h_nci, NCI_OPCODE_RF_DEACTIVATE_CMD, &cmd, NULL, 0, NULL, NULL);
			next_state = E_STATE_DE_ACTIVATING;
			break;
		}

		default:
		{
			OSA_ASSERT(0);
		}
	}

	return 	next_state;
}
Esempio n. 16
0
void nci_unregister_vendor_specific_ntf_cb(	nfc_handle_t h_nci, nfc_u16 opcode,	vendor_specific_cb_f f_ntf_cb)
{
	struct nci_context *p_nci = (struct nci_context*)h_nci;
	nci_vendor_specific_ntf *p_prev = 0;
	nfc_u8 ntf_id = NCI_OPCODE_OID_GET((nfc_u8*)&opcode);
	nci_vendor_specific_ntf *p_ntf = p_nci->p_vendor_specific_ntf_tbl[ntf_id];

	while(p_ntf)
	{
		if(p_ntf->vendor_specific_ntf_cb == f_ntf_cb)
		{
			if(p_prev)
			{
				p_prev->p_next = p_ntf->p_next;
			}
			else
			{
				p_nci->p_vendor_specific_ntf_tbl[ntf_id] = p_ntf->p_next;
			}
			osa_mem_free(p_ntf);
			return;
		}

		p_prev = p_ntf;
		p_ntf = p_ntf->p_next;
	}
	OSA_ASSERT(0);
}
Esempio n. 17
0
void osa_list_init_head(struct osa_list *head)
{
	OSA_ASSERT(head);

	head->next = head;
	head->prev = head;
}
Esempio n. 18
0
tee_stat_t tee_memm_get_user_mem(tee_memm_ss_t tee_memm_ss,
				 void __user *virt, uint32_t size,
				 void __kernel **kvirt)
{
	ulong_t start = (ulong_t) virt;
	ulong_t end = (start + size + PAGE_SIZE - 1) & PAGE_MASK;

	struct vm_area_struct *vma;
	ulong_t cur = start & PAGE_MASK, cur_end;
	int32_t err, write;
	tee_memm_handle_t *tee_memm_handle;

	OSA_ASSERT(virt && tee_memm_ss);

	tee_memm_handle = (tee_memm_handle_t *) tee_memm_ss;
	if (!(IS_MEMM_MAGIC_VALID(tee_memm_handle->magic)))
		OSA_ASSERT(0);

	down_read(&current->mm->mmap_sem);

	do {
		vma = find_vma(current->mm, cur);
		if (!vma) {
			up_read(&current->mm->mmap_sem);
			*kvirt = NULL;
			return TEEC_SUCCESS;
		}
		cur_end = ((end <= vma->vm_end) ? end : vma->vm_end);

		/* this vma is NOT mmap-ed and pfn-direct mapped */
		if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) {
			write = ((vma->vm_flags & VM_WRITE) != 0);
			/* NOTE: no get_page since overall sync-flow */
			err = get_user_pages(current, current->mm,
					     (ulong_t) cur,
					     (cur_end - cur) >> PAGE_SHIFT,
					     write, 0, NULL, NULL);
			if (err < 0) {
				up_read(&current->mm->mmap_sem);
				*kvirt = NULL;
				return TEEC_SUCCESS;
			}
		}

		cur = cur_end;
	} while (cur_end < end);
/* ******************
 * get cmd in ntw
 * *******************/
tee_stat_t tee_msgm_get_cmd(tee_msgm_t msgm, tee_cmd_t *cmd, void *arg)
{
	tee_msgm_ntw_struct *ntw_handle = NULL;
	tee_stat_t get_cmd_stat = TEEC_SUCCESS;

	OSA_ASSERT(msgm);
	OSA_ASSERT((cmd || arg));
	ntw_handle = (tee_msgm_ntw_struct *) msgm;
	OSA_ASSERT(IS_MAGIC_VALID(ntw_handle->magic));

	if (NULL != cmd)
		*cmd = ntw_handle->ntw_cmd->cmd;

	if (NULL != arg)
		get_cmd_stat = ntw_handle->op->get_cmd(msgm, arg);

	return get_cmd_stat;
}
Esempio n. 20
0
/******************************************************************************
*
* Name: nci_data_init_conns
*
* Description: Initiate NCI Connections context according to received
*			  max_logical_connections (within init response).
*
* Input: 	h_data - handle to NCI DATA context object
*		max_logical_connections - number of logical connections
*
* Output: None
*
* Return: None
*
*******************************************************************************/
void nci_data_init_conns(nfc_handle_t h_data, nfc_u8 max_logical_connections)
{
	struct nci_data_context *p_ctx = (struct nci_data_context *)h_data;

	OSA_ASSERT(max_logical_connections <= MAX_LOGICAL_CONNS);

	/* Initiate connections context */
	p_ctx->max_logical_connections = max_logical_connections;
}
Esempio n. 21
0
tee_stat_t tee_memm_parse_phys_pages(tee_memm_ss_t tee_memm_ss,
				     void *virt, uint32_t length,
				     tee_mem_page_t *pages, uint32_t pages_num)
{
	tee_memm_handle_t *tee_memm_handle;

	if (!tee_memm_ss || !virt || !pages)
		OSA_ASSERT(0);

	tee_memm_handle = (tee_memm_handle_t *) tee_memm_ss;
	if (!(IS_MEMM_MAGIC_VALID(tee_memm_handle->magic)))
		OSA_ASSERT(0);

	memcpy(pages, tee_memm_handle->page_list_buf,
		tee_memm_handle->page_list_size);

	return TEEC_SUCCESS;
}
Esempio n. 22
0
void tee_cm_get_msgm_head(void *msg_head)
{
	int32_t idx = IN_RD_IDX;

	OSA_ASSERT(msg_head);

	_in_read((int8_t *)msg_head, sizeof(tee_msg_head_t), &idx);

	return;
}
/* ********************
 * set cmd in ntw
 * ********************/
tee_stat_t tee_msgm_set_cmd(tee_msgm_t msgm, tee_cmd_t cmd, void *arg)
{
	tee_msgm_ntw_struct *ntw_handle = NULL;
	tee_stat_t set_cmd_stat = TEEC_SUCCESS;

	OSA_ASSERT(msgm);
	if (TEE_CMD_INVALID == cmd) {
		TZDD_DBG("cmd TEE_CMD_INVALID\n");
		return set_cmd_stat;
	}
	ntw_handle = (tee_msgm_ntw_struct *) msgm;
	OSA_ASSERT(IS_MAGIC_VALID(ntw_handle->magic));
	INIT_CMD_MAGIC(ntw_handle->ntw_cmd->magic);

	ntw_handle->ntw_cmd->cmd = cmd;
	if (NULL != arg)
		set_cmd_stat = ntw_handle->op->set_cmd(msgm, arg);

	return set_cmd_stat;
}
Esempio n. 24
0
/******************************************************************************
*
* Name: nci_register_ntf_cb
*
* Description: Register a callback to specific notification
*
* Input: 	h_nci -handle to NCI object
*		ntf_id - Notification id from nci_ntf_e enum
*		f_ntf_cb - callback function to be invoked upon notification reception
*		h_ntf_cb - Optional parameter that is passed to f_rsp_cb, if invoked (caller object handle)
*
* Output: None
*
* Return: None
*
*******************************************************************************/
void nci_register_ntf_cb(nfc_handle_t h_nci, nci_ntf_e ntf_id,
						 ntf_cb_f f_ntf_cb, nfc_handle_t h_ntf_cb)
{
	struct nci_context *p_nci = (struct nci_context*)h_nci;
	struct nci_ntf *p_ntf = (struct nci_ntf *)osa_mem_alloc(sizeof(struct nci_ntf));

	OSA_ASSERT(p_ntf);
	p_ntf->f_ntf_cb = f_ntf_cb;
	p_ntf->h_ntf_cb = h_ntf_cb;
	p_ntf->p_next = p_nci->p_ntf_tbl[ntf_id];
	p_nci->p_ntf_tbl[ntf_id] = p_ntf;
}
Esempio n. 25
0
/******************************************************************************
*
* Name: static_send_core_set_config
*
* Description: Send CORE_SET_CONFIG command - according to card protocol type
*			  configure TLV structure and send it.
*			  NOTE: this function assumes that p_rf_mgmt->card_proto_mask != 0. This
*			  verfication should be done by calling task.
*
* Input: 	p_rf_mgmt - handle to RF Management object
*
* Output: None
*
* Return: Success -NFC_RES_OK
*		  Failure -NFC_RES_ERROR
*
*******************************************************************************/
static nfc_status static_send_core_set_config(struct ncix_rf_mgmt *p_rf_mgmt)
{
	nci_status_e status = NCI_STATUS_OK;
	nfc_u8 la_proto = 0;
	nfc_u8 lb_proto = 0;
	nfc_u8 lf_proto = 0;
	struct nci_tlv tlv[NCI_MAX_TLV_IN_CMD];
	nfc_u8 index = 0;
	struct nci_cmd_core_set_config core_set_config;

	/* set la_protocol  - configure as card */
	if(p_rf_mgmt->card_proto_mask & NAL_PROTOCOL_CARD_P2P_TARGET)
	{
		if(bUseP2PFTech == 0)
			la_proto |= NCI_CFG_TYPE_LA_PROTOCOL_TYPE_NFC_DEP;
		else
			lf_proto |= NCI_CFG_TYPE_LF_PROTOCOL_TYPE_NFC_DEP;
	}

	if(p_rf_mgmt->card_proto_mask & NAL_PROTOCOL_CARD_ISO_14443_4_A)
	{
		la_proto |= NCI_CFG_TYPE_LA_PROTOCOL_TYPE_ISO_DEP;
	}

	if(p_rf_mgmt->card_proto_mask & NAL_PROTOCOL_CARD_ISO_14443_4_B)
	{
		lb_proto |= NCI_CFG_TYPE_LB_PROTOCOL_TYPE_ISO_DEP;
	}

	tlv[index].type = NCI_CFG_TYPE_LA_PROTOCOL_TYPE;
	tlv[index].length = NCI_CFG_PROTOCOL_TYPE_SIZE;
	tlv[index++].p_value = &la_proto;

	tlv[index].type = NCI_CFG_TYPE_LB_PROTOCOL_TYPE;
	tlv[index].length = NCI_CFG_PROTOCOL_TYPE_SIZE;
	tlv[index++].p_value = &lb_proto;

	tlv[index].type = NCI_CFG_TYPE_LF_PROTOCOL_TYPE1;
	tlv[index].length = NCI_CFG_PROTOCOL_TYPE_SIZE;
	tlv[index++].p_value = &lf_proto;

	core_set_config.num_of_tlvs = index;
	OSA_ASSERT(core_set_config.num_of_tlvs > 0);
	core_set_config.p_tlv = tlv;

	status = nci_send_cmd(p_rf_mgmt->h_nci, NCI_OPCODE_CORE_SET_CONFIG_CMD,
				(nci_cmd_param_u *)&core_set_config, NULL, 0, hndlr_core_set_config_rsp, p_rf_mgmt);

	return (status == NCI_STATUS_OK) ? NFC_RES_OK:NFC_RES_ERROR;
}
Esempio n. 26
0
/******************************************************************************
*
* Name: hndlr_op_rf_enable
*
* Description: Callback that is installed by RF main module creation. It will be
*			  invoked by RF operation callback in result of RF_ENABLE request.
*
* Input: 	h_rf_mgmt - handle to RF main object
*		pu_param - NCI operation structure
*
* Output: None
*
* Return: None
*
*******************************************************************************/
void hndlr_op_rf_enable(nfc_handle_t h_rf_mgmt, op_param_u *pu_param)
{
	struct ncix_rf_mgmt *p_rf_mgmt = (struct ncix_rf_mgmt *)h_rf_mgmt;
	if(pu_param)
	{
		p_rf_mgmt->card_proto_mask = pu_param->rf_enable.ce_bit_mask;
		p_rf_mgmt->reader_proto_mask = pu_param->rf_enable.rw_bit_mask;
		ncix_sm_process_evt(p_rf_mgmt->h_sm, E_EVT_ENABLE_C);
	}
	else
	{
		OSA_ASSERT(0);
	}
}
Esempio n. 27
0
/******************************************************************************
*
* Name: static_fc_decrement_credit
*
* Description: Decrement flow-control credit (by 1) per-connection upon sending
*			  of frame. If new credit balance is now 0 than perform flow control -
*			  block connection queue.
*
* Input:	p_ctx - handle to NCI DATA context object
*		conn_id - Connection ID
*
* Output: None
*
* Return: None
*
*******************************************************************************/
static void static_fc_decrement_credit(struct nci_data_context *p_ctx, nfc_u8 conn_id)
{
	struct nci_conn *p_conn = &p_ctx->p_conn_tbl[conn_id];

	/* connection queue callback should be invoked only when credits are available
		(see flow control handling, below) */
	OSA_ASSERT(p_conn->current_fc_credit > 0);

	/* FLow Control Handling - Block connection queue when credit is exhausted */
	if(--p_conn->current_fc_credit == 0)
	{
		disable_conn_taskq(p_ctx, conn_id);
	}
}
Esempio n. 28
0
char* get_tlv_str(nfc_u8 type)
{
	nfc_s8 i = 0;

	for(i = 0; i < dbg_tlv_data_num_recs; i++)
	{
		if(dbg_tlv_data[i].type == type)
			return dbg_tlv_data[i].str;
	}

	OSA_ASSERT(0);

	return NULL;
}
Esempio n. 29
0
/**
 * \fn     que_Enqueue
 * \brief  Enqueue an item
 *
 * Enqueue an item at the queue's tail
 *
 * \note
 * \param  h_que   - The queue object
 * \param  h_item  - Handle to queued item
 * \return RES_COMPLETE if item was queued, or RES_ERROR if not queued due to overflow
 * \sa     que_Dequeue, que_Requeue
 */
nfc_status que_enqueue (nfc_handle_t h_que, nfc_handle_t h_item)
{
	struct queue	*p_que = (struct queue *)h_que;
	struct q_item	*q_item = 	(struct q_item *)osa_mem_alloc(sizeof(struct q_item));

	OSA_ASSERT(q_item);

	q_item->h_item = h_item;

	/* Enqueue item to the queue tail and increment items counter */
	dll_insert_tail (&p_que->head, &q_item->head);
	p_que->u_count++;
	return NFC_RES_COMPLETE;

}
Esempio n. 30
0
tee_cm_stat tee_cm_init(void)
{
	tee_cm_stat ret = TEEC_SUCCESS;
#ifdef TEE_PERF_MEASURE
	uint32_t *perf_buffer;
#endif
	/* map RB */
	_g_phys_rb = _read_rb_phys_addr();
	_g_size_rb = _read_rb_size();
	_g_virt_rb =
	    (uint32_t) ioremap_nocache(_g_phys_rb, (uint32_t) (_g_size_rb));
	printk(KERN_ERR "remap rb to 0x%x\n", _g_virt_rb);

	/* map RC */
	_g_phys_rc = _read_rc_phys_addr();
	_g_size_rc = _read_rc_size();
	_g_virt_rc =
	    (uint32_t) ioremap_nocache(_g_phys_rc, (uint32_t) (_g_size_rc));
	printk(KERN_ERR "remap rc to 0x%x\n", _g_virt_rc);

#ifdef TEE_PERF_MEASURE
	/* map permance log buffer */
	perf_buffer =
	    (uint32_t *) ioremap_nocache(PERF_BUF_ADDR, PERF_BUF_SIZE);
	tee_perf_init((uint32_t *) perf_buffer);
	printk(KERN_ERR
		"remap perf log buffer to 0x%x\n",
		(uint32_t) perf_buffer);
#endif

	in_header = (void *)_g_virt_rb;
	in_buf = (void *)((uint32_t) in_header + sizeof(cm_index_header_t));
	in_buf_size = _g_size_rb / 2 - sizeof(cm_index_header_t);

	OSA_ASSERT(_g_virt_rc);
	memset((void *)_g_virt_rc, 0, _g_size_rc);
	out_header = (void *)_g_virt_rc;
	out_buf = (void *)((uint32_t) out_header + sizeof(cm_index_header_t));
	out_buf_size = _g_size_rc / 2 - sizeof(cm_index_header_t);

#ifdef TEE_DEBUG_ENALBE_PROC_FS_LOG
	tee_dbg_log_init((uint32_t) in_buf + in_buf_size,
			 (uint32_t) out_buf + out_buf_size);
#endif

	return ret;
}