Rev 1260 | Rev 1702 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1260 | Rev 1434 | ||
---|---|---|---|
Line 74... | Line 74... | ||
74 | ipl_t interrupts_read(void) |
74 | ipl_t interrupts_read(void) |
75 | { |
75 | { |
76 | return cp0_status_read(); |
76 | return cp0_status_read(); |
77 | } |
77 | } |
78 | 78 | ||
- | 79 | /* TODO: This is SMP unsafe!!! */ |
|
- | 80 | static unsigned long nextcount; |
|
- | 81 | /** Start hardware clock */ |
|
- | 82 | static void timer_start(void) |
|
- | 83 | { |
|
- | 84 | nextcount = cp0_compare_value + cp0_count_read(); |
|
- | 85 | cp0_compare_write(nextcount); |
|
- | 86 | } |
|
- | 87 | ||
79 | static void timer_exception(int n, istate_t *istate) |
88 | static void timer_exception(int n, istate_t *istate) |
80 | { |
89 | { |
- | 90 | unsigned long drift; |
|
- | 91 | ||
- | 92 | drift = cp0_count_read() - nextcount; |
|
- | 93 | while (drift > cp0_compare_value) { |
|
- | 94 | drift -= cp0_compare_value; |
|
- | 95 | CPU->missed_clock_ticks++; |
|
- | 96 | } |
|
81 | cp0_compare_write(cp0_count_read() + cp0_compare_value); |
97 | nextcount = cp0_count_read() + cp0_compare_value - drift; |
- | 98 | cp0_compare_write(nextcount); |
|
82 | clock(); |
99 | clock(); |
83 | } |
100 | } |
84 | 101 | ||
85 | static void swint0(int n, istate_t *istate) |
102 | static void swint0(int n, istate_t *istate) |
86 | { |
103 | { |
Line 98... | Line 115... | ||
98 | void interrupt_init(void) |
115 | void interrupt_init(void) |
99 | { |
116 | { |
100 | int_register(TIMER_IRQ, "timer", timer_exception); |
117 | int_register(TIMER_IRQ, "timer", timer_exception); |
101 | int_register(0, "swint0", swint0); |
118 | int_register(0, "swint0", swint0); |
102 | int_register(1, "swint1", swint1); |
119 | int_register(1, "swint1", swint1); |
- | 120 | timer_start(); |
|
103 | } |
121 | } |
104 | 122 | ||
105 | static void ipc_int(int n, istate_t *istate) |
123 | static void ipc_int(int n, istate_t *istate) |
106 | { |
124 | { |
107 | ipc_irq_send_notif(n-INT_OFFSET); |
125 | ipc_irq_send_notif(n-INT_OFFSET); |