Index: trunk/hal/x86_64/core/hal_exception.c
===================================================================
--- trunk/hal/x86_64/core/hal_exception.c	(revision 138)
+++ trunk/hal/x86_64/core/hal_exception.c	(revision 142)
@@ -1,8 +1,6 @@
 /*
- * hal_exception.c - implementation of exception handler for TSAR-MIPS32.
- * 
- * Author   Alain Greiner (2016, 2017)
+ * hal_exception.c - Implementation of exception handler for x86_64
  *
- * Copyright (c) UPMC Sorbonne Universites
+ * Copyright (c) 2017 Maxime Villard
  *
  * This file is part of ALMOS-MKH.
@@ -18,5 +16,5 @@
  *
  * You should have received a copy of the GNU General Public License
- * along with ALMOS-MKH; if not, write to the Free Software Foundation,
+ * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
@@ -26,17 +24,65 @@
 #include <hal_exception.h>
 #include <thread.h>
-#include <printk.h>
-#include <vmm.h>
 #include <errno.h>
-#include <scheduler.h>
 #include <core.h>
-#include <signal.h>
-#include <syscalls.h>
 #include <do_exception.h>
-#include <remote_spinlock.h>
 
+
+#include <hal_kentry.h>
 #include <hal_internal.h>
 
-void hal_do_exception( thread_t * this, 
+static const char *exc_type[] = {
+	[T_PRIVINFLT]= "privileged instruction fault",
+	[T_BPTFLT] = "breakpoint trap",
+	[T_ARITHTRAP] = "arithmetic trap",
+	[T_ASTFLT] = "asynchronous system trap",
+	[T_PROTFLT] = "protection fault",
+	[T_TRCTRAP] = "trace trap",
+	[T_PAGEFLT] = "page fault",
+	[T_ALIGNFLT] = "alignment fault",
+	[T_DIVIDE] = "integer divide fault",
+	[T_NMI] = "non-maskable interrupt",
+	[T_OFLOW] = "overflow trap",
+	[T_BOUND] = "bounds check fault",
+	[T_DNA] = "FPU not available fault",
+	[T_DOUBLEFLT] = "double fault",
+	[T_FPOPFLT] = "FPU operand fetch fault",
+	[T_TSSFLT] = "invalid TSS fault",
+	[T_SEGNPFLT] = "segment not present fault",
+	[T_STKFLT] = "stack fault",
+	[T_MCA] = "machine check fault",
+	[T_XMM] = "SSE FP exception",
+};
+int	exc_types = __arraycount(exc_type);
+
+/*
+ * Hexception handler.
+ */
+void hal_exception_entry(struct small_trapframe *tf)
+{
+	uint64_t excno = tf->tf_trapno;
+	const char *buf;
+
+	if (excno < exc_types) {
+		buf = exc_type[excno];
+	} else {
+		buf = "unknown exception";
+	}
+
+	x86_printf("\n****** FAULT OCCURRED ******\n");
+	x86_printf("%s\n", (char *)buf);
+	x86_printf("-> rip = %Z\n", tf->tf_rip);
+	x86_printf("-> rsp = %Z\n", tf->tf_rsp);
+	x86_printf("-> err = %Z\n", tf->tf_err);
+	if (excno == T_PAGEFLT)
+		x86_printf("-> va  = %Z\n", rcr2());
+	x86_printf("****** FAULT OCCURRED ******\n\n");
+
+	while (1);
+}
+
+/* -------------------------------------------------------------------------- */
+
+void hal_do_exception( thread_t * this,
                        reg_t    * regs_tbl )
 {
Index: trunk/hal/x86_64/core/hal_interrupt.c
===================================================================
--- trunk/hal/x86_64/core/hal_interrupt.c	(revision 138)
+++ trunk/hal/x86_64/core/hal_interrupt.c	(revision 142)
@@ -1,8 +1,6 @@
 /*
- * hal_interrupt.c - implementation of interrupt handler for TSAR-MIPS32
- * 
- * Author   Alain Greiner (2016,2017)
+ * hal_interrupt.c - Implementation of interrupt handler for x86_64
  *
- * Copyright (c) UPMC Sorbonne Universites
+ * Copyright (c) 2017 Maxime Villard
  *
  * This file is part of ALMOS-MKH.
@@ -18,5 +16,5 @@
  *
  * You should have received a copy of the GNU General Public License
- * along with ALMOS-MKH; if not, write to the Free Software Foundation,
+ * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
@@ -28,8 +26,98 @@
 #include <hal_interrupt.h>
 
+#include <hal_kentry.h>
 #include <hal_internal.h>
 
-void hal_do_interrupt( thread_t * this, 
-		               reg_t    * regs_tbl ) 
+/* -------------------------------------------------------------------------- */
+
+/*
+ * Timer interrupt
+ */
+void hal_timer_intr(struct trapframe *tf)
+{
+	x86_printf("-> got timer: rip=%Z\n", tf->tf_rip);
+	return;
+}
+
+/* -------------------------------------------------------------------------- */
+
+#define PS2_DATA	0x60
+
+#define PS2_STATUS	0x64
+#	define STATUS_OUT_FULL	0x00
+#	define STATUS_IN_FULL	0x01
+#	define STATUS_SYS_FLAG	0x02
+
+#define PS2_CMD	0x64
+
+/*
+ * US scancode table, found on the internet.
+ */
+unsigned char scancode_US[128] =
+{
+	 0,     27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=',
+	'\b', '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']',
+	'\n',
+	 0,	/* 29   - Control */
+	'a',   's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`',
+	 0,	/* Left shift */
+	'\\',  'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/',
+	 0,	/* Right shift */
+	'*',
+	 0,	/* Alt */
+	' ',	/* Space bar */
+	 0,	/* Caps lock */
+	 0,	/* 59 - F1 key ... > */
+	 0,   0,   0,   0,   0,   0,   0,   0,
+	 0,	/* < ... F10 */
+	 0,	/* 69 - Num lock*/
+	 0,	/* Scroll Lock */
+	 0,	/* Home key */
+	 0,	/* Up Arrow */
+	 0,	/* Page Up */
+	'-',
+	 0,	/* Left Arrow */
+	 0,
+	 0,	/* Right Arrow */
+	'+',
+	 0,	/* 79 - End key*/
+	 0,	/* Down Arrow */
+	 0,	/* Page Down */
+	 0,	/* Insert Key */
+	 0,	/* Delete Key */
+	 0,   0,   0,
+	 0,	/* F11 Key */
+	 0,	/* F12 Key */
+	 0,	/* All other keys are undefined */
+};	
+
+/*
+ * Keyboard interrupt (8042 PS/2)
+ */
+void hal_keyboard_intr(struct trapframe *tf)
+{
+	uint64_t val;
+
+	do {
+		val = in8(PS2_STATUS);
+	} while ((val & STATUS_IN_FULL) == 0);
+
+	val = in8(PS2_DATA);
+
+	x86_printf("-> got keyboard: rip=%Z key=%c ", tf->tf_rip, scancode_US[val]);
+
+	if (val & 0x80)
+		x86_printf("[released]\n");
+	else
+		x86_printf("[pressed]\n");
+
+	return;
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+void hal_do_interrupt( thread_t * this,
+		               reg_t    * regs_tbl )
 {
 	x86_panic((char *)__func__);
Index: trunk/hal/x86_64/core/hal_kentry.S
===================================================================
--- trunk/hal/x86_64/core/hal_kentry.S	(revision 138)
+++ trunk/hal/x86_64/core/hal_kentry.S	(revision 142)
@@ -34,8 +34,8 @@
 
 	.text
-	.globl	hal_trap_entry
+	.globl	hal_exception_entry
 	.globl	hal_timer_intr
 	.globl	hal_keyboard_intr
-	.type	hal_trap_entry, @function
+	.type	hal_exception_entry, @function
 	.type	hal_timer_intr, @function
 	.type	hal_keyboard_intr, @function
@@ -215,5 +215,5 @@
 alltraps:
 	movq	%rsp,%rdi
-	call	hal_trap_entry
+	call	hal_exception_entry
 	/* NOTREACHED */
 
Index: trunk/hal/x86_64/core/hal_trap.c
===================================================================
--- trunk/hal/x86_64/core/hal_trap.c	(revision 138)
+++ 	(revision )
@@ -1,161 +1,0 @@
-/*
- * hal_trap.c - Trap handler
- * 
- * Copyright (c) 2017 Maxime Villard
- * 
- * This file is part of ALMOS-MKH.
- *
- * ALMOS-MKH is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2.0 of the License.
- *
- * ALMOS-MKH is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <hal_types.h>
-#include <hal_kentry.h>
-#include <hal_internal.h>
-
-static const char *trap_type[] = {
-	[T_PRIVINFLT]= "privileged instruction fault",
-	[T_BPTFLT] = "breakpoint trap",
-	[T_ARITHTRAP] = "arithmetic trap",
-	[T_ASTFLT] = "asynchronous system trap",
-	[T_PROTFLT] = "protection fault",
-	[T_TRCTRAP] = "trace trap",
-	[T_PAGEFLT] = "page fault",
-	[T_ALIGNFLT] = "alignment fault",
-	[T_DIVIDE] = "integer divide fault",
-	[T_NMI] = "non-maskable interrupt",
-	[T_OFLOW] = "overflow trap",
-	[T_BOUND] = "bounds check fault",
-	[T_DNA] = "FPU not available fault",
-	[T_DOUBLEFLT] = "double fault",
-	[T_FPOPFLT] = "FPU operand fetch fault",
-	[T_TSSFLT] = "invalid TSS fault",
-	[T_SEGNPFLT] = "segment not present fault",
-	[T_STKFLT] = "stack fault",
-	[T_MCA] = "machine check fault",
-	[T_XMM] = "SSE FP exception",
-};
-int	trap_types = __arraycount(trap_type);
-
-void x86_printf(char *s, ...);
-
-/*
- * Trap handler.
- */
-void hal_trap_entry(struct small_trapframe *tf)
-{
-	uint64_t trapno = tf->tf_trapno;
-	const char *buf;
-
-	if (trapno < trap_types) {
-		buf = trap_type[trapno];
-	} else {
-		buf = "unknown trap";
-	}
-
-	x86_printf("\n****** FAULT OCCURRED ******\n");
-	x86_printf("%s\n", (char *)buf);
-	x86_printf("-> rip = %Z\n", tf->tf_rip);
-	x86_printf("-> rsp = %Z\n", tf->tf_rsp);
-	x86_printf("-> err = %Z\n", tf->tf_err);
-	if (trapno == T_PAGEFLT)
-		x86_printf("-> va  = %Z\n", rcr2());
-	x86_printf("****** FAULT OCCURRED ******\n\n");
-
-	while (1);
-}
-
-/*
- * Timer interrupt
- */
-void hal_timer_intr(struct trapframe *tf)
-{
-	x86_printf("-> got timer: rip=%Z\n", tf->tf_rip);
-	return;
-}
-
-/* -------------------------------------------------------------------------- */
-
-#define PS2_DATA	0x60
-
-#define PS2_STATUS	0x64
-#	define STATUS_OUT_FULL	0x00
-#	define STATUS_IN_FULL	0x01
-#	define STATUS_SYS_FLAG	0x02
-
-#define PS2_CMD	0x64
-
-/*
- * US scancode table, found on the internet.
- */
-unsigned char scancode_US[128] =
-{
-	 0,     27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=',
-	'\b', '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']',
-	'\n',
-	 0,	/* 29   - Control */
-	'a',   's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`',
-	 0,	/* Left shift */
-	'\\',  'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/',
-	 0,	/* Right shift */
-	'*',
-	 0,	/* Alt */
-	' ',	/* Space bar */
-	 0,	/* Caps lock */
-	 0,	/* 59 - F1 key ... > */
-	 0,   0,   0,   0,   0,   0,   0,   0,
-	 0,	/* < ... F10 */
-	 0,	/* 69 - Num lock*/
-	 0,	/* Scroll Lock */
-	 0,	/* Home key */
-	 0,	/* Up Arrow */
-	 0,	/* Page Up */
-	'-',
-	 0,	/* Left Arrow */
-	 0,
-	 0,	/* Right Arrow */
-	'+',
-	 0,	/* 79 - End key*/
-	 0,	/* Down Arrow */
-	 0,	/* Page Down */
-	 0,	/* Insert Key */
-	 0,	/* Delete Key */
-	 0,   0,   0,
-	 0,	/* F11 Key */
-	 0,	/* F12 Key */
-	 0,	/* All other keys are undefined */
-};	
-
-/*
- * Keyboard interrupt (8042 PS/2)
- */
-void hal_keyboard_intr(struct trapframe *tf)
-{
-	uint64_t val;
-
-	do {
-		val = in8(PS2_STATUS);
-	} while ((val & STATUS_IN_FULL) == 0);
-
-	val = in8(PS2_DATA);
-
-	x86_printf("-> got keyboard: rip=%Z key=%c ", tf->tf_rip, scancode_US[val]);
-
-	if (val & 0x80)
-		x86_printf("[released]\n");
-	else
-		x86_printf("[pressed]\n");
-
-	return;
-}
-
