Rev 958 | Rev 1050 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 226 | palkovsky | 1 | /* |
| 2 | * Copyright (C) 2001-2004 Jakub Jermar |
||
| 3 | * All rights reserved. |
||
| 4 | * |
||
| 5 | * Redistribution and use in source and binary forms, with or without |
||
| 6 | * modification, are permitted provided that the following conditions |
||
| 7 | * are met: |
||
| 8 | * |
||
| 9 | * - Redistributions of source code must retain the above copyright |
||
| 10 | * notice, this list of conditions and the following disclaimer. |
||
| 11 | * - Redistributions in binary form must reproduce the above copyright |
||
| 12 | * notice, this list of conditions and the following disclaimer in the |
||
| 13 | * documentation and/or other materials provided with the distribution. |
||
| 14 | * - The name of the author may not be used to endorse or promote products |
||
| 15 | * derived from this software without specific prior written permission. |
||
| 16 | * |
||
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
||
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
||
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
| 27 | */ |
||
| 28 | |||
| 29 | #include <arch/interrupt.h> |
||
| 30 | #include <print.h> |
||
| 31 | #include <debug.h> |
||
| 32 | #include <panic.h> |
||
| 33 | #include <arch/i8259.h> |
||
| 34 | #include <func.h> |
||
| 35 | #include <cpu.h> |
||
| 36 | #include <arch/asm.h> |
||
| 37 | #include <mm/tlb.h> |
||
| 703 | jermar | 38 | #include <mm/as.h> |
| 226 | palkovsky | 39 | #include <arch.h> |
| 268 | palkovsky | 40 | #include <symtab.h> |
| 282 | palkovsky | 41 | #include <arch/asm.h> |
| 309 | palkovsky | 42 | #include <proc/scheduler.h> |
| 391 | jermar | 43 | #include <proc/thread.h> |
| 226 | palkovsky | 44 | |
| 958 | jermar | 45 | static void print_info_errcode(int n, istate_t *istate) |
| 297 | palkovsky | 46 | { |
| 47 | char *symbol; |
||
| 958 | jermar | 48 | __u64 *x = &istate->stack[0]; |
| 297 | palkovsky | 49 | |
| 1021 | jermar | 50 | if (!(symbol=get_symtab_entry(istate->rip))) |
| 286 | palkovsky | 51 | symbol = ""; |
| 52 | |||
| 1021 | jermar | 53 | printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n, __FUNCTION__); |
| 54 | printf("%%rip: %Q (%s)\n",istate->rip, symbol); |
||
| 55 | printf("ERROR_WORD=%Q\n", istate->error_word); |
||
| 56 | printf("%%rcs=%Q, flags=%Q, %%cr0=%Q\n", istate->cs, istate->rflags,read_cr0()); |
||
| 958 | jermar | 57 | printf("%%rax=%Q, %%rbx=%Q, %%rcx=%Q\n",istate->rax,istate->rbx,istate->rcx); |
| 58 | printf("%%rdx=%Q, %%rsi=%Q, %%rdi=%Q\n",istate->rdx,istate->rsi,istate->rdi); |
||
| 59 | printf("%%r8 =%Q, %%r9 =%Q, %%r10=%Q\n",istate->r8,istate->r9,istate->r10); |
||
| 60 | printf("%%r11=%Q, %%r12=%Q, %%r13=%Q\n",istate->r11,istate->r12,istate->r13); |
||
| 61 | printf("%%r14=%Q, %%r15=%Q, %%rsp=%Q\n",istate->r14,istate->r15,&istate->stack[0]); |
||
| 62 | printf("%%rbp=%Q\n",istate->rbp); |
||
| 286 | palkovsky | 63 | printf("stack: %Q, %Q, %Q\n", x[5], x[6], x[7]); |
| 64 | printf(" %Q, %Q, %Q\n", x[8], x[9], x[10]); |
||
| 65 | printf(" %Q, %Q, %Q\n", x[11], x[12], x[13]); |
||
| 66 | printf(" %Q, %Q, %Q\n", x[14], x[15], x[16]); |
||
| 67 | } |
||
| 68 | |||
| 226 | palkovsky | 69 | /* |
| 70 | * Interrupt and exception dispatching. |
||
| 71 | */ |
||
| 72 | |||
| 73 | void (* disable_irqs_function)(__u16 irqmask) = NULL; |
||
| 74 | void (* enable_irqs_function)(__u16 irqmask) = NULL; |
||
| 75 | void (* eoi_function)(void) = NULL; |
||
| 76 | |||
| 958 | jermar | 77 | void null_interrupt(int n, istate_t *istate) |
| 226 | palkovsky | 78 | { |
| 1021 | jermar | 79 | print_info_errcode(n, istate); |
| 226 | palkovsky | 80 | panic("unserviced interrupt\n"); |
| 81 | } |
||
| 82 | |||
| 958 | jermar | 83 | void gp_fault(int n, istate_t *istate) |
| 226 | palkovsky | 84 | { |
| 958 | jermar | 85 | print_info_errcode(n, istate); |
| 226 | palkovsky | 86 | panic("general protection fault\n"); |
| 87 | } |
||
| 88 | |||
| 958 | jermar | 89 | void ss_fault(int n, istate_t *istate) |
| 226 | palkovsky | 90 | { |
| 958 | jermar | 91 | print_info_errcode(n, istate); |
| 226 | palkovsky | 92 | panic("stack fault\n"); |
| 93 | } |
||
| 94 | |||
| 95 | |||
| 958 | jermar | 96 | void nm_fault(int n, istate_t *istate) |
| 226 | palkovsky | 97 | { |
| 458 | decky | 98 | #ifdef CONFIG_FPU_LAZY |
| 309 | palkovsky | 99 | scheduler_fpu_lazy_request(); |
| 100 | #else |
||
| 101 | panic("fpu fault"); |
||
| 102 | #endif |
||
| 226 | palkovsky | 103 | } |
| 104 | |||
| 958 | jermar | 105 | void page_fault(int n, istate_t *istate) |
| 226 | palkovsky | 106 | { |
| 703 | jermar | 107 | __address page; |
| 108 | |||
| 109 | page = read_cr2(); |
||
| 110 | if (!as_page_fault(page)) { |
||
| 958 | jermar | 111 | print_info_errcode(n, istate); |
| 703 | jermar | 112 | printf("Page fault address: %Q\n", page); |
| 113 | panic("page fault\n"); |
||
| 114 | } |
||
| 226 | palkovsky | 115 | } |
| 116 | |||
| 958 | jermar | 117 | void tlb_shootdown_ipi(int n, istate_t *istate) |
| 226 | palkovsky | 118 | { |
| 119 | trap_virtual_eoi(); |
||
| 120 | tlb_shootdown_ipi_recv(); |
||
| 121 | } |
||
| 122 | |||
| 123 | void trap_virtual_enable_irqs(__u16 irqmask) |
||
| 124 | { |
||
| 125 | if (enable_irqs_function) |
||
| 126 | enable_irqs_function(irqmask); |
||
| 127 | else |
||
| 128 | panic("no enable_irqs_function\n"); |
||
| 129 | } |
||
| 130 | |||
| 131 | void trap_virtual_disable_irqs(__u16 irqmask) |
||
| 132 | { |
||
| 133 | if (disable_irqs_function) |
||
| 134 | disable_irqs_function(irqmask); |
||
| 135 | else |
||
| 136 | panic("no disable_irqs_function\n"); |
||
| 137 | } |
||
| 138 | |||
| 139 | void trap_virtual_eoi(void) |
||
| 140 | { |
||
| 141 | if (eoi_function) |
||
| 142 | eoi_function(); |
||
| 143 | else |
||
| 144 | panic("no eoi_function\n"); |
||
| 145 | |||
| 146 | } |