Rev 393 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 393 | Rev 444 | ||
---|---|---|---|
- | 1 | $Revision: 431 $ |
|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
- | |
- | 3 | ;; ;; |
|
- | 4 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
|
- | 5 | ;; Distributed under terms of the GNU General Public License ;; |
|
- | 6 | ;; ;; |
|
3 | ;; Shutdown for Menuet |
7 | ;; Shutdown for Menuet ;; |
4 | ;; |
- | |
- | 8 | ;; ;; |
|
5 | ;; Distributed under General Public License |
9 | ;; Distributed under General Public License ;; |
6 | ;; See file COPYING for details. |
10 | ;; See file COPYING for details. ;; |
7 | ;; Copyright 2003 Ville Turjanmaa |
11 | ;; Copyright 2003 Ville Turjanmaa ;; |
8 | ;; |
- | |
- | 12 | ;; ;; |
|
- | 13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
9 | 14 | ||
10 | align 4 |
15 | align 4 |
11 | pr_mode_exit: |
16 | pr_mode_exit: |
12 | 17 | ||
13 | ; setup stack |
18 | ; setup stack |
14 | mov ax, 0x3000 |
19 | mov ax, 0x3000 |
15 | mov ss, ax |
20 | mov ss, ax |
16 | mov esp, 0x0EC00 |
21 | mov esp, 0x0EC00 |
17 | ; setup ds |
22 | ; setup ds |
18 | push cs |
23 | push cs |
19 | pop ds |
24 | pop ds |
20 | 25 | ||
21 | lidt [old_ints_h] |
26 | lidt [old_ints_h] |
22 | ;remap IRQs |
27 | ;remap IRQs |
23 | mov al,0x11 |
28 | mov al,0x11 |
24 | out 0x20,al |
29 | out 0x20,al |
25 | call rdelay |
30 | call rdelay |
26 | out 0xA0,al |
31 | out 0xA0,al |
27 | call rdelay |
32 | call rdelay |
28 | 33 | ||
29 | mov al,0x08 |
34 | mov al,0x08 |
30 | out 0x21,al |
35 | out 0x21,al |
31 | call rdelay |
36 | call rdelay |
32 | mov al,0x70 |
37 | mov al,0x70 |
33 | out 0xA1,al |
38 | out 0xA1,al |
34 | call rdelay |
39 | call rdelay |
35 | 40 | ||
36 | mov al,0x04 |
41 | mov al,0x04 |
37 | out 0x21,al |
42 | out 0x21,al |
38 | call rdelay |
43 | call rdelay |
39 | mov al,0x02 |
44 | mov al,0x02 |
40 | out 0xA1,al |
45 | out 0xA1,al |
41 | call rdelay |
46 | call rdelay |
42 | 47 | ||
43 | mov al,0x01 |
48 | mov al,0x01 |
44 | out 0x21,al |
49 | out 0x21,al |
45 | call rdelay |
50 | call rdelay |
46 | out 0xA1,al |
51 | out 0xA1,al |
47 | call rdelay |
52 | call rdelay |
48 | 53 | ||
49 | mov al,0xB8 |
54 | mov al,0xB8 |
50 | out 0x21,al |
55 | out 0x21,al |
51 | call rdelay |
56 | call rdelay |
52 | mov al,0xBD |
57 | mov al,0xBD |
53 | out 0xA1,al |
58 | out 0xA1,al |
54 | sti |
59 | sti |
55 | 60 | ||
56 | temp_3456: |
61 | temp_3456: |
57 | xor ax,ax |
62 | xor ax,ax |
58 | mov es,ax |
63 | mov es,ax |
59 | mov al,byte [es:0x9030] |
64 | mov al,byte [es:0x9030] |
60 | cmp al,1 |
65 | cmp al,1 |
61 | jl nbw |
66 | jl nbw |
62 | cmp al,4 |
67 | cmp al,4 |
63 | jle nbw32 |
68 | jle nbw32 |
64 | 69 | ||
65 | nbw: |
70 | nbw: |
66 | in al,0x60 |
71 | in al,0x60 |
67 | call pause_key |
72 | call pause_key |
68 | cmp al,6 |
73 | cmp al,6 |
69 | jae nbw |
74 | jae nbw |
70 | mov bl,al |
75 | mov bl,al |
71 | nbw2: |
76 | nbw2: |
72 | in al,0x60 |
77 | in al,0x60 |
73 | call pause_key |
78 | call pause_key |
74 | cmp al,bl |
79 | cmp al,bl |
75 | je nbw2 |
80 | je nbw2 |
76 | cmp al,240 ;ax,240 |
81 | cmp al,240 ;ax,240 |
77 | jne nbw31 |
82 | jne nbw31 |
78 | mov al,bl |
83 | mov al,bl |
79 | dec ax |
84 | dec ax |
80 | jmp nbw32 |
85 | jmp nbw32 |
81 | nbw31: |
86 | nbw31: |
82 | add bl,128 |
87 | add bl,128 |
83 | cmp al,bl |
88 | cmp al,bl |
84 | jne nbw |
89 | jne nbw |
85 | sub al,129 |
90 | sub al,129 |
- | 91 | ||
86 | nbw32: |
92 | nbw32: |
87 | 93 | ||
88 | dec ax ; 1 = write floppy |
94 | dec ax ; 1 = write floppy |
89 | js nbw |
95 | js nbw |
90 | jnz no_floppy_write |
96 | jnz no_floppy_write |
91 | call floppy_write |
97 | call floppy_write |
92 | jmp temp_3456 ;nbw |
98 | jmp temp_3456 ;nbw |
93 | no_floppy_write: |
99 | no_floppy_write: |
94 | 100 | ||
95 | dec ax ; 2 = power off |
101 | dec ax ; 2 = power off |
96 | jnz no_apm_off |
102 | jnz no_apm_off |
97 | call APM_PowerOff |
103 | call APM_PowerOff |
98 | jmp $ |
104 | jmp $ |
99 | no_apm_off: |
105 | no_apm_off: |
100 | 106 | ||
101 | dec ax ; 3 = reboot |
107 | dec ax ; 3 = reboot |
102 | jnz restart_kernel ; 4 = restart kernel |
108 | jnz restart_kernel ; 4 = restart kernel |
103 | push 0x40 |
109 | push 0x40 |
104 | pop ds |
110 | pop ds |
105 | mov word[0x0072],0x1234 |
111 | mov word[0x0072],0x1234 |
106 | jmp 0xF000:0xFFF0 |
112 | jmp 0xF000:0xFFF0 |
107 | 113 | ||
108 | pause_key: |
114 | pause_key: |
109 | mov cx,100 |
115 | mov cx,100 |
110 | pause_key_1: |
116 | pause_key_1: |
111 | loop pause_key_1 |
117 | loop pause_key_1 |
112 | ret |
118 | ret |
113 | 119 | ||
114 | rdelay: |
120 | rdelay: |
115 | ret |
121 | ret |
116 | 122 | ||
117 | floppy_write: ; write diskette image to physical floppy |
123 | floppy_write: ; write diskette image to physical floppy |
118 | 124 | ||
119 | cmp [flm],byte 1 |
125 | cmp [flm],byte 1 |
120 | je fwwritedone |
126 | je fwwritedone |
121 | mov [flm],byte 1 |
127 | mov [flm],byte 1 |
122 | 128 | ||
123 | xor ax, ax ; reset drive |
129 | xor ax, ax ; reset drive |
124 | xor dx, dx |
130 | xor dx, dx |
125 | int 0x13 |
131 | int 0x13 |
126 | 132 | ||
127 | mov cx,0x0001 ; startcyl,startsector |
133 | mov cx,0x0001 ; startcyl,startsector |
128 | xor dx, dx ; starthead,drive |
134 | xor dx, dx ; starthead,drive |
129 | mov ax, 80*2 ; read no of sect |
135 | mov ax, 80*2 ; read no of sect |
130 | 136 | ||
131 | fwwrites: |
137 | fwwrites: |
132 | push ax |
138 | push ax |
133 | 139 | ||
134 | ; move 1mb+ -> 0:a000 |
140 | ; move 1mb+ -> 0:a000 |
135 | 141 | ||
136 | pusha |
142 | pusha |
137 | mov si, fwmovedesc |
143 | mov si, fwmovedesc |
138 | mov cx,256*18 |
144 | mov cx,256*18 |
139 | mov ah,0x87 |
145 | mov ah,0x87 |
140 | push ds |
146 | push ds |
141 | pop es |
147 | pop es |
142 | int 0x15 |
148 | int 0x15 |
143 | add dword [fwmovedesc+0x12], 512*18 |
149 | add dword [fwmovedesc+0x12], 512*18 |
144 | popa |
150 | popa |
145 | 151 | ||
146 | xor si,si |
152 | xor si,si |
147 | mov es,si |
153 | mov es,si |
148 | fwnewwrite: |
154 | fwnewwrite: |
149 | mov bx,0xa000 ; es:bx -> data area |
155 | mov bx,0xa000 ; es:bx -> data area |
150 | mov ax,0x0300+18 ; read, no of sectors to read |
156 | mov ax,0x0300+18 ; read, no of sectors to read |
151 | int 0x13 |
157 | int 0x13 |
152 | 158 | ||
153 | test ah, ah |
159 | test ah, ah |
154 | jz fwgoodwrite |
160 | jz fwgoodwrite |
155 | 161 | ||
156 | inc si |
162 | inc si |
157 | cmp si,10 |
163 | cmp si,10 |
158 | jnz fwnewwrite |
164 | jnz fwnewwrite |
159 | 165 | ||
160 | ; can't access diskette - return |
166 | ; can't access diskette - return |
161 | pop ax |
167 | pop ax |
162 | ret |
168 | ret |
163 | 169 | ||
164 | fwgoodwrite: |
170 | fwgoodwrite: |
165 | inc dh |
171 | inc dh |
166 | cmp dh,2 |
172 | cmp dh,2 |
167 | jnz fwbb2 |
173 | jnz fwbb2 |
168 | mov dh,0 |
174 | mov dh,0 |
169 | inc ch |
175 | inc ch |
170 | fwbb2: |
176 | fwbb2: |
171 | pop ax |
177 | pop ax |
172 | dec ax |
178 | dec ax |
173 | jnz fwwrites |
179 | jnz fwwrites |
174 | ret |
180 | ret |
175 | 181 | ||
176 | APM_PowerOff: |
182 | APM_PowerOff: |
177 | mov ax, 5304h |
183 | mov ax, 5304h |
178 | xor bx, bx |
184 | xor bx, bx |
179 | int 15h |
185 | int 15h |
180 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
186 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
181 | mov ax,0x5300 |
187 | mov ax,0x5300 |
182 | xor bx,bx |
188 | xor bx,bx |
183 | int 0x15 |
189 | int 0x15 |
184 | push ax |
190 | push ax |
185 | 191 | ||
186 | mov ax,0x5301 |
192 | mov ax,0x5301 |
187 | xor bx,bx |
193 | xor bx,bx |
188 | int 0x15 |
194 | int 0x15 |
189 | 195 | ||
190 | mov ax,0x5308 |
196 | mov ax,0x5308 |
191 | mov bx,1 |
197 | mov bx,1 |
192 | mov cx,bx |
198 | mov cx,bx |
193 | int 0x15 |
199 | int 0x15 |
194 | 200 | ||
195 | mov ax,0x530E |
201 | mov ax,0x530E |
196 | xor bx,bx |
202 | xor bx,bx |
197 | pop cx |
203 | pop cx |
198 | int 0x15 |
204 | int 0x15 |
199 | 205 | ||
200 | mov ax,0x530D |
206 | mov ax,0x530D |
201 | mov bx,1 |
207 | mov bx,1 |
202 | mov cx,bx |
208 | mov cx,bx |
203 | int 0x15 |
209 | int 0x15 |
204 | 210 | ||
205 | mov ax,0x530F |
211 | mov ax,0x530F |
206 | mov bx,1 |
212 | mov bx,1 |
207 | mov cx,bx |
213 | mov cx,bx |
208 | int 0x15 |
214 | int 0x15 |
209 | 215 | ||
210 | mov ax,0x5307 |
216 | mov ax,0x5307 |
211 | mov bx,1 |
217 | mov bx,1 |
212 | mov cx,3 |
218 | mov cx,3 |
213 | int 0x15 |
219 | int 0x15 |
214 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
220 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
215 | fwwritedone: |
221 | fwwritedone: |
216 | ret |
222 | ret |
217 | 223 | ||
218 | restart_kernel: |
224 | restart_kernel: |
219 | 225 | ||
220 | mov ax,0x0003 ; set text mode for screen |
226 | mov ax,0x0003 ; set text mode for screen |
221 | int 0x10 |
227 | int 0x10 |
222 | jmp 0x4000:0000 |
228 | jmp 0x4000:0000 |
223 | 229 | ||
224 | restart_kernel_4000: |
230 | restart_kernel_4000: |
225 | cli |
231 | cli |
226 | 232 | ||
227 | push ds |
233 | push ds |
228 | pop es |
234 | pop es |
229 | mov cx, 0x8000 |
235 | mov cx, 0x8000 |
230 | push cx |
236 | push cx |
231 | mov ds, cx |
237 | mov ds, cx |
232 | xor si, si |
238 | xor si, si |
233 | xor di, di |
239 | xor di, di |
234 | rep movsw |
240 | rep movsw |
235 | push 0x9000 |
241 | push 0x9000 |
236 | pop ds |
242 | pop ds |
237 | push 0x2000 |
243 | push 0x2000 |
238 | pop es |
244 | pop es |
239 | pop cx |
245 | pop cx |
240 | rep movsw |
246 | rep movsw |
241 | 247 | ||
242 | wbinvd ; write and invalidate cache |
248 | wbinvd ; write and invalidate cache |
243 | 249 | ||
244 | mov al, 00110100b |
250 | mov al, 00110100b |
245 | out 43h, al |
251 | out 43h, al |
246 | jcxz $+2 |
252 | jcxz $+2 |
247 | mov al, 0xFF |
253 | mov al, 0xFF |
248 | out 40h, al |
254 | out 40h, al |
249 | jcxz $+2 |
255 | jcxz $+2 |
250 | out 40h, al |
256 | out 40h, al |
251 | jcxz $+2 |
257 | jcxz $+2 |
252 | sti |
258 | sti |
253 | 259 | ||
254 | ; (hint by Black_mirror) |
260 | ; (hint by Black_mirror) |
255 | ; We must read data from keyboard port, |
261 | ; We must read data from keyboard port, |
256 | ; because there may be situation when previous keyboard interrupt is lost |
262 | ; because there may be situation when previous keyboard interrupt is lost |
257 | ; (due to return to real mode and IRQ reprogramming) |
263 | ; (due to return to real mode and IRQ reprogramming) |
258 | ; and next interrupt will not be generated (as keyboard waits for handling) |
264 | ; and next interrupt will not be generated (as keyboard waits for handling) |
259 | in al, 0x60 |
265 | in al, 0x60 |
260 | 266 | ||
261 | ; bootloader interface |
267 | ; bootloader interface |
262 | push 0x1000 |
268 | push 0x1000 |
263 | pop ds |
269 | pop ds |
264 | mov si, kernel_restart_bootblock |
270 | mov si, kernel_restart_bootblock |
265 | mov ax, 'KL' |
271 | mov ax, 'KL' |
266 | jmp 0x1000:0000 |
272 | jmp 0x1000:0000 |