Changeset 0287820 in mainline


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

Location:
kernel/arch/mips32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/mips32/include/cycle.h

    rd4e38c7 r0287820  
    3636#define KERN_mips32_CYCLE_H_
    3737
     38#include <arch/cp0.h>
     39#include <arch/interrupt.h>
     40
    3841static inline uint64_t get_cycle(void)
    3942{
    40         return 0;
     43        return ((uint64_t) count_hi << 32) + ((uint64_t) cp0_count_read());
    4144}
    4245
  • kernel/arch/mips32/include/interrupt.h

    rd4e38c7 r0287820  
    4343
    4444extern function virtual_timer_fnc;
     45extern uint32_t count_hi;
    4546
    4647extern void interrupt_init(void);
  • 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.