Subversion Repositories Kolibri OS

Rev

Rev 388 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 388 Rev 393
Line 5... Line 5...
5
;;  Distributed under General Public License
5
;;  Distributed under General Public License
6
;;  See file COPYING for details.
6
;;  See file COPYING for details.
7
;;  Copyright 2003 Ville Turjanmaa
7
;;  Copyright 2003 Ville Turjanmaa
8
;;
8
;;
Line 9... Line -...
9
 
-
 
10
 
-
 
11
system_shutdown:          ; shut down the system
-
 
12
    call stop_all_services
-
 
13
 
-
 
14
    push 3        ; stop playing cd
-
 
15
    pop  eax
-
 
16
    call sys_cd_audio
-
 
17
    cld
-
 
18
 
-
 
19
    mov  al,[BOOT_VAR+0x9030]
-
 
20
    cmp  al,1
-
 
21
    jl   no_shutdown_parameter
-
 
22
    cmp  al,4
-
 
23
    jle  yes_shutdown_param
-
 
24
 no_shutdown_parameter:
-
 
25
 
-
 
26
;    movzx ecx,word [BOOT_VAR+0x900A]
-
 
27
;    movzx esi,word [BOOT_VAR+0x900C]
-
 
28
;    imul ecx,esi  ;[0xfe04]
-
 
29
;;    mov  ecx,0x500000/4  ;3fff00/4    ; darken screen
-
 
30
;    push ecx
-
 
31
;    mov  esi,[0xfe80]
-
 
32
;    cmp  esi,32*0x100000
-
 
33
;    jbe  no_darken_screen
-
 
34
;    mov  edi,16*0x100000
-
 
35
;    push esi edi
-
 
36
;  sdnewpix:
-
 
37
;    lodsd
-
 
38
;    shr  eax,1
-
 
39
;    and  eax,0x7f7f7f7f
-
 
40
;    stosd
-
 
41
;    loop sdnewpix
-
 
42
;    pop  ecx
-
 
43
;    pop  esi edi
-
 
44
;    rep  movsd
-
 
45
;  no_darken_screen:
-
 
46
 
-
 
47
; read shutdown code:
-
 
48
; 1) display shutdown "window"
-
 
49
 
-
 
50
    mov  eax,[0xfe00]
-
 
51
    shr  eax,1
-
 
52
    lea  esi,[eax+220]        ; x end
-
 
53
    sub  eax,220        ; x start
-
 
54
 
-
 
55
    mov  ebx,[ScreenHeight]
-
 
56
    shr  ebx,1
-
 
57
    mov  [shutdownpos],ebx
-
 
58
    lea  ebp,[ebx+105]        ; y end
-
 
59
    sub  ebx,120        ; y start
-
 
60
 
-
 
61
    xor  edi,edi
-
 
62
    inc  edi        ; force putpixel & dtext
-
 
63
    mov  ecx,0x0000ff
-
 
64
 
-
 
65
; vertical loop begin
-
 
66
  sdnewpix1:
-
 
67
    push eax    ; save x start
-
 
68
 
-
 
69
; horizontal loop begin
-
 
70
  sdnewpix2:
-
 
71
 
-
 
72
    call [putpixel]
-
 
73
 
-
 
74
    inc  eax
-
 
75
    cmp  eax,esi
-
 
76
    jnz  sdnewpix2
-
 
77
; horizontal loop end
-
 
78
 
-
 
79
    dec  ecx    ; color
-
 
80
    pop  eax    ; restore x start
-
 
81
 
-
 
82
    inc  ebx    ; advance y pos
-
 
83
    cmp  ebx,ebp
-
 
84
    jnz  sdnewpix1
-
 
85
; vertical loop end
-
 
86
 
-
 
87
; 2) display text strings
-
 
88
;    a) version
-
 
89
    mov  eax,[0xfe00]
-
 
90
    shr  eax,1
-
 
91
    shl  eax,16
-
 
92
    mov  ax,word [shutdownpos]
-
 
93
    push eax
-
 
94
    sub  eax,(220-27)*10000h + 105
-
 
95
    mov  ebx,0xffff00
-
 
96
    mov  ecx,version
-
 
97
    push 34
-
 
98
    pop  edx
-
 
99
    call dtext
-
 
100
 
-
 
101
;    b) variants
-
 
102
    add  eax,105+33
-
 
103
    push 6
-
 
104
    pop  esi
-
 
105
;    mov  ebx,0xffffff
-
 
106
    mov  bl,0xFF
-
 
107
    mov  ecx,shutdowntext
-
 
108
    mov  dl,40
-
 
109
  newsdt:
-
 
110
    call dtext
-
 
111
    add  eax,10
-
 
112
    add  ecx,edx
-
 
113
    dec  esi
-
 
114
    jnz  newsdt
-
 
115
 
-
 
116
; 3) load & display rose.txt
-
 
117
    mov  eax,rosef          ; load rose.txt
-
 
118
    xor  ebx,ebx
-
 
119
    push 2
-
 
120
    pop  ecx
-
 
121
    mov  edx,0x90000
-
 
122
    push edx
-
 
123
    push 12
-
 
124
    pop  esi
-
 
125
    push edi    ; may be destroyed
-
 
126
    call fileread
-
 
127
    pop  edi
-
 
128
 
-
 
129
    pop  ecx
-
 
130
    inc  ecx    ; do not display stars from rose.txt
-
 
131
    pop  eax
-
 
132
    add  eax,20*10000h - 110
-
 
133
 
-
 
134
    mov  ebx,0x00ff00
-
 
135
    push 27
-
 
136
    pop  edx
-
 
137
 
-
 
138
   nrl:
-
 
139
    call dtext
-
 
140
;    sub  ebx,0x050000
-
 
141
        ror     ebx, 16
-
 
142
        sub     bl, 0x05
-
 
143
        ror     ebx, 16
-
 
144
    add  eax,8
-
 
145
    add  ecx,31
-
 
146
    cmp  cx,word 0x0001+25*31
-
 
147
    jnz  nrl
-
 
148
 
-
 
149
    call checkVga_N13
-
 
150
 
-
 
151
 yes_shutdown_param:
9
 
152
    cli
-
 
153
 
-
 
154
    mov  eax,kernel               ; load kernel.mnt to 0x8000:0
-
 
155
    push 12
-
 
156
    pop  esi
-
 
157
    xor  ebx,ebx
-
 
158
    or   ecx,-1
-
 
159
    mov  edx,0x80000
-
 
160
    call fileread
-
 
161
 
-
 
162
    mov  esi,restart_kernel_4000+0x10000  ; move kernel re-starter to 0x4000:0
-
 
163
    mov  edi,0x40000
-
 
164
    mov  ecx,1000
-
 
165
    rep  movsb
-
 
166
 
-
 
167
    mov  eax,0x2F0000    ; restore 0x0 - 0xffff
-
 
168
    xor  ebx,ebx
-
 
169
    mov  ecx,0x10000
-
 
170
    call memmove
-
 
171
 
-
 
172
    call restorefatchain
-
 
173
 
-
 
174
    mov al, 0xFF
-
 
175
    out 0x21, al
-
 
176
    out 0xA1, al
-
 
177
 
-
 
178
    mov  word [0x467+0],pr_mode_exit-0x10000
-
 
179
    mov  word [0x467+2],0x1000
-
 
180
 
-
 
181
    mov  al,0x0F
-
 
182
    out  0x70,al
-
 
183
    mov  al,0x05
-
 
184
    out  0x71,al
-
 
185
 
-
 
186
    mov  al,0xFE
-
 
187
    out  0x64,al
-
 
188
    hlt
-
 
189
 
-
 
190
use16
-
 
191
 
10
align 4
192
pr_mode_exit:
-
 
Line 193... Line 11...
193
org $-0x10000
11
pr_mode_exit:
194
 
12
 
195
; setup stack
13
; setup stack
196
    mov    ax, 3000h
14
        mov    ax, 0x3000
197
    mov    ss, ax
15
        mov    ss, ax
198
    mov    esp, 0EC00h
16
        mov    esp, 0x0EC00
199
; setup ds
17
; setup ds
Line 200... Line 18...
200
    push    cs
18
        push    cs
201
    pop    ds
19
        pop    ds
202
 
20
 
203
    lidt [old_ints_h-0x10000]
21
        lidt [old_ints_h]
204
;remap IRQs
22
;remap IRQs
205
    mov  al,0x11
23
        mov  al,0x11
Line 263... Line 81...
263
  nbw31:
81
nbw31:
264
    add  bl,128
82
        add  bl,128
265
    cmp  al,bl
83
        cmp  al,bl
266
    jne  nbw
84
        jne  nbw
267
    sub  al,129
85
        sub  al,129
268
 
-
 
269
  nbw32:
86
nbw32:
Line 270... Line 87...
270
 
87
 
271
    dec  ax    ; 1 = write floppy
88
        dec  ax    ; 1 = write floppy
272
    js   nbw
89
        js   nbw
Line 295... Line 112...
295
      ret
112
        ret
Line 296... Line 113...
296
 
113
 
297
rdelay:
114
rdelay:
Line 298... Line -...
298
    ret
-
 
299
 
115
        ret
300
iglobal
-
 
301
  kernel  db  'KERNEL  MNT'
-
 
Line -... Line 116...
-
 
116
 
302
;  shutdown_parameter db 0
117
floppy_write:   ; write diskette image to physical floppy
-
 
118
 
Line 303... Line 119...
303
endg
119
        cmp  [flm],byte 1
-
 
120
        je   fwwritedone
304
 
121
        mov  [flm],byte 1
Line -... Line 122...
-
 
122
 
-
 
123
        xor    ax, ax        ; reset drive
305
restart_kernel:
124
        xor    dx, dx
Line -... Line 125...
-
 
125
        int     0x13
-
 
126
 
Line 306... Line 127...
306
 
127
        mov     cx,0x0001               ; startcyl,startsector
307
        mov     ax,0x0003      ; set text mode for screen
-
 
Line 308... Line -...
308
        int     0x10
-
 
309
 
-
 
310
        jmp     0x4000:0000
-
 
311
 
-
 
312
 
-
 
313
restart_kernel_4000:
-
 
314
        cli
-
 
315
 
-
 
316
;        mov     di,0x1000      ; load kernel image from 0x8000:0 -> 0x1000:0
-
 
317
;
-
 
318
;      new_kernel_block_move:
128
        xor    dx, dx                    ; starthead,drive
319
;
129
        mov    ax, 80*2               ; read no of sect
320
;        mov     ebx,0
130
 
321
;
131
fwwrites:
322
;      new_kernel_byte_move:
-
 
323
;
-
 
324
;        mov     ax,di
-
 
325
;        add     ax,0x7000
-
 
326
;        mov     es,ax
-
 
327
;        mov     dl,[es:bx]
-
 
328
;        mov     es,di
-
 
329
;        mov     [es:bx],dl
-
 
330
;
132
        push    ax
331
;        inc     ebx
133
 
332
;        cmp     ebx,65536
134
        ; move 1mb+ -> 0:a000
333
;        jbe     new_kernel_byte_move
135
 
334
;
136
         pusha
-
 
137
        mov     si, fwmovedesc
335
;        add     di,0x1000
138
        mov     cx,256*18
336
;        cmp     di,0x2000
139
        mov     ah,0x87
337
;        jbe     new_kernel_block_move
140
        push    ds
338
    push    ds
141
        pop    es
339
    pop    es
-
 
340
    mov    cx, 0x8000
142
        int     0x15
341
    push    cx
-
 
342
    mov    ds, cx
143
        add    dword [fwmovedesc+0x12], 512*18
343
    xor    si, si
-
 
Line -... Line 144...
-
 
144
        popa
344
    xor    di, di
145
 
Line 345... Line -...
345
    rep    movsw
-
 
346
    push    0x9000
146
        xor     si,si
347
    pop    ds
-
 
348
    push    0x2000
147
        mov    es,si
349
    pop    es
148
fwnewwrite:
350
    pop    cx
-
 
351
    rep    movsw
-
 
352
 
-
 
353
        wbinvd  ; write and invalidate cache
-
 
354
 
-
 
355
;        mov     ax,0x1000
-
 
356
;        mov     es,ax
-
 
357
;        mov     ax,0x3000
-
 
358
;        mov     ss,ax
-
 
359
;        mov     sp,0xec00
-
 
Line 360... Line 149...
360
; restore timer
149
        mov     bx,0xa000               ; es:bx -> data area
361
    mov    al, 00110100b
150
        mov     ax,0x0300+18            ; read, no of sectors to read
362
    out    43h, al
-
 
363
    jcxz    $+2
-
 
364
    mov    al, 0xFF
-
 
365
    out    40h, al
151
        int     0x13
Line 366... Line 152...
366
    jcxz    $+2
152
 
367
    out    40h, al
153
         test    ah, ah
368
    jcxz    $+2
154
        jz      fwgoodwrite
369
        sti
155
 
370
 
156
        inc    si
-
 
157
        cmp     si,10
-
 
158
        jnz     fwnewwrite
-
 
159
 
-
 
160
; can't access diskette - return
371
; (hint by Black_mirror)
161
        pop    ax
-
 
162
        ret
Line 372... Line 163...
372
; We must read data from keyboard port,
163
 
373
; because there may be situation when previous keyboard interrupt is lost
164
fwgoodwrite:
374
; (due to return to real mode and IRQ reprogramming)
165
        inc     dh
375
; and next interrupt will not be generated (as keyboard waits for handling)
166
        cmp     dh,2
Line 421... Line 212...
421
mov cx,3
212
        mov cx,3
422
int 0x15
213
        int 0x15
423
;!!!!!!!!!!!!!!!!!!!!!!!!
214
;!!!!!!!!!!!!!!!!!!!!!!!!
424
fwwritedone:
215
fwwritedone:
425
        ret
216
        ret
426
org $+0x10000
-
 
427
flm db 0
-
 
428
org $-0x10000
-
 
429
 
-
 
430
floppy_write:   ; write diskette image to physical floppy
-
 
Line 431... Line -...
431
 
-
 
432
        cmp  [flm-0x10000],byte 1
-
 
433
        je   fwwritedone
-
 
434
        mov  [flm-0x10000],byte 1
-
 
435
 
-
 
436
    xor    ax, ax        ; reset drive
217
 
437
    xor    dx, dx
-
 
438
        int     0x13
-
 
439
 
-
 
440
        mov     cx,0x0001               ; startcyl,startsector
-
 
441
;        mov     dx,0x0000               ; starthead,drive
-
 
442
    xor    dx, dx
-
 
Line -... Line 218...
-
 
218
restart_kernel:
443
        mov    ax, 80*2               ; read no of sect
219
 
444
 
220
        mov     ax,0x0003      ; set text mode for screen
Line 445... Line 221...
445
      fwwrites:
221
        int     0x10
-
 
222
        jmp     0x4000:0000
Line 446... Line -...
446
    push    ax
-
 
447
 
-
 
448
        ; move 1mb+ -> 0:a000
-
 
449
 
-
 
450
    pusha
223
 
451
        mov     si,fwmovedesc -0x10000
224
restart_kernel_4000:
452
        mov     cx,256*18
225
        cli
453
        mov     ah,0x87
226
 
454
        push    ds
227
        push    ds
455
        pop    es
-
 
456
        int     0x15
228
        pop    es
457
        add    dword [fwmovedesc-0x10000+0x12], 512*18
229
        mov    cx, 0x8000
458
        popa
230
        push    cx
459
 
231
        mov    ds, cx
-
 
232
        xor    si, si
