Rev 1937 | Rev 2060 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1937 | Rev 1942 | ||
|---|---|---|---|
| Line 32... | Line 32... | ||
| 32 | */ |
32 | */ |
| 33 | /** @file |
33 | /** @file |
| 34 | */ |
34 | */ |
| 35 | 35 | ||
| 36 | #include <arch/interrupt.h> |
36 | #include <arch/interrupt.h> |
| - | 37 | #include <interrupt.h> |
|
| - | 38 | #include <ddi/irq.h> |
|
| 37 | #include <panic.h> |
39 | #include <panic.h> |
| 38 | #include <print.h> |
40 | #include <print.h> |
| - | 41 | #include <symtab.h> |
|
| - | 42 | #include <debug.h> |
|
| 39 | #include <console/console.h> |
43 | #include <console/console.h> |
| 40 | #include <arch/types.h> |
44 | #include <arch/types.h> |
| 41 | #include <arch/asm.h> |
45 | #include <arch/asm.h> |
| 42 | #include <arch/barrier.h> |
46 | #include <arch/barrier.h> |
| 43 | #include <arch/register.h> |
47 | #include <arch/register.h> |
| 44 | #include <arch/drivers/it.h> |
- | |
| 45 | #include <arch.h> |
48 | #include <arch.h> |
| 46 | #include <symtab.h> |
- | |
| 47 | #include <debug.h> |
- | |
| 48 | #include <syscall/syscall.h> |
49 | #include <syscall/syscall.h> |
| 49 | #include <print.h> |
50 | #include <print.h> |
| 50 | #include <proc/scheduler.h> |
51 | #include <proc/scheduler.h> |
| 51 | #include <ipc/sysipc.h> |
52 | #include <ipc/sysipc.h> |
| 52 | #include <ipc/irq.h> |
53 | #include <ipc/irq.h> |
| 53 | #include <ipc/ipc.h> |
54 | #include <ipc/ipc.h> |
| 54 | #include <interrupt.h> |
55 | #include <synch/spinlock.h> |
| 55 | - | ||
| 56 | 56 | ||
| 57 | #define VECTORS_64_BUNDLE 20 |
57 | #define VECTORS_64_BUNDLE 20 |
| 58 | #define VECTORS_16_BUNDLE 48 |
58 | #define VECTORS_16_BUNDLE 48 |
| 59 | #define VECTORS_16_BUNDLE_START 0x5000 |
59 | #define VECTORS_16_BUNDLE_START 0x5000 |
| 60 | #define VECTOR_MAX 0x7f00 |
60 | #define VECTOR_MAX 0x7f00 |
| 61 | 61 | ||
| 62 | #define BUNDLE_SIZE 16 |
62 | #define BUNDLE_SIZE 16 |
| 63 | 63 | ||
| 64 | - | ||
| 65 | char *vector_names_64_bundle[VECTORS_64_BUNDLE] = { |
64 | char *vector_names_64_bundle[VECTORS_64_BUNDLE] = { |
| 66 | "VHPT Translation vector", |
65 | "VHPT Translation vector", |
| 67 | "Instruction TLB vector", |
66 | "Instruction TLB vector", |
| 68 | "Data TLB vector", |
67 | "Data TLB vector", |
| 69 | "Alternate Instruction TLB vector", |
68 | "Alternate Instruction TLB vector", |
| Line 195... | Line 194... | ||
| 195 | dump_interrupted_context(istate); |
194 | dump_interrupted_context(istate); |
| 196 | panic("Interruption: %#hx (%s)\n", (uint16_t) vector, vector_to_string(vector)); |
195 | panic("Interruption: %#hx (%s)\n", (uint16_t) vector, vector_to_string(vector)); |
| 197 | #endif |
196 | #endif |
| 198 | } |
197 | } |
| 199 | 198 | ||
| 200 | - | ||
| 201 | void nop_handler(uint64_t vector, istate_t *istate) |
199 | void nop_handler(uint64_t vector, istate_t *istate) |
| 202 | { |
200 | { |
| 203 | } |
201 | } |
| 204 | 202 | ||
| 205 | - | ||
| 206 | /** Handle syscall. */ |
203 | /** Handle syscall. */ |
| 207 | int break_instruction(uint64_t vector, istate_t *istate) |
204 | int break_instruction(uint64_t vector, istate_t *istate) |
| 208 | { |
205 | { |
| 209 | /* |
206 | /* |
| 210 | * Move to next instruction after BREAK. |
207 | * Move to next instruction after BREAK. |
| Line 226... | Line 223... | ||
| 226 | panic("Interruption: %#hx (%s)\n", (uint16_t) vector, vector_to_string(vector)); |
223 | panic("Interruption: %#hx (%s)\n", (uint16_t) vector, vector_to_string(vector)); |
| 227 | } |
224 | } |
| 228 | 225 | ||
| 229 | void external_interrupt(uint64_t vector, istate_t *istate) |
226 | void external_interrupt(uint64_t vector, istate_t *istate) |
| 230 | { |
227 | { |
| - | 228 | irq_t *irq; |
|
| 231 | cr_ivr_t ivr; |
229 | cr_ivr_t ivr; |
| 232 | 230 | ||
| 233 | ivr.value = ivr_read(); |
231 | ivr.value = ivr_read(); |
| 234 | srlz_d(); |
232 | srlz_d(); |
| 235 | 233 | ||
| - | 234 | irq = irq_dispatch_and_lock(ivr.vector); |
|
| 236 | switch(ivr.vector) { |
235 | if (irq) { |
| 237 | case INTERRUPT_TIMER: |
236 | irq->handler(irq, irq->arg); |
| 238 | it_interrupt(); |
237 | spinlock_unlock(&irq->lock); |
| 239 | break; |
238 | } else { |
| - | 239 | switch (ivr.vector) { |
|
| 240 | case INTERRUPT_SPURIOUS: |
240 | case INTERRUPT_SPURIOUS: |
| - | 241 | #ifdef CONFIG_DEBUG |
|
| 241 | printf("cpu%d: spurious interrupt\n", CPU->id); |
242 | printf("cpu%d: spurious interrupt\n", CPU->id); |
| 242 | break; |
- | |
| 243 | default: |
243 | #endif |
| 244 | panic("\nUnhandled External Interrupt Vector %d\n", ivr.vector); |
- | |
| 245 | break; |
244 | break; |
| 246 | } |
- | |
| 247 | } |
- | |
| 248 | 245 | ||
| 249 | void virtual_interrupt(uint64_t irq, void *param) |
- | |
| 250 | { |
- | |
| 251 | switch(irq) { |
- | |
| 252 | case IRQ_KBD: |
- | |
| 253 | if (kbd_uspace) |
- | |
| 254 | ipc_irq_send_notif(irq); |
- | |
| 255 | break; |
- | |
| 256 | default: |
246 | default: |
| 257 | panic("\nUnhandled Virtual Interrupt request %d\n", irq); |
247 | panic("\nUnhandled External Interrupt Vector %d\n", ivr.vector); |
| 258 | break; |
248 | break; |
| - | 249 | } |
|
| 259 | } |
250 | } |
| 260 | } |
251 | } |
| 261 | 252 | ||
| 262 | /** @} |
253 | /** @} |
| 263 | */ |
254 | */ |