~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/include/asm/apm.h

Version: ~ [ linux-4.17-rc6 ] ~ [ linux-4.16.10 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.42 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.101 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.132 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.51 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.109 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.56 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.101 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.27.62 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp