mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-18 01:01:57 -04:00
Improve system call systems
This commit is contained in:
parent
30d7f2d34b
commit
19b68b7e9f
@ -32,6 +32,12 @@ struct syscall_regs {
|
|||||||
uint64_t rdx;
|
uint64_t rdx;
|
||||||
uint64_t rsi;
|
uint64_t rsi;
|
||||||
uint64_t rdi;
|
uint64_t rdi;
|
||||||
|
uint64_t r8;
|
||||||
|
uint64_t r9;
|
||||||
|
uint64_t r10;
|
||||||
|
uint64_t r11;
|
||||||
|
uint64_t r12;
|
||||||
|
uint64_t code;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
void setup_interrupts();
|
void setup_interrupts();
|
||||||
|
@ -241,11 +241,9 @@ void _irq_handler(size_t code){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _syscall_handler(interrupt::syscall_regs regs){
|
void _syscall_handler(interrupt::syscall_regs regs){
|
||||||
auto code = regs.rdi;
|
|
||||||
|
|
||||||
//If there is a handler call, it
|
//If there is a handler call, it
|
||||||
if(syscall_handlers[code]){
|
if(syscall_handlers[regs.code]){
|
||||||
syscall_handlers[code](regs);
|
syscall_handlers[regs.code](regs);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Emit an error somehow if there is no handler
|
//TODO Emit an error somehow if there is no handler
|
||||||
|
@ -24,80 +24,70 @@
|
|||||||
_syscall0:
|
_syscall0:
|
||||||
cli
|
cli
|
||||||
|
|
||||||
push rdi
|
push 0
|
||||||
mov rdi, 0
|
|
||||||
|
|
||||||
jmp syscall_common_handler
|
jmp syscall_common_handler
|
||||||
|
|
||||||
_syscall1:
|
_syscall1:
|
||||||
cli
|
cli
|
||||||
|
|
||||||
push rdi
|
push 1
|
||||||
mov rdi, 1
|
|
||||||
|
|
||||||
jmp syscall_common_handler
|
jmp syscall_common_handler
|
||||||
|
|
||||||
_syscall2:
|
_syscall2:
|
||||||
cli
|
cli
|
||||||
|
|
||||||
push rdi
|
push 2
|
||||||
mov rdi, 2
|
|
||||||
|
|
||||||
jmp syscall_common_handler
|
jmp syscall_common_handler
|
||||||
|
|
||||||
_syscall3:
|
_syscall3:
|
||||||
cli
|
cli
|
||||||
|
|
||||||
push rdi
|
push 3
|
||||||
mov rdi, 3
|
|
||||||
|
|
||||||
jmp syscall_common_handler
|
jmp syscall_common_handler
|
||||||
|
|
||||||
_syscall4:
|
_syscall4:
|
||||||
cli
|
cli
|
||||||
|
|
||||||
push rdi
|
push 4
|
||||||
mov rdi, 4
|
|
||||||
|
|
||||||
jmp syscall_common_handler
|
jmp syscall_common_handler
|
||||||
|
|
||||||
_syscall5:
|
_syscall5:
|
||||||
cli
|
cli
|
||||||
|
|
||||||
push rdi
|
push 5
|
||||||
mov rdi, 5
|
|
||||||
|
|
||||||
jmp syscall_common_handler
|
jmp syscall_common_handler
|
||||||
|
|
||||||
_syscall6:
|
_syscall6:
|
||||||
cli
|
cli
|
||||||
|
|
||||||
push rdi
|
push 6
|
||||||
mov rdi, 6
|
|
||||||
|
|
||||||
jmp syscall_common_handler
|
jmp syscall_common_handler
|
||||||
|
|
||||||
_syscall7:
|
_syscall7:
|
||||||
cli
|
cli
|
||||||
|
|
||||||
push rdi
|
push 7
|
||||||
mov rdi, 7
|
|
||||||
|
|
||||||
jmp syscall_common_handler
|
jmp syscall_common_handler
|
||||||
|
|
||||||
_syscall8:
|
_syscall8:
|
||||||
cli
|
cli
|
||||||
|
|
||||||
push rdi
|
push 8
|
||||||
mov rdi, 8
|
|
||||||
|
|
||||||
jmp syscall_common_handler
|
jmp syscall_common_handler
|
||||||
|
|
||||||
_syscall9:
|
_syscall9:
|
||||||
cli
|
cli
|
||||||
|
|
||||||
push rdi
|
push 9
|
||||||
mov rdi, 9
|
|
||||||
|
|
||||||
jmp syscall_common_handler
|
jmp syscall_common_handler
|
||||||
|
|
||||||
@ -105,33 +95,33 @@ _syscall9:
|
|||||||
|
|
||||||
//TODO Check if really safe to trash r12
|
//TODO Check if really safe to trash r12
|
||||||
syscall_common_handler:
|
syscall_common_handler:
|
||||||
push r8
|
|
||||||
push r9
|
|
||||||
push r10
|
|
||||||
push r11
|
|
||||||
push r12
|
push r12
|
||||||
push rax
|
push r11
|
||||||
push rbx
|
push r10
|
||||||
push rcx
|
push r9
|
||||||
push rdx
|
push r8
|
||||||
push rsi
|
|
||||||
push rdi
|
push rdi
|
||||||
|
push rsi
|
||||||
|
push rdx
|
||||||
|
push rcx
|
||||||
|
push rbx
|
||||||
|
push rax
|
||||||
|
|
||||||
call _syscall_handler
|
call _syscall_handler
|
||||||
|
|
||||||
pop rdi
|
|
||||||
pop rsi
|
|
||||||
pop rdx
|
|
||||||
pop rcx
|
|
||||||
pop rbx
|
|
||||||
pop rax
|
pop rax
|
||||||
pop r12
|
pop rbx
|
||||||
pop r11
|
pop rcx
|
||||||
pop r10
|
pop rdx
|
||||||
pop r9
|
pop rsi
|
||||||
|
pop rdi
|
||||||
pop r8
|
pop r8
|
||||||
|
pop r9
|
||||||
|
pop r10
|
||||||
|
pop r11
|
||||||
|
pop r12
|
||||||
|
|
||||||
//Was pushed by the base handler code
|
//Was pushed by the base handler code
|
||||||
pop rdi
|
add rsp, 8
|
||||||
|
|
||||||
iretq // iret will clean the other automatically pushed stuff
|
iretq // iret will clean the other automatically pushed stuff
|
||||||
|
@ -13,5 +13,5 @@ void system_call_entry(const interrupt::syscall_regs& regs){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void install_system_calls(){
|
void install_system_calls(){
|
||||||
interrupt::register_syscall_handler(interrupt::SYSCALL_FIRST, &system_call_entry);
|
interrupt::register_syscall_handler(0, &system_call_entry);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user