1 /* SPDX-License-Identifier: GPL-2.0-only */
7 int protected_mode_call_narg(uint32_t arg_count
,
13 * Drops into protected mode and calls the function, which must have been compiled for x86_32.
14 * After the function returns it enters long mode again.
15 * The function pointer destination must be below 4GiB in physical memory.
17 * The called function doesn't have arguments and returns an int.
19 static inline int protected_mode_call(void *func
)
21 return protected_mode_call_narg(0, (uintptr_t)func
, 0, 0);
25 * Drops into protected mode and calls the function, which must have been compiled for x86_32.
26 * After the function returns it enters long mode again.
27 * The function pointer destination must be below 4GiB in physical memory.
28 * Only the lower 32bits of the argument are passed to the called function.
30 * The called function have one argument and returns an int.
32 static inline int protected_mode_call_1arg(void *func
, uint32_t arg1
)
34 return protected_mode_call_narg(1, (uintptr_t)func
, arg1
, 0);
38 * Drops into protected mode and calls the function, which must have been compiled for x86_32.
39 * After the function returns it enters long mode again.
40 * The function pointer destination must be below 4GiB in physical memory.
41 * Only the lower 32bits of the argument are passed to the called function.
43 * The called function has two arguments and returns an int.
45 static inline int protected_mode_call_2arg(void *func
, uint32_t arg1
, uint32_t arg2
)
47 return protected_mode_call_narg(2, (uintptr_t)func
, arg1
, arg2
);
50 static inline int protected_mode_call(void *func
)
52 int (*doit
)(void) = func
;
57 static inline int protected_mode_call_1arg(void *func
, uint32_t arg1
)
59 int (*doit
)(uint32_t arg1
) = func
;
64 static inline int protected_mode_call_2arg(void *func
, uint32_t arg1
, uint32_t arg2
)
66 int (*doit
)(uint32_t arg1
, uint32_t arg2
) = func
;
68 return doit(arg1
, arg2
);