Ignore:
Timestamp:
Jun 21, 2017, 8:35:30 AM (7 years ago)
Author:
max@…
Message:

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:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/x86_64/hal_kentry.h

    r25 r29  
    11/*
    2  * cpu-regs.h - mips register map
     2 * hal_kentry.h - General values used in the different kernel entries
    33 *
    4  * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
    5  * Copyright (c) 2011,2012 UPMC Sorbonne Universites
     4 * Copyright (c) 2017 Maxime Villard
    65 *
    7  * This file is part of ALMOS-kernel.
     6 * This file is part of ALMOS-MKH.
    87 *
    9  * ALMOS-kernel is free software; you can redistribute it and/or modify it
     8 * ALMOS-MKH is free software; you can redistribute it and/or modify it
    109 * under the terms of the GNU General Public License as published by
    1110 * the Free Software Foundation; version 2.0 of the License.
    1211 *
    13  * ALMOS-kernel is distributed in the hope that it will be useful, but
     12 * ALMOS-MKH is distributed in the hope that it will be useful, but
    1413 * WITHOUT ANY WARRANTY; without even the implied warranty of
    1514 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     
    1716 *
    1817 * You should have received a copy of the GNU General Public License
    19  * along with ALMOS-kernel; if not, write to the Free Software Foundation,
     18 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
    2019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    2120 */
    2221
    23 #ifndef _HAL_KENTRY_H_
    24 #define _HAL_KENTRY_H_
     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 */
    2543
    26 #define      KSP          0
    27 #define      AT           1
    28 #define      V0           2
    29 #define      V1           3
    30 #define      A0           4
    31 #define      A1           5
    32 #define      A2           6
    33 #define      A3           7
    34 #define      T0           8
    35 #define      T1           9
    36 #define      T2           10
    37 #define      T3           11
    38 #define      T4           12
    39 #define      T5           13
    40 #define      T6           14
    41 #define      T7           15
    42 #define      T8           16
    43 #define      T9           17
    44 #define      S0           18
    45 #define      S1           19
    46 #define      S2           20
    47 #define      S3           21
    48 #define      S4           22
    49 #define      S5           23
    50 #define      S6           24
    51 #define      S7           25
    52 #define      S8           26
    53 #define      GP           27
    54 #define      RA           28
    55 #define      EPC          29
    56 #define      CR           30
    57 #define      SP           31
    58 #define      SR           32
    59 #define      LO           33
    60 #define      HI           34
    61 #define      TLS_K1       35
    62 #define      DP_EXT           36   // DATA PADDR EXTENSION
    63 #define      MMU_MD           37   // MMU MODE
    64 #define      REGS_NR      38
     44/* Trap's coming from user mode */
     45#define T_USER  0x100
    6546
    66 #define CPU_IN_KERNEL 1
     47#ifndef x86_ASM
    6748
    68 #endif  /* _HAL_ENTRY_H_ */
     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 TracChangeset for help on using the changeset viewer.