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);
}
示例#2
0
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);
}