summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorSebastian Herbszt <herbszt@gmx.de>2009-05-04 20:05:20 +0200
committerH. Peter Anvin <hpa@zytor.com>2009-05-04 11:33:12 -0700
commitcc460b847361b2d4bdfca41b72f72c21a29d5e8c (patch)
treec37dd4f6e9e22cfadfabb04ab336f1672c424aaf /modules
parentde1ecabd369a2105f7822f4f8be10fb1937b9f86 (diff)
downloadsyslinux-cc460b847361b2d4bdfca41b72f72c21a29d5e8c.tar.gz
poweroff COMBOOT module
This module is able to power off a system via APM. It was tested on QEMU, Bochs and VMware. Possible usage: TIMEOUT 3000 TOTALTIMEOUT 9000 ONTIMEOUT poweroff.com - Sebastian
Diffstat (limited to 'modules')
-rw-r--r--modules/Makefile2
-rw-r--r--modules/poweroff.asm86
2 files changed, 87 insertions, 1 deletions
diff --git a/modules/Makefile b/modules/Makefile
index 2668be82..80eb995d 100644
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -19,7 +19,7 @@ include $(topdir)/MCONFIG.embedded
INCLUDES = -I$(com32)/include
-BINS = pxechain.com gfxboot.com
+BINS = pxechain.com gfxboot.com poweroff.com
all: $(BINS)
diff --git a/modules/poweroff.asm b/modules/poweroff.asm
new file mode 100644
index 00000000..474723de
--- /dev/null
+++ b/modules/poweroff.asm
@@ -0,0 +1,86 @@
+ absolute 0
+pspInt20: resw 1
+pspNextP: resw 1
+ resb 124
+pspCmdLen: resb 1
+pspCmdArg: resb 127
+
+ section .text
+ org 0x100
+
+_start:
+ mov ax,5300h ; APM Installation Check (00h)
+ xor bx,bx ; APM BIOS (0000h)
+ int 15h
+ jnc check_sig
+
+ mov bx, msg_notpresent
+ jmp error
+
+check_sig:
+ cmp bx,504Dh ; signature 'PM'
+ je check_ver
+
+ mov bx, msg_notpresent
+ jmp error
+
+check_ver:
+ cmp ax,0101h ; Need version 1.1+
+ jae check_state
+
+ mov bx, msg_notsup
+ jmp error
+
+check_state:
+ test cx,8 ; bit 3 APM BIOS Power Management disabled
+ jz connect
+
+ mov bx, msg_pmdisabled
+ jmp error
+
+connect:
+ mov ax,5301h ; APM Real Mode Interface Connect (01h)
+ xor bx,bx ; APM BIOS (0000h)
+ int 15h
+ jnc connect_ok
+
+ mov bx, msg_connect
+ jmp error
+
+connect_ok:
+ mov ax,530Eh ; APM Driver Version (0Eh)
+ xor bx,bx ; APM BIOS (0000h)
+ mov cx,0101h ; APM Driver version 1.1
+ int 15h
+ jnc apm0101_check
+
+ mov bx, msg_notsup
+ jmp error
+
+apm0101_check:
+ cmp cx,0101h ; APM Connection version
+ jae apm0101_ok
+
+ mov bx, msg_notsup
+ jmp error
+
+apm0101_ok:
+ mov ax,5307h ; Set Power State (07h)
+ mov bx,0001h ; All devices power managed by the APM BIOS
+ mov cx,0003h ; Power state off
+ int 15h
+ jnc off
+
+ mov bx, msg_failed
+
+error:
+ mov ax,2
+ int 22h
+off:
+ ret
+
+msg_notpresent: db 'APM not present.',0dh,0ah,0
+msg_notsup: db 'APM 1.1+ not supported.',0dh,0ah,0
+msg_pmdisabled: db 'Power management disabled.',0dh,0ah,0
+msg_connect: db 'APM RM interface connect failed.',0dh,0ah,0
+msg_failed: db 'Power off failed.',0dh,0ah,0