From 36089d20ca1f7c57f36c4172759a5084bdf87a3a Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 21 Jul 2021 21:31:52 +0200 Subject: barebones syscall --- src/kernel/arch/i386/sysenter.s | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/kernel/arch/i386/sysenter.s') diff --git a/src/kernel/arch/i386/sysenter.s b/src/kernel/arch/i386/sysenter.s index 0cfeb10..3fcd4c3 100644 --- a/src/kernel/arch/i386/sysenter.s +++ b/src/kernel/arch/i386/sysenter.s @@ -4,6 +4,8 @@ .set SEG_r3data, 4 .set IA32_SYSENTER_CS, 0x174 +.set IA32_SYSENTER_ESP, 0x175 +.set IA32_SYSENTER_EIP, 0x176 .section .text .global sysexit @@ -30,7 +32,33 @@ sysexit: .type sysenter_setup, @function sysenter_setup: xor %edx, %edx + mov $(SEG_r0code << 3), %eax mov $IA32_SYSENTER_CS, %ecx wrmsr + + mov $IA32_SYSENTER_ESP, %ecx + mov $_bss_end, %eax + wrmsr + + mov $IA32_SYSENTER_EIP, %ecx + mov $sysenter_handler, %eax + wrmsr + ret + +sysenter_handler: + pushal + + mov %cr0, %eax + and $0x7FFFFFFF, %eax // disable paging + mov %eax, %cr0 + + call syscall_handler + + mov %cr0, %eax + or $0x80000000, %eax // enable paging + mov %eax, %cr0 + + popal + sysexit -- cgit v1.2.3