Use correct format for arguments in debug messages
[reactos.git] / reactos / hal / halx86 / generic / pwroff.c
1 /* $Id$
2 *
3 * FILE : reactos/hal/x86/apm.c
4 * DESCRIPTION: Turn CPU off...
5 * PROJECT : ReactOS Operating System
6 * AUTHOR : D. Lindauer (July 11 1997)
7 * NOTE : This program is public domain
8 * REVISIONS :
9 * 1999-12-26
10 */
11
12 #define APM_FUNCTION_AVAILABLE 0x5300
13 #define APM_FUNCTION_CONNREAL 0x5301
14 #define APM_FUNCTION_POWEROFF 0x5307
15 #define APM_FUNCTION_ENABLECPU 0x530d
16 #define APM_FUNCTION_ENABLEAPM 0x530e
17
18 #define APM_DEVICE_BIOS 0
19 #define APM_DEVICE_ALL 1
20
21 #define APM_MODE_DISABLE 0
22 #define APM_MODE_ENABLE 1
23
24
25
26 #if defined(__GNUC__)
27
28 nopm db 'No power management functionality',10,13,'$'
29 errmsg db 'Power management error',10,13,'$'
30 wrongver db 'Need APM version 1.1 or better',10,13,'$'
31 ;
32 ; Entry point
33 ;
34 go:
35 mov dx,offset nopm
36 jc error
37 cmp ax,101h ; See if version 1.1 or greater
38 mov dx,offset wrongver
39 jc error
40
41 mov [ver],ax
42 mov ax,5301h ; Do a real mode connection
43 mov bx,0 ; device = BIOS
44 int 15h
45 jnc noconerr
46
47 cmp ah,2 ; Pass if already connected
48 mov dx,offset errmsg ; else error
49 jnz error
50 noconerr:
51 mov ax,530eh ; Enable latest version of APM
52 mov bx,0 ; device = BIOS
53 mov cx,[ver] ; version
54 int 15h
55 mov dx,offset errmsg
56 jc error
57
58 mov ax,530dh ; Now engage and enable CPU management
59 mov bx,1 ; device = all
60 mov cx,1 ; enable
61 int 15h
62 mov dx,offset errmsg
63 jc error
64
65 mov ax,530fh
66 mov bx,1 ; device = ALL
67 mov cx,1 ; enable
68 int 15h
69 mov dx,offset errmsg
70 jc error
71
72 mov dx,offset errmsg
73 error:
74 call print
75 mov ax,4c01h
76 int 21h
77 int 3
78 end start
79
80
81 BOOLEAN
82 ApmCall (
83 DWORD Function,
84 DWORD Device,
85 DWORD Mode
86 )
87 {
88 /* AX <== Function */
89 /* BX <== Device */
90 /* CX <== Mode */
91 __asm__("int 21\n"); /* 0x15 */
92 }
93
94 #elif defined(_MSC_VER)
95 #else
96 #error Unknown compiler for inline assembler
97 #endif
98
99
100 BOOLEAN
101 HalPowerOff (VOID)
102 {
103 ApmCall (
104 APM_FUNCTION_AVAILABLE,
105 APM_DEVICE_BIOS,
106 0
107 );
108 ApmCall (
109 APM_FUNCTION_ENABLEAPM,
110 );
111 /* Shutdown CPU */
112 ApmCall (
113 APM_FUNCTION_POWEROFF,
114 APM_DEVICE_ALL,
115 3
116 );
117 return TRUE;
118 }
119
120
121 /* EOF */