Subversion Repositories Kolibri OS

Rev

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

Rev 46 Rev 61
Line 8... Line 8...
8
;;
8
;;
Line 9... Line 9...
9
 
9
 
Line 10... Line 10...
10
 
10
 
-
 
11
system_shutdown:          ; shut down the system
11
system_shutdown:          ; shut down the system
12
 
12
 
-
 
13
    mov  eax,3            ; stop playing cd
13
    push 3		; stop playing cd
Line 14... Line 14...
14
    call sys_cd_audio
14
    pop  eax
15
    cli
15
    call sys_cd_audio
16
    cld
16
    cld
17
 
17
 
18
    mov  al,[0x2f0000+0x9030]
-
 
19
    cmp  al,1
18
    mov  al,[0x2f0000+0x9030]
20
    jl   no_shutdown_parameter
19
    cmp  al,1
Line 21... Line 20...
21
    cmp  al,4
20
    jl   no_shutdown_parameter
22
    jg   no_shutdown_parameter
21
    cmp  al,4
23
    jmp  yes_shutdown_param
22
    jle  yes_shutdown_param
24
 no_shutdown_parameter:
23
 no_shutdown_parameter:
25
 
24
 
26
    movzx ecx,word [0x2f0000+0x900A]
25
;    movzx ecx,word [0x2f0000+0x900A]
27
    movzx esi,word [0x2f0000+0x900C]
26
;    movzx esi,word [0x2f0000+0x900C]
28
    imul ecx,esi  ;[0xfe04]
27
;    imul ecx,esi  ;[0xfe04]
29
;    mov  ecx,0x500000/4  ;3fff00/4    ; darken screen
28
;;    mov  ecx,0x500000/4  ;3fff00/4    ; darken screen
-
 
29
;    push ecx
30
    push ecx
30
;    mov  esi,[0xfe80]
31
    mov  esi,[0xfe80]
-
 
32
    cmp  esi,32*0x100000
31
;    cmp  esi,32*0x100000
33
    jbe  no_darken_screen
32
;    jbe  no_darken_screen
34
    mov  edi,16*0x100000
33
;    mov  edi,16*0x100000
35
  sdnewpix:
34
;    push esi edi
36
    mov  eax,[esi]
35
;  sdnewpix:
37
    add  esi,4
36
;    lodsd
38
    shr  eax,1
-
 
39
    and  eax,0x7f7f7f7f
37
;    shr  eax,1
40
    stosd
-
 
41
    loop sdnewpix
38
;    and  eax,0x7f7f7f7f
42
    pop  ecx
39
;    stosd
-
 
40
;    loop sdnewpix
-
 
41
;    pop  ecx
-
 
42
;    pop  esi edi
Line 43... Line 43...
43
    mov  esi,16*0x100000
43
;    rep  movsd
44
    mov  edi,[0xfe80]
44
;  no_darken_screen:
-
 
45
 
45
    cld
46
; read shutdown code:
Line 46... Line 47...
46
    rep  movsd
47
; 1) display shutdown "window"
47
  no_darken_screen:
48
 
48
 
49
    mov  eax,[0xfe00]
-
 
50
    shr  eax,1
49
    mov  eax,[0xfe00]
51
    lea  esi,[eax+220]		; x end
Line 50... Line 52...
50
    shr  eax,1
52
    sub  eax,220		; x start
-
 
53
 
51
    sub  eax,220
54
    mov  ebx,[0xfe04]
Line -... Line 55...
-
 
55
    shr  ebx,1
-
 
56
    mov  [shutdownpos],ebx
-
 
57
    lea  ebp,[ebx+105]		; y end
-
 
58
    sub  ebx,120		; y start
-
 
59
 
52
 
60
    xor  edi,edi
Line 53... Line 61...
53
    mov  ebx,[0xfe04]
61
    inc  edi		; force putpixel & dtext
Line 54... Line 62...
54
    shr  ebx,1
62
    mov  ecx,0x0000ff
55
    mov  [shutdownpos],ebx
-
 
56
    sub  ebx,120
-
 
57
 
-
 
58
    mov  edi,1
63
 
59
    mov  ecx,0x0000ff
64
; vertical loop begin
-
 
65
  sdnewpix1:
Line 60... Line 66...
60
 
66
    push eax	; save x start
-
 
67
 
Line -... Line 68...
-
 
68
; horizontal loop begin
-
 
69
  sdnewpix2:
-
 
70
 
-
 
71
    call [putpixel]
-
 
