diff options
author | dzwdz | 2021-07-21 21:31:52 +0200 |
---|---|---|
committer | dzwdz | 2021-07-21 21:31:52 +0200 |
commit | 36089d20ca1f7c57f36c4172759a5084bdf87a3a (patch) | |
tree | ac31e75f3379e0dcad6cb98f23cba6cbce236380 /src/kernel/arch/i386/sysenter.s | |
parent | 46fb83d6eb44b5d52520783570dc40b7ef25260b (diff) |
barebones syscall
Diffstat (limited to 'src/kernel/arch/i386/sysenter.s')
-rw-r--r-- | src/kernel/arch/i386/sysenter.s | 28 |
1 files changed, 28 insertions, 0 deletions
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 |