source: mainline/arch/amd64/src/interrupt.c@ bfb87df

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since bfb87df was bfb87df, checked in by Jakub Jermar <jakub@…>, 19 years ago

Remove WAKEUP_IPI stuff.

Make it possible to use PAGE_GLOBAL on ia32, amd64 and mips32.
Make ia32 and amd64 map the kernel using PAGE_GLOBAL.

  • Property mode set to 100644
File size: 4.6 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
[fb10289b]45/*
[ff4c4f5]46static void messy_stack_trace(__native *stack)
47{
[2c55af3]48 __native *upper_limit = (__native *)(((__native)get_stack_base()) + STACK_SIZE);
[ff4c4f5]49 char *symbol;
50
51 printf("Stack contents: ");
52 while (stack < upper_limit) {
53 symbol = get_symtab_entry((__address)*stack);
54 if (symbol)
55 printf("%s, ", symbol);
56 stack++;
57 }
58 printf("\n");
59}
[fb10289b]60*/
[49a39c2]61
62static void print_info_errcode(int n, struct interrupt_context *ctx)
[8ec9bae]63{
64 char *symbol;
[49a39c2]65 __u64 *x = &ctx->stack[0];
[8ec9bae]66
67 if (!(symbol=get_symtab_entry(x[1])))
68 symbol = "";
69
70 printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n,__FUNCTION__);
[49a39c2]71 printf("%%rip: %Q (%s)\n",ctx->stack[1],symbol);
72 printf("ERROR_WORD=%Q\n", ctx->stack[0]);
73 printf("%%rcs=%Q,flags=%Q, %%cr0=%Q\n", ctx->stack[2],
74 ctx->stack[3],read_cr0());
75 printf("%%rax=%Q, %%rbx=%Q, %%rcx=%Q\n",ctx->rax,ctx->rbx,ctx->rcx);
76 printf("%%rdx=%Q, %%rsi=%Q, %%rdi=%Q\n",ctx->rdx,ctx->rsi,ctx->rdi);
77 printf("%%r8 =%Q, %%r9 =%Q, %%r10=%Q\n",ctx->r8,ctx->r9,ctx->r10);
78 printf("%%r11=%Q, %%r12=%Q, %%r13=%Q\n",ctx->r11,ctx->r12,ctx->r13);
79 printf("%%r14=%Q, %%r15=%Q, %%rsp=%Q\n",ctx->r14,ctx->r15,&ctx->stack[0]);
80 printf("%%rbp=%Q\n",ctx->rbp);
[8ec9bae]81 printf("stack: %Q, %Q, %Q\n", x[5], x[6], x[7]);
82 printf(" %Q, %Q, %Q\n", x[8], x[9], x[10]);
83 printf(" %Q, %Q, %Q\n", x[11], x[12], x[13]);
84 printf(" %Q, %Q, %Q\n", x[14], x[15], x[16]);
[fb10289b]85// messy_stack_trace(&x[5]);
[8ec9bae]86}
[db3341e]87
88/*
89 * Interrupt and exception dispatching.
90 */
91
92void (* disable_irqs_function)(__u16 irqmask) = NULL;
93void (* enable_irqs_function)(__u16 irqmask) = NULL;
94void (* eoi_function)(void) = NULL;
95
[49a39c2]96void null_interrupt(int n, struct interrupt_context *ctx)
[db3341e]97{
[3396f59]98 printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n,__FUNCTION__); \
[49a39c2]99 printf("stack: %X, %X, %X, %X\n", ctx->stack[0], ctx->stack[1],
100 ctx->stack[2], ctx->stack[3]);
[db3341e]101 panic("unserviced interrupt\n");
102}
103
[fcfac420]104void gp_fault(int n, void *stack)
[db3341e]105{
[8ec9bae]106 print_info_errcode(n,stack);
[db3341e]107 panic("general protection fault\n");
108}
109
[fcfac420]110void ss_fault(int n, void *stack)
[db3341e]111{
[8ec9bae]112 print_info_errcode(n,stack);
[db3341e]113 panic("stack fault\n");
114}
115
116
[fcfac420]117void nm_fault(int n, void *stack)
[db3341e]118{
[5f85c91]119#ifdef CONFIG_FPU_LAZY
[b49f4ae]120 scheduler_fpu_lazy_request();
121#else
122 panic("fpu fault");
123#endif
[db3341e]124}
125
[49a39c2]126void page_fault(int n, struct interrupt_context *ctx)
[db3341e]127{
[20d50a1]128 __address page;
129
130 page = read_cr2();
131 if (!as_page_fault(page)) {
[49a39c2]132 print_info_errcode(n,ctx);
[20d50a1]133 printf("Page fault address: %Q\n", page);
134 panic("page fault\n");
135 }
[db3341e]136}
137
[fcfac420]138void tlb_shootdown_ipi(int n, void *stack)
[db3341e]139{
140 trap_virtual_eoi();
141 tlb_shootdown_ipi_recv();
142}
143
144void trap_virtual_enable_irqs(__u16 irqmask)
145{
146 if (enable_irqs_function)
147 enable_irqs_function(irqmask);
148 else
149 panic("no enable_irqs_function\n");
150}
151
152void trap_virtual_disable_irqs(__u16 irqmask)
153{
154 if (disable_irqs_function)
155 disable_irqs_function(irqmask);
156 else
157 panic("no disable_irqs_function\n");
158}
159
160void trap_virtual_eoi(void)
161{
162 if (eoi_function)
163 eoi_function();
164 else
165 panic("no eoi_function\n");
166
167}
Note: See TracBrowser for help on using the repository browser.