Improve system call systems

This commit is contained in:
Baptiste Wicht 2014-01-18 17:59:05 +01:00
parent 30d7f2d34b
commit 19b68b7e9f
4 changed files with 38 additions and 44 deletions

View File

@ -32,6 +32,12 @@ struct syscall_regs {
uint64_t rdx;
uint64_t rsi;
uint64_t rdi;
uint64_t r8;
uint64_t r9;
uint64_t r10;
uint64_t r11;
uint64_t r12;
uint64_t code;
} __attribute__((packed));
void setup_interrupts();

View File

@ -241,11 +241,9 @@ void _irq_handler(size_t code){
}
void _syscall_handler(interrupt::syscall_regs regs){
auto code = regs.rdi;
//If there is a handler call, it
if(syscall_handlers[code]){
syscall_handlers[code](regs);
if(syscall_handlers[regs.code]){
syscall_handlers[regs.code](regs);
}
//TODO Emit an error somehow if there is no handler

View File

@ -24,80 +24,70 @@
_syscall0:
cli
push rdi
mov rdi, 0
push 0
jmp syscall_common_handler
_syscall1:
cli
push rdi
mov rdi, 1
push 1
jmp syscall_common_handler
_syscall2:
cli
push rdi
mov rdi, 2
push 2
jmp syscall_common_handler
_syscall3:
cli
push rdi
mov rdi, 3
push 3
jmp syscall_common_handler
_syscall4:
cli
push rdi
mov rdi, 4
push 4
jmp syscall_common_handler
_syscall5:
cli
push rdi
mov rdi, 5
push 5
jmp syscall_common_handler
_syscall6:
cli
push rdi
mov rdi, 6
push 6
jmp syscall_common_handler
_syscall7:
cli
push rdi
mov rdi, 7
push 7
jmp syscall_common_handler
_syscall8:
cli
push rdi
mov rdi, 8
push 8
jmp syscall_common_handler
_syscall9:
cli
push rdi
mov rdi, 9
push 9
jmp syscall_common_handler
@ -105,33 +95,33 @@ _syscall9:
//TODO Check if really safe to trash r12
syscall_common_handler:
push r8
push r9
push r10
push r11
push r12
push rax
push rbx
push rcx
push rdx
push rsi
push r11
push r10
push r9
push r8
push rdi
push rsi
push rdx
push rcx
push rbx
push rax
call _syscall_handler
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
pop r12
pop r11
pop r10
pop r9
pop rbx
pop rcx
pop rdx
pop rsi
pop rdi
pop r8
pop r9
pop r10
pop r11
pop r12
//Was pushed by the base handler code
pop rdi
add rsp, 8
iretq // iret will clean the other automatically pushed stuff

View File

@ -13,5 +13,5 @@ void system_call_entry(const interrupt::syscall_regs& regs){
}
void install_system_calls(){
interrupt::register_syscall_handler(interrupt::SYSCALL_FIRST, &system_call_entry);
interrupt::register_syscall_handler(0, &system_call_entry);
}