72
 
-
 
73
    inc  eax
-
 
74
    cmp  eax,esi
61
  sdnewpix2:
75
    jnz  sdnewpix2
62
 
76
; horizontal loop end
63
    call [putpixel]
77
 
64
 
-
 
65
    inc  eax
-
 
66
    mov  esi,[0xfe00]
-
 
67
    shr  esi,1
78
    dec  ecx	; color
68
    add  esi,220
-
 
69
    cmp  eax,esi
-
 
70
    jnz  sdnewpix2
-
 
71
 
-
 
72
    dec  ecx
-
 
73
 
-
 
74
    mov  eax,[0xfe00]
-
 
75
    shr  eax,1
-
 
76
    sub  eax,220
-
 
77
 
-
 
78
    inc  ebx
79
    pop  eax	; restore x start
79
 
-
 
80
    mov  edx,[shutdownpos]
80
 
81
    add  edx,105
81
    inc  ebx	; advance y pos
82
    cmp  ebx,edx
82
    cmp  ebx,ebp
83
    jnz  sdnewpix2
83
    jnz  sdnewpix1
84
 
84
; vertical loop end
85
 
85
 
Line 86... Line -...
86
    mov  esi,[0xfe00]      ; menuet version
-
 
87
    shr  esi,1
-
 
88
    sub  esi,220
86
; 2) display text strings
89
    add  esi,27
87
;    a) version
90
    shl  esi,16
88
    mov  eax,[0xfe00]
91
    mov  eax,esi
89
    shr  eax,1
92
    add  eax,[shutdownpos]
-
 
93
    sub  eax,105
-
 
94
    mov  ebx,0xffff00
90
    shl  eax,16
95
    mov  ecx,version
91
    mov  ax,word [shutdownpos]
96
    mov  edx,34
92
    push eax
97
    mov  edi,1
93
    sub  eax,(220-27)*10000h + 105
98
    call dtext
-
 
99
 
94
    mov  ebx,0xffff00
100
    mov  esi,[0xfe00]      ; 'it is safe..'
95
    mov  ecx,version
101
    shr  esi,1
96
    push 34
102
    sub  esi,220
97
    pop  edx
103
    add  esi,27
98
    call dtext
104
    shl  esi,16
99
 
Line -... Line 100...
-
 
100
;    b) variants
105
    mov  eax,esi
101
    add  eax,105+33
106
    add  eax,[shutdownpos]
102
    push 6
-
 
103
    pop  esi
107
    add  eax,33
104
;    mov  ebx,0xffffff
108
    mov  esi,6
105
    mov  bl,0xFF
-
 
106
    mov  ecx,shutdowntext
-
 
107
    mov  dl,40
109
    mov  ebx,0xffffff
108
  newsdt:
-
 
109
    call dtext
110
    mov  ecx,shutdowntext
110
    add  eax,10
-
 
111
    add  ecx,edx
Line 111... Line -...
111
    mov  edx,40
-
 
112
    mov  edi,1
112
    dec  esi
113
  newsdt:
-
 
114
    call dtext
113
    jnz  newsdt
115
    add  eax,10
114
 
116
    add  ecx,40
115
; 3) load & display rose.txt
117
    dec  esi
-
 
Line 118... Line 116...
118
    jnz  newsdt
116
    mov  eax,rosef          ; load rose.txt
119
 
-
 
120
    mov  eax,rosef          ; load rose.txt
117
    xor  ebx,ebx
121
    mov  ebx,0
118
    push 2
Line 122... Line 119...
122
    mov  ecx,16800
119
    pop  ecx
123
    mov  edx,0x90000
120
    mov  edx,0x90000
124
    mov  esi,12
121
    push edx
125
    call fileread
122
    push 12
126
 
123
    pop  esi
127
    mov  esi,[0xfe00]       ; draw rose
124
    push edi	; may be destroyed
128
    shr  esi,1
125
    call fileread
Line 129... Line 126...
129
    add  esi,20
126
    pop  edi
Line 130... Line 127...
130
    shl  esi,16
127
 
131
    mov  eax,esi
-
 
132
    add  eax,[shutdownpos]
128
    pop  ecx
Line 133... Line 129...
133
    sub  eax,110
129
    inc  ecx	; do not display stars from rose.txt
-
 
130
    pop  eax
134
 
131
    add  eax,20*10000h - 110
135
    mov  ebx,0x00ff00
132
 
136
    mov  ecx,0x90001
133
    mov  ebx,0x00ff00
