Changeset 0287820 in mainline for kernel/arch/mips32/src/interrupt.c


Ignore:
Timestamp:
2007-12-02T00:54:24Z (17 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8df2eab
Parents:
d4e38c7
Message:

CPU cycle accounting on MIPS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/mips32/src/interrupt.c

    rd4e38c7 r0287820  
    9090
    9191/* TODO: This is SMP unsafe!!! */
     92uint32_t count_hi = 0;
    9293static unsigned long nextcount;
     94static unsigned long lastcount;
     95
    9396/** Start hardware clock */
    9497static void timer_start(void)
    9598{
     99        lastcount = cp0_count_read();
    96100        nextcount = cp0_compare_value + cp0_count_read();
    97101        cp0_compare_write(nextcount);
     
    106110{
    107111        unsigned long drift;
    108 
     112       
     113        if (cp0_count_read() < lastcount) {
     114                /* Count overflow detection */
     115                count_hi++;
     116                lastcount = cp0_count_read();
     117        }
     118       
    109119        drift = cp0_count_read() - nextcount;
    110120        while (drift > cp0_compare_value) {
     
    114124        nextcount = cp0_count_read() + cp0_compare_value - drift;
    115125        cp0_compare_write(nextcount);
    116 
     126       
    117127        /*
    118128         * We are holding a lock which prevents preemption.
Note: See TracChangeset for help on using the changeset viewer.