extern EOconfirmationManager* eo_confman_New(const eOconfman_cfg_t *cfg) { EOconfirmationManager *retptr = NULL; if(NULL == cfg) { cfg = &eOconfman_cfg_default; } if(eoconfman_mode_disabled == cfg->mode) { return(NULL); } // i get the memory for the object retptr = eo_mempool_GetMemory(eo_mempool_GetHandle(), eo_mempool_align_32bit, sizeof(EOconfirmationManager), 1); memcpy(&retptr->config, cfg, sizeof(eOconfman_cfg_t)); retptr->confrequests = (0 == cfg->maxnumberofconfreqrops) ? (NULL) : (eo_vector_New(sizeof(eOropdescriptor_t), cfg->maxnumberofconfreqrops, NULL, 0, NULL, NULL)); retptr->mtx = (NULL == cfg->mutex_fn_new) ? (NULL) : (cfg->mutex_fn_new()); return(retptr); }
static eOresult_t s_eo_nvset_InitBRD(EOnvSet* p, eOnvsetOwnership_t ownership, eOipv4addr_t ipaddress, eOnvBRD_t brdnum) { eOnvset_brd_t *theBoard = NULL; if(NULL == p) { return(eores_NOK_nullpointer); } theBoard = &p->theboard; if(NULL != theBoard->theendpoints) { // already initted return(eores_NOK_nullpointer); } theBoard->ipaddress = ipaddress; theBoard->boardnum = (eo_nvset_ownership_local == ownership) ? (eoprot_board_localboard) : (brdnum); theBoard->ownership = ownership; theBoard->theendpoints = eo_vector_New(sizeof(eOnvset_ep_t*), eo_vectorcapacity_dynamic, NULL, 0, NULL, NULL); theBoard->mtx_board = (eo_nvset_protection_one_per_board == p->protection) ? p->mtxderived_new() : NULL; // reset the ep2indexlut to have all values EOK_uint16dummy { uint8_t i = 0; const uint8_t lutsize = eonvset_max_endpoint_value+1; for(i=0; i<lutsize; i++) { theBoard->ep2indexlut[i] = EOK_uint16dummy; } } return(eores_OK); }
extern EOtheSKIN* eo_skin_Initialise(void) { EOtheSKIN* p = &s_eo_theskin; if(eobool_true == p->service.initted) { return(p); } p->numofskinpatches = 0; p->numofmtbs = 0; p->service.servconfig.type = eomn_serv_NONE; p->sharedcan.boardproperties = eo_vector_New(sizeof(eObrd_canproperties_t), eo_skin_maxnumberofMTBboards, NULL, NULL, NULL, NULL); p->sharedcan.entitydescriptor = eo_vector_New(sizeof(eOcanmap_entitydescriptor_t), eo_skin_maxnumberofMTBboards, NULL, NULL, NULL, NULL); uint8_t i=0; for(i=0; i<eomn_serv_skin_maxpatches; i++) { p->skinpatches[i] = NULL; p->patchisrunning[i] = eobool_false; p->rxdata[i] = eo_vector_New(sizeof(eOsk_candata_t), 64, NULL, NULL, NULL, NULL); } p->id32ofregulars = eo_array_New(skin_maxRegulars, sizeof(uint32_t), NULL); p->diagnostics.reportTimer = eo_timer_New(); p->diagnostics.errorType = eo_errortype_error; p->diagnostics.errorDescriptor.sourceaddress = eo_errman_sourcedevice_localboard; p->diagnostics.errorDescriptor.code = eoerror_code_get(eoerror_category_Config, eoerror_value_CFG_skin_not_verified_yet); p->service.initted = eobool_true; p->service.active = eobool_false; p->service.started = eobool_false; p->service.state = eomn_serv_state_idle; eo_service_hid_SynchServiceState(eo_services_GetHandle(), eomn_serv_category_skin, p->service.state); return(p); }
extern EOnvsetBRDbuilder* eo_nvsetbrdbuilder_New(eOnvBRD_t board) { EOnvsetBRDbuilder *p = NULL; // uint8_t i = 0; // i get the memory for the object p = eo_mempool_New(eo_mempool_GetHandle(), 1*sizeof(EOnvsetBRDbuilder)); p->epcfg_vector = eo_vector_New(sizeof(eOprot_EPcfg_t), eo_vectorcapacity_dynamic, NULL, 0, NULL, NULL); p->brdcfg = eo_mempool_New(eo_mempool_GetHandle(), 1*sizeof(eOnvset_BRDcfg_t)); p->brdcfg->boardnum = board; p->brdcfg->epcfg_constvect = eo_constvector_Load(p->epcfg_vector); return(p); }
extern eOresult_t eo_nvset_LoadEP(EOnvSet* p, eOprot_EPcfg_t *cfgofep, eObool_t initNVs) { eOnvset_brd_t* theBoard = NULL; eOnvBRD_t brd = 0; // local or 0, 1, 2, etc. eOnvset_ep_t *theEndpoint = NULL; uint16_t epnvsnumberof = 0; uint16_t sizeofram =0; if((NULL == p) || (NULL == cfgofep)) { return(eores_NOK_nullpointer); } theBoard = &p->theboard; brd = p->theboard.boardnum; theEndpoint = eo_mempool_New(eo_mempool_GetHandle(), 1*sizeof(eOnvset_ep_t)); memcpy(&theEndpoint->epcfg, cfgofep, sizeof(eOprot_EPcfg_t)); // ok, now in theEndpoint->epcfg.numberofsentities[] we have some ram. we use it to load the protocol. eoprot_config_endpoint_entities(brd, theEndpoint->epcfg.endpoint, theEndpoint->epcfg.numberofentities); // now it is ok to compute the size of the endpoint using the proper protocol function sizeofram = eoprot_endpoint_sizeof_get(brd, theEndpoint->epcfg.endpoint); // now that i have loaded the number of entities i verify if they are ok by checking the number of variables in the endpoint. epnvsnumberof = eoprot_endpoint_numberofvariables_get(brd, cfgofep->endpoint); if(0 == epnvsnumberof) { //#warning TBD: see how we continue in here .... char str[64] = {0}; snprintf(str, sizeof(str), "EOnvSet: ep %d has 0 nvs", cfgofep->endpoint); eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, str, NULL, &eo_errman_DescrRuntimeErrorLocal); eoprot_config_endpoint_entities(brd, theEndpoint->epcfg.endpoint, NULL); eo_mempool_Delete(eo_mempool_GetHandle(), theEndpoint); return(eores_NOK_generic); } theEndpoint->epnvsnumberof = epnvsnumberof; theEndpoint->initted = eobool_false; theEndpoint->epram = eo_mempool_GetMemory(eo_mempool_GetHandle(), eo_mempool_align_auto, sizeofram, 1); theEndpoint->mtx_endpoint = (eo_nvset_protection_one_per_endpoint == p->protection) ? p->mtxderived_new() : NULL; // now we must load the ram in the endpoint eoprot_config_endpoint_ram(brd, theEndpoint->epcfg.endpoint, theEndpoint->epram, sizeofram); // now add the vector of mtx if needed. if(eo_nvset_protection_one_per_netvar == p->protection) { uint16_t i; theEndpoint->themtxofthenvs = eo_vector_New(sizeof(EOVmutexDerived*), epnvsnumberof, NULL, 0, NULL, NULL); for(i=0; i<epnvsnumberof; i++) { EOVmutexDerived* mtx = p->mtxderived_new(); eo_vector_PushBack(theEndpoint->themtxofthenvs, &mtx); } } // now, i must update the mapping function from ep value to vector of endpoints theBoard->ep2indexlut[theEndpoint->epcfg.endpoint] = eo_vector_Size(theBoard->theendpoints); // and only now i push back the endpoint eo_vector_PushBack(theBoard->theendpoints, &theEndpoint); if(eobool_true == initNVs) { s_eo_nvset_NVsOfEP_Initialise(p, theEndpoint, theEndpoint->epcfg.endpoint); } return(eores_OK); }