C Microkernel Realtime eXecutive
Realtime Operating System for Cortex-M based microcontrollers
Loading...
Searching...
No Matches
sysenter.h
1
#pragma once
2
3
/*
4
* RISC-V syscall implementation.
5
*
6
* Uses standard RISC-V syscall convention:
7
* - Syscall number in a7
8
* - Arguments in a0-a3 (already there from C calling convention)
9
* - Return value in a0
10
*
11
* The ecall instruction causes mcause=11 (environment call from M-mode)
12
* which is handled by isr_riscv_machine_ecall_mmode_exception.
13
*/
14
15
#define __SYSCALL __attribute__((naked)) __attribute__((noinline))
16
17
/*
18
* Perform syscall via ecall instruction.
19
* @param no syscall number (placed in a7 before ecall)
20
*
21
* The function arguments are already in a0-a3 per RISC-V calling convention.
22
* We load the syscall number into a7, execute ecall, then return.
23
* The ecall handler will place the return value in a0.
24
*/
25
#define __SVC(no, ...) \
26
asm volatile( \
27
"li a7, %[syscall_id]\n\t" \
28
"ecall\n\t" \
29
"ret\n\t" \
30
: \
31
: [syscall_id] "i" (no) \
32
: "a7" \
33
)
34
src
os
arch
riscv
hal
arch
sysenter.h
Generated by
1.9.8