apm_shutdown2.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "common.h"
  2. BEGIN
  3. movb $0x53,%ah #this is an APM command
  4. movb $0x0,%al #installation check command
  5. xorw %bx,%bx #device id (0 = APM BIOS)
  6. int $0x15 #call the BIOS function through interrupt 15h
  7. jc APM_error #if the carry flag is set there was an error
  8. #the function was successful
  9. #AX = APM version number
  10. #AH = Major revision number (in BCD format)
  11. #AL = Minor revision number (also BCD format)
  12. #BX = ASCII characters "P" (in BH) and "M" (in BL)
  13. #CX = APM flags (see the official documentation for more details)
  14. #disconnect from any APM interface
  15. movb $0x53,%ah #this is an APM command
  16. movb $0x4,%al #interface disconnect command
  17. xorw %bx,%bx #device id (0 = APM BIOS)
  18. int $0x15 #call the BIOS function through interrupt 15h
  19. jc .disconnect_error #if the carry flag is set see what the fuss is about.
  20. jmp .no_error
  21. .disconnect_error: #the error code is in ah.
  22. cmpb $0x3,%ah #if the error code is anything but 03h there was an error.
  23. jne APM_error #the error code 03h means that no interface was connected in the first place.
  24. .no_error:
  25. #the function was successful
  26. #Nothing is returned.
  27. #connect to an APM interface
  28. movb $0x53,%ah #this is an APM command
  29. movb $0x01,%al #see above description
  30. xorw %bx,%bx #device id (0 = APM BIOS)
  31. int $0x15 #call the BIOS function through interrupt 15h
  32. jc APM_error #if the carry flag is set there was an error
  33. #the function was successful
  34. #The return values are different for each interface.
  35. #The Real Mode Interface returns nothing.
  36. #See the official documentation for the
  37. #return values for the protected mode interfaces.
  38. #Enable power management for all devices
  39. movb $0x53,%ah #this is an APM command
  40. movb $0x8,%al #Change the state of power management...
  41. movw $0x001,%bx #...on all devices to...
  42. movw $0x001,%cx #...power management on.
  43. int $0x15 #call the BIOS function through interrupt 15h
  44. jc APM_error #if the carry flag is set there was an error
  45. #Set the power state for all devices
  46. movb $0x53,%ah #this is an APM command
  47. movb $0x07,%al #Set the power state...
  48. movw $0x0001,%bx #...on all devices to...
  49. movw $0x0003,%cx #see above
  50. int $0x15 #call the BIOS function through interrupt 15h
  51. jc APM_error #if the carry flag is set there was an error
  52. APM_error:
  53. hlt