Blame view

kernel/linux-rt-4.4.41/arch/x86/include/asm/apm.h 1.68 KB
5113f6f70   김현기   kernel add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
  /*
   *  Machine specific APM BIOS functions for generic.
   *  Split out from apm.c by Osamu Tomita <tomita@cinet.co.jp>
   */
  
  #ifndef _ASM_X86_MACH_DEFAULT_APM_H
  #define _ASM_X86_MACH_DEFAULT_APM_H
  
  #ifdef APM_ZERO_SEGS
  #	define APM_DO_ZERO_SEGS \
  		"pushl %%ds
  \t" \
  		"pushl %%es
  \t" \
  		"xorl %%edx, %%edx
  \t" \
  		"mov %%dx, %%ds
  \t" \
  		"mov %%dx, %%es
  \t" \
  		"mov %%dx, %%fs
  \t" \
  		"mov %%dx, %%gs
  \t"
  #	define APM_DO_POP_SEGS \
  		"popl %%es
  \t" \
  		"popl %%ds
  \t"
  #else
  #	define APM_DO_ZERO_SEGS
  #	define APM_DO_POP_SEGS
  #endif
  
  static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
  					u32 *eax, u32 *ebx, u32 *ecx,
  					u32 *edx, u32 *esi)
  {
  	/*
  	 * N.B. We do NOT need a cld after the BIOS call
  	 * because we always save and restore the flags.
  	 */
  	__asm__ __volatile__(APM_DO_ZERO_SEGS
  		"pushl %%edi
  \t"
  		"pushl %%ebp
  \t"
  		"lcall *%%cs:apm_bios_entry
  \t"
  		"setc %%al
  \t"
  		"popl %%ebp
  \t"
  		"popl %%edi
  \t"
  		APM_DO_POP_SEGS
  		: "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx),
  		  "=S" (*esi)
  		: "a" (func), "b" (ebx_in), "c" (ecx_in)
  		: "memory", "cc");
  }
  
  static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
  						u32 ecx_in, u32 *eax)
  {
  	int	cx, dx, si;
  	u8	error;
  
  	/*
  	 * N.B. We do NOT need a cld after the BIOS call
  	 * because we always save and restore the flags.
  	 */
  	__asm__ __volatile__(APM_DO_ZERO_SEGS
  		"pushl %%edi
  \t"
  		"pushl %%ebp
  \t"
  		"lcall *%%cs:apm_bios_entry
  \t"
  		"setc %%bl
  \t"
  		"popl %%ebp
  \t"
  		"popl %%edi
  \t"
  		APM_DO_POP_SEGS
  		: "=a" (*eax), "=b" (error), "=c" (cx), "=d" (dx),
  		  "=S" (si)
  		: "a" (func), "b" (ebx_in), "c" (ecx_in)
  		: "memory", "cc");
  	return error;
  }
  
  #endif /* _ASM_X86_MACH_DEFAULT_APM_H */