Changeset 142 for trunk/hal/x86_64/core


Ignore:
Timestamp:
Jul 5, 2017, 10:49:55 AM (7 years ago)
Author:
max@…
Message:

remove hal_trap.c, and put its content in hal_interrupt.c and
hal_exception.c

Location:
trunk/hal/x86_64/core
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/x86_64/core/hal_exception.c

    r51 r142  
    11/*
    2  * hal_exception.c - implementation of exception handler for TSAR-MIPS32.
    3  *
    4  * Author   Alain Greiner (2016, 2017)
     2 * hal_exception.c - Implementation of exception handler for x86_64
    53 *
    6  * Copyright (c) UPMC Sorbonne Universites
     4 * Copyright (c) 2017 Maxime Villard
    75 *
    86 * This file is part of ALMOS-MKH.
     
    1816 *
    1917 * You should have received a copy of the GNU General Public License
    20  * along with ALMOS-MKH; if not, write to the Free Software Foundation,
     18 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
    2119 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    2220 */
     
    2624#include <hal_exception.h>
    2725#include <thread.h>
    28 #include <printk.h>
    29 #include <vmm.h>
    3026#include <errno.h>
    31 #include <scheduler.h>
    3227#include <core.h>
    33 #include <signal.h>
    34 #include <syscalls.h>
    3528#include <do_exception.h>
    36 #include <remote_spinlock.h>
    3729
     30
     31#include <hal_kentry.h>
    3832#include <hal_internal.h>
    3933
    40 void hal_do_exception( thread_t * this,
     34static const char *exc_type[] = {
     35        [T_PRIVINFLT]= "privileged instruction fault",
     36        [T_BPTFLT] = "breakpoint trap",
     37        [T_ARITHTRAP] = "arithmetic trap",
     38        [T_ASTFLT] = "asynchronous system trap",
     39        [T_PROTFLT] = "protection fault",
     40        [T_TRCTRAP] = "trace trap",
     41        [T_PAGEFLT] = "page fault",
     42        [T_ALIGNFLT] = "alignment fault",
     43        [T_DIVIDE] = "integer divide fault",
     44        [T_NMI] = "non-maskable interrupt",
     45        [T_OFLOW] = "overflow trap",
     46        [T_BOUND] = "bounds check fault",
     47        [T_DNA] = "FPU not available fault",
     48        [T_DOUBLEFLT] = "double fault",
     49        [T_FPOPFLT] = "FPU operand fetch fault",
     50        [T_TSSFLT] = "invalid TSS fault",
     51        [T_SEGNPFLT] = "segment not present fault",
     52        [T_STKFLT] = "stack fault",
     53        [T_MCA] = "machine check fault",
     54        [T_XMM] = "SSE FP exception",
     55};
     56int     exc_types = __arraycount(exc_type);
     57
     58/*
     59 * Hexception handler.
     60 */
     61void hal_exception_entry(struct small_trapframe *tf)
     62{
     63        uint64_t excno = tf->tf_trapno;
     64        const char *buf;
     65
     66        if (excno < exc_types) {
     67                buf = exc_type[excno];
     68        } else {
     69                buf = "unknown exception";
     70        }
     71
     72        x86_printf("\n****** FAULT OCCURRED ******\n");
     73        x86_printf("%s\n", (char *)buf);
     74        x86_printf("-> rip = %Z\n", tf->tf_rip);
     75        x86_printf("-> rsp = %Z\n", tf->tf_rsp);
     76        x86_printf("-> err = %Z\n", tf->tf_err);
     77        if (excno == T_PAGEFLT)
     78                x86_printf("-> va  = %Z\n", rcr2());
     79        x86_printf("****** FAULT OCCURRED ******\n\n");
     80
     81        while (1);
     82}
     83
     84/* -------------------------------------------------------------------------- */
     85
     86void hal_do_exception( thread_t * this,
    4187                       reg_t    * regs_tbl )
    4288{
  • trunk/hal/x86_64/core/hal_interrupt.c

    r51 r142  
    11/*
    2  * hal_interrupt.c - implementation of interrupt handler for TSAR-MIPS32
    3  *
    4  * Author   Alain Greiner (2016,2017)
     2 * hal_interrupt.c - Implementation of interrupt handler for x86_64
    53 *
    6  * Copyright (c) UPMC Sorbonne Universites
     4 * Copyright (c) 2017 Maxime Villard
    75 *
    86 * This file is part of ALMOS-MKH.
     
    1816 *
    1917 * You should have received a copy of the GNU General Public License
    20  * along with ALMOS-MKH; if not, write to the Free Software Foundation,
     18 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
    2119 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    2220 */
     
    2826#include <hal_interrupt.h>
    2927
     28#include <hal_kentry.h>
    3029#include <hal_internal.h>
    3130
    32 void hal_do_interrupt( thread_t * this,
    33                                reg_t    * regs_tbl )
     31/* -------------------------------------------------------------------------- */
     32
     33/*
     34 * Timer interrupt
     35 */
     36void hal_timer_intr(struct trapframe *tf)
     37{
     38        x86_printf("-> got timer: rip=%Z\n", tf->tf_rip);
     39        return;
     40}
     41
     42/* -------------------------------------------------------------------------- */
     43
     44#define PS2_DATA        0x60
     45
     46#define PS2_STATUS      0x64
     47#       define STATUS_OUT_FULL  0x00
     48#       define STATUS_IN_FULL   0x01
     49#       define STATUS_SYS_FLAG  0x02
     50
     51#define PS2_CMD 0x64
     52
     53/*
     54 * US scancode table, found on the internet.
     55 */
     56unsigned char scancode_US[128] =
     57{
     58         0,     27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=',
     59        '\b', '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']',
     60        '\n',
     61         0,     /* 29   - Control */
     62        'a',   's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`',
     63         0,     /* Left shift */
     64        '\\',  'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/',
     65         0,     /* Right shift */
     66        '*',
     67         0,     /* Alt */
     68        ' ',    /* Space bar */
     69         0,     /* Caps lock */
     70         0,     /* 59 - F1 key ... > */
     71         0,   0,   0,   0,   0,   0,   0,   0,
     72         0,     /* < ... F10 */
     73         0,     /* 69 - Num lock*/
     74         0,     /* Scroll Lock */
     75         0,     /* Home key */
     76         0,     /* Up Arrow */
     77         0,     /* Page Up */
     78        '-',
     79         0,     /* Left Arrow */
     80         0,
     81         0,     /* Right Arrow */
     82        '+',
     83         0,     /* 79 - End key*/
     84         0,     /* Down Arrow */
     85         0,     /* Page Down */
     86         0,     /* Insert Key */
     87         0,     /* Delete Key */
     88         0,   0,   0,
     89         0,     /* F11 Key */
     90         0,     /* F12 Key */
     91         0,     /* All other keys are undefined */
     92};     
     93
     94/*
     95 * Keyboard interrupt (8042 PS/2)
     96 */
     97void hal_keyboard_intr(struct trapframe *tf)
     98{
     99        uint64_t val;
     100
     101        do {
     102                val = in8(PS2_STATUS);
     103        } while ((val & STATUS_IN_FULL) == 0);
     104
     105        val = in8(PS2_DATA);
     106
     107        x86_printf("-> got keyboard: rip=%Z key=%c ", tf->tf_rip, scancode_US[val]);
     108
     109        if (val & 0x80)
     110                x86_printf("[released]\n");
     111        else
     112                x86_printf("[pressed]\n");
     113
     114        return;
     115}
     116
     117
     118/* -------------------------------------------------------------------------- */
     119
     120void hal_do_interrupt( thread_t * this,
     121                               reg_t    * regs_tbl )
    34122{
    35123        x86_panic((char *)__func__);
  • trunk/hal/x86_64/core/hal_kentry.S

    r138 r142  
    3434
    3535        .text
    36         .globl  hal_trap_entry
     36        .globl  hal_exception_entry
    3737        .globl  hal_timer_intr
    3838        .globl  hal_keyboard_intr
    39         .type   hal_trap_entry, @function
     39        .type   hal_exception_entry, @function
    4040        .type   hal_timer_intr, @function
    4141        .type   hal_keyboard_intr, @function
     
    215215alltraps:
    216216        movq    %rsp,%rdi
    217         call    hal_trap_entry
     217        call    hal_exception_entry
    218218        /* NOTREACHED */
    219219
Note: See TracChangeset for help on using the changeset viewer.