0001
0002
0003
0004
0005
0006
0007 #ifndef _ASM_X86_MACH_DEFAULT_APM_H
0008 #define _ASM_X86_MACH_DEFAULT_APM_H
0009
0010 #ifdef APM_ZERO_SEGS
0011 # define APM_DO_ZERO_SEGS \
0012 "pushl %%ds\n\t" \
0013 "pushl %%es\n\t" \
0014 "xorl %%edx, %%edx\n\t" \
0015 "mov %%dx, %%ds\n\t" \
0016 "mov %%dx, %%es\n\t" \
0017 "mov %%dx, %%fs\n\t" \
0018 "mov %%dx, %%gs\n\t"
0019 # define APM_DO_POP_SEGS \
0020 "popl %%es\n\t" \
0021 "popl %%ds\n\t"
0022 #else
0023 # define APM_DO_ZERO_SEGS
0024 # define APM_DO_POP_SEGS
0025 #endif
0026
0027 static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
0028 u32 *eax, u32 *ebx, u32 *ecx,
0029 u32 *edx, u32 *esi)
0030 {
0031
0032
0033
0034
0035 __asm__ __volatile__(APM_DO_ZERO_SEGS
0036 "pushl %%edi\n\t"
0037 "pushl %%ebp\n\t"
0038 "lcall *%%cs:apm_bios_entry\n\t"
0039 "setc %%al\n\t"
0040 "popl %%ebp\n\t"
0041 "popl %%edi\n\t"
0042 APM_DO_POP_SEGS
0043 : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx),
0044 "=S" (*esi)
0045 : "a" (func), "b" (ebx_in), "c" (ecx_in)
0046 : "memory", "cc");
0047 }
0048
0049 static inline bool apm_bios_call_simple_asm(u32 func, u32 ebx_in,
0050 u32 ecx_in, u32 *eax)
0051 {
0052 int cx, dx, si;
0053 bool error;
0054
0055
0056
0057
0058
0059 __asm__ __volatile__(APM_DO_ZERO_SEGS
0060 "pushl %%edi\n\t"
0061 "pushl %%ebp\n\t"
0062 "lcall *%%cs:apm_bios_entry\n\t"
0063 "setc %%bl\n\t"
0064 "popl %%ebp\n\t"
0065 "popl %%edi\n\t"
0066 APM_DO_POP_SEGS
0067 : "=a" (*eax), "=b" (error), "=c" (cx), "=d" (dx),
0068 "=S" (si)
0069 : "a" (func), "b" (ebx_in), "c" (ecx_in)
0070 : "memory", "cc");
0071 return error;
0072 }
0073
0074 #endif