diff options
Diffstat (limited to 'include/asm-x86/mach-default/apm.h')
-rw-r--r-- | include/asm-x86/mach-default/apm.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/include/asm-x86/mach-default/apm.h b/include/asm-x86/mach-default/apm.h new file mode 100644 index 000000000000..1f730b8bd1fd --- /dev/null +++ b/include/asm-x86/mach-default/apm.h | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | * include/asm-i386/mach-default/apm.h | ||
3 | * | ||
4 | * Machine specific APM BIOS functions for generic. | ||
5 | * Split out from apm.c by Osamu Tomita <tomita@cinet.co.jp> | ||
6 | */ | ||
7 | |||
8 | #ifndef _ASM_APM_H | ||
9 | #define _ASM_APM_H | ||
10 | |||
11 | #ifdef APM_ZERO_SEGS | ||
12 | # define APM_DO_ZERO_SEGS \ | ||
13 | "pushl %%ds\n\t" \ | ||
14 | "pushl %%es\n\t" \ | ||
15 | "xorl %%edx, %%edx\n\t" \ | ||
16 | "mov %%dx, %%ds\n\t" \ | ||
17 | "mov %%dx, %%es\n\t" \ | ||
18 | "mov %%dx, %%fs\n\t" \ | ||
19 | "mov %%dx, %%gs\n\t" | ||
20 | # define APM_DO_POP_SEGS \ | ||
21 | "popl %%es\n\t" \ | ||
22 | "popl %%ds\n\t" | ||
23 | #else | ||
24 | # define APM_DO_ZERO_SEGS | ||
25 | # define APM_DO_POP_SEGS | ||
26 | #endif | ||
27 | |||
28 | static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in, | ||
29 | u32 *eax, u32 *ebx, u32 *ecx, | ||
30 | u32 *edx, u32 *esi) | ||
31 | { | ||
32 | /* | ||
33 | * N.B. We do NOT need a cld after the BIOS call | ||
34 | * because we always save and restore the flags. | ||
35 | */ | ||
36 | __asm__ __volatile__(APM_DO_ZERO_SEGS | ||
37 | "pushl %%edi\n\t" | ||
38 | "pushl %%ebp\n\t" | ||
39 | "lcall *%%cs:apm_bios_entry\n\t" | ||
40 | "setc %%al\n\t" | ||
41 | "popl %%ebp\n\t" | ||
42 | "popl %%edi\n\t" | ||
43 | APM_DO_POP_SEGS | ||
44 | : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx), | ||
45 | "=S" (*esi) | ||
46 | : "a" (func), "b" (ebx_in), "c" (ecx_in) | ||
47 | : "memory", "cc"); | ||
48 | } | ||
49 | |||
50 | static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in, | ||
51 | u32 ecx_in, u32 *eax) | ||
52 | { | ||
53 | int cx, dx, si; | ||
54 | u8 error; | ||
55 | |||
56 | /* | ||
57 | * N.B. We do NOT need a cld after the BIOS call | ||
58 | * because we always save and restore the flags. | ||
59 | */ | ||
60 | __asm__ __volatile__(APM_DO_ZERO_SEGS | ||
61 | "pushl %%edi\n\t" | ||
62 | "pushl %%ebp\n\t" | ||
63 | "lcall *%%cs:apm_bios_entry\n\t" | ||
64 | "setc %%bl\n\t" | ||
65 | "popl %%ebp\n\t" | ||
66 | "popl %%edi\n\t" | ||
67 | APM_DO_POP_SEGS | ||
68 | : "=a" (*eax), "=b" (error), "=c" (cx), "=d" (dx), | ||
69 | "=S" (si) | ||
70 | : "a" (func), "b" (ebx_in), "c" (ecx_in) | ||
71 | : "memory", "cc"); | ||
72 | return error; | ||
73 | } | ||
74 | |||
75 | #endif /* _ASM_APM_H */ | ||