1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3
4#include <mos/mos_global.h>
5#include <mos/types.h>
6
7enum
8{
9 X86_SYSCALL_IOPL_ENABLE = 0, // enable IO operations for the current process
10 X86_SYSCALL_IOPL_DISABLE = 1, // disable IO operations for the current process
11 X86_SYSCALL_SET_FS_BASE = 2, // set the FS base address
12 X86_SYSCALL_SET_GS_BASE = 3, // set the GS base address
13};
14
15should_inline reg_t platform_syscall0(reg_t number)
16{
17 reg_t result = 0;
18 __asm__ volatile("int $0x88" : "=a"(result) : "a"(number) : "memory");
19 return result;
20}
21
22should_inline reg_t platform_syscall1(reg_t number, reg_t arg1)
23{
24 reg_t result = 0;
25 __asm__ volatile("int $0x88" : "=a"(result) : "a"(number), "b"(arg1) : "memory");
26 return result;
27}
28
29should_inline reg_t platform_syscall2(reg_t number, reg_t arg1, reg_t arg2)
30{
31 reg_t result = 0;
32 __asm__ volatile("int $0x88" : "=a"(result) : "a"(number), "b"(arg1), "c"(arg2) : "memory");
33 return result;
34}
35
36should_inline reg_t platform_syscall3(reg_t number, reg_t arg1, reg_t arg2, reg_t arg3)
37{
38 reg_t result = 0;
39 __asm__ volatile("int $0x88" : "=a"(result) : "a"(number), "b"(arg1), "c"(arg2), "d"(arg3) : "memory");
40 return result;
41}
42
43should_inline reg_t platform_syscall4(reg_t number, reg_t arg1, reg_t arg2, reg_t arg3, reg_t arg4)
44{
45 reg_t result = 0;
46 __asm__ volatile("int $0x88" : "=a"(result) : "a"(number), "b"(arg1), "c"(arg2), "d"(arg3), "S"(arg4) : "memory");
47 return result;
48}
49
50should_inline reg_t platform_syscall5(reg_t number, reg_t arg1, reg_t arg2, reg_t arg3, reg_t arg4, reg_t arg5)
51{
52 reg_t result = 0;
53 __asm__ volatile("int $0x88" : "=a"(result) : "a"(number), "b"(arg1), "c"(arg2), "d"(arg3), "S"(arg4), "D"(arg5) : "memory");
54 return result;
55}
56
57should_inline reg_t platform_syscall6(reg_t number, reg_t arg1, reg_t arg2, reg_t arg3, reg_t arg4, reg_t arg5, reg_t arg6)
58{
59 reg_t result = 0;
60 __asm__ volatile("int $0x88" : "=a"(result) : "a"(number), "b"(arg1), "c"(arg2), "d"(arg3), "S"(arg4), "D"(arg5), "r"(arg6) : "memory");
61 return result;
62}
63