Пример #1
0
/************************************************************************
* NAME: fnet_timer_new
*
* DESCRIPTION: Creates new software timer with the period 
*              
*************************************************************************/
fnet_timer_desc_t fnet_timer_new( unsigned long period_ticks, void (*handler)( void * ), void *cookie )
{
    struct fnet_net_timer *timer = FNET_NULL;

    if( period_ticks && handler )
    {
        timer = (struct fnet_net_timer *)fnet_malloc(sizeof(struct fnet_net_timer));

        if(timer)
        {
            timer->next = fnet_tl_head;

            fnet_tl_head = timer;

            timer->timer_cnt = 0;

            timer->timer_rv = period_ticks;

            timer->handler = handler;
            timer->cookie = cookie;
        }
    }

    return (fnet_timer_desc_t)timer;
}
Пример #2
0
/************************************************************************
* NAME: fnet_isr_register
*
* DESCRIPTION: Register 'handler' at the isr table.
*************************************************************************/
static int fnet_isr_register( unsigned int vector_number, void (*handler_top)(void *cookie), void (*handler_bottom)(void *cookie), void *cookie )
{
    int                 result;
    fnet_isr_entry_t    *isr_temp;

    isr_temp = (fnet_isr_entry_t *)fnet_malloc(sizeof(fnet_isr_entry_t));

    if(isr_temp)
    {
        isr_temp->vector_number = vector_number;
        isr_temp->handler_top = (void (*)(void *cookie))handler_top;
        isr_temp->handler_bottom = (void (*)(void *cookie))handler_bottom;
        isr_temp->next = fnet_isr_table;
        isr_temp->pended = 0;
        isr_temp->cookie = cookie;
        isr_temp->num_of_times_pended = 0;
        isr_temp->num_of_times_serviced = 0;
        fnet_isr_table = isr_temp;
        
        result = FNET_OK;
    }
    else
        result = FNET_ERR;

    return result;
}
Пример #3
0
/************************************************************************
* NAME: fnet_malloc
*
* DESCRIPTION: Allocates memory in heap for TCP/IP
*              
*************************************************************************/
void *fnet_malloc_zero( fnet_size_t nbytes )
{
    void *result;

    result = fnet_malloc(nbytes);
    if(result)
    {
        fnet_memset_zero(result, nbytes);
    }

    return result;
}
Пример #4
0
/************************************************************************
* NAME: fnet_malloc
*
* DESCRIPTION: Allocates memory in heap for TCP/IP
*              
*************************************************************************/
void *fnet_malloc_zero( unsigned nbytes )
{
    void *result;

    result = fnet_malloc(nbytes);
    if(result)
    {
        fnet_memset_zero(result, nbytes);
    }

    return result;
}
Пример #5
0
/************************************************************************
* NAME: fnet_heap_init
*
* DESCRIPTION: Heap init
*              
*************************************************************************/
int fnet_heap_init( unsigned char *heap_ptr, unsigned long heap_size )
{
    int result;


/* Init memory pools. */
#if FNET_HEAP_SPLIT
    if(((fnet_mempool_main = fnet_mempool_init( heap_ptr, heap_size, FNET_MEMPOOL_ALIGN_8 )) != 0) &&
       ((fnet_mempool_netbuf = fnet_mempool_init( (void*)((unsigned long)fnet_malloc( FNET_NETBUF_MEMPOOL_SIZE(heap_size))), 
                                                    FNET_NETBUF_MEMPOOL_SIZE(heap_size), FNET_MEMPOOL_ALIGN_8 )) != 0) )

#else
     if((fnet_mempool_main = fnet_mempool_init( heap_ptr, heap_size, FNET_MEMPOOL_ALIGN_8 )) != 0)
#endif
        result = FNET_OK;
     else
        result = FNET_ERR;  
                                                             
   
    return result;
}
Пример #6
0
/************************************************************************
* NAME: fnet_heap_init
*
* DESCRIPTION: Heap init
*              
*************************************************************************/
fnet_return_t fnet_heap_init( void *heap_ptr, fnet_size_t heap_size )
{
    fnet_return_t result;

/* Init memory pools. */
#if FNET_HEAP_SPLIT
    if(((fnet_mempool_main = fnet_mempool_init( heap_ptr, heap_size, FNET_MEMPOOL_ALIGN_8 )) != 0) &&
       ((fnet_mempool_netbuf = fnet_mempool_init( (void*)((fnet_uint32_t)fnet_malloc( FNET_NETBUF_MEMPOOL_SIZE(heap_size))), 
                                                    FNET_NETBUF_MEMPOOL_SIZE(heap_size), FNET_MEMPOOL_ALIGN_8 )) != 0) )

#else
     if((fnet_mempool_main = fnet_mempool_init( heap_ptr, heap_size, FNET_MEMPOOL_ALIGN_8 )) != 0)
#endif
    {
        result = FNET_OK;
    }
    else
    {
        result = FNET_ERR;  
    }

    return result;
}