rewrite the device subsystem interfaces (#48)
[lunaix-os.git] / lunaix-os / arch / x86 / arch.c
1 #include <hal/hwtimer.h>
2
3 #include <lunaix/spike.h>
4 #include <lunaix/process.h>
5
6 #include <asm/x86_isrm.h>
7
8 #include "asm/x86.h"
9 #include "asm/hart.h"
10
11 #include "hal/apic_timer.h"
12
13 void
14 exception_init()
15 {
16     exception_install_handler();
17     isrm_init();
18     intr_routine_init();
19 }
20
21 extern void
22 syscall_hndlr(const struct hart_state* hstate);
23
24 void
25 arch_preinit()
26 {
27     exception_init();
28
29     isrm_bindiv(LUNAIX_SYS_CALL, syscall_hndlr);
30 }
31
32 void
33 update_tss()
34 {
35     extern struct x86_tss _tss;
36 #ifdef CONFIG_ARCH_X86_64
37     _tss.rsps[0] = (ptr_t)current_thread->hstate;
38 #else
39     _tss.esp0 = (u32_t)current_thread->hstate;
40 #endif
41 }