1 /* ----------------------------------------------------------------------- *
3 * Copyright 2013 Sebastian Herbszt - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
8 * Boston MA 02110-1301, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
25 com32sys_t inregs
, outregs
;
27 memset(&inregs
, 0, sizeof inregs
);
29 inregs
.eax
.l
= 0x5300; /* APM Installation Check (00h) */
30 inregs
.ebx
.l
= 0; /* APM BIOS (0000h) */
31 __intcall(0x15, &inregs
, &outregs
);
33 if (outregs
.eflags
.l
& EFLAGS_CF
) {
34 printf("APM not present.\n");
38 if ((outregs
.ebx
.l
& 0xffff) != 0x504d) { /* signature 'PM' */
39 printf("APM not present.\n");
43 if ((outregs
.eax
.l
& 0xffff) < 0x101) { /* Need version 1.1+ */
44 printf("APM 1.1+ not supported.\n");
48 if ((outregs
.ecx
.l
& 0x8) == 0x8) { /* bit 3 APM BIOS Power Management disabled */
49 printf("Power management disabled.\n");
53 inregs
.eax
.l
= 0x5301; /* APM Real Mode Interface Connect (01h) */
54 inregs
.ebx
.l
= 0; /* APM BIOS (0000h) */
55 __intcall(0x15, &inregs
, &outregs
);
57 if (outregs
.eflags
.l
& EFLAGS_CF
) {
58 printf("APM RM interface connect failed.\n");
62 inregs
.eax
.l
= 0x530e; /* APM Driver Version (0Eh) */
63 inregs
.ebx
.l
= 0; /* APM BIOS (0000h) */
64 inregs
.ecx
.l
= 0x101; /* APM Driver version 1.1 */
65 __intcall(0x15, &inregs
, &outregs
);
67 if (outregs
.eflags
.l
& EFLAGS_CF
) {
68 printf("APM 1.1+ not supported.\n");
72 if ((outregs
.ecx
.l
& 0xffff) < 0x101) { /* APM Connection version */
73 printf("APM 1.1+ not supported.\n");
77 inregs
.eax
.l
= 0x5307; /* Set Power State (07h) */
78 inregs
.ebx
.l
= 1; /* All devices power managed by the APM BIOS */
79 inregs
.ecx
.l
= 3; /* Power state off */
80 __intcall(0x15, &inregs
, &outregs
);
82 if (outregs
.eflags
.l
& EFLAGS_CF
) {
83 printf("Power off failed.\n");