59 for (
uint64_t i = 0; i < syscallsInTable; i++)
102 ASM(
"cli" :: :
"memory");
#define assert(expression)
#define GDT_KERNEL_CODE
Kernel code segment selector.
#define GDT_RING3
User ring.
#define GDT_USER_CODE
User code segment selector.
_NORETURN void interrupt_fake(interrupt_frame_t *frame)
Enter a fake interrupt context as if an interrupt had occurred at the given frame.
@ VECTOR_FAKE
Used to implement interrupt_fake().
#define SELF
Macro to access data in the current cpu.
#define PERCPU_DEFINE_CTOR(type, name)
Macro to define a percpu variable with a constructor.
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 _syscall_table_start[]
Linker defined start of the syscall table.
syscall_descriptor_t _syscall_table_end[]
Linker defined end of the syscall table.
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
#define LOG_INFO(format,...)
#define LOG_DEBUG(format,...)
bool thread_is_note_pending(thread_t *thread)
Check if a thread has a note pending.
static thread_t * thread_current(void)
Retrieves the currently running thread.
#define ENOSYS
Function not implemented.
#define errno
Error number variable.
#define ASM(...)
Inline assembly macro.
#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)
static uint64_t rflags_read(void)
#define EFER_SYSCALL_ENABLE
static uint64_t msr_read(uint32_t msr)
#define MSR_SYSCALL_FLAG_MASK
_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)