source: trunk/hal/x86_64/hal_trap.c @ 36

Last change on this file since 36 was 31, checked in by max@…, 8 years ago

Silence a few gcc warnings.

File size: 2.0 KB
Line 
1/*
2 * hal_trap.c - Trap handler
3 *
4 * Copyright (c) 2017 Maxime Villard
5 *
6 * This file is part of ALMOS-MKH.
7 *
8 * ALMOS-MKH is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.0 of the License.
11 *
12 * ALMOS-MKH is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <hal_types.h>
23#include <hal_kentry.h>
24
25static const char *trap_type[] = {
26        [T_PRIVINFLT]= "privileged instruction fault",
27        [T_BPTFLT] = "breakpoint trap",
28        [T_ARITHTRAP] = "arithmetic trap",
29        [T_ASTFLT] = "asynchronous system trap",
30        [T_PROTFLT] = "protection fault",
31        [T_TRCTRAP] = "trace trap",
32        [T_PAGEFLT] = "page fault",
33        [T_ALIGNFLT] = "alignment fault",
34        [T_DIVIDE] = "integer divide fault",
35        [T_NMI] = "non-maskable interrupt",
36        [T_OFLOW] = "overflow trap",
37        [T_BOUND] = "bounds check fault",
38        [T_DNA] = "FPU not available fault",
39        [T_DOUBLEFLT] = "double fault",
40        [T_FPOPFLT] = "FPU operand fetch fault",
41        [T_TSSFLT] = "invalid TSS fault",
42        [T_SEGNPFLT] = "segment not present fault",
43        [T_STKFLT] = "stack fault",
44        [T_MCA] = "machine check fault",
45        [T_XMM] = "SSE FP exception",
46};
47int     trap_types = __arraycount(trap_type);
48
49void x86_printf(char *s, ...);
50
51/*
52 * Trap handler.
53 */
54void
55hal_trap_entry(struct small_trapframe *tf)
56{
57        uint64_t trapno = tf->tf_trapno;
58        const char *buf;
59
60        if (trapno < trap_types) {
61                buf = trap_type[trapno];
62        } else {
63                buf = "unknown trap";
64        }
65
66        x86_printf("\n");
67        x86_printf("****** FAULT OCCURRED ******\n");
68        x86_printf((char *)buf);
69        x86_printf("\n");
70        x86_printf("****** FAULT OCCURRED ******\n");
71        x86_printf("\n");
72
73        while (1);
74}
75
76
Note: See TracBrowser for help on using the repository browser.