source: mainline/arch/amd64/src/interrupt.c@ 280a27e

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 280a27e was 280a27e, checked in by Josef Cejka <malyzelenyhnus@…>, 19 years ago

Printf ported back from uspace to kernel.
Printf calls changed to match new conventions.

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[db3341e]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>
[20d50a1]38#include <mm/as.h>
[db3341e]39#include <arch.h>
[ab08b42]40#include <symtab.h>
[3396f59]41#include <arch/asm.h>
[b49f4ae]42#include <proc/scheduler.h>
[1084a784]43#include <proc/thread.h>
[8ec9bae]44
[1ee9ced]45void print_info_errcode(int n, istate_t *istate)
[8ec9bae]46{
47 char *symbol;
[37c57f2]48/* __u64 *x = &istate->stack[0]; */
[8ec9bae]49
[8e0eb63]50 if (!(symbol=get_symtab_entry(istate->rip)))
[8ec9bae]51 symbol = "";
52
[8e0eb63]53 printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n, __FUNCTION__);
[280a27e]54 printf("%%rip: %#llX (%s)\n",istate->rip, symbol);
55 printf("ERROR_WORD=%#llX\n", istate->error_word);
56 printf("%%rcs=%#llX, flags=%#llX, %%cr0=%#llX\n", istate->cs, istate->rflags,read_cr0());
57 printf("%%rax=%#llX, %%rcx=%#llX, %%rdx=%#llX\n",istate->rax,istate->rcx,istate->rdx);
58 printf("%%rsi=%#llX, %%rdi=%#llX, %%r8 =%#llX\n",istate->rsi,istate->rdi,istate->r8);
59 printf("%%r9 =%#llX, %%r10 =%#llX, %%r11=%#llX\n",istate->r9,istate->r10,istate->r11);
[53f9821]60#ifdef CONFIG_DEBUG_ALLREGS
[280a27e]61 printf("%%r12=%#llX, %%r13=%#llX, %%r14=%#llX\n",istate->r12,istate->r13,istate->r14);
62 printf("%%r15=%#llX, %%rbx=%#llX, %%rbp=%#llX\n",istate->r15,istate->rbx,&istate->rbp);
[53f9821]63#endif
[280a27e]64 printf("%%rsp=%#llX\n",&istate->stack[0]);
[8ec9bae]65}
[db3341e]66
67/*
68 * Interrupt and exception dispatching.
69 */
70
71void (* disable_irqs_function)(__u16 irqmask) = NULL;
72void (* enable_irqs_function)(__u16 irqmask) = NULL;
73void (* eoi_function)(void) = NULL;
74
[25d7709]75void null_interrupt(int n, istate_t *istate)
[db3341e]76{
[8e0eb63]77 print_info_errcode(n, istate);
[db3341e]78 panic("unserviced interrupt\n");
79}
80
[25d7709]81void gp_fault(int n, istate_t *istate)
[db3341e]82{
[25d7709]83 print_info_errcode(n, istate);
[db3341e]84 panic("general protection fault\n");
85}
86
[25d7709]87void ss_fault(int n, istate_t *istate)
[db3341e]88{
[25d7709]89 print_info_errcode(n, istate);
[db3341e]90 panic("stack fault\n");
91}
92
[25d7709]93void nm_fault(int n, istate_t *istate)
[db3341e]94{
[5f85c91]95#ifdef CONFIG_FPU_LAZY
[b49f4ae]96 scheduler_fpu_lazy_request();
97#else
98 panic("fpu fault");
99#endif
[db3341e]100}
101
[25d7709]102void tlb_shootdown_ipi(int n, istate_t *istate)
[db3341e]103{
104 trap_virtual_eoi();
105 tlb_shootdown_ipi_recv();
106}
107
108void trap_virtual_enable_irqs(__u16 irqmask)
109{
110 if (enable_irqs_function)
111 enable_irqs_function(irqmask);
112 else
113 panic("no enable_irqs_function\n");
114}
115
116void trap_virtual_disable_irqs(__u16 irqmask)
117{
118 if (disable_irqs_function)
119 disable_irqs_function(irqmask);
120 else
121 panic("no disable_irqs_function\n");
122}
123
124void trap_virtual_eoi(void)
125{
126 if (eoi_function)
127 eoi_function();
128 else
129 panic("no eoi_function\n");
130
131}
Note: See TracBrowser for help on using the repository browser.