/**************************************************************************** Name : ncs_eda_startup Description : This routine creates a EDSv agent infrastructure to interface with EDSv service. Once the infrastructure is created from then on use_count is incremented for every startup request. Arguments : - NIL- Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ unsigned int ncs_eda_startup(void) { NCS_LIB_REQ_INFO lib_create; m_EDA_AGENT_LOCK; if (eda_use_count > 0) { /* Already created, so just increment the use_count */ eda_use_count++; m_EDA_AGENT_UNLOCK; return NCSCC_RC_SUCCESS; } /*** Init EDA ***/ memset(&lib_create, 0, sizeof(lib_create)); lib_create.i_op = NCS_LIB_REQ_CREATE; if (ncs_eda_lib_req(&lib_create) != NCSCC_RC_SUCCESS) { m_EDA_AGENT_UNLOCK; return m_LEAP_DBG_SINK(NCSCC_RC_FAILURE); } else { m_NCS_DBG_PRINTF("\nEDSV:EDA:ON"); eda_use_count = 1; } m_EDA_AGENT_UNLOCK; return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : ncs_eda_startup Description : This routine creates a EDSv agent infrastructure to interface with EDSv service. Once the infrastructure is created from then on use_count is incremented for every startup request. Arguments : - NIL- Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ unsigned int ncs_eda_startup(void) { NCS_LIB_REQ_INFO lib_create; TRACE_ENTER(); osaf_mutex_lock_ordie(&s_agent_startup_mutex); if (eda_use_count > 0) { /* Already created, so just increment the use_count */ eda_use_count++; osaf_mutex_unlock_ordie(&s_agent_startup_mutex); TRACE_LEAVE2("Library use count: %u", eda_use_count); return NCSCC_RC_SUCCESS; } /*** Init EDA ***/ memset(&lib_create, 0, sizeof(lib_create)); lib_create.i_op = NCS_LIB_REQ_CREATE; if (ncs_eda_lib_req(&lib_create) != NCSCC_RC_SUCCESS) { osaf_mutex_unlock_ordie(&s_agent_startup_mutex); return NCSCC_RC_FAILURE; } else { eda_use_count = 1; TRACE("EDA agent library initialized"); } osaf_mutex_unlock_ordie(&s_agent_startup_mutex); TRACE_LEAVE2("Library use count: %u", eda_use_count); return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : ncs_eda_shutdown Description : This routine destroys the EDSv agent infrastructure created to interface EDSv service. If the registered users are > 1, it just decrements the use_count. Arguments : - NIL - Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ unsigned int ncs_eda_shutdown(void) { uns32 rc = NCSCC_RC_SUCCESS; m_EDA_AGENT_LOCK; if (eda_use_count > 1) { /* Still users extis, so just decrement the use_count */ eda_use_count--; } else if (eda_use_count == 1) { NCS_LIB_REQ_INFO lib_destroy; memset(&lib_destroy, 0, sizeof(lib_destroy)); lib_destroy.i_op = NCS_LIB_REQ_DESTROY; rc = ncs_eda_lib_req(&lib_destroy); eda_use_count = 0; } m_EDA_AGENT_UNLOCK; return rc; }
/**************************************************************************** Name : ncs_eda_shutdown Description : This routine destroys the EDSv agent infrastructure created to interface EDSv service. If the registered users are > 1, it just decrements the use_count. Arguments : - NIL - Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ unsigned int ncs_eda_shutdown(void) { uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); osaf_mutex_lock_ordie(&s_agent_startup_mutex); if (eda_use_count > 1) { /* Still users extis, so just decrement the use_count */ eda_use_count--; } else if (eda_use_count == 1) { NCS_LIB_REQ_INFO lib_destroy; memset(&lib_destroy, 0, sizeof(lib_destroy)); lib_destroy.i_op = NCS_LIB_REQ_DESTROY; rc = ncs_eda_lib_req(&lib_destroy); eda_use_count = 0; } osaf_mutex_unlock_ordie(&s_agent_startup_mutex); TRACE_LEAVE2("Library use count: %u", eda_use_count); return rc; }