apm.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifndef _ASM_APM_H
  8. #define _ASM_APM_H
  9. #ifdef APM_ZERO_SEGS
  10. # define APM_DO_ZERO_SEGS \
  11. "pushl %%ds\n\t" \
  12. "pushl %%es\n\t" \
  13. "xorl %%edx, %%edx\n\t" \
  14. "mov %%dx, %%ds\n\t" \
  15. "mov %%dx, %%es\n\t" \
  16. "mov %%dx, %%fs\n\t" \
  17. "mov %%dx, %%gs\n\t"
  18. # define APM_DO_POP_SEGS \
  19. "popl %%es\n\t" \
  20. "popl %%ds\n\t"
  21. #else
  22. # define APM_DO_ZERO_SEGS
  23. # define APM_DO_POP_SEGS
  24. #endif
  25. static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
  26. u32 *eax, u32 *ebx, u32 *ecx,
  27. u32 *edx, u32 *esi)
  28. {
  29. /*
  30. * N.B. We do NOT need a cld after the BIOS call
  31. * because we always save and restore the flags.
  32. */
  33. __asm__ __volatile__(APM_DO_ZERO_SEGS
  34. "pushl %%edi\n\t"
  35. "pushl %%ebp\n\t"
  36. "lcall *%%cs:apm_bios_entry\n\t"
  37. "setc %%al\n\t"
  38. "popl %%ebp\n\t"
  39. "popl %%edi\n\t"
  40. APM_DO_POP_SEGS
  41. : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx),
  42. "=S" (*esi)
  43. : "a" (func), "b" (ebx_in), "c" (ecx_in)
  44. : "memory", "cc");
  45. }
  46. static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
  47. u32 ecx_in, u32 *eax)
  48. {
  49. int cx, dx, si;
  50. u8 error;
  51. /*
  52. * N.B. We do NOT need a cld after the BIOS call
  53. * because we always save and restore the flags.
  54. */
  55. __asm__ __volatile__(APM_DO_ZERO_SEGS
  56. "pushl %%edi\n\t"
  57. "pushl %%ebp\n\t"
  58. "lcall *%%cs:apm_bios_entry\n\t"
  59. "setc %%bl\n\t"
  60. "popl %%ebp\n\t"
  61. "popl %%edi\n\t"
  62. APM_DO_POP_SEGS
  63. : "=a" (*eax), "=b" (error), "=c" (cx), "=d" (dx),
  64. "=S" (si)
  65. : "a" (func), "b" (ebx_in), "c" (ecx_in)
  66. : "memory", "cc");
  67. return error;
  68. }
  69. #endif /* _ASM_APM_H */