Rev 3742 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3742 | Rev 3770 | ||
|---|---|---|---|
| Line 51... | Line 51... | ||
| 51 | /* initialize TICK interrupt */ |
51 | /* initialize TICK interrupt */ |
| 52 | tick_compare_reg_t compare; |
52 | tick_compare_reg_t compare; |
| 53 | 53 | ||
| 54 | interrupt_register(14, "tick_int", tick_interrupt); |
54 | interrupt_register(14, "tick_int", tick_interrupt); |
| 55 | compare.int_dis = false; |
55 | compare.int_dis = false; |
| - | 56 | compare.tick_cmpr = tick_counter_read() + |
|
| 56 | compare.tick_cmpr = CPU->arch.clock_frequency / HZ; |
57 | CPU->arch.clock_frequency / HZ; |
| 57 | CPU->arch.next_tick_cmpr = compare.tick_cmpr; |
58 | CPU->arch.next_tick_cmpr = compare.tick_cmpr; |
| 58 | tick_compare_write(compare.value); |
59 | tick_compare_write(compare.value); |
| 59 | tick_write(0); |
- | |
| 60 | 60 | ||
| 61 | #if defined (US3) |
61 | #if defined (US3) |
| 62 | /* disable STICK interrupts and clear any pending ones */ |
62 | /* disable STICK interrupts and clear any pending ones */ |
| 63 | tick_compare_reg_t stick_compare; |
63 | tick_compare_reg_t stick_compare; |
| 64 | softint_reg_t clear; |
64 | softint_reg_t clear; |
| Line 108... | Line 108... | ||
| 108 | * For now, we can ignore the potential of the registers to overflow. |
108 | * For now, we can ignore the potential of the registers to overflow. |
| 109 | * On a 360MHz Ultra 60, the 63-bit compare counter will overflow in |
109 | * On a 360MHz Ultra 60, the 63-bit compare counter will overflow in |
| 110 | * about 812 years. If there was a 2GHz UltraSPARC computer, it would |
110 | * about 812 years. If there was a 2GHz UltraSPARC computer, it would |
| 111 | * overflow only in 146 years. |
111 | * overflow only in 146 years. |
| 112 | */ |
112 | */ |
| 113 | drift = tick_read() - CPU->arch.next_tick_cmpr; |
113 | drift = tick_counter_read() - CPU->arch.next_tick_cmpr; |
| 114 | while (drift > CPU->arch.clock_frequency / HZ) { |
114 | while (drift > CPU->arch.clock_frequency / HZ) { |
| 115 | drift -= CPU->arch.clock_frequency / HZ; |
115 | drift -= CPU->arch.clock_frequency / HZ; |
| 116 | CPU->missed_clock_ticks++; |
116 | CPU->missed_clock_ticks++; |
| 117 | } |
117 | } |
| 118 | CPU->arch.next_tick_cmpr = tick_read() + |
118 | CPU->arch.next_tick_cmpr = tick_counter_read() + |
| 119 | (CPU->arch.clock_frequency / HZ) - drift; |
119 | (CPU->arch.clock_frequency / HZ) - drift; |
| 120 | tick_compare_write(CPU->arch.next_tick_cmpr); |
120 | tick_compare_write(CPU->arch.next_tick_cmpr); |
| 121 | clock(); |
121 | clock(); |
| 122 | } |
122 | } |
| 123 | 123 | ||