PowerBlocks SDK
 
Loading...
Searching...
No Matches
syscall.h File Reference

Handle syscall exceptions. More...

#include "powerblocks/core/system/exceptions.h"
#include <stdint.h>

Go to the source code of this file.

Macros

#define SYSCALL_ID_YIELD   0
 
#define SYSCALL_ID_ASSERT   1
 
#define SYSCALL_ID_OUT_OF_MEMORY   2
 
#define SYSCALL_REGISTRY_SIZE   2
 
#define SYSCALL(num, arg1, arg2, arg3)
 Calls a Syscall with a linux like calling convention.
 
#define SYSCALL_YIELD()
 Called for FreeRTOS to task switch the current context.
 
#define SYSCALL_ASSERT(error_name, line, file)
 Called for when an assert fails to report the information.
 

Typedefs

typedef uint32_t(* syscall_handler_t) (exception_context_t *context, uint32_t arg1, uint32_t arg2, uint32_t arg3)
 Function pointer to handle syscalls.
 

Variables

const syscall_handler_t syscall_registry [SYSCALL_REGISTRY_SIZE]
 

Detailed Description

Handle syscall exceptions.

Handle syscall exceptions, usually for task control and debugging.

Author
Samuel Fitzsimons (rainbain)
Date
2025 @license MIT (see LICENSE file)

Macro Definition Documentation

◆ SYSCALL

#define SYSCALL ( num,
arg1,
arg2,
arg3 )
Value:
({ \
register uint32_t r0 __asm__("r0") = (num); \
register uint32_t r3 __asm__("r3") = (uint32_t)(arg1); \
register uint32_t r4 __asm__("r4") = (uint32_t)(arg2); \
register uint32_t r5 __asm__("r5") = (uint32_t)(arg3); \
__asm__ volatile ( \
"sc\n\t" \
: "+r" (r3) \
: "r" (r0), "r" (r4), "r" (r5) \
: "cr0", "memory" \
); \
r3; /* return value in r3 */ \
});

Calls a Syscall with a linux like calling convention.

Calls a Syscall with a linux like calling convention.

◆ SYSCALL_ASSERT

#define SYSCALL_ASSERT ( error_name,
line,
file )
Value:
SYSCALL(SYSCALL_ID_ASSERT, error_name, line, file)
#define SYSCALL(num, arg1, arg2, arg3)
Calls a Syscall with a linux like calling convention.
Definition syscall.h:49

Called for when an assert fails to report the information.

Called for when an assert fails to report the information.

◆ SYSCALL_YIELD

#define SYSCALL_YIELD ( )
Value:
SYSCALL(SYSCALL_ID_YIELD, 0, 0, 0)

Called for FreeRTOS to task switch the current context.

Called for FreeRTOS to task switch the current context. Use taskYIELD for most applications.

Typedef Documentation

◆ syscall_handler_t

typedef uint32_t(* syscall_handler_t) (exception_context_t *context, uint32_t arg1, uint32_t arg2, uint32_t arg3)

Function pointer to handle syscalls.

Function pointer to handle syscalls.

Parameters
contextPointer to the stack frame of the saved context during interrupts.
arg1First argument passed to syscall
arg2Second argument passed to syscall
arg3Third argument passed to syscall
Returns
Return value of syscall.