2007-03-26 14:18:08 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;; Shutdown for Menuet ;;
|
|
|
|
;; ;;
|
|
|
|
;; Distributed under General Public License ;;
|
|
|
|
;; See file COPYING for details. ;;
|
|
|
|
;; Copyright 2003 Ville Turjanmaa ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2005-10-06 19:56:22 +02:00
|
|
|
|
2007-07-27 15:52:03 +02:00
|
|
|
$Revision$
|
|
|
|
|
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
align 4
|
2005-10-06 19:56:22 +02:00
|
|
|
pr_mode_exit:
|
|
|
|
|
2006-02-14 11:00:45 +01:00
|
|
|
; setup stack
|
2007-04-18 08:37:14 +02:00
|
|
|
mov ax, 0x3000
|
|
|
|
mov ss, ax
|
|
|
|
mov esp, 0x0EC00
|
2006-02-14 11:00:45 +01:00
|
|
|
; setup ds
|
2007-04-18 08:37:14 +02:00
|
|
|
push cs
|
|
|
|
pop ds
|
2005-10-06 19:56:22 +02:00
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
lidt [old_ints_h]
|
2005-11-25 17:46:29 +01:00
|
|
|
;remap IRQs
|
2007-04-18 08:37:14 +02:00
|
|
|
mov al,0x11
|
|
|
|
out 0x20,al
|
|
|
|
call rdelay
|
|
|
|
out 0xA0,al
|
|
|
|
call rdelay
|
|
|
|
|
|
|
|
mov al,0x08
|
|
|
|
out 0x21,al
|
|
|
|
call rdelay
|
|
|
|
mov al,0x70
|
|
|
|
out 0xA1,al
|
|
|
|
call rdelay
|
|
|
|
|
|
|
|
mov al,0x04
|
|
|
|
out 0x21,al
|
|
|
|
call rdelay
|
|
|
|
mov al,0x02
|
|
|
|
out 0xA1,al
|
|
|
|
call rdelay
|
|
|
|
|
|
|
|
mov al,0x01
|
|
|
|
out 0x21,al
|
|
|
|
call rdelay
|
|
|
|
out 0xA1,al
|
|
|
|
call rdelay
|
|
|
|
|
|
|
|
mov al,0xB8
|
|
|
|
out 0x21,al
|
|
|
|
call rdelay
|
|
|
|
mov al,0xBD
|
|
|
|
out 0xA1,al
|
2005-12-22 12:38:36 +01:00
|
|
|
sti
|
2005-10-06 19:56:22 +02:00
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
temp_3456:
|
|
|
|
xor ax,ax
|
|
|
|
mov es,ax
|
|
|
|
mov al,byte [es:0x9030]
|
|
|
|
cmp al,1
|
|
|
|
jl nbw
|
|
|
|
cmp al,4
|
|
|
|
jle nbw32
|
|
|
|
|
|
|
|
nbw:
|
|
|
|
in al,0x60
|
|
|
|
call pause_key
|
|
|
|
cmp al,6
|
|
|
|
jae nbw
|
|
|
|
mov bl,al
|
|
|
|
nbw2:
|
|
|
|
in al,0x60
|
|
|
|
call pause_key
|
|
|
|
cmp al,bl
|
|
|
|
je nbw2
|
|
|
|
cmp al,240 ;ax,240
|
|
|
|
jne nbw31
|
|
|
|
mov al,bl
|
|
|
|
dec ax
|
|
|
|
jmp nbw32
|
|
|
|
nbw31:
|
|
|
|
add bl,128
|
|
|
|
cmp al,bl
|
|
|
|
jne nbw
|
|
|
|
sub al,129
|
|
|
|
|
|
|
|
nbw32:
|
|
|
|
|
|
|
|
dec ax ; 1 = write floppy
|
|
|
|
js nbw
|
|
|
|
jnz no_floppy_write
|
|
|
|
call floppy_write
|
|
|
|
jmp temp_3456 ;nbw
|
|
|
|
no_floppy_write:
|
|
|
|
|
|
|
|
dec ax ; 2 = power off
|
|
|
|
jnz no_apm_off
|
|
|
|
call APM_PowerOff
|
|
|
|
jmp $
|
|
|
|
no_apm_off:
|
|
|
|
|
|
|
|
dec ax ; 3 = reboot
|
|
|
|
jnz restart_kernel ; 4 = restart kernel
|
|
|
|
push 0x40
|
|
|
|
pop ds
|
|
|
|
mov word[0x0072],0x1234
|
|
|
|
jmp 0xF000:0xFFF0
|
|
|
|
|
|
|
|
pause_key:
|
|
|
|
mov cx,100
|
|
|
|
pause_key_1:
|
|
|
|
loop pause_key_1
|
|
|
|
ret
|
2005-10-06 19:56:22 +02:00
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
rdelay:
|
2005-10-06 19:56:22 +02:00
|
|
|
ret
|
|
|
|
|
2006-03-20 10:57:24 +01:00
|
|
|
floppy_write: ; write diskette image to physical floppy
|
2005-10-06 19:56:22 +02:00
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
cmp [flm],byte 1
|
2005-10-06 19:56:22 +02:00
|
|
|
je fwwritedone
|
2007-04-18 08:37:14 +02:00
|
|
|
mov [flm],byte 1
|
2005-10-06 19:56:22 +02:00
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
xor ax, ax ; reset drive
|
|
|
|
xor dx, dx
|
2005-10-06 19:56:22 +02:00
|
|
|
int 0x13
|
|
|
|
|
|
|
|
mov cx,0x0001 ; startcyl,startsector
|
2007-04-18 08:37:14 +02:00
|
|
|
xor dx, dx ; starthead,drive
|
2006-08-10 20:18:33 +02:00
|
|
|
mov ax, 80*2 ; read no of sect
|
2005-10-06 19:56:22 +02:00
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
fwwrites:
|
|
|
|
push ax
|
2005-10-06 19:56:22 +02:00
|
|
|
|
|
|
|
; move 1mb+ -> 0:a000
|
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
pusha
|
|
|
|
mov si, fwmovedesc
|
2005-10-06 19:56:22 +02:00
|
|
|
mov cx,256*18
|
|
|
|
mov ah,0x87
|
2006-08-10 20:18:33 +02:00
|
|
|
push ds
|
|
|
|
pop es
|
2005-10-06 19:56:22 +02:00
|
|
|
int 0x15
|
2007-04-18 08:37:14 +02:00
|
|
|
add dword [fwmovedesc+0x12], 512*18
|
2005-10-06 19:56:22 +02:00
|
|
|
popa
|
|
|
|
|
|
|
|
xor si,si
|
2006-08-10 20:18:33 +02:00
|
|
|
mov es,si
|
2007-04-18 08:37:14 +02:00
|
|
|
fwnewwrite:
|
2005-10-06 19:56:22 +02:00
|
|
|
mov bx,0xa000 ; es:bx -> data area
|
|
|
|
mov ax,0x0300+18 ; read, no of sectors to read
|
|
|
|
int 0x13
|
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
test ah, ah
|
2005-10-06 19:56:22 +02:00
|
|
|
jz fwgoodwrite
|
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
inc si
|
2005-10-06 19:56:22 +02:00
|
|
|
cmp si,10
|
|
|
|
jnz fwnewwrite
|
|
|
|
|
2006-03-20 10:57:24 +01:00
|
|
|
; can't access diskette - return
|
2007-04-18 08:37:14 +02:00
|
|
|
pop ax
|
2005-10-06 19:56:22 +02:00
|
|
|
ret
|
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
fwgoodwrite:
|
2005-10-06 19:56:22 +02:00
|
|
|
inc dh
|
|
|
|
cmp dh,2
|
|
|
|
jnz fwbb2
|
|
|
|
mov dh,0
|
|
|
|
inc ch
|
2007-04-18 08:37:14 +02:00
|
|
|
fwbb2:
|
2005-10-06 19:56:22 +02:00
|
|
|
pop ax
|
|
|
|
dec ax
|
2006-03-20 10:57:24 +01:00
|
|
|
jnz fwwrites
|
|
|
|
ret
|
2007-04-18 08:37:14 +02:00
|
|
|
|
|
|
|
APM_PowerOff:
|
|
|
|
mov ax, 5304h
|
|
|
|
xor bx, bx
|
|
|
|
int 15h
|
|
|
|
;!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
mov ax,0x5300
|
|
|
|
xor bx,bx
|
|
|
|
int 0x15
|
|
|
|
push ax
|
|
|
|
|
|
|
|
mov ax,0x5301
|
|
|
|
xor bx,bx
|
|
|
|
int 0x15
|
|
|
|
|
|
|
|
mov ax,0x5308
|
|
|
|
mov bx,1
|
|
|
|
mov cx,bx
|
|
|
|
int 0x15
|
|
|
|
|
|
|
|
mov ax,0x530E
|
|
|
|
xor bx,bx
|
|
|
|
pop cx
|
|
|
|
int 0x15
|
|
|
|
|
|
|
|
mov ax,0x530D
|
|
|
|
mov bx,1
|
|
|
|
mov cx,bx
|
|
|
|
int 0x15
|
|
|
|
|
|
|
|
mov ax,0x530F
|
|
|
|
mov bx,1
|
|
|
|
mov cx,bx
|
|
|
|
int 0x15
|
|
|
|
|
|
|
|
mov ax,0x5307
|
|
|
|
mov bx,1
|
|
|
|
mov cx,3
|
|
|
|
int 0x15
|
|
|
|
;!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
fwwritedone:
|
|
|
|
ret
|
|
|
|
|
|
|
|
restart_kernel:
|
|
|
|
|
|
|
|
mov ax,0x0003 ; set text mode for screen
|
|
|
|
int 0x10
|
|
|
|
jmp 0x4000:0000
|
|
|
|
|
|
|
|
restart_kernel_4000:
|
|
|
|
cli
|
|
|
|
|
|
|
|
push ds
|
2007-12-13 19:45:44 +01:00
|
|
|
pop es
|
|
|
|
mov cx, 0x8000
|
2007-04-18 08:37:14 +02:00
|
|
|
push cx
|
2007-12-13 19:45:44 +01:00
|
|
|
push 0x7000
|
|
|
|
pop ds
|
|
|
|
xor si, si
|
|
|
|
xor di, di
|
|
|
|
rep movsw
|
|
|
|
pop cx
|
|
|
|
mov ds, cx
|
2007-04-18 08:37:14 +02:00
|
|
|
push 0x2000
|
2007-12-13 19:45:44 +01:00
|
|
|
pop es
|
|
|
|
rep movsw
|
|
|
|
push 0x9000
|
|
|
|
pop ds
|
|
|
|
push 0x3000
|
|
|
|
pop es
|
|
|
|
mov cx, 0xE000/2
|
|
|
|
rep movsw
|
2007-04-18 08:37:14 +02:00
|
|
|
|
|
|
|
wbinvd ; write and invalidate cache
|
|
|
|
|
|
|
|
mov al, 00110100b
|
|
|
|
out 43h, al
|
|
|
|
jcxz $+2
|
|
|
|
mov al, 0xFF
|
|
|
|
out 40h, al
|
|
|
|
jcxz $+2
|
|
|
|
out 40h, al
|
|
|
|
jcxz $+2
|
|
|
|
sti
|
|
|
|
|
|
|
|
; (hint by Black_mirror)
|
|
|
|
; We must read data from keyboard port,
|
|
|
|
; because there may be situation when previous keyboard interrupt is lost
|
|
|
|
; (due to return to real mode and IRQ reprogramming)
|
|
|
|
; and next interrupt will not be generated (as keyboard waits for handling)
|
|
|
|
in al, 0x60
|
|
|
|
|
|
|
|
; bootloader interface
|
|
|
|
push 0x1000
|
|
|
|
pop ds
|
|
|
|
mov si, kernel_restart_bootblock
|
|
|
|
mov ax, 'KL'
|
|
|
|
jmp 0x1000:0000
|
|
|
|
|
|
|
|
|