module: Fix incorrect list_entry() use
[syslinux.git] / modules / poweroff.asm
blobf4f19a2fcfd95d221266b3580cf77a067849cdb2
1 ; ****************************************************************************
3 ; poweroff.asm
5 ; Copyright 2009 Sebastian Herbszt
7 ; APM poweroff module.
9 ; This program is free software; you can redistribute it and/or modify
10 ; it under the terms of the GNU General Public License as published by
11 ; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
12 ; Boston MA 02111-1307, USA; either version 2 of the License, or
13 ; (at your option) any later version; incorporated herein by reference.
15 ; ****************************************************************************
17 absolute 0
18 pspInt20: resw 1
19 pspNextP: resw 1
20 resb 124
21 pspCmdLen: resb 1
22 pspCmdArg: resb 127
24 section .text
25 org 0x100
27 _start:
28 mov ax,5300h ; APM Installation Check (00h)
29 xor bx,bx ; APM BIOS (0000h)
30 int 15h
31 jnc check_sig
33 mov bx, msg_notpresent
34 jmp error
36 check_sig:
37 cmp bx,504Dh ; signature 'PM'
38 je check_ver
40 mov bx, msg_notpresent
41 jmp error
43 check_ver:
44 cmp ax,0101h ; Need version 1.1+
45 jae check_state
47 mov bx, msg_notsup
48 jmp error
50 check_state:
51 test cx,8 ; bit 3 APM BIOS Power Management disabled
52 jz connect
54 mov bx, msg_pmdisabled
55 jmp error
57 connect:
58 mov ax,5301h ; APM Real Mode Interface Connect (01h)
59 xor bx,bx ; APM BIOS (0000h)
60 int 15h
61 jnc connect_ok
63 mov bx, msg_connect
64 jmp error
66 connect_ok:
67 mov ax,530Eh ; APM Driver Version (0Eh)
68 xor bx,bx ; APM BIOS (0000h)
69 mov cx,0101h ; APM Driver version 1.1
70 int 15h
71 jnc apm0101_check
73 mov bx, msg_notsup
74 jmp error
76 apm0101_check:
77 cmp cx,0101h ; APM Connection version
78 jae apm0101_ok
80 mov bx, msg_notsup
81 jmp error
83 apm0101_ok:
84 mov ax,5307h ; Set Power State (07h)
85 mov bx,0001h ; All devices power managed by the APM BIOS
86 mov cx,0003h ; Power state off
87 int 15h
88 jnc off
90 mov bx, msg_failed
92 error:
93 mov ax,2
94 int 22h
95 off:
96 ret
98 msg_notpresent: db 'APM not present.',0dh,0ah,0
99 msg_notsup: db 'APM 1.1+ not supported.',0dh,0ah,0
100 msg_pmdisabled: db 'Power management disabled.',0dh,0ah,0
101 msg_connect: db 'APM RM interface connect failed.',0dh,0ah,0
102 msg_failed: db 'Power off failed.',0dh,0ah,0