1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Machine specific APM BIOS functions for generic.
4 * Split out from apm.c by Osamu Tomita <tomita@cinet.co.jp>
7 #ifndef _ASM_X86_MACH_DEFAULT_APM_H
8 #define _ASM_X86_MACH_DEFAULT_APM_H
10 #include <asm/nospec-branch.h>
13 # define APM_DO_ZERO_SEGS \
16 "xorl %%edx, %%edx\n\t" \
17 "mov %%dx, %%ds\n\t" \
18 "mov %%dx, %%es\n\t" \
19 "mov %%dx, %%fs\n\t" \
21 # define APM_DO_POP_SEGS \
25 # define APM_DO_ZERO_SEGS
26 # define APM_DO_POP_SEGS
29 static inline void apm_bios_call_asm(u32 func
, u32 ebx_in
, u32 ecx_in
,
30 u32
*eax
, u32
*ebx
, u32
*ecx
,
34 * N.B. We do NOT need a cld after the BIOS call
35 * because we always save and restore the flags.
37 firmware_restrict_branch_speculation_start();
38 __asm__
__volatile__(APM_DO_ZERO_SEGS
41 "lcall *%%cs:apm_bios_entry\n\t"
46 : "=a" (*eax
), "=b" (*ebx
), "=c" (*ecx
), "=d" (*edx
),
48 : "a" (func
), "b" (ebx_in
), "c" (ecx_in
)
50 firmware_restrict_branch_speculation_end();
53 static inline bool apm_bios_call_simple_asm(u32 func
, u32 ebx_in
,
60 * N.B. We do NOT need a cld after the BIOS call
61 * because we always save and restore the flags.
63 firmware_restrict_branch_speculation_start();
64 __asm__
__volatile__(APM_DO_ZERO_SEGS
67 "lcall *%%cs:apm_bios_entry\n\t"
72 : "=a" (*eax
), "=b" (error
), "=c" (cx
), "=d" (dx
),
74 : "a" (func
), "b" (ebx_in
), "c" (ecx_in
)
76 firmware_restrict_branch_speculation_end();
80 #endif /* _ASM_X86_MACH_DEFAULT_APM_H */