460
        xor     si,si
233
        xor    di, di
-
 
234
        rep    movsw
461
        mov    es,si
235
        push    0x9000
-
 
236
        pop    ds
Line 462... Line -...
462
      fwnewwrite:
-
 
463
        mov     bx,0xa000               ; es:bx -> data area
237
        push    0x2000
Line -... Line 238...
-
 
238
        pop    es
-
 
239
        pop    cx
-
 
240
        rep    movsw
-
 
241
 
-
 
242
        wbinvd  ; write and invalidate cache
-
 
243
 
-
 
244
        mov    al, 00110100b
-
 
245
        out    43h, al
464
        mov     ax,0x0300+18            ; read, no of sectors to read
246
        jcxz    $+2
-
 
247
        mov    al, 0xFF
-
 
248
        out    40h, al
-
 
249
        jcxz    $+2
-
 
250
        out    40h, al
-
 
251
        jcxz    $+2
-
 
252
        sti
-
 
253
 
-
 
254
; (hint by Black_mirror)
-
 
255
; We must read data from keyboard port,
-
 
256
; because there may be situation when previous keyboard interrupt is lost
465
        int     0x13
257
; (due to return to real mode and IRQ reprogramming)
-
 
258
; and next interrupt will not be generated (as keyboard waits for handling)
-
 
259
        in      al, 0x60
466
 
260
 
Line 467... Line -...
467
    test    ah, ah
-
 
468
        jz      fwgoodwrite
-
 
469
 
-
 
Line 470... Line -...
470
    inc    si
-
 
471
        cmp     si,10
-
 
472
        jnz     fwnewwrite
-
 
473
 
-
 
474
; can't access diskette - return
-
 
475
    pop    ax
-
 
476
        ret
-
 
477
 
-
 
478
      fwgoodwrite:
-
 
479
        inc     dh
-
 
480
        cmp     dh,2
-
 
481
        jnz     fwbb2
-
 
482
        mov     dh,0
-
 
483
        inc     ch
-
 
484
      fwbb2:
-
 
485
        pop     ax
-
 
486
        dec     ax
-
 
487
        jnz     fwwrites
-
 
488
        ret
-
 
489
org $+0x10000
-
 
490
      fwmovedesc:
-
 
491
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
492
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
493
        db      0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
-
 
494
        db      0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
-
 
495
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
496
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
497
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
498
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
499
org $-0x10000
-
 
500
use32
-
 
501
org $+0x10000
-
 
502
uglobal
-
 
503
  shutdownpos dd 0x0
-
 
504
endg
-
 
505
 
-
 
506
iglobal
-
 
507
if lang eq en
-
 
508
shutdowntext:
-
 
509
    db   "IT'S SAFE TO POWER OFF COMPUTER OR      "
-
 
510
    db   '                                        '
-
 
511
    db   '1) SAVE RAMDISK TO FLOPPY               '
-
 
512
    db   '2) APM - POWEROFF                       '
-
 
513
    db   '3) REBOOT                               '
-
 
514
    db   '4) RESTART KERNEL                       '
-
 
515
else if lang eq ru
-
 
516
shutdowntext:
-
 
517
    db   "¥§®¯ á­®¥ ¢ëª«î祭¨¥ ª®¬¯ìîâ¥à  ¨«¨    "
-
 
518
    db   '                                        '
-
 
519
    db   '1) ‘®åà ­¨âì à ¬¤¨áª ­  ¤¨áª¥âã         '
-
 
520
    db   '2) APM - ¢ëª«î祭¨¥ ¯¨â ­¨ï             '
-
 
521
    db   '3) ¥à¥§ £à㧪  á¨áâ¥¬ë                 '
-
 
522
    db   '4) ¥áâ àâ ï¤à  ¨§ Ž‡“                  '
-
 
523
else
-
 
524
shutdowntext:
-
 
525
    db   "SIE KOENNEN DEN COMPUTER NUN AUSSCHALTEN"
-
 
526
    db   '                                        '
-