コード例 #1
0
/*
 *  ======== TimestampProvider_get32 ========
 *  The 32-bit timestamp can be retrieved more efficiently than the 64-bit one,
 *  so it has a different implementation.
 */
Bits32 TimestampProvider_get32() 
{
    /*
     * If we're sharing the Clock timer, get the timestamp by using the Clock
     * tick count.
     */
    if (TimestampProvider_useClockTimer) {
        UInt key;
        UInt32 timestamp;

        /* 
         * Disable interrupts so that the Clock tick count doesn't change if 
         * the timer expires while we are reading it.
         */
        key = Hwi_disable();

        /* 
         * timestamp = (clock ticks) x (tick period) + (current timer count)
         * The 'getExpiredCounts' API retrieves the current Timer count and
         * also accounts for timer rollover.
         */
        timestamp = Clock_getTicks() * Timer_getPeriod(MOD->timer)
                    + Timer_getExpiredCounts(MOD->timer);

        Hwi_restore(key);

        return (timestamp);
    }
    /* If we have a dedicated timer, just read the timer count. */
    else {
        return (Timer_getCount(MOD->timer));
    }
}
コード例 #2
0
ファイル: Timer.c プロジェクト: mobiaqua/ti-sysbios-c64t
/*
 *  ======== Timer_getExpiredTicks ========
 */
UInt32 Timer_getExpiredTicks(Timer_Object *obj, UInt32 tickPeriod)
{
    UInt32 ticks;

    ticks = Timer_getExpiredCounts(obj) / tickPeriod;

    return (ticks);
}
コード例 #3
0
/*
 *  ======== TimestampProvider_get32 ========
 */
Bits32 TimestampProvider_get32()
{
    UInt32 timestamp;
    UInt key;

    key = Hwi_disable();

    if (BIOS_clockEnabled && TimestampProvider_useClockTimer) {
        timestamp = (Clock_getCompletedTicks() * Clock_getTickPeriod())
                   + Timer_getExpiredCounts(MOD->timer);
    }
    else {
        timestamp = (MOD->rollovers * Timer_MAX_PERIOD)
                   + Timer_getExpiredCounts(MOD->timer);
    }

    Hwi_restore(key);

    return (timestamp);
}
コード例 #4
0
/*
 *  ======== TimestampProvider_get32 ========
 */
Bits32 TimestampProvider_get32()
{
    UInt32 timestamp;
    UInt key;

    key = Hwi_disable();

    if (TimestampProvider_useClockTimer) {
        timestamp = (Clock_getCompletedTicks() * Clock_getTickPeriod())
                   + Timer_getExpiredCounts(MOD->timer);
    }
    else {
        timestamp = (MOD->rollovers << 16) + Timer_getExpiredCounts(MOD->timer);
        timestamp -= MOD->rollovers; /* adjust for Timer_MAX_PERIOD = 0xFFFF */
    }

    Hwi_restore(key);

    return (timestamp);
}
コード例 #5
0
/*
 *  ======== TimestampProvider_get64 ========
 */
Void TimestampProvider_get64(Types_Timestamp64 *result)
{
    UInt key;
    UInt64 timestamp;

    key = Hwi_disable();

    if (TimestampProvider_useClockTimer) {

        timestamp = Clock_getTicks() * Timer_getPeriod(MOD->timer)
                   + Timer_getExpiredCounts(MOD->timer);
    }
    else {
        timestamp = ((UInt64)MOD->hi << 32) + Timer_getExpiredCounts(MOD->timer);
    }

    Hwi_restore(key);

    result->hi = timestamp >> 32;
    result->lo = timestamp;
}
コード例 #6
0
/*
 *  ======== TimestampProvider_get32 ========
 */
Bits32 TimestampProvider_get32()
{
    if (TimestampProvider_useClockTimer) {
        UInt key;
        UInt32 timestamp;

        key = Hwi_disable();

        timestamp = Clock_getTicks() * Timer_getPeriod(MOD->timer)
                    + Timer_getExpiredCounts(MOD->timer);

        Hwi_restore(key);

        return (timestamp);
    }
    else {
        return (Timer_getCount(MOD->timer));
    }
}
コード例 #7
0
/*
 *  ======== TimestampProvider_get64 ========
 *  This API has different implementations based on whether we're using a
 *  dedicated timer or sharing the Clock timer. 
 *  If we're sharing the Clock timer, we have to multiply the Clock tick count
 *  by the Clock tick period. If we have a dedicate timer, the timer period is
 *  2^32, so we can just use the MOD->hi tick count as the upper 32-bits of the
 *  timestamp.
 */
Void TimestampProvider_get64(Types_Timestamp64 *result) 
{
    UInt key;
    
    /*
     * If we're sharing the Clock timer, get the timestamp by using the Clock
     * tick count.
     */
    if (TimestampProvider_useClockTimer) {
        UInt64 timestamp;
        
        /* 
         * Disable interrupts so that the Clock tick count doesn't change if 
         * the timer expires while we are reading it.
         */
        key = Hwi_disable();

        /* 
         * timestamp = (clock ticks) x (tick period) + (current timer count)
         * The 'getExpiredCounts' API retrieves the current Timer count and
         * also accounts for timer rollover.
         */
        timestamp = (UInt64) Clock_getTicks() * Timer_getPeriod(MOD->timer)
                    + Timer_getExpiredCounts(MOD->timer);

        Hwi_restore(key);

        /* 
         * Copy the value into the result structure.
         *
         * The 28x is little endian, so it stores the 16-bit words
         * in reverse order. For example, the value
         * 0xFEDCBA9876543210
         * Is stored as:
         *   Address   Value
         *   0x0       0x3210
         *   0x1       0x7654
         *   0x2       0xBA98
         *   0x3       0xFEDC
         *
         * To retrieve the lower 32 bits, simply cast the value as a UInt32.
         * To retrieve the upper 32 bits, cast the address of 'timestamp' as a
         * pointer to a UInt32, increment the pointer by 1, then retrieve the
         * value at that address.
         */
        result->lo = (UInt32) timestamp;
        result->hi = *(((UInt32 *) &timestamp) + 1);
    }
    /* If we have a dedicated timer... */
    else {
        /* Disable interrupts while reading the tick count and timer value. */
        key = Hwi_disable();
        
        /* Use the tick counter as the upper 32-bits. */
        result->hi = MOD->hi;
        /* 
         * Get the timer value as the lower 32-bits. This API will also take
         * timer rollover into account and add 1 to result->hi if necessary.
         */
        Timer_getExpiredCounts64(MOD->timer, result);

        Hwi_restore(key);        
    }
}