kernel - v0.7 beta
+ acpi: add acpi support + lapic: add lapic support + ioapic: add ioapic support + arch/x86_64: add support for "syscall"/"sysret"
This commit is contained in:
parent
4d52bac946
commit
a8e919b033
53 changed files with 772 additions and 331 deletions
18
kernel/src/arch/x86_64/syscall.c
Normal file
18
kernel/src/arch/x86_64/syscall.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <arch/x86_64/msr.h>
|
||||
#include <arch/x86_64/syscall.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern void syscall_entry();
|
||||
|
||||
void __x86_64_syscall_init() {
|
||||
uint64_t efer = rdmsr(IA32_EFER);
|
||||
efer |= (1 << 0);
|
||||
wrmsr(IA32_EFER, efer);
|
||||
uint64_t star = 0;
|
||||
star |= ((uint64_t)0x28 << 32); // kernel cs
|
||||
star |= ((uint64_t)0x30 << 48); // user cs base (SYSCALL adds 16 for CS=0x38, 24 for SS=0x40)
|
||||
wrmsr(IA32_STAR, star);
|
||||
wrmsr(IA32_LSTAR, (uint64_t)syscall_entry);
|
||||
wrmsr(IA32_CSTAR, 0x0);
|
||||
wrmsr(IA32_CSTAR + 1, 0x200);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue