Subversion Repositories Kolibri OS

Rev

Rev 1161 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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