source: trunk/hal/x86_64/hal_kentry.h @ 32

Last change on this file since 32 was 29, checked in by max@…, 7 years ago

Update. The kernel now enables the GDT/IDT, and has trap entries. A
x86_printf function is added for debugging purposes only. The new Makefile
will come in another commit.

File size: 2.7 KB
RevLine 
[25]1/*
[29]2 * hal_kentry.h - General values used in the different kernel entries
[25]3 *
[29]4 * Copyright (c) 2017 Maxime Villard
[25]5 *
[29]6 * This file is part of ALMOS-MKH.
[25]7 *
[29]8 * ALMOS-MKH is free software; you can redistribute it and/or modify it
[25]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 *
[29]12 * ALMOS-MKH is distributed in the hope that it will be useful, but
[25]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
[29]18 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
[25]19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
[29]22#define T_PRIVINFLT      0      /* privileged instruction */
23#define T_BPTFLT         1      /* breakpoint trap */
24#define T_ARITHTRAP      2      /* arithmetic trap */
25#define T_ASTFLT         3      /* asynchronous system trap */
26#define T_PROTFLT        4      /* protection fault */
27#define T_TRCTRAP        5      /* trace trap */
28#define T_PAGEFLT        6      /* page fault */
29#define T_ALIGNFLT       7      /* alignment fault */
30#define T_DIVIDE         8      /* integer divide fault */
31#define T_NMI            9      /* non-maskable interrupt */
32#define T_OFLOW         10      /* overflow trap */
33#define T_BOUND         11      /* bounds check fault */
34#define T_DNA           12      /* device not available fault */
35#define T_DOUBLEFLT     13      /* double fault */
36#define T_FPOPFLT       14      /* fp coprocessor operand fetch fault */
37#define T_TSSFLT        15      /* invalid tss fault */
38#define T_SEGNPFLT      16      /* segment not present fault */
39#define T_STKFLT        17      /* stack fault */
40#define T_MCA           18      /* machine check */
41#define T_XMM           19      /* SSE FP exception */
42#define T_RESERVED      20      /* reserved fault base */
[25]43
[29]44/* Trap's coming from user mode */
45#define T_USER  0x100
[25]46
[29]47#ifndef x86_ASM
[25]48
[29]49/*
50 * The x86_64 trap frame.
51 */
52struct trapframe {
53        uint64_t tf_rdi;
54        uint64_t tf_rsi;
55        uint64_t tf_rdx;
56        uint64_t tf_r10;
57        uint64_t tf_r8;
58        uint64_t tf_r9;
59
60        uint64_t tf_arg6;
61        uint64_t tf_arg7;
62        uint64_t tf_arg8;
63        uint64_t tf_arg9;
64
65        uint64_t tf_rcx;
66        uint64_t tf_r11;
67        uint64_t tf_r12;
68        uint64_t tf_r13;
69        uint64_t tf_r14;
70        uint64_t tf_r15;
71        uint64_t tf_rbp;
72        uint64_t tf_rbx;
73        uint64_t tf_rax;
74
75        uint64_t tf_gs;
76        uint64_t tf_fs;
77        uint64_t tf_es;
78        uint64_t tf_ds;
79
80        uint64_t tf_trapno;
81
82        /* These are pushed for a trap */
83        uint64_t tf_err;
84        uint64_t tf_rip;
85        uint64_t tf_cs;
86        uint64_t tf_rflags;
87
88        /* These are always pushed */
89        uint64_t tf_rsp;
90        uint64_t tf_ss;
91};
92
93/*
94 * Our small trap frame.
95 */
96struct small_trapframe {
97        uint64_t tf_trapno;
98
99        /* These are pushed for a trap */
100        uint64_t tf_err;
101        uint64_t tf_rip;
102        uint64_t tf_cs;
103        uint64_t tf_rflags;
104
105        /* These are always pushed */
106        uint64_t tf_rsp;
107        uint64_t tf_ss;
108};
109
110#endif
111
Note: See TracBrowser for help on using the repository browser.