khypervisor  v1
Functions | Variables
timer.c File Reference
#include "timer.h"
#include "generic_timer.h"
#include <config/cfg_platform.h>
#include <k-hypervisor-config.h>
Include dependency graph for timer.c:

Go to the source code of this file.

Functions

static void _timer_each_callback_channel (timer_channel_t channel, void *param)
static int _timer_channel_num_callbacks (timer_channel_t channel)
static void _timer_hw_callback (void *pdata)
hvmm_status_t timer_init (timer_channel_t channel)
hvmm_status_t timer_start (timer_channel_t channel)
hvmm_status_t timer_stop (timer_channel_t channel)
hvmm_status_t timer_set_interval (timer_channel_t channel, uint32_t interval_us)
uint32_t timer_get_interval (timer_channel_t channel)
hvmm_status_t timer_add_callback (timer_channel_t channel, timer_callback_t callback)
hvmm_status_t timer_remove_callback (timer_channel_t channel, timer_callback_t callback)
uint64_t timer_t2c (uint64_t time_us)

Variables

static struct timer_channel _channels [TIMER_NUM_MAX_CHANNELS]

Function Documentation

static int _timer_channel_num_callbacks ( timer_channel_t  channel) [static]

Definition at line 23 of file timer.c.

{
    int i, count = 0;
    for( i = 0; i < TIMER_MAX_CHANNEL_CALLBACKS; i++) {
        if( _channels[channel].callbacks[i] ) count++;
    }
    return count;
}
static void _timer_each_callback_channel ( timer_channel_t  channel,
void *  param 
) [static]

Definition at line 15 of file timer.c.

{
    int i;
    for( i = 0; i < TIMER_MAX_CHANNEL_CALLBACKS; i++ ) {
        if( _channels[channel].callbacks[i] ) _channels[channel].callbacks[i](param);
    }
}
static void _timer_hw_callback ( void *  pdata) [static]

Definition at line 87 of file timer.c.

{
    int i;
    hvmm_status_t result = HVMM_STATUS_BUSY;
    for( i = 0; i < TIMER_MAX_CHANNEL_CALLBACKS; i++ ) {
        if( _channels[channel].callbacks[i] == 0 ) {
            _channels[channel].callbacks[i] = callback;
            result = HVMM_STATUS_SUCCESS;
            break;
        }
    }
    return result;
}

Definition at line 82 of file timer.c.

{
    return _channels[channel].interval_us;
}

Definition at line 43 of file timer.c.

{   
    int i;
    for( i = 0; i < TIMER_MAX_CHANNEL_CALLBACKS; i++ ) {
        _channels[channel].callbacks[i] = 0;
    }

    generic_timer_init();
    return HVMM_STATUS_SUCCESS;
}

Here is the call graph for this function:

Definition at line 101 of file timer.c.

{
    int i;
    hvmm_status_t result = HVMM_STATUS_NOT_FOUND;
    for( i = 0; i < TIMER_MAX_CHANNEL_CALLBACKS; i++ ) {
        if ( _channels[channel].callbacks[i] == callback ) {
            _channels[channel].callbacks[i] = 0;
            result = HVMM_STATUS_SUCCESS;
            break;
        }
    }
    return result;
}
hvmm_status_t timer_set_interval ( timer_channel_t  channel,
uint32_t  interval_us 
)

Definition at line 76 of file timer.c.

{
    _channels[channel].interval_us = timer_t2c(interval_us);
    return HVMM_STATUS_SUCCESS;
}

Here is the call graph for this function:

Definition at line 70 of file timer.c.

Here is the call graph for this function:

uint64_t timer_t2c ( uint64_t  time_us)

Definition at line 115 of file timer.c.

{
    return time_us * COUNT_PER_USEC;
}

Variable Documentation

Definition at line 13 of file timer.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines