PebbleOS
Loading...
Searching...
No Matches
syscall.h File Reference
#include <stdbool.h>
#include <stdckdint.h>
#include <stddef.h>
#include <stdint.h>
#include <pbl/kernel/compiler.h>

Macros

#define PBL_SYSCALL_COPY_MAX   128
 Largest argument PBL_SYSCALL() copies onto the syscall stack.
 
#define PBL_SYSCALL(ret, name, ...)   PRV_SC_DEFINE(, return, ret, name, __VA_ARGS__)
 Define a syscall whose arguments are checked from their declared kinds.
 
#define PBL_SYSCALL_NORETURN(name, ...)   PRV_SC_DEFINE([[noreturn]], , void, name, __VA_ARGS__)
 As PBL_SYSCALL(), for a syscall that never returns.
 

Functions

void pbl_syscall_fail (void)
 Kill the thread whose syscall is in progress.
 
void pbl_syscall_verify_user (const void *buf, size_t num_bytes)
 Kill the caller unless a range is its memory.
 
bool pbl_user_access_ok (const void *buf, size_t num_bytes)
 Check that the caller of the syscall in progress may access a range.
 
int pbl_user_copy_from (void *dst, const void *src, size_t num_bytes)
 Copy from the caller's memory.
 
int pbl_user_copy_to (void *dst, const void *src, size_t num_bytes)
 Copy to the caller's memory.
 
int pbl_user_strnlen (const char *str, size_t max)
 Measure a string in the caller's memory.
 
static bool pbl_is_user_context (void)
 Check whether the CPU runs unprivileged code.
 
void pbl_user_mode_enter (void)
 Drop the calling thread to unprivileged mode for good.
 
void pbl_user_call (void(*fn)(void *), void *ctx)
 Call a function unprivileged from privileged thread mode.
 
void pbl_kernel_syscall_exit (void)
 Called on the way out of every syscall made from unprivileged code.
 
void pbl_kernel_syscall_fault (uintptr_t lr)
 Kill the thread whose syscall failed.