summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/cpu.c')
-rw-r--r--arch/x86_64/cpu.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/arch/x86_64/cpu.c b/arch/x86_64/cpu.c
new file mode 100644
index 0000000..d088fcd
--- /dev/null
+++ b/arch/x86_64/cpu.c
@@ -0,0 +1,35 @@
+#include "arch/cpu.h"
+#include "arch/x86_64/msr.h"
+
+extern void _syscall_entry(void);
+
+extern void idt_init();
+
+void
+cpu_setup(void)
+{
+ idt_init();
+
+ cpu_arch_enable_sce();
+ cpu_set_syscall_entry((void*)_syscall_entry);
+}
+
+void cpu_arch_enable_sce(void)
+{
+ msr_efer_t feat = msr_efer_read();
+ feat.sce = 1;
+ msr_efer_write(feat);
+
+ msr_star_t star = msr_star_read();
+ star.kcs = 0x08;
+ star.ucs = 0x18;
+ msr_star_write(star);
+}
+
+void
+cpu_set_syscall_entry(void *ptr)
+{
+ msr_lstar_t lstar = (msr_lstar_t)ptr;
+ msr_lstar_write(lstar);
+}
+