Changeset 2a0cda72 in mainline


Ignore:
Timestamp:
2006-12-14T18:14:47Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7f95cc5d
Parents:
aeaebcc
Message:

On sparc64's tick interrupt, adjust the TICK_COMPARE register instead of the TICK
register. The TICK register now increments linearily and can be used by the get_cycle()
function.

Location:
kernel/arch/sparc64
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/include/cpu.h

    raeaebcc r2a0cda72  
    5656        ver_reg_t ver;
    5757        uint32_t clock_frequency;       /**< Processor frequency in MHz. */
     58        uint64_t next_tick_cmpr;        /**< Next clock interrupt should be
     59                                         *   generated in this amount of ticks.
     60                                         */
    5861};
    5962       
  • kernel/arch/sparc64/include/cycle.h

    raeaebcc r2a0cda72  
    4040static inline uint64_t get_cycle(void)
    4141{
    42         return 0;       /* not yet supported */
     42        return tick_read();
    4343}
    4444
  • kernel/arch/sparc64/src/drivers/tick.c

    raeaebcc r2a0cda72  
    5353        interrupt_register(14, "tick_int", tick_interrupt);
    5454        compare.int_dis = false;
    55         compare.tick_cmpr = CPU->arch.clock_frequency/HZ;
     55        compare.tick_cmpr = CPU->arch.clock_frequency / HZ;
     56        CPU->arch.next_tick_cmpr = compare.tick_cmpr;
    5657        tick_compare_write(compare.value);
    5758        tick_write(0);
     
    6667{
    6768        softint_reg_t softint, clear;
    68         uint64_t next, compare, start, stop;
     69        uint64_t drift;
    6970       
    7071        softint.value = softint_read();
     
    8889       
    8990        /*
    90          * Restart counter.
     91         * Reprogram the compare register.
     92         * For now, we can ignore the potential of the registers to overflow.
     93         * On a 360MHz Ultra 60, the 63-bit compare counter will overflow in
     94         * about 812 years. If there was a 2GHz UltraSPARC computer, it would
     95         * overflow only in 146 years.
    9196         */
    92         compare = CPU->arch.clock_frequency/HZ;
    93         start = tick_read();
    94         next = start - compare;
    95         while (next >= compare - TICK_RESTART_TIME) {
    96                 next -= compare;
     97        drift = tick_read() - CPU->arch.next_tick_cmpr;
     98        while (drift > CPU->arch.clock_frequency / HZ) {
     99                drift -= CPU->arch.clock_frequency / HZ;
    97100                CPU->missed_clock_ticks++;
    98101        }
    99         stop = tick_read();
    100         tick_write(next + (stop - start));
    101        
     102        CPU->arch.next_tick_cmpr = tick_read() + (CPU->arch.clock_frequency / HZ)
     103                - drift;
     104        tick_compare_write(CPU->arch.next_tick_cmpr);
    102105        clock();
    103106}
Note: See TracChangeset for help on using the changeset viewer.