Ejemplo n.º 1
0
static eOresult_t s_eo_nvset_DeinitEPs(EOnvSet* p)
{
    eOnvset_brd_t* theBoard = &p->theboard;   
    uint16_t i = 0;  
    uint16_t endpointsnum = 0;
    
    if(NULL == theBoard->theendpoints)
    {   // already deinitted
        return(eores_OK);
    }
   
    endpointsnum = eo_vector_Size(theBoard->theendpoints);
 
    for(i=0; i<endpointsnum; i++)
    {
        eOnvset_ep_t **ppep = (eOnvset_ep_t **)eo_vector_At(theBoard->theendpoints, i);
        eOnvset_ep_t *theEndpoint = *ppep;
        
        // now i erase memory associated with this endpoint
        eo_mempool_Delete(eo_mempool_GetHandle(), theEndpoint->epram);
        // and i dissociates that from from the internals of the eoprot library
        eoprot_config_endpoint_ram(theBoard->boardnum, theEndpoint->epcfg.endpoint, NULL, 0);
        // i also de-init the number of entities for that endpoint
        eoprot_config_endpoint_entities(theBoard->boardnum, theEndpoint->epcfg.endpoint, NULL);
        
        // now i delete all data associated to the mutex protection
        
        if(NULL != theEndpoint->mtx_endpoint)
        {
            eov_mutex_Delete(theEndpoint->mtx_endpoint);
        }
        if(NULL != theEndpoint->themtxofthenvs)
        {
            uint16_t size = eo_vector_Size(theEndpoint->themtxofthenvs);
            int j = 0;
            for(j=0; j<size; j++)
            {
                EOVmutexDerived** pmtx =  (EOVmutexDerived**)eo_vector_At(theEndpoint->themtxofthenvs, j);
                eov_mutex_Delete(*pmtx);            
            } 
            eo_vector_Delete(theEndpoint->themtxofthenvs);
        }
   
        // now i erase the memory of the entire eOnvset_ep_t entry        
        eo_mempool_Delete(eo_mempool_GetHandle(), theEndpoint);       
    }
    
    // so that we dont get in here inside again
    theBoard->theendpoints = NULL;

    return(eores_OK);
}
Ejemplo n.º 2
0
extern eOresult_t eo_confman_ConfirmationRequests_Process(EOconfirmationManager *p, eOipv4addr_t toipaddr)
{
    if(NULL == p)
    {
        return(eores_NOK_generic);  
    }
    
    eov_mutex_Take(p->mtx, eok_reltimeINFINITE);

    if(0 != eo_vector_Size(p->confrequests))
    {
        uint16_t size = eo_vector_Size(p->confrequests);
        uint16_t i=0;
        for(i=0; i<size; i++)
        {
            eOropdescriptor_t *ropdes = (eOropdescriptor_t*) eo_vector_At(p->confrequests, i);
            eo_confman_Confirmation_Requested(p, toipaddr, ropdes);            
        }       
        eo_vector_Clear(p->confrequests);   // remove the conf requests
    }
    
    eov_mutex_Release(p->mtx);
    
    return(eores_OK);    
}
Ejemplo n.º 3
0
static EOVmutexDerived* s_eo_nvset_get_nvmutex(EOnvSet* p, eOnvID32_t id32)
{
    EOVmutexDerived* mtx2use = NULL;
    
    if(eo_nvset_protection_none == p->protection)
    {   // the most common situation is no protection, thus ...
        mtx2use = NULL;
    }
    else
    {
        switch(p->protection)
        {            
            case eo_nvset_protection_one_per_board:
            {
                mtx2use = p->theboard.mtx_board;
            } break;            
       
            case eo_nvset_protection_one_per_endpoint:
            {
                // compute the endpoint and ....
                eOnvset_ep_t* theEndpoint = s_eo_nvset_get_endpoint(p, eoprot_ID2endpoint(id32));
                if(NULL != theEndpoint)
                {
                    mtx2use = theEndpoint->mtx_endpoint;
                }                    
            } break;  
            
            case eo_nvset_protection_one_per_netvar:
            {
                eOnvset_ep_t* theEndpoint = s_eo_nvset_get_endpoint(p, eoprot_ID2endpoint(id32));
                if(NULL != theEndpoint)
                {
                    //#warning .... i think of void* as a uint32_t* ///////////// think of it
                    uint32_t nvprognumber = eoprot_endpoint_id2prognum(p->theboard.boardnum, id32);
                    uint32_t** addr = eo_vector_At(theEndpoint->themtxofthenvs, nvprognumber);
                    mtx2use = (EOVmutexDerived*) (*addr);
                }
            } break;  
            
            default:
            {
                mtx2use = NULL;
            } break;
            
        }
    }
    
    return(mtx2use);  
}
Ejemplo n.º 4
0
static eOnvset_ep_t* s_eo_nvset_get_endpoint(EOnvSet* p, eOnvEP8_t ep8)
{
    eOnvset_brd_t* theBoard = &p->theboard;
    eOnvset_ep_t** ptheEndpoint = NULL;
    uint16_t onendpointindex = s_eonvset_EP2INDEX(p, ep8);
 
    if(EOK_uint16dummy == onendpointindex)
    {
        return(NULL);
    }   
    
    ptheEndpoint = (eOnvset_ep_t**) eo_vector_At(theBoard->theendpoints, onendpointindex);
    if(NULL == ptheEndpoint)
    {
        return(NULL);
    }    
   
    return(*ptheEndpoint);
}
Ejemplo n.º 5
0
extern eOresult_t eo_nvset_NVSinitialise(EOnvSet* p)
{
    eOnvset_brd_t* theBoard = NULL;   
    uint16_t j;
    uint16_t nendpoints;

 	if(NULL == p) 
	{
		return(eores_NOK_nullpointer); 
	}

    theBoard = &p->theboard;
    nendpoints = eo_vector_Size(theBoard->theendpoints);
    
    for(j=0; j<nendpoints; j++)
    {
        eOnvset_ep_t** theEndpoint = (eOnvset_ep_t**) eo_vector_At(theBoard->theendpoints, j);                        
        s_eo_nvset_NVsOfEP_Initialise(p, (*theEndpoint), (*theEndpoint)->epcfg.endpoint);
    }       

    return(eores_OK);
}
Ejemplo n.º 6
0
static eOresult_t s_eo_nvset_NVsOfEP_Initialise(EOnvSet* p, eOnvset_ep_t* endpoint, eOnvEP8_t ep08)
{
    eOnvset_brd_t* theBoard = NULL;
    eOnvset_ep_t* theEndpoint = endpoint;

    eOvoid_fp_uint32_voidp_t initialise = NULL;
    
 	if(NULL == p) 
	{
		return(eores_NOK_nullpointer); 
	}
    
    theBoard = &p->theboard;
    

    if(NULL == theEndpoint)
    {
        theEndpoint = s_eo_nvset_get_endpoint(p, ep08);   
        if(NULL == theEndpoint)
        {
            return(eores_NOK_generic);
        } 
        
//        if(ep08 != theEndpoint->epcfg.endpoint)
//        {
//            return(eores_NOK_generic);
//        }        
    }    
       

    if(eobool_true == (theEndpoint->initted))
    {   // already initted
        return(eores_OK);
    }            

    initialise = eoprot_endpoint_get_initialiser(ep08);
    
    if(NULL != initialise)
    {
        initialise(theBoard->ipaddress, theEndpoint->epram);
    }
    
    theEndpoint->initted = eobool_true;
    

#define EO_NVSET_INIT_EVERY_NV
#if defined(EO_NVSET_INIT_EVERY_NV)
    {   // put parenthesis to create a new scope and avoid errors in non c99 environments as windows
        EOnv thenv = {0};
        uint16_t k = 0;
        EOnv_rom_t* rom = NULL;
        uint8_t* ram = NULL;
        uint16_t nvars = theEndpoint->epnvsnumberof;
        eOipv4addr_t ip = theBoard->ipaddress;
        uint8_t brd =  theBoard->boardnum; // local or 0, 1, 2, 3
        eOnvID32_t id32 = EOK_uint32dummy;     
        uint32_t prog = 0;
        eObool_t proxied = eobool_false;
        eOvoid_fp_cnvp_cropdesp_t onsay = NULL;
        
        EOVmutexDerived* mtx2use = NULL;

        if(eo_nvset_protection_one_per_board == p->protection)
        {
            mtx2use = theBoard->mtx_board;
        }
        else if(eo_nvset_protection_one_per_endpoint == p->protection)
        {
            mtx2use = theEndpoint->mtx_endpoint;
        }
        // else if eo_nvset_protection_one_per_netvar ... eval foreach k

        for(k=0; k<nvars; k++)
        {
            if(eo_nvset_protection_one_per_netvar == p->protection)
            {
                //#warning -> think of uint32 and void* maybe use uint64
                uint32_t** addr = eo_vector_At(theEndpoint->themtxofthenvs, k);
                mtx2use = (EOVmutexDerived*) (*addr);
            }
            
            prog = k;
            // - 0. the id32 
            id32 = eoprot_endpoint_prognum2id(brd, ep08, prog);               
            if(EOK_uint32dummy == id32)
            {
                continue;
            }

            // - 0+. proxied?
            proxied = eoprot_variable_is_proxied(brd, id32);                
            // - 0++ onsay
            onsay = eoprot_onsay_endpoint_get(ep08); 
            // - 1. the rom
            rom = (EOnv_rom_t*) eoprot_variable_romof_get(brd, id32);
            // - 2. the ram
            ram = (uint8_t*) eoprot_variable_ramof_get(brd, id32);
            // - 3. the mtx
            mtx2use = mtx2use;
            // - load everything into the nv
            eo_nv_hid_Load(     &thenv,
                                ip, 
                                brd,
                                proxied,
                                id32,
                                onsay,
                                rom,
                                ram,
                                mtx2use
                          );                    
            
         
            eo_nv_Init(&thenv);                             
        }
    }   // put parenthesis to create a new scope and avoid errors in non c99 environments as windows
#endif //EO_NVSET_INIT_EVERY_NV                   

    
    return(eores_OK);    
}