Rev 1065 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1065 | Lrz | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
||
4 | ;; Distributed under terms of the GNU General Public License ;; |
||
5 | ;; ;; |
||
6 | ;; Shutdown for Menuet ;; |
||
7 | ;; ;; |
||
8 | ;; Distributed under General Public License ;; |
||
9 | ;; See file COPYING for details. ;; |
||
10 | ;; Copyright 2003 Ville Turjanmaa ;; |
||
11 | ;; ;; |
||
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
13 | |||
14 | |||
15 | align 4 |
||
16 | pr_mode_exit: |
||
17 | |||
18 | ; setup stack |
||
19 | mov ax, 0x3000 |
||
20 | mov ss, ax |
||
21 | mov esp, 0x0EC00 |
||
22 | ; setup ds |
||
23 | push cs |
||
24 | pop ds |
||
25 | |||
26 | lidt [old_ints_h] |
||
27 | ;remap IRQs |
||
28 | mov al,0x11 |
||
29 | out 0x20,al |
||
30 | call rdelay |
||
31 | out 0xA0,al |
||
32 | call rdelay |
||
33 | |||
34 | mov al,0x08 |
||
35 | out 0x21,al |
||
36 | call rdelay |
||
37 | mov al,0x70 |
||
38 | out 0xA1,al |
||
39 | call rdelay |
||
40 | |||
41 | mov al,0x04 |
||
42 | out 0x21,al |
||
43 | call rdelay |
||
44 | mov al,0x02 |
||
45 | out 0xA1,al |
||
46 | call rdelay |
||
47 | |||
48 | mov al,0x01 |
||
49 | out 0x21,al |
||
50 | call rdelay |
||
51 | out 0xA1,al |
||
52 | call rdelay |
||
53 | |||
54 | mov al,0xB8 |
||
55 | out 0x21,al |
||
56 | call rdelay |
||
57 | mov al,0xBD |
||
58 | out 0xA1,al |
||
59 | sti |
||
60 | |||
61 | temp_3456: |
||
62 | xor ax,ax |
||
63 | mov es,ax |
||
64 | mov al,byte [es:0x9030] |
||
65 | cmp al,1 |
||
66 | jl nbw |
||
67 | cmp al,4 |
||
68 | jle nbw32 |
||
69 | |||
70 | nbw: |
||
71 | in al,0x60 |
||
72 | cmp al,6 |
||
73 | jae nbw |
||
74 | mov bl,al |
||
75 | nbw2: |
||
76 | in al,0x60 |
||
77 | cmp al,bl |
||
78 | je nbw2 |
||
79 | cmp al,240 ;ax,240 |
||
80 | jne nbw31 |
||
81 | mov al,bl |
||
82 | dec ax |
||
83 | jmp nbw32 |
||
84 | nbw31: |
||
85 | add bl,128 |
||
86 | cmp al,bl |
||
87 | jne nbw |
||
88 | sub al,129 |
||
89 | |||
90 | nbw32: |
||
91 | |||
92 | dec ax |
||
93 | dec ax ; 2 = power off |
||
94 | jnz no_apm_off |
||
95 | call APM_PowerOff |
||
96 | jmp $ |
||
97 | no_apm_off: |
||
98 | |||
99 | dec ax ; 3 = reboot |
||
100 | jnz restart_kernel ; 4 = restart kernel |
||
101 | push 0x40 |
||
102 | pop ds |
||
103 | mov word[0x0072],0x1234 |
||
104 | jmp 0xF000:0xFFF0 |
||
105 | |||
106 | |||
107 | rdelay: |
||
108 | ret |
||
109 | |||
110 | APM_PowerOff: |
||
111 | mov ax, 5304h |
||
112 | xor bx, bx |
||
113 | int 15h |
||
114 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
||
115 | mov ax,0x5300 |
||
116 | xor bx,bx |
||
117 | int 0x15 |
||
118 | push ax |
||
119 | |||
120 | mov ax,0x5301 |
||
121 | xor bx,bx |
||
122 | int 0x15 |
||
123 | |||
124 | mov ax,0x5308 |
||
125 | mov bx,1 |
||
126 | mov cx,bx |
||
127 | int 0x15 |
||
128 | |||
129 | mov ax,0x530E |
||
130 | xor bx,bx |
||
131 | pop cx |
||
132 | int 0x15 |
||
133 | |||
134 | mov ax,0x530D |
||
135 | mov bx,1 |
||
136 | mov cx,bx |
||
137 | int 0x15 |
||
138 | |||
139 | mov ax,0x530F |
||
140 | mov bx,1 |
||
141 | mov cx,bx |
||
142 | int 0x15 |
||
143 | |||
144 | mov ax,0x5307 |
||
145 | mov bx,1 |
||
146 | mov cx,3 |
||
147 | int 0x15 |
||
148 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
||
149 | ret |
||
150 | |||
151 | restart_kernel: |
||
152 | |||
153 | mov ax,0x0003 ; set text mode for screen |
||
154 | int 0x10 |
||
155 | jmp 0x4000:0000 |
||
156 | |||
157 | restart_kernel_4000: |
||
158 | cli |
||
159 | |||
160 | push ds |
||
161 | pop es |
||
162 | mov cx, 0x8000 |
||
163 | push cx |
||
164 | push 0x7000 |
||
165 | pop ds |
||
166 | xor si, si |
||
167 | xor di, di |
||
168 | rep movsw |
||
169 | pop cx |
||
170 | mov ds, cx |
||
171 | push 0x2000 |
||
172 | pop es |
||
173 | rep movsw |
||
174 | push 0x9000 |
||
175 | pop ds |
||
176 | push 0x3000 |
||
177 | pop es |
||
178 | mov cx, 0xE000/2 |
||
179 | rep movsw |
||
180 | |||
181 | wbinvd ; write and invalidate cache |
||
182 | |||
183 | mov al, 00110100b |
||
184 | out 43h, al |
||
185 | jcxz $+2 |
||
186 | mov al, 0xFF |
||
187 | out 40h, al |
||
188 | jcxz $+2 |
||
189 | out 40h, al |
||
190 | jcxz $+2 |
||
191 | sti |
||
192 | |||
193 | ; (hint by Black_mirror) |
||
194 | ; We must read data from keyboard port, |
||
195 | ; because there may be situation when previous keyboard interrupt is lost |
||
196 | ; (due to return to real mode and IRQ reprogramming) |
||
197 | ; and next interrupt will not be generated (as keyboard waits for handling) |
||
198 | in al, 0x60 |
||
199 | |||
200 | ; bootloader interface |
||
201 | push 0x1000 |
||
202 | pop ds |
||
203 | mov si, kernel_restart_bootblock |
||
204 | mov ax, 'KL' |
||
205 | jmp 0x1000:0000 |
||
206 |