apm.h 1.7 KB

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