PowerBlocks SDK
 
Loading...
Searching...
No Matches
syscall.h
Go to the documentation of this file.
1
12
13#pragma once
14
16
17#include <stdint.h>
18
19
33typedef uint32_t (*syscall_handler_t)(exception_context_t* context, uint32_t arg1, uint32_t arg2, uint32_t arg3);
34
35#define SYSCALL_ID_YIELD 0
36#define SYSCALL_ID_ASSERT 1
37#define SYSCALL_ID_OUT_OF_MEMORY 2
38
39#define SYSCALL_REGISTRY_SIZE 2
40
41extern const syscall_handler_t syscall_registry[SYSCALL_REGISTRY_SIZE];
42
43
49#define SYSCALL(num, arg1, arg2, arg3) \
50({ \
51 register uint32_t r0 __asm__("r0") = (num); \
52 register uint32_t r3 __asm__("r3") = (uint32_t)(arg1); \
53 register uint32_t r4 __asm__("r4") = (uint32_t)(arg2); \
54 register uint32_t r5 __asm__("r5") = (uint32_t)(arg3); \
55 __asm__ volatile ( \
56 "sc\n\t" \
57 : "+r" (r3) \
58 : "r" (r0), "r" (r4), "r" (r5) \
59 : "cr0", "memory" \
60 ); \
61 r3; /* return value in r3 */ \
62});
63
70#define SYSCALL_YIELD() SYSCALL(SYSCALL_ID_YIELD, 0, 0, 0)
71
77#define SYSCALL_ASSERT(error_name, line, file) SYSCALL(SYSCALL_ID_ASSERT, error_name, line, file)
Handles System Exceptions.
Pointer to the stack frame of the saved context during interrupts.
Definition exceptions.h:43
uint32_t(* syscall_handler_t)(exception_context_t *context, uint32_t arg1, uint32_t arg2, uint32_t arg3)
Function pointer to handle syscalls.
Definition syscall.h:33