| 2717 | int lastSyscall = 0; |
| 2718 | extern "C" |
| 2719 | void SyscallHandler(regs64_t* regs) { |
| 2720 | if (regs->rax >= NUM_SYSCALLS) // If syscall is non-existant then return |
| 2721 | return; |
| 2722 | |
| 2723 | asm("sti"); // By reenabling interrupts, a thread in a syscall can be preempted |
| 2724 | |
| 2725 | thread_t* thread = GetCPULocal()->currentThread; |
| 2726 | if(!syscalls[regs->rax]) return; |
| 2727 | if(thread->state == ThreadStateZombie) for(;;); |
| 2728 | |
| 2729 | uint64_t rsp = 0; |
| 2730 | asm volatile("mov %%rsp, %0" : "=r"(rsp)); |
| 2731 | |
| 2732 | IF_DEBUG((rsp < KERNEL_VIRTUAL_BASE), { |
| 2733 | Log::Info("warning: call: %d, thread rip: %x, kstack: %x, kernel rsp: %x, tss rsp0: %x, thread cs: %x, thread ss: %x", regs->rax, regs->rip, GetCPULocal()->currentThread->kernelStack, rsp, GetCPULocal()->tss.rsp0, regs->cs, regs->ss); |
| 2734 | }); |
| 2735 | |
| 2736 | acquireLock(&thread->lock); |
| 2737 | regs->rax = syscalls[regs->rax](regs); // Call syscall |
| 2738 | releaseLock(&thread->lock); |
| 2739 | } |
nothing calls this directly
no test coverage detected