/kernel/trunk/arch/amd64/src/amd64.c |
---|
44,6 → 44,7 |
#include <arch/cpuid.h> |
#include <genarch/acpi/acpi.h> |
#include <panic.h> |
#include <interrupt.h> |
void arch_pre_mm_init(void) |
{ |
72,11 → 73,12 |
i8259_init(); /* PIC */ |
i8254_init(); /* hard clock */ |
trap_register(VECTOR_SYSCALL, syscall); |
exc_register(VECTOR_SYSCALL, "syscall", syscall); |
#ifdef CONFIG_SMP |
trap_register(VECTOR_TLB_SHOOTDOWN_IPI, tlb_shootdown_ipi); |
trap_register(VECTOR_WAKEUP_IPI, wakeup_ipi); |
exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", |
tlb_shootdown_ipi); |
exc_register(VECTOR_WAKEUP_IPI, "wakeup_ipi", wakeup_ipi); |
#endif /* CONFIG_SMP */ |
} |
} |
/kernel/trunk/arch/amd64/src/pm.c |
---|
31,6 → 31,7 |
#include <arch/types.h> |
#include <arch/interrupt.h> |
#include <arch/asm.h> |
#include <interrupt.h> |
#include <config.h> |
174,11 → 175,11 |
} |
idt_setoffset(d, ((__address) interrupt_handlers) + i*interrupt_handler_size); |
trap_register(i, null_interrupt); |
exc_register(i, "undef", null_interrupt); |
} |
trap_register(13, gp_fault); |
trap_register( 7, nm_fault); |
trap_register(12, ss_fault); |
exc_register(13, "gp_fault", gp_fault); |
exc_register( 7, "nm_fault", nm_fault); |
exc_register(12, "ss_fault", ss_fault); |
} |
/kernel/trunk/arch/amd64/src/asm_utils.S |
---|
159,7 → 159,7 |
# vectors starting at vector i. |
# |
# The handlers setup data segment registers |
# and call trap_dispatcher(). |
# and call exc_dispatch(). |
# |
.macro handler i n |
pushq %rbp |
170,7 → 170,7 |
movq $(\i),%rdi # %rdi - first parameter |
movq %rbp, %rsi |
addq $8, %rsi # %rsi - second parameter - original stack |
call trap_dispatcher # trap_dispatcher(i, stack) |
call exc_dispatch # exc_dispatch(i, stack) |
# Test if this is interrupt with error word or not |
mov $\i,%cl; |
/kernel/trunk/arch/amd64/src/mm/page.c |
---|
34,6 → 34,7 |
#include <arch/asm.h> |
#include <config.h> |
#include <memstr.h> |
#include <interrupt.h> |
static __address bootstrap_dba; |
55,7 → 56,7 |
page_mapping_insert(PA2KA(cur), cur, PAGE_CACHEABLE | PAGE_EXEC, KA2PA(dba)); |
} |
trap_register(14, page_fault); |
exc_register(14, "page_fault", page_fault); |
write_cr3(KA2PA(dba)); |
} |
else { |
/kernel/trunk/arch/amd64/src/interrupt.c |
---|
57,9 → 57,10 |
printf("\n"); |
} |
static void print_info_errcode(__u8 n, __native x[]) |
static void print_info_errcode(int n, void *st) |
{ |
char *symbol; |
__native *x = (__native *) st; |
if (!(symbol=get_symtab_entry(x[1]))) |
symbol = ""; |
88,49 → 89,26 |
* Interrupt and exception dispatching. |
*/ |
static iroutine ivt[IVT_ITEMS]; |
void (* disable_irqs_function)(__u16 irqmask) = NULL; |
void (* enable_irqs_function)(__u16 irqmask) = NULL; |
void (* eoi_function)(void) = NULL; |
iroutine trap_register(__u8 n, iroutine f) |
void null_interrupt(int n, void *st) |
{ |
ASSERT(n < IVT_ITEMS); |
iroutine old; |
old = ivt[n]; |
ivt[n] = f; |
return old; |
} |
__native *stack = (__native *) st; |
/* |
* Called directly from the assembler code. |
* CPU is interrupts_disable()'d. |
*/ |
void trap_dispatcher(__u8 n, __native stack[]) |
{ |
ASSERT(n < IVT_ITEMS); |
ivt[n](n, stack); |
} |
void null_interrupt(__u8 n, __native stack[]) |
{ |
printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n,__FUNCTION__); \ |
printf("stack: %L, %L, %L, %L\n", stack[0], stack[1], stack[2], stack[3]); |
panic("unserviced interrupt\n"); |
} |
void gp_fault(__u8 n, __native stack[]) |
void gp_fault(int n, void *stack) |
{ |
print_info_errcode(n,stack); |
panic("general protection fault\n"); |
} |
void ss_fault(__u8 n, __native stack[]) |
void ss_fault(int n, void *stack) |
{ |
print_info_errcode(n,stack); |
panic("stack fault\n"); |
137,7 → 115,7 |
} |
void nm_fault(__u8 n, __native stack[]) |
void nm_fault(int n, void *stack) |
{ |
#ifdef CONFIG_FPU_LAZY |
scheduler_fpu_lazy_request(); |
148,7 → 126,7 |
void page_fault(__u8 n, __native stack[]) |
void page_fault(int n, void *stack) |
{ |
print_info_errcode(n,stack); |
printf("Page fault address: %Q\n", read_cr2()); |
155,19 → 133,19 |
panic("page fault\n"); |
} |
void syscall(__u8 n, __native stack[]) |
void syscall(int n, void *stack) |
{ |
printf("cpu%d: syscall\n", CPU->id); |
thread_usleep(1000); |
} |
void tlb_shootdown_ipi(__u8 n, __native stack[]) |
void tlb_shootdown_ipi(int n, void *stack) |
{ |
trap_virtual_eoi(); |
tlb_shootdown_ipi_recv(); |
} |
void wakeup_ipi(__u8 n, __native stack[]) |
void wakeup_ipi(int n, void *stack) |
{ |
trap_virtual_eoi(); |
} |