/**************************************************************************** Name : ava_lib_req Description : This routine is exported to the external entities & is used to create & destroy the AvA library. Arguments : req_info - ptr to the request info Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ uns32 ava_lib_req(NCS_LIB_REQ_INFO *req_info) { uns32 rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); switch (req_info->i_op) { case NCS_LIB_REQ_CREATE: rc = ava_create(&req_info->info.create); if (NCSCC_RC_SUCCESS == rc) { TRACE_1("AVA creation success"); } else { TRACE_4("AVA creation failed"); } break; case NCS_LIB_REQ_DESTROY: ava_destroy(&req_info->info.destroy); if (NCSCC_RC_SUCCESS == rc) { TRACE_1("AVA creation success"); } else { TRACE_4("AVA creation failed"); } break; default: break; } TRACE_LEAVE(); return rc; }
bool Frontend::run() { TRACE_1("Getting ELAB\n"); this->elab = new SCElab(llvmMod); this->elab->complete(); this->scjit = new SCJit(llvmMod, elab); this->sccfactory = new SCCFactory(scjit); TRACE_1("Analyzing code\n"); if (this->elab->getProcesses()->empty()) { TRACE_1("WARNING: No process found.\n"); } TRACE_4("NB of functions BEFORE inlining : " << llvmMod->size() << "\n"); if (this->inlineFunctions) { this->inlineProcessFct(); } TRACE_4("NB of functions after inlining : " << llvmMod->size() << "\n"); this->handleConstruct_and_GV(); TRACE_4("NB of functions after frontend : " << llvmMod->size() << "\n"); return false; }
/**************************************************************************** Name : eda_enc_chan_unlink_msg Description : This routine encodes a chan unlink API msg Arguments : NCS_UBAID *msg, EDSV_MSG *msg Return Values : uint32_t Notes : None. ******************************************************************************/ static uint32_t eda_enc_chan_unlink_msg(NCS_UBAID *uba, EDSV_MSG *msg) { uint8_t *p8; uint32_t total_bytes = 0; EDSV_EDA_CHAN_UNLINK_PARAM *param = &msg->info.api_info.param.chan_unlink; if (uba == NULL) { TRACE_4("uba is NULL"); return 0; } /** encode the contents **/ p8 = ncs_enc_reserve_space(uba, 6); if (!p8) { TRACE_4("reserve space failed"); } ncs_encode_32bit(&p8, param->reg_id); ncs_encode_16bit(&p8, param->chan_name.length); ncs_enc_claim_space(uba, 6); total_bytes += 6; ncs_encode_n_octets_in_uba(uba, param->chan_name.value, (uint32_t)param->chan_name.length); total_bytes += (uint32_t)param->chan_name.length; return total_bytes; }
/**************************************************************************** Name : eda_enc_retention_time_clr_msg Description : This routine encodes a retention time clear API msg Arguments : NCS_UBAID *msg, EDSV_MSG *msg Return Values : uint32_t Notes : None. ******************************************************************************/ static uint32_t eda_enc_retention_time_clr_msg(NCS_UBAID *uba, EDSV_MSG *msg) { uint8_t *p8; uint32_t total_bytes = 0; EDSV_EDA_RETENTION_TIME_CLR_PARAM *param = &msg->info.api_info.param.rettimeclr; if (uba == NULL) { TRACE_4("uba is NULL"); return 0; } /** encode the contents **/ p8 = ncs_enc_reserve_space(uba, 16); if (!p8) { TRACE_4("reserve space failed"); } ncs_encode_32bit(&p8, param->reg_id); ncs_encode_32bit(&p8, param->chan_id); ncs_encode_32bit(&p8, param->chan_open_id); ncs_encode_32bit(&p8, param->event_id); ncs_enc_claim_space(uba, 16); total_bytes += 16; return total_bytes; }
/**************************************************************************** Name : eda_enc_unsubscribe_msg Description : This routine encodes a unsubscribe API msg Arguments : NCS_UBAID *msg, EDSV_MSG *msg Return Values : uint32_t Notes : None. ******************************************************************************/ static uint32_t eda_enc_unsubscribe_msg(NCS_UBAID *uba, EDSV_MSG *msg) { uint8_t *p8; uint32_t total_bytes = 0; EDSV_EDA_UNSUBSCRIBE_PARAM *param = &msg->info.api_info.param.unsubscribe; if (uba == NULL) { TRACE_4("uba is NULL"); return 0; } /** encode the contents **/ p8 = ncs_enc_reserve_space(uba, 16); if (!p8) { TRACE_4("reserve space failed"); } ncs_encode_32bit(&p8, param->reg_id); ncs_encode_32bit(&p8, param->chan_id); ncs_encode_32bit(&p8, param->chan_open_id); ncs_encode_32bit(&p8, param->sub_id); ncs_enc_claim_space(uba, 16); total_bytes += 16; return total_bytes; }
/**************************************************************************** Name : cpa_mds_enc_flat Description : This function encodes an events sent from CPA. Arguments : cb : CPA control Block. enc_info : Info for encoding Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ static uint32_t cpa_mds_enc_flat(CPA_CB *cb, MDS_CALLBACK_ENC_FLAT_INFO *info) { CPSV_EVT *evt = NULL; NCS_UBAID *uba = info->io_uba; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); /* Get the Msg Format version from the SERVICE_ID & RMT_SVC_PVT_SUBPART_VERSION */ if (info->i_to_svc_id == NCSMDS_SVC_ID_CPND) { info->o_msg_fmt_ver = m_NCS_ENC_MSG_FMT_GET(info->i_rem_svc_pvt_ver, CPA_WRT_CPND_SUBPART_VER_MIN, CPA_WRT_CPND_SUBPART_VER_MAX, cpa_cpnd_msg_fmt_table); } if (info->o_msg_fmt_ver) { if (info->i_to_svc_id == NCSMDS_SVC_ID_CPND) { /* as all the event structures are flat */ evt = (CPSV_EVT *)info->i_msg; rc = cpsv_evt_enc_flat(&cb->edu_hdl, evt, uba); if (rc != NCSCC_RC_SUCCESS) TRACE_4("CPA mds_enc_flat failed with return value:%d",rc); TRACE_LEAVE(); return rc; } else { TRACE_4("CPA mds_enc_flat failed with return value:%d",rc); return NCSCC_RC_FAILURE; } } else { /* Drop The Message */ TRACE_4("CPA mds_enc_flat failed with return value:%d",rc); return NCSCC_RC_FAILURE; } }
/***************************************************************************** PROCEDURE NAME : eds_stop_tmr DESCRIPTION : Stops the EDS timer. ARGUMENTS : tmr - ptr to the EDS timer block RETURNS : void NOTES : None *****************************************************************************/ void eds_stop_tmr(EDS_TMR *tmr) { /* If timer type is invalid just return */ if (tmr == NULL) { TRACE_4("timer is NULL"); TRACE_LEAVE(); return; } else if (EDS_TMR_MAX <= tmr->type) { TRACE_4("unsupported timer type"); TRACE_LEAVE(); return; } /* Stop the timer if it is active... */ if (tmr->is_active == true) { m_NCS_TMR_STOP(tmr->tmr_id); tmr->is_active = false; } /* Destroy the timer if it exists.. */ if (tmr->tmr_id != TMR_T_NULL) { m_NCS_TMR_DESTROY(tmr->tmr_id); tmr->tmr_id = TMR_T_NULL; } return; }
/**************************************************************************** Name : eda_enc_subscribe_msg Description : This routine encodes a subscribe API msg Arguments : NCS_UBAID *msg, EDSV_MSG *msg Return Values : uint32_t Notes : None. ******************************************************************************/ static uint32_t eda_enc_subscribe_msg(NCS_UBAID *uba, EDSV_MSG *msg) { uint8_t *p8; uint32_t x; uint32_t total_bytes = 0; SaEvtEventFilterT *filter_ptr; EDSV_EDA_SUBSCRIBE_PARAM *param = &msg->info.api_info.param.subscribe; if (uba == NULL) { TRACE_4("uba is NULL"); return 0; } /** encode the contents **/ p8 = ncs_enc_reserve_space(uba, 24); if (!p8) { TRACE_4("reserve space failed"); } ncs_encode_32bit(&p8, param->reg_id); ncs_encode_32bit(&p8, param->chan_id); ncs_encode_32bit(&p8, param->chan_open_id); ncs_encode_32bit(&p8, param->sub_id); ncs_encode_64bit(&p8, param->filter_array->filtersNumber); ncs_enc_claim_space(uba, 24); total_bytes += 24; /* Encode the filters */ filter_ptr = param->filter_array->filters; for (x = 0; x < (uint32_t)param->filter_array->filtersNumber; x++) { /* Save room for the filterType(4 bytes), patternSize(8 bytes) */ p8 = ncs_enc_reserve_space(uba, 12); if (!p8) { TRACE_4("reserve space failed"); } ncs_encode_32bit(&p8, filter_ptr->filterType); ncs_encode_64bit(&p8, filter_ptr->filter.patternSize); ncs_enc_claim_space(uba, 12); total_bytes = 12; /* For zero length filters, fake encode zero */ if ((uint32_t)filter_ptr->filter.patternSize == 0) { p8 = ncs_enc_reserve_space(uba, 4); if (!p8) { TRACE_4("reserve space failed"); } ncs_encode_32bit(&p8, 0); ncs_enc_claim_space(uba, 4); total_bytes += 4; } else { ncs_encode_n_octets_in_uba(uba, filter_ptr->filter.pattern, (uint32_t)filter_ptr->filter.patternSize); total_bytes += (uint32_t)filter_ptr->filter.patternSize; } filter_ptr++; } return total_bytes; }
/**************************************************************************** * PROCEDURE: mbcsv_lib_init * * Description : This is the function which initalize the mbcsv libarary. * This function creates an global lock, creates MBCSV linked * list, etc. * * Arguments : req_info - Request info. * * Return Values : SA_AIS_OK/Failure code. * * Notes : None. *****************************************************************************/ uint32_t mbcsv_lib_init(NCS_LIB_REQ_INFO *req_info) { NCS_PATRICIA_PARAMS pt_params; uint32_t rc = SA_AIS_OK; TRACE_ENTER(); if (mbcsv_cb.created == true) { TRACE_LEAVE2("Lib init request failed: MBCA already created"); return SA_AIS_ERR_INIT; } /* * Create global lock */ m_NCS_LOCK_INIT(&mbcsv_cb.global_lock); /* * Create patricia tree for the MBCA registration instance */ pt_params.key_size = sizeof(uint32_t); if (ncs_patricia_tree_init(&mbcsv_cb.reg_list, &pt_params) != NCSCC_RC_SUCCESS) { TRACE_4("pat tree init failed"); rc = SA_AIS_ERR_FAILED_OPERATION; goto err1; } if (NCSCC_RC_SUCCESS != mbcsv_initialize_mbx_list()) { TRACE_4("pat tree init for mailbox failed"); rc = SA_AIS_ERR_FAILED_OPERATION; goto err2; } /* * Create patricia tree for the peer list */ if (mbcsv_initialize_peer_list() != NCSCC_RC_SUCCESS) { TRACE_4("pat tree init for peer list failed"); rc = SA_AIS_ERR_FAILED_OPERATION; goto err3; } mbcsv_cb.created = true; return rc; /* Handle Different Error Situations */ err3: ncs_patricia_tree_destroy(&mbcsv_cb.mbx_list); m_NCS_LOCK_DESTROY(&mbcsv_cb.mbx_list_lock); err2: ncs_patricia_tree_destroy(&mbcsv_cb.reg_list); err1: m_NCS_LOCK_DESTROY(&mbcsv_cb.global_lock); TRACE_LEAVE(); return rc; }
uint32_t cpa_mds_register(CPA_CB *cb) { NCSMDS_INFO svc_info; MDS_SVC_ID subs_id[2] = { NCSMDS_SVC_ID_CPND, NCSMDS_SVC_ID_CPD }; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); /* STEP1: Get the MDS Handle */ if (cpa_mds_get_handle(cb) != NCSCC_RC_SUCCESS) return NCSCC_RC_FAILURE; /* memset the svc_info */ memset(&svc_info, 0, sizeof(NCSMDS_INFO)); /* STEP 2 : Install on ADEST with MDS with service ID NCSMDS_SVC_ID_CPA. */ svc_info.i_mds_hdl = cb->cpa_mds_hdl; svc_info.i_svc_id = NCSMDS_SVC_ID_CPA; svc_info.i_op = MDS_INSTALL; svc_info.info.svc_install.i_yr_svc_hdl = cb->agent_handle_id; svc_info.info.svc_install.i_install_scope = NCSMDS_SCOPE_NONE; /* node specific */ svc_info.info.svc_install.i_svc_cb = cpa_mds_callback; /* callback */ svc_info.info.svc_install.i_mds_q_ownership = false; /* CPA owns the mds queue */ svc_info.info.svc_install.i_mds_svc_pvt_ver = CPA_MDS_PVT_SUBPART_VERSION; /* Private Subpart Version of CPA for Versioning infrastructure */ if ((rc = ncsmds_api(&svc_info)) != NCSCC_RC_SUCCESS) { TRACE_4("CPA MDS:INSTALL failed with return value:%d",rc); return rc; } cb->cpa_mds_dest = svc_info.info.svc_install.o_dest; /* STEP 3: Subscribe to CPND up/down events */ svc_info.i_op = MDS_SUBSCRIBE; svc_info.info.svc_subscribe.i_num_svcs = 1; svc_info.info.svc_subscribe.i_scope = NCSMDS_SCOPE_NONE; svc_info.info.svc_subscribe.i_svc_ids = &subs_id[0]; if ((rc = ncsmds_api(&svc_info)) != NCSCC_RC_SUCCESS) { TRACE_4("CPA MDS:SUBSCRIBE failed with return value:%d",rc); goto error; } return NCSCC_RC_SUCCESS; error: /* Uninstall with the mds */ cpa_mds_unregister(cb); TRACE_LEAVE2("retval = %u", rc); return NCSCC_RC_FAILURE; }
/**************************************************************************** Name : cpa_mds_msg_send Description : This routine sends the CPA message to CPND. Arguments : uint32_t cpa_mds_hdl Handle of CPA MDS_DEST *destination - destintion to send to CPSV_EVT *i_evt - CPSV_EVT pointer Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ uint32_t cpa_mds_msg_send(uint32_t cpa_mds_hdl, MDS_DEST *destination, CPSV_EVT *i_evt, uint32_t to_svc) { NCSMDS_INFO mds_info; uint32_t rc; TRACE_ENTER(); if (!i_evt) return NCSCC_RC_FAILURE; memset(&mds_info, 0, sizeof(NCSMDS_INFO)); mds_info.i_mds_hdl = cpa_mds_hdl; mds_info.i_svc_id = NCSMDS_SVC_ID_CPA; mds_info.i_op = MDS_SEND; /* fill the send structure */ mds_info.info.svc_send.i_msg = (NCSCONTEXT)i_evt; mds_info.info.svc_send.i_priority = MDS_SEND_PRIORITY_MEDIUM; mds_info.info.svc_send.i_to_svc = to_svc; mds_info.info.svc_send.i_sendtype = MDS_SENDTYPE_SND; /* fill the send rsp strcuture */ mds_info.info.svc_send.info.snd.i_to_dest = *destination; /* send the message */ rc = ncsmds_api(&mds_info); if (NCSCC_RC_SUCCESS != rc) TRACE_4("Cpa MDS send failed"); else TRACE_1("Cpa MDS send success"); TRACE_LEAVE(); return rc; }
/**************************************************************************** Name : eda_dec_chan_open_cbk_msg Description : This routine decodes a channel open callback message Arguments : NCS_UBAID *msg, EDSV_MSG *msg Return Values : uint32_t Notes : None. ******************************************************************************/ static uint32_t eda_dec_chan_open_cbk_msg(NCS_UBAID *uba, EDSV_MSG *msg) { uint8_t *p8; int32_t total_bytes = 0; EDSV_EDA_CHAN_OPEN_CBK_PARAM *param = &msg->info.cbk_info.param.chan_open_cbk; uint8_t local_data[256]; if (uba == NULL) { TRACE_4("uba is NULL"); return 0; } /* chan_name_len */ p8 = ncs_dec_flatten_space(uba, local_data, 2); param->chan_name.length = ncs_decode_16bit(&p8); ncs_dec_skip_space(uba, 2); total_bytes += 2; /* chan_name */ ncs_decode_n_octets_from_uba(uba, param->chan_name.value, (uint32_t)param->chan_name.length); total_bytes += (uint32_t)param->chan_name.length; /* chan_id, chan_open_id, chan_open_flags, eda_chan_hdl, error */ p8 = ncs_dec_flatten_space(uba, local_data, 17); param->chan_id = ncs_decode_32bit(&p8); param->chan_open_id = ncs_decode_32bit(&p8); param->chan_open_flags = ncs_decode_8bit(&p8); param->eda_chan_hdl = ncs_decode_32bit(&p8); param->error = ncs_decode_32bit(&p8); ncs_dec_skip_space(uba, 17); total_bytes += 17; return total_bytes; }
void Frontend::handleFctConstruct_and_GV(Process* proc, Function* F, std::vector<Function*>* fctStack) { for(inst_iterator i = inst_begin(F); i != inst_end(F); ++i) { bool callB = false; Function* calledFunction = NULL; Instruction* currentInst = &*i; BasicBlock* bb = currentInst->getParent(); if (CallInst *callInst = dyn_cast < CallInst > (currentInst)) { callB = true; calledFunction = callInst->getCalledFunction(); } else if(InvokeInst *invokeInst = dyn_cast < InvokeInst > (currentInst)) { callB = true; calledFunction = invokeInst->getCalledFunction(); } if (! calledFunction) { TRACE_6("Encountered call to function pointer. Not parsing it.\n"); } else if (! this->sccfactory->handle(proc, F, bb, currentInst, calledFunction)) { TRACE_6("CallInst : " << currentInst << "\n"); TRACE_6("CalledFct : " << calledFunction << "\n"); PRINT_6(currentInst->dump()); TRACE_4("Call not handled : " << calledFunction->getName().str() << "\n"); fctStack->push_back(calledFunction); proc->addUsedFunction(calledFunction); } else if (calledFunction->getIntrinsicID() != Intrinsic::not_intrinsic) { TRACE_6("Encountered call to intrinsic function \"" << calledFunction->getName().str() << "\" (id = " << calledFunction->getIntrinsicID() << "). Not parsing it.\n"); } if (! callB) { this->fillGlobalVars(currentInst); } } }
static int __init_mqnd(void) { NCS_LIB_REQ_INFO lib_create; TRACE_ENTER(); /* Init LIB_CREATE request for Server */ memset(&lib_create, 0, sizeof(lib_create)); lib_create.i_op = NCS_LIB_REQ_CREATE; lib_create.info.create.argc = 0; lib_create.info.create.argv = NULL; if (ncs_agents_startup() != NCSCC_RC_SUCCESS) { TRACE_4("ncs_agents_startup failed"); return m_LEAP_DBG_SINK(NCSCC_RC_FAILURE); } /* Init MQND */ printf("\nMQSV:MQND:ON"); if (mqnd_lib_req(&lib_create) != NCSCC_RC_SUCCESS) { fprintf(stderr, "mqnd_lib_req FAILED\n"); return m_LEAP_DBG_SINK(NCSCC_RC_FAILURE); } TRACE_LEAVE(); return (NCSCC_RC_SUCCESS); }
/** * response to the lib on a saNtfNotificationReadNext request * @param error error code sent back to the library * @param notification The next notification read or NULL if none exist */ void read_next_res_lib(SaAisErrorT error, ntfsv_send_not_req_t *notification, MDS_DEST mdsDest, MDS_SYNC_SND_CTXT *mdsCtxt) { uns32 rc = NCSCC_RC_SUCCESS; ntfsv_msg_t msg; TRACE_ENTER(); msg.type = NTFSV_NTFA_API_RESP_MSG; msg.info.api_resp_info.type = NTFSV_READ_NEXT_RSP; msg.info.api_resp_info.rc = error; msg.info.api_resp_info.param.read_next_rsp.readNotification = notification; if (msg.info.api_resp_info.rc == SA_AIS_OK) { SaNtfNotificationHeaderT *header; ntfsv_get_ntf_header(notification, &header); TRACE_4("notId: %llu, rv: %u", *header->notificationId, error); } rc = ntfs_mds_msg_send(ntfs_cb, &msg, &mdsDest, mdsCtxt, MDS_SEND_PRIORITY_HIGH); if (rc != NCSCC_RC_SUCCESS) { TRACE("ntfs_mds_msg_send FAILED"); /* TODO: what to do exit here? */ } TRACE_LEAVE(); /* TODO: async update*/ };
/**************************************************************************** Name : cpa_mds_dec Description : This function decodes an events sent to CPA. Arguments : cb : CPA control Block. info : Info for decoding Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ static uint32_t cpa_mds_dec(CPA_CB *cb, MDS_CALLBACK_DEC_INFO *dec_info) { CPSV_EVT *msg_ptr = NULL; EDU_ERR ederror = 0; uint32_t rc = NCSCC_RC_SUCCESS; uint8_t local_data[20]; uint8_t *pstream; bool is_valid_msg_fmt = false; TRACE_ENTER(); if (dec_info->i_fr_svc_id == NCSMDS_SVC_ID_CPND) { is_valid_msg_fmt = m_NCS_MSG_FORMAT_IS_VALID(dec_info->i_msg_fmt_ver, CPA_WRT_CPND_SUBPART_VER_MIN, CPA_WRT_CPND_SUBPART_VER_MAX, cpa_cpnd_msg_fmt_table); } else if (dec_info->i_fr_svc_id == NCSMDS_SVC_ID_CPD) { is_valid_msg_fmt = m_NCS_MSG_FORMAT_IS_VALID(dec_info->i_msg_fmt_ver, CPA_WRT_CPD_SUBPART_VER_MIN, CPA_WRT_CPD_SUBPART_VER_MAX, cpa_cpd_msg_fmt_table); } if (is_valid_msg_fmt) { msg_ptr = m_MMGR_ALLOC_CPSV_EVT(NCS_SERVICE_ID_CPA); if (!msg_ptr) return NCSCC_RC_FAILURE; memset(msg_ptr, 0, sizeof(CPSV_EVT)); dec_info->o_msg = (NCSCONTEXT)msg_ptr; pstream = ncs_dec_flatten_space(dec_info->io_uba, local_data, 8); msg_ptr->type = ncs_decode_32bit(&pstream); if (msg_ptr->type == CPSV_EVT_TYPE_CPA) { /* For Events Write/Read Call EDU VER_EXEC*/ rc = m_NCS_EDU_VER_EXEC(&cb->edu_hdl, FUNC_NAME(CPSV_EVT), dec_info->io_uba, EDP_OP_TYPE_DEC, (CPSV_EVT **)&dec_info->o_msg, &ederror, dec_info->i_msg_fmt_ver); goto free; /* if(msg_ptr->info.cpa.type == CPA_EVT_ND2A_CKPT_DATA_RSP) */ } /* if( msg_ptr->type == CPSV_EVT_TYPE_CPA) */ /* For all Other Cases Other Than CPA( Read / Write Rsp Follow EDU rules */ rc = m_NCS_EDU_EXEC(&cb->edu_hdl, FUNC_NAME(CPSV_EVT), dec_info->io_uba, EDP_OP_TYPE_DEC, (CPSV_EVT **)&dec_info->o_msg, &ederror); free: if (rc != NCSCC_RC_SUCCESS) { m_MMGR_FREE_CPSV_EVT(dec_info->o_msg, NCS_SERVICE_ID_CPA); } TRACE_LEAVE(); return rc; } else { TRACE_4("CPA:Processing failed for mds_dec "); TRACE_LEAVE(); return NCSCC_RC_FAILURE; } }
/************************************************************************************ * Name : cpd_a2s_ckpt_create * Description : This routine will update the CPD_MBCSV_MSG (message) which has * to be sent to Standby for checkpoint create Async Update * Input Values : CPD_CB , CPD_CKPT_INFO_NODE - CPD checkpoint node * Return Values : SA_AIS_OK if success else return appropriate error * * Notes : The information present in the ckpt_node is copied into cpd_msg(which has to be sent to Standby ) **************************************************************************************************************/ uint32_t cpd_a2s_ckpt_create(CPD_CB *cb, CPD_CKPT_INFO_NODE *ckpt_node) { CPD_MBCSV_MSG cpd_msg; SaAisErrorT rc = SA_AIS_OK; uint32_t count = 0; TRACE_ENTER(); memset(&cpd_msg, '\0', sizeof(CPD_MBCSV_MSG)); cpd_msg.type = CPD_A2S_MSG_CKPT_CREATE; cpd_msg.info.ckpt_create.ckpt_name = ckpt_node->ckpt_name; cpd_msg.info.ckpt_create.ckpt_id = ckpt_node->ckpt_id; cpd_msg.info.ckpt_create.ckpt_attrib = ckpt_node->attributes; cpd_msg.info.ckpt_create.is_unlink_set = ckpt_node->is_unlink_set; cpd_msg.info.ckpt_create.create_time = ckpt_node->create_time; cpd_msg.info.ckpt_create.num_users = ckpt_node->num_users; cpd_msg.info.ckpt_create.num_readers = ckpt_node->num_readers; cpd_msg.info.ckpt_create.num_writers = ckpt_node->num_writers; cpd_msg.info.ckpt_create.num_sections = ckpt_node->num_sections; cpd_msg.info.ckpt_create.is_active_exists = ckpt_node->is_active_exists; if (cpd_msg.info.ckpt_create.is_active_exists) cpd_msg.info.ckpt_create.active_dest = ckpt_node->active_dest; if (ckpt_node->dest_cnt) { CPD_NODE_REF_INFO *node_list = ckpt_node->node_list; cpd_msg.info.ckpt_create.dest_cnt = ckpt_node->dest_cnt; cpd_msg.info.ckpt_create.dest_list = m_MMGR_ALLOC_CPSV_CPND_DEST_INFO(ckpt_node->dest_cnt); if (cpd_msg.info.ckpt_create.dest_list == NULL) { LOG_CR("cpd cpnd dest info memory allocation failed"); rc = SA_AIS_ERR_NO_MEMORY; goto end; } else { memset(cpd_msg.info.ckpt_create.dest_list, '\0', (sizeof(CPSV_CPND_DEST_INFO) * ckpt_node->dest_cnt)); for (count = 0; count < ckpt_node->dest_cnt; count++) { cpd_msg.info.ckpt_create.dest_list[count].dest = node_list->dest; node_list = node_list->next; } } } /* send it to MBCSv */ rc = cpd_mbcsv_async_update(cb, &cpd_msg); if (rc != SA_AIS_OK) TRACE_4("cpd A2S ckpt create async failed for ckptid :%llx",ckpt_node->ckpt_id); else TRACE_1("cpd A2S ckpt create async success for ckptid :%llx",ckpt_node->ckpt_id); if (cpd_msg.info.ckpt_create.dest_list) m_MMGR_FREE_CPSV_CPND_DEST_INFO(cpd_msg.info.ckpt_create.dest_list); end: TRACE_LEAVE(); return rc; }
/**************************************************************************** Name : cpa_mds_dec_flat Description : This function decodes an events sent to CPA. Arguments : cb : CPA control Block. dec_info : Info for decoding Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ static uint32_t cpa_mds_dec_flat(CPA_CB *cb, MDS_CALLBACK_DEC_FLAT_INFO *info) { CPSV_EVT *evt = NULL; NCS_UBAID *uba = info->io_uba; uint32_t rc = NCSCC_RC_SUCCESS; bool is_valid_msg_fmt = false; TRACE_ENTER(); if (info->i_fr_svc_id == NCSMDS_SVC_ID_CPND) { is_valid_msg_fmt = m_NCS_MSG_FORMAT_IS_VALID(info->i_msg_fmt_ver, CPA_WRT_CPND_SUBPART_VER_MIN, CPA_WRT_CPND_SUBPART_VER_MAX, cpa_cpnd_msg_fmt_table); } else if (info->i_fr_svc_id == NCSMDS_SVC_ID_CPD) { is_valid_msg_fmt = m_NCS_MSG_FORMAT_IS_VALID(info->i_msg_fmt_ver, CPA_WRT_CPD_SUBPART_VER_MIN, CPA_WRT_CPD_SUBPART_VER_MAX, cpa_cpd_msg_fmt_table); } if (is_valid_msg_fmt) { if (info->i_fr_svc_id == NCSMDS_SVC_ID_CPND || info->i_fr_svc_id == NCSMDS_SVC_ID_CPD) { evt = (CPSV_EVT *)m_MMGR_ALLOC_CPSV_EVT(NCS_SERVICE_ID_CPA); if (evt == NULL) { TRACE_4("cpa mem allocation failed in mds_dec_flat"); return NCSCC_RC_OUT_OF_MEM; } info->o_msg = evt; rc = cpsv_evt_dec_flat(&cb->edu_hdl, uba, evt); TRACE_LEAVE(); return rc; } else { TRACE_4("cpa api processing failed in mds_dec_flat with return value:%d",rc); return NCSCC_RC_FAILURE; } } else { TRACE_4("cpa api processing failed in mds_dec_flat with return value:%d",rc); return NCSCC_RC_FAILURE; } }
/**************************************************************************** Name : eda_enc_finalize_msg Description : This routine encodes a finalize API msg Arguments : NCS_UBAID *msg, EDSV_MSG *msg Return Values : uint32_t Notes : None. ******************************************************************************/ static uint32_t eda_enc_finalize_msg(NCS_UBAID *uba, EDSV_MSG *msg) { uint8_t *p8; uint32_t total_bytes = 0; EDSV_EDA_FINALIZE_PARAM *param = &msg->info.api_info.param.finalize; if (uba == NULL) { TRACE_4("uba is NULL"); return 0; } /** encode the contents **/ p8 = ncs_enc_reserve_space(uba, 4); if (!p8) { TRACE_4("reserve space failed"); } ncs_encode_32bit(&p8, param->reg_id); ncs_enc_claim_space(uba, 4); total_bytes += 4; return total_bytes; }
/**************************************************************************** * Name : cpnd_ckpt_sec_del * * Description : Function to remove the section from a checkpoint. * * Arguments : CPND_CKPT_NODE *cp_node - Check point node. * : SaCkptSectionIdT id - Section Identifier * * Return Values : ptr to CPND_CKPT_SECTION_INFO/NULL; * * Notes : None. *****************************************************************************/ CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_del(CPND_CKPT_NODE *cp_node, SaCkptSectionIdT *id) { CPND_CKPT_SECTION_INFO *pSecPtr = NULL; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); pSecPtr = cp_node->replica_info.section_info; while (pSecPtr != NULL) { if ((pSecPtr->sec_id.idLen == id->idLen) && (memcmp(pSecPtr->sec_id.id, id->id, id->idLen) == 0)) { /* delete it from the list and return the pointer */ if (cp_node->replica_info.section_info == pSecPtr) cp_node->replica_info.section_info = cp_node->replica_info.section_info->next; if (pSecPtr->prev) pSecPtr->prev->next = pSecPtr->next; if (pSecPtr->next) pSecPtr->next->prev = pSecPtr->prev; cp_node->replica_info.n_secs--; cp_node->replica_info.mem_used = cp_node->replica_info.mem_used - (pSecPtr->sec_size); /* UPDATE THE SECTION HEADER */ rc = cpnd_sec_hdr_update(pSecPtr, cp_node); if (rc == NCSCC_RC_FAILURE) { TRACE_4("cpnd sect hdr update failed"); } /* UPDATE THE CHECKPOINT HEADER */ rc = cpnd_ckpt_hdr_update(cp_node); if (rc == NCSCC_RC_FAILURE) { TRACE_4("cpnd ckpt hdr update failed"); } TRACE_LEAVE(); return pSecPtr; } pSecPtr = pSecPtr->next; } TRACE_LEAVE(); return NULL; }
/**************************************************************************** Name : eda_enc_initialize_msg Description : This routine encodes an initialize API msg Arguments : NCS_UBAID *msg, EDSV_MSG *msg Return Values : uint32_t Notes : None. ******************************************************************************/ static uint32_t eda_enc_initialize_msg(NCS_UBAID *uba, EDSV_MSG *msg) { uint8_t *p8; uint32_t total_bytes = 0; EDSV_EDA_INIT_PARAM *param = &msg->info.api_info.param.init; if (uba == NULL) { TRACE_4("uba is NULL"); return 0; } /** encode the contents **/ p8 = ncs_enc_reserve_space(uba, 3); if (!p8) { TRACE_4("reserve space failed"); } ncs_encode_8bit(&p8, param->version.releaseCode); ncs_encode_8bit(&p8, param->version.majorVersion); ncs_encode_8bit(&p8, param->version.minorVersion); ncs_enc_claim_space(uba, 3); total_bytes += 3; return total_bytes; }
bool Frontend::inlineForProcessFct(Function* F) { for(inst_iterator i = inst_begin(F); i != inst_end(F); ++i) { Function* calledFunction = NULL; Instruction* currentInst = &*i; BasicBlock* bb = currentInst->getParent(); bool isInvoke = false; if (CallInst *callInst = dyn_cast < CallInst > (currentInst)) { calledFunction = callInst->getCalledFunction(); } else if(InvokeInst *invokeInst = dyn_cast < InvokeInst > (currentInst)) { calledFunction = invokeInst->getCalledFunction(); isInvoke = true; } if (! calledFunction) { TRACE_6("Encountered call to function pointer. Not parsing it.\n"); } else if (! this->sccfactory->handlerExists(F, bb, currentInst, calledFunction)) { TRACE_6("CallInst : " << currentInst << "\n"); TRACE_6("CalledFct : " << calledFunction << "\n"); PRINT_6(currentInst->dump()); TRACE_4("Call not handled : " << calledFunction->getName().str() << "\n"); TRACE_4("Inlining function : " << calledFunction->getName().str() << "\n"); bool isInlined = false; llvm::InlineFunctionInfo ifi; if (isInvoke) { isInlined = llvm::InlineFunction(dyn_cast<InvokeInst>(currentInst), ifi); } else { isInlined = llvm::InlineFunction(dyn_cast<CallInst>(currentInst), ifi); } // InlineFunction invalidates iterators => restart loop. if (isInlined) { return true; } } } return false; }
/**************************************************************************** Name : ava_destroy Description : This routine destroys the AvA control block. Arguments : destroy_info - ptr to the destroy info Return Values : None Notes : None ******************************************************************************/ void ava_destroy(NCS_LIB_DESTROY *destroy_info) { AVA_CB *cb = 0; uns32 rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); /* retrieve AvA CB */ cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl); if (!cb) { LOG_ER("Unable to take handle for control block"); goto done; } /* delete the hdl db */ ava_hdl_del(cb); TRACE_1("Deleted the handles DB"); /* unregister with MDS */ rc = ava_mds_unreg(cb); if (NCSCC_RC_SUCCESS != rc) TRACE_4("MDS unregistration failed"); else TRACE_1("MDS unregistration success"); /* EDU cleanup */ m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl); TRACE_1("EDU cleanup failed"); /* destroy the lock */ m_NCS_LOCK_DESTROY(&cb->lock); TRACE_1("Destroying lock for control block failed"); /* return AvA CB */ ncshm_give_hdl(gl_ava_hdl); /* remove the association with hdl-mngr */ ncshm_destroy_hdl(NCS_SERVICE_ID_AVA, cb->cb_hdl); TRACE_1("Removing association with handle manager failed"); /* free the control block */ free(cb); /* reset the global cb handle */ gl_ava_hdl = 0; done: TRACE_LEAVE(); return; }
uint32_t cpa_mds_get_handle(CPA_CB *cb) { NCSADA_INFO arg; uint32_t rc; memset(&arg, 0, sizeof(NCSADA_INFO)); arg.req = NCSADA_GET_HDLS; rc = ncsada_api(&arg); if (rc != NCSCC_RC_SUCCESS) { TRACE_4("CPA processing failed for ADA:GET_HDLS with return value:%d",rc); return rc; } cb->cpa_mds_hdl = arg.info.adest_get_hdls.o_mds_pwe1_hdl; return rc; }
/**************************************************************************** Name : mqa_destroy Description : This routine destroys the MQA control block. Arguments : destroy_info - ptr to the destroy info Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ static uint32_t mqa_destroy(NCS_LIB_DESTROY *destroy_info) { MQA_CB *cb = 0; TRACE_ENTER(); /* validate the CB */ cb = (MQA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_MQA, gl_mqa_hdl); if (!cb) return NCSCC_RC_FAILURE; /* return MQA CB */ ncshm_give_hdl(gl_mqa_hdl); /* remove the association with hdl-mngr */ ncshm_destroy_hdl(NCS_SERVICE_ID_MQA, cb->agent_handle_id); if (m_NCS_LOCK(&cb->cb_lock, NCS_LOCK_WRITE) != NCSCC_RC_SUCCESS) { TRACE_4("FAILURE: mqa_destroy Failed to acquire lock"); return NCSCC_RC_FAILURE; } mqa_timer_table_destroy(cb); /* Unregister with ASAPi */ mqa_asapi_unregister(cb); /* MDS unregister. */ mqa_mds_unregister(cb); m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl); mqa_queue_tree_destroy(cb); /* delete all the client info */ mqa_client_tree_destroy(cb); m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE); /* destroy the lock */ m_NCS_LOCK_DESTROY(&cb->cb_lock); /* reset the global cb handle */ gl_mqa_hdl = 0; TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/* * Arrange that func(arg) be called after delta clock ticks. */ static timeout_id_t timeout_common(void (*func)(void *), void *arg, clock_t delta, callout_table_t *ct) { callout_t *cp; callout_id_t id; clock_t runtime; mutex_enter(&ct->ct_lock); if ((cp = ct->ct_freelist) == NULL) cp = callout_alloc(ct); else ct->ct_freelist = cp->c_idnext; cp->c_func = func; cp->c_arg = arg; /* * Make sure the callout runs at least 1 tick in the future. */ if (delta <= 0) delta = 1; cp->c_runtime = runtime = lbolt + delta; /* * Assign an ID to this callout */ if (delta > CALLOUT_LONGTERM_TICKS) ct->ct_long_id = id = (ct->ct_long_id - CALLOUT_COUNTER_LOW) | CALLOUT_COUNTER_HIGH; else ct->ct_short_id = id = (ct->ct_short_id - CALLOUT_COUNTER_LOW) | CALLOUT_COUNTER_HIGH; cp->c_xid = id; CALLOUT_HASH_UPDATE(INSERT, ct, cp, id, runtime); mutex_exit(&ct->ct_lock); TRACE_4(TR_FAC_CALLOUT, TR_TIMEOUT, "timeout:%K(%p) in %ld ticks, cp %p", func, arg, delta, cp); return ((timeout_id_t)id); }
/**************************************************************************** * Name : cpnd_ckpt_sec_add * * Description : Function to add the section to a checkpoint. * * Arguments : CPND_CKPT_NODE *cp_node - Check point node. * : SaCkptSectionIdT id - Section Identifier * * Return Values : NULL/CPND_CKPT_SECTION_INFO * * Notes : None. *****************************************************************************/ CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_add(CPND_CKPT_NODE *cp_node, SaCkptSectionIdT *id, SaTimeT exp_time, uint32_t gen_flag) { CPND_CKPT_SECTION_INFO *pSecPtr = NULL; int32_t lcl_sec_id = 0; uint32_t rc = NCSCC_RC_SUCCESS; uint32_t value = 0, i = 0, j = 0; TRACE_ENTER(); /* get the lcl_sec_id */ lcl_sec_id = cpnd_ckpt_get_lck_sec_id(cp_node); if (lcl_sec_id == -1) { /* -1 is invalid section Id need to define it in *.h file */ TRACE_4("cpnd creating more than max sections"); return NULL; } /* creat the cpnd_ckpt_section_info structure,memset */ pSecPtr = m_MMGR_ALLOC_CPND_CKPT_SECTION_INFO; if (pSecPtr == NULL) { LOG_ER("cpnd ckpt section info memory allocation failed"); return NULL; } memset(pSecPtr, '\0', sizeof(CPND_CKPT_SECTION_INFO)); if (gen_flag) { if (cp_node->create_attrib.maxSectionIdSize > CPSV_GEN_SECTION_ID_SIZE) pSecPtr->sec_id.idLen = CPSV_GEN_SECTION_ID_SIZE; else pSecPtr->sec_id.idLen = cp_node->create_attrib.maxSectionIdSize; /* convert the lcl_sec_id to Network order */ value = lcl_sec_id; pSecPtr->sec_id.id = m_MMGR_ALLOC_CPND_DEFAULT(pSecPtr->sec_id.idLen); if (pSecPtr->sec_id.id == NULL) { LOG_ER("cpnd sect memory allocation failed"); return NULL; } memset(pSecPtr->sec_id.id, '\0', pSecPtr->sec_id.idLen); for (i = (CPSV_GEN_SECTION_ID_SIZE - pSecPtr->sec_id.idLen); i < CPSV_GEN_SECTION_ID_SIZE; i++) { pSecPtr->sec_id.id[j] = (value >> (24 - (8 * i))) & 0xff; j++; } } else {
/**************************************************************************** * PROCEDURE : mbcsv_lib_destroy * * Description : This is the function which destroys the MBCSV. * * Arguments : None. * * Return Values : SA_AIS_OK/Failure code. * * Notes : None. *****************************************************************************/ uint32_t mbcsv_lib_destroy(void) { MBCSV_REG *mbc_reg; SS_SVC_ID svc_id = 0; SaAisErrorT rc = SA_AIS_OK; TRACE_ENTER(); if (mbcsv_cb.created == false) { TRACE_LEAVE2("Lib destroy request failed: Create MBCA before destroying"); return SA_AIS_ERR_EXIST; } m_NCS_LOCK(&mbcsv_cb.global_lock, NCS_LOCK_WRITE); mbcsv_cb.created = false; /* * Walk through MBCSv reg list and destroy all the registration instances. */ while (NULL != (mbc_reg = (MBCSV_REG *)ncs_patricia_tree_getnext(&mbcsv_cb.reg_list, (const uint8_t *)&svc_id))) { svc_id = mbc_reg->svc_id; if (NCSCC_RC_SUCCESS != mbcsv_rmv_reg_inst((MBCSV_REG *)&mbcsv_cb.reg_list, mbc_reg)) { /* Not required to return for failure, log the err message and go ahead with cleanup */ TRACE_4("Failed to remove this service instance:%u", mbc_reg->svc_id); } } ncs_patricia_tree_destroy(&mbcsv_cb.reg_list); /* * Call function which will destroy and free all the entries of the peer list. */ mbcsv_destroy_peer_list(); /* * Call function which will destroy mail box list. */ mbcsv_destroy_mbx_list(); m_NCS_UNLOCK(&mbcsv_cb.global_lock, NCS_LOCK_WRITE); m_NCS_LOCK_DESTROY(&mbcsv_cb.global_lock); TRACE_LEAVE(); return rc; }
/**************************************************************************** Name : mqa_client_tree_find_and_add Description : This routine adds the new client to the client tree and creates the selection object for that client. Arguments : mqa_cb : pointer to the mqa control block. hdl_id : the handle id. flag : true/false if true create the new node if node doesn't exist.FALSE -> search for an existing node. Return Values : returns the MQA_CLIENT_INFO node. Notes : The caller takes the cb lock before calling this function ******************************************************************************/ MQA_CLIENT_INFO *mqa_client_tree_find_and_add(MQA_CB *mqa_cb, SaMsgHandleT hdl_id, bool flag) { MQA_CLIENT_INFO *client_info = NULL; NCS_PATRICIA_PARAMS param; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); client_info = (MQA_CLIENT_INFO *)ncs_patricia_tree_get(&mqa_cb->mqa_client_tree, (uint8_t *)&hdl_id); if (flag == true) { /* create and allocate the memory */ if (!client_info) { client_info = (MQA_CLIENT_INFO *)m_MMGR_ALLOC_MQA_CLIENT_INFO; if (!client_info) { TRACE_4("Client database creation failed"); return NULL; } memset(client_info, 0, sizeof(MQA_CLIENT_INFO)); /* Store the client_info pointer as msghandle. */ client_info->msgHandle = NCS_PTR_TO_UNS64_CAST(client_info); client_info->patnode.key_info = (uint8_t *)&client_info->msgHandle; if ((rc = ncs_patricia_tree_add(&mqa_cb->mqa_client_tree, &client_info->patnode)) != NCSCC_RC_SUCCESS) { TRACE_2("Client database Registration Failed"); m_MMGR_FREE_MQA_CLIENT_INFO(client_info); return NULL; } /* Create the group track tree */ memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); param.key_size = SA_MAX_NAME_LENGTH; if (ncs_patricia_tree_init(&client_info->mqa_track_tree, ¶m) != NCSCC_RC_SUCCESS) { TRACE_2("Initialization of the client tree failed"); m_MMGR_FREE_MQA_CLIENT_INFO(client_info); return NULL; } } } TRACE_LEAVE(); return client_info; }
static uint32_t eda_dec_clm_status_cbk_msg(NCS_UBAID *uba, EDSV_MSG *msg) { uint8_t *p8; int32_t total_bytes = 0; EDSV_EDA_CLM_STATUS_CBK_PARAM *param = &msg->info.cbk_info.param.clm_status_cbk; uint8_t local_data[256]; if (uba == NULL) { TRACE_4("uba is NULL"); return 0; } /* ClmNodeStatus */ p8 = ncs_dec_flatten_space(uba, local_data, 2); param->node_status = ncs_decode_16bit(&p8); ncs_dec_skip_space(uba, 2); total_bytes += 2; return total_bytes; }