1#ifndef __SEMIHOST_H
2#define __SEMIHOST_H
3
4#include <stdint.h>
5
6static inline uint64_t semihost_syscall(uint64_t op, void *param) {
7    uint64_t ret;
8
9    __asm volatile(
10        "mov x0, %[op];"
11        "mov x1, %[param];"
12        "hlt 0xf000;"
13        "mov %[ret], x0;"
14        : [ret] "=r" (ret)
15        : [op] "r" (op), [param] "r" (param)
16        : "x0", "x1");
17
18    return ret;
19}
20
21#endif /* __SEMIHOST_H */
22