2002-07-09 16:24:59 +04:00
|
|
|
/* Contains the basic code for fault handling. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
|
|
|
** Distributed under the terms of the NewOS License.
|
|
|
|
*/
|
2003-05-03 20:20:38 +04:00
|
|
|
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <kernel.h>
|
|
|
|
#include <faults_priv.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <arch/int.h>
|
|
|
|
#include <int.h>
|
|
|
|
#include <arch/faults.h>
|
2003-10-08 03:12:37 +04:00
|
|
|
#include <boot/kernel_args.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2003-05-03 20:20:38 +04:00
|
|
|
|
|
|
|
int
|
|
|
|
faults_init(kernel_args *ka)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
dprintf("init_fault_handlers: entry\n");
|
|
|
|
return arch_faults_init(ka);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-03 20:20:38 +04:00
|
|
|
int
|
|
|
|
general_protection_fault(int errorcode)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
panic("GENERAL PROTECTION FAULT: errcode 0x%x. Killing system.\n", errorcode);
|
|
|
|
|
2002-07-19 20:07:36 +04:00
|
|
|
return B_HANDLED_INTERRUPT;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2003-05-03 20:20:38 +04:00
|
|
|
|
|
|
|
static const char *
|
|
|
|
fpu_fault_to_str(enum fpu_faults fpu_fault)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2003-05-03 20:20:38 +04:00
|
|
|
switch (fpu_fault) {
|
2002-07-09 16:24:59 +04:00
|
|
|
default:
|
|
|
|
case FPU_FAULT_CODE_UNKNOWN:
|
|
|
|
return "unknown";
|
|
|
|
case FPU_FAULT_CODE_DIVBYZERO:
|
|
|
|
return "divbyzero";
|
|
|
|
case FPU_FAULT_CODE_INVALID_OP:
|
|
|
|
return "invalid op";
|
|
|
|
case FPU_FAULT_CODE_OVERFLOW:
|
|
|
|
return "overflow";
|
|
|
|
case FPU_FAULT_CODE_UNDERFLOW:
|
|
|
|
return "underflow";
|
|
|
|
case FPU_FAULT_CODE_INEXACT:
|
|
|
|
return "inexact";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-03 20:20:38 +04:00
|
|
|
|
|
|
|
int
|
|
|
|
fpu_fault(int fpu_fault)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
panic("FPU FAULT: errcode 0x%x (%s), Killing system.\n", fpu_fault, fpu_fault_to_str(fpu_fault));
|
|
|
|
|
2002-07-19 20:07:36 +04:00
|
|
|
return B_HANDLED_INTERRUPT;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2003-05-03 20:20:38 +04:00
|
|
|
|
|
|
|
int
|
|
|
|
fpu_disable_fault(void)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
panic("FPU DISABLE FAULT: Killing system.\n");
|
|
|
|
|
2002-07-19 20:07:36 +04:00
|
|
|
return B_HANDLED_INTERRUPT;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|