47 for (
uint64_t i = 0; i < syscallsInTable; i++)
97 asm volatile(
"cli" :::
"memory");
#define assert(expression)
@ GDT_KERNEL_CODE
Kernel code segment selector.
@ GDT_USER_CODE
User code segment selector.
_NORETURN void interrupt_fake(interrupt_frame_t *frame, cpu_t *self)
Enter a fake interrupt context as if an interrupt had occurred at the given frame.
@ VECTOR_FAKE
Used to implement interrupt_fake().
syscall_descriptor_t _syscallTableEnd[]
Linker defined end of the syscall table.
void syscall_ctx_init(syscall_ctx_t *ctx, const stack_pointer_t *syscallStack)
Initialize a syscall context.
void syscall_table_init(void)
Sort the syscall table and verify that all syscalls are present.
syscall_descriptor_t _syscallTableStart[]
Linker defined start of the syscall table.
void syscalls_cpu_init(void)
Initialize syscalls on the current CPU.
void syscall_handler(interrupt_frame_t *frame)
Main C syscall handler.
void syscall_ctx_load(syscall_ctx_t *ctx)
Load the syscall context into the MSR_KERNEL_GS_BASE MSR.
void syscall_entry(void)
Assembly entry point for syscalls.
@ SYSCALL_FORCE_FAKE_INTERRUPT
static cpu_t * cpu_get_unsafe(void)
Gets the current CPU structure without disabling interrupts.
#define LOG_INFO(format,...)
#define LOG_DEBUG(format,...)
bool thread_is_note_pending(thread_t *thread)
Check if a thread has a note pending.
thread_t * sched_thread(void)
Retrieves the currently running thread.
#define ENOSYS
Function not implemented.
#define errno
Error number variable.
#define NULL
Pointer error value.
#define ERR
Integer error value.
#define RFLAGS_INTERRUPT_ENABLE
#define RFLAGS_NESTED_TASK
static void msr_write(uint32_t msr, uint64_t value)
#define EFER_SYSCALL_ENABLE
static uint64_t msr_read(uint32_t msr)
#define MSR_SYSCALL_FLAG_MASK
#define MSR_KERNEL_GS_BASE
static uint64_t rflags_read()
_PUBLIC void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *))
Structure to define a stack in memory.
uintptr_t top
The top of the stack, this address is not inclusive.
Per thread syscall context.
uintptr_t userRsp
Used to avoid clobbering registers when switching stacks.
interrupt_frame_t * frame
If a fake interrupt is generated, this is the interrupt frame to return to.
uintptr_t syscallRsp
The stack pointer to use when handling syscalls.
syscall_flags_t flags
Flags for the current syscall.
uint64_t(* handler)(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t)
Thread of execution structure.
const syscall_descriptor_t * syscall_get_descriptor(uint64_t number)
static int syscall_descriptor_cmp(const void *a, const void *b)