137
    mov  edx,27
134
    push 27
138
    mov  edi,1
135
    pop  edx
Line 139... Line 136...
139
 
136
 
140
   nrl:
137
   nrl:
141
    call dtext
138
    call dtext
142
    sub  ebx,0x050000
-
 
143
    add  eax,8
139
    sub  ebx,0x050000
Line 144... Line 140...
144
    add  ecx,31
140
    add  eax,8
145
    cmp  ecx,dword 0x90001+25*31
141
    add  ecx,31
146
    jnz  nrl
142
    cmp  cx,word 0x0001+25*31
147
 
143
    jnz  nrl
Line 148... Line 144...
148
    call checkEgaCga
144
 
Line 149... Line 145...
149
 
145
    call checkEgaCga
150
 yes_shutdown_param:
-
 
151
 
146
 
Line 152... Line 147...
152
    cli
147
 yes_shutdown_param:
153
 
148
    cli
154
    mov  eax,kernel               ; load kernel.mnt to 0x8000:0
149
 
155
    mov  esi,12
150
    mov  eax,kernel               ; load kernel.mnt to 0x8000:0
Line 193... Line 188...
193
	mov	ss, ax
188
	mov	ss, ax
194
	mov	esp, 0EC00h
189
	mov	esp, 0EC00h
195
; setup ds
190
; setup ds
196
	push	cs
191
	push	cs
197
	pop	ds
192
	pop	ds
198
;    mov ax,1000
-
 
199
;    mov ds,ax
-
 
200
;    mov es,ax
-
 
201
;    mov fs,ax
-
 
202
;    mov gs,ax
-
 
203
;    mov ss,ax
-
 
204
;    mov bl,[shutdown_parameter]
-
 
205
;    mov [es:shutdown_parameter-0x10000],bl
-
 
206
 
-
 
207
    jmp real_mode-0x10000       
-
 
208
 
-
 
209
old_ints_h:
-
 
210
        dw      4*0x20
-
 
211
        dd      0
-
 
212
        dw      0
-
 
213
 
-
 
214
rdelay:
-
 
215
    ret
-
 
216
real_mode:
-
 
Line 217... Line 193...
217
 
193
 
218
    lidt [old_ints_h-0x10000]
194
    lidt [old_ints_h-0x10000]
219
;remap IRQs
195
;remap IRQs
220
    mov  al,0x11
196
    mov  al,0x11
Line 247... Line 223...
247
    out  0x21,al
223
    out  0x21,al
248
    call rdelay
224
    call rdelay
249
    out  0xA1,al
225
    out  0xA1,al
250
    sti
226
    sti
Line 251... Line 227...
251
 
227
 
-
 
228
  temp_3456:
-
 
229
    xor  ax,ax
-
 
230
    mov  es,ax
-
 
231
    mov  al,byte [es:0x9030]
-
 
232
    cmp  al,1
-
 
233
    jl   nbw
-
 
234
    cmp  al,4
Line 252... Line 235...
252
    jmp  temp_3456
235
    jle  nbw32
253
 
-
 
254
  nbw:
236
  
255
    xor  ax,ax
237
  nbw:
256
    in   al,0x60
238
    in   al,0x60
257
    call pause_key
239
    call pause_key
258
    cmp  al,7
240
    cmp  al,6
259
    jge  nbw
241
    jae  nbw
260
    mov  bl,al
242
    mov  bl,al
261
  nbw2:
243
  nbw2:
262
    in   al,0x60
244
    in   al,0x60
263
    call pause_key
245
    call pause_key
264
    cmp  al,bl
246
    cmp  al,bl
265
    je   nbw2
247
    je   nbw2
266
    cmp  al,240  ;ax,240
248
    cmp  al,240  ;ax,240
267
    jne  nbw31
249
    jne  nbw31
268
    mov  al,bl
250
    mov  al,bl
269
    dec  al
251
    dec  ax
270
    jmp  nbw32
252
    jmp  nbw32
271
  nbw31:
253
  nbw31:
272
    add  bl,128
254
    add  bl,128
273
    cmp  al,bl
255
    cmp  al,bl
Line 274... Line 256...
274
    jne  nbw
256
    jne  nbw
Line 275... Line 257...
275
    sub  al,129
257
    sub  al,129
-
 
258
 
276
 
259
  nbw32:
277
  nbw32:
260
 
278
    
261
    dec  ax	; 1 = write floppy
279
    cmp  al,1              ; write floppy
262
    js   nbw
Line 280... Line 263...
280
    jne  no_floppy_write
263
    jnz  no_floppy_write
281
    call floppy_write
264
    call floppy_write
282
    jmp  temp_3456 ;nbw
265
    jmp  temp_3456 ;nbw
-
 
266
  no_floppy_write:
283
  no_floppy_write:
267
 
Line 284... Line 268...
284
 
268
    dec  ax	; 2 = power off
285
    cmp  al,2              ; poweroff
269
    jnz  no_apm_off
286
    jne  no_apm_off
270
    call APM_PowerOff
287
    call APM_PowerOff
271
    jmp  $
288
  no_apm_off:
272
  no_apm_off:
289
 
273
 
290
    cmp  al,3              ; boot 
-
 
291
    jnz  no_sys_boot 
-
 
292
    mov  ax,0x0040 
-
 
293
    mov  ds,ax 
-
 
Line 294... Line -...
294
    mov  word[0x0072],0x1234 
-
 
295
    jmp  0xF000:0xFFF0
-
 
296
  no_sys_boot:
-
 
297
 
-
 
298
    cmp  al,4              ; restart kernel
-
 
299
    je   restart_kernel
-
 
300
 
-
 
301
  temp_3456:
-
 
302
    push    word 0x0000
-
 
303
    pop     es
-
 
304
    mov  al,byte [es:0x9030]
-
 
305
    cmp  al,1
274
    dec  ax	; 3 = reboot
306
    jl   nbw
275
    jnz  restart_kernel		; 4 = restart kernel
307
    cmp  al,4
276
    push 0x40
308
    jg   nbw
277
    pop  ds
309
    jmp  nbw32
278
    mov  word[0x0072],0x1234 
Line -... Line 279...
-
 
279
    jmp  0xF000:0xFFF0
-
 
280
 
-
 
281
    pause_key:
-
 
282
      mov cx,100
-
 
283
    pause_key_1:
-
 
284
      loop  pause_key_1
-
 
285
      ret
-
 
286
 
310
  
287
old_ints_h:
311
;    jmp  nbw
288
        dw      0x400
312
    pause_key:
289
        dd      0
313
      mov ecx,100
290
        dw      0
Line 359... Line 336...
359
	push	cx
336
	push	cx
360
	mov	ds, cx
337
	mov	ds, cx
361
	xor	si, si
338
	xor	si, si
362
	xor	di, di
339
	xor	di, di
363
	rep	movsw
340
	rep	movsw
364
	mov	ax, 0x9000
341
	push	0x9000
365
	mov	ds, ax
342
	pop	ds
366
	mov	ax, 0x2000
343
	push	0x2000
367
	mov	es, ax
344
	pop	es
368
	pop	cx
345
	pop	cx
369
	rep	movsw
346
	rep	movsw
Line 370... Line 347...
370
 
347
 
Line 432... Line 409...
432
mov ax,0x5307
409
mov ax,0x5307
433
mov bx,1
410
mov bx,1
434
mov cx,3
411
mov cx,3
435
int 0x15
412
int 0x15
436
;!!!!!!!!!!!!!!!!!!!!!!!!
413
;!!!!!!!!!!!!!!!!!!!!!!!!
-
 
414
fwwritedone:
437
        ret
415
        ret
438
uglobal
416
 
439
  flm db 0
417
flm db 0
440
endg
-
 
Line 441... Line 418...
441
 
418
 
Line 442... Line -...
442
floppy_write:   ; write diskette image to physical floppy
-
 
443
 
-
 
444
        pusha
-
 
445
 
-
 
446
        mov  ax,0x1000
419
floppy_write:   ; write diskette image to physical floppy
447
        mov  es,ax
420
 
448
        cmp  [es:flm-0x10000],byte 1
421
        cmp  [flm-0x10000],byte 1
Line 449... Line 422...
449
        je   fwwritedone
422
        je   fwwritedone
450
        mov  [es:flm-0x10000],byte 1
423
        mov  [flm-0x10000],byte 1
451
 
424
 
Line 452... Line 425...
452
        mov     ax,0x0000               ; reset drive
425
	xor	ax, ax		; reset drive
453
        mov     dx,0x0000
426
	xor	dx, dx
-
 
427
        int     0x13
454
        int     0x13
428
 
Line 455... Line 429...
455
 
429
        mov     cx,0x0001               ; startcyl,startsector
456
        mov     cx,0x0001               ; startcyl,startsector
