Rev 1196 | Rev 1258 | 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> |
| 1256 | jermar | 44 | #include <proc/task.h> |
| 45 | #include <synch/spinlock.h> |
||
| 46 | #include <arch/ddi/ddi.h> |
||
| 226 | palkovsky | 47 | |
| 1051 | jermar | 48 | void print_info_errcode(int n, istate_t *istate) |
| 297 | palkovsky | 49 | { |
| 50 | char *symbol; |
||
| 1060 | palkovsky | 51 | /* __u64 *x = &istate->stack[0]; */ |
| 297 | palkovsky | 52 | |
| 1021 | jermar | 53 | if (!(symbol=get_symtab_entry(istate->rip))) |
| 286 | palkovsky | 54 | symbol = ""; |
| 55 | |||
| 1021 | jermar | 56 | printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n, __FUNCTION__); |
| 1196 | cejka | 57 | printf("%%rip: %#llX (%s)\n",istate->rip, symbol); |
| 58 | printf("ERROR_WORD=%#llX\n", istate->error_word); |
||
| 59 | printf("%%rcs=%#llX, flags=%#llX, %%cr0=%#llX\n", istate->cs, istate->rflags,read_cr0()); |
||
| 60 | printf("%%rax=%#llX, %%rcx=%#llX, %%rdx=%#llX\n",istate->rax,istate->rcx,istate->rdx); |
||
| 61 | printf("%%rsi=%#llX, %%rdi=%#llX, %%r8 =%#llX\n",istate->rsi,istate->rdi,istate->r8); |
||
| 62 | printf("%%r9 =%#llX, %%r10 =%#llX, %%r11=%#llX\n",istate->r9,istate->r10,istate->r11); |
||
| 1100 | palkovsky | 63 | #ifdef CONFIG_DEBUG_ALLREGS |
| 1196 | cejka | 64 | printf("%%r12=%#llX, %%r13=%#llX, %%r14=%#llX\n",istate->r12,istate->r13,istate->r14); |
| 65 | printf("%%r15=%#llX, %%rbx=%#llX, %%rbp=%#llX\n",istate->r15,istate->rbx,&istate->rbp); |
||
| 1100 | palkovsky | 66 | #endif |
| 1196 | cejka | 67 | printf("%%rsp=%#llX\n",&istate->stack[0]); |
| 286 | palkovsky | 68 | } |
| 69 | |||
| 226 | palkovsky | 70 | /* |
| 71 | * Interrupt and exception dispatching. |
||
| 72 | */ |
||
| 73 | |||
| 74 | void (* disable_irqs_function)(__u16 irqmask) = NULL; |
||
| 75 | void (* enable_irqs_function)(__u16 irqmask) = NULL; |
||
| 76 | void (* eoi_function)(void) = NULL; |
||
| 77 | |||
| 958 | jermar | 78 | void null_interrupt(int n, istate_t *istate) |
| 226 | palkovsky | 79 | { |
| 1021 | jermar | 80 | print_info_errcode(n, istate); |
| 226 | palkovsky | 81 | panic("unserviced interrupt\n"); |
| 82 | } |
||
| 83 | |||
| 1256 | jermar | 84 | /** General Protection Fault. */ |
| 958 | jermar | 85 | void gp_fault(int n, istate_t *istate) |
| 226 | palkovsky | 86 | { |
| 1256 | jermar | 87 | if (TASK) { |
| 88 | count_t ver; |
||
| 89 | |||
| 90 | spinlock_lock(&TASK->lock); |
||
| 91 | ver = TASK->arch.iomapver; |
||
| 92 | spinlock_unlock(&TASK->lock); |
||
| 93 | |||
| 94 | if (CPU->arch.iomapver_copy != ver) { |
||
| 95 | /* |
||
| 96 | * This fault can be caused by an early access |
||
| 97 | * to I/O port because of an out-dated |
||
| 98 | * I/O Permission bitmap installed on CPU. |
||
| 99 | * Install the fresh copy and restart |
||
| 100 | * the instruction. |
||
| 101 | */ |
||
| 102 | io_perm_bitmap_install(); |
||
| 103 | return; |
||
| 104 | } |
||
| 105 | } |
||
| 106 | |||
| 958 | jermar | 107 | print_info_errcode(n, istate); |
| 226 | palkovsky | 108 | panic("general protection fault\n"); |
| 109 | } |
||
| 110 | |||
| 958 | jermar | 111 | void ss_fault(int n, istate_t *istate) |
| 226 | palkovsky | 112 | { |
| 958 | jermar | 113 | print_info_errcode(n, istate); |
| 226 | palkovsky | 114 | panic("stack fault\n"); |
| 115 | } |
||
| 116 | |||
| 958 | jermar | 117 | void nm_fault(int n, istate_t *istate) |
| 226 | palkovsky | 118 | { |
| 458 | decky | 119 | #ifdef CONFIG_FPU_LAZY |
| 309 | palkovsky | 120 | scheduler_fpu_lazy_request(); |
| 121 | #else |
||
| 122 | panic("fpu fault"); |
||
| 123 | #endif |
||
| 226 | palkovsky | 124 | } |
| 125 | |||
| 958 | jermar | 126 | void tlb_shootdown_ipi(int n, istate_t *istate) |
| 226 | palkovsky | 127 | { |
| 128 | trap_virtual_eoi(); |
||
| 129 | tlb_shootdown_ipi_recv(); |
||
| 130 | } |
||
| 131 | |||
| 132 | void trap_virtual_enable_irqs(__u16 irqmask) |
||
| 133 | { |
||
| 134 | if (enable_irqs_function) |
||
| 135 | enable_irqs_function(irqmask); |
||
| 136 | else |
||
| 137 | panic("no enable_irqs_function\n"); |
||
| 138 | } |
||
| 139 | |||
| 140 | void trap_virtual_disable_irqs(__u16 irqmask) |
||
| 141 | { |
||
| 142 | if (disable_irqs_function) |
||
| 143 | disable_irqs_function(irqmask); |
||
| 144 | else |
||
| 145 | panic("no disable_irqs_function\n"); |
||
| 146 | } |
||
| 147 | |||
| 148 | void trap_virtual_eoi(void) |
||
| 149 | { |
||
| 150 | if (eoi_function) |
||
| 151 | eoi_function(); |
||
| 152 | else |
||
| 153 | panic("no eoi_function\n"); |
||
| 154 | |||
| 155 | } |