Subversion Repositories Kolibri OS

Rev

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

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