430
;        mov     dx,0x0000               ; starthead,drive
Line 457... Line 431...
457
        mov     dx,0x0000               ; starthead,drive
431
	xor	dx, dx
Line 458... Line 432...
458
        push    word 80*2               ; read no of sect
432
        mov	ax, 80*2               ; read no of sect
459
 
433
 
460
      fwwrites:
-
 
461
        pusha
-
 
462
 
434
      fwwrites:
463
        ; move 1mb+ -> 0:a000
435
	push	ax
-
 
436
 
-
 
437
        ; move 1mb+ -> 0:a000
464
 
438
 
465
        pusha
-
 
466
        mov     si,fwmovedesc -0x10000
-
 
467
        push    word 0x1000
439
	pusha
468
        pop     es
440
        mov     si,fwmovedesc -0x10000
Line 469... Line 441...
469
        mov     cx,256*18
441
        mov     cx,256*18
-
 
442
        mov     ah,0x87
470
        mov     ah,0x87
443
        push	ds
471
        int     0x15
-
 
472
        mov     eax,[es:fwmovedesc-0x10000+0x12]
-
 
473
        add     eax,512*18
444
        pop	es
474
        mov     [es:fwmovedesc-0x10000+0x12],eax
445
        int     0x15
475
        popa
446
        add	dword [fwmovedesc-0x10000+0x12], 512*18
Line 476... Line 447...
476
 
447
        popa
477
        xor     si,si
448
 
Line 478... Line 449...
478
      fwnewwrite:
449
        xor     si,si
479
        push    word 0x0
450
        mov	es,si
480
        pop     es
451
      fwnewwrite:
Line 481... Line 452...
481
        mov     bx,0xa000               ; es:bx -> data area
452
        mov     bx,0xa000               ; es:bx -> data area
482
        mov     ax,0x0300+18            ; read, no of sectors to read
453
        mov     ax,0x0300+18            ; read, no of sectors to read
483
        int     0x13
-
 
484
 
454
        int     0x13
Line 485... Line 455...
485
        cmp     ah,0
455
 
486
        jz      fwgoodwrite
-
 
487
 
-
 
488
        add     si,1
-
 
489
        cmp     si,10
456
	test	ah, ah
490
        jnz     fwnewwrite
457
        jz      fwgoodwrite
491
 
458
 
492
        add     esp,32+2
459
	inc	si
493
 
460
        cmp     si,10
494
        popa                            ; can't access diskette
-
 
495
        ret
461
        jnz     fwnewwrite
496
 
-
 
497
      fwgoodwrite:
-
 
498
 
462
 
499
        popa
463
; can't access diskette - return
500
 
-
 
501
        inc     dh
-
 
502
        cmp     dh,2
464
	pop	ax
503
        jnz     fwbb2
-
 
504
        mov     dh,0
-
 
505
        inc     ch
-
 
506
 
-
 
507
      fwbb2:
465
        ret
508
 
-
 
Line 509... Line 466...
509
        cld
466
 
510
        pop     ax
-
 
511
        dec     ax
467
      fwgoodwrite:
512
        push    ax
468
        inc     dh
513
        cmp     ax,0
469
        cmp     dh,2
514
        jnz     fwrs
470
        jnz     fwbb2
515
 
471
        mov     dh,0
516
        pop     ax
472
        inc     ch
517
 
473
      fwbb2:
518
        jmp     fwwritedone
474
        pop     ax
Line 519... Line -...
519
      fwrs:
-
 
520
        jmp     fwwrites
-
 
521
 
-
 
522
      fwmovedesc:
-
 
523
 
-
 
524
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
525
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
526
        db      0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
475
        dec     ax
Line 527... Line 476...
527
        db      0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
476
        jnz     fwwrites
528
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
477
        ret
529
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
478
 
Line 530... Line 479...
530
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
479
      fwmovedesc:
-
 
480
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
531
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
481
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
532
 
482
        db      0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
533
      fwwritedone:
483
        db      0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
534
 
484
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
535
        popa
485
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
536
 
486
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
537
        ret
487
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
488
 
538
 
489
use32
539
 
490
 
540
use32
491
uglobal
541
 
492
  shutdownpos dd 0x0
542
uglobal
493
endg
543
  shutdownpos dd 0x0
494
 
544
endg
495
iglobal
-
 
496
if lang eq en
545
 
497
shutdowntext:
546
iglobal
498
    db   "IT'S SAFE TO POWER OFF COMPUTER OR      "
547
;shutdowntext:
499
    db   '                                        '