2011-10-14 23:38:50 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2022-02-12 18:27:41 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;;
|
2011-10-14 23:38:50 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
|
|
|
|
|
|
|
;setting date,time,clock and alarm-clock
|
|
|
|
;add sys_settime at servetable as for ex. 22 fcn:
|
|
|
|
; 22 - SETTING DATE TIME, CLOCK AND ALARM-CLOCK
|
|
|
|
; ebx =0 - set time ecx - 00SSMMHH
|
|
|
|
; ebx =1 - set date ecx=00DDMMYY
|
|
|
|
; ebx =2 - set day of week ecx- 1-7
|
|
|
|
; ebx =3 - set alarm-clock ecx - 00SSMMHH
|
|
|
|
; out: 0 -Ok 1 -wrong format 2 -battery low
|
|
|
|
sys_settime:
|
|
|
|
cli
|
|
|
|
mov al, 0x0d
|
|
|
|
out 0x70, al
|
|
|
|
in al, 0x71
|
|
|
|
bt ax, 7
|
2023-04-08 23:24:05 +02:00
|
|
|
jnc .bat_low
|
|
|
|
cmp ebx, 2 ;day of week
|
|
|
|
jne .nosetweek
|
2011-10-14 23:38:50 +02:00
|
|
|
test ecx, ecx ;test day of week
|
2023-04-08 23:24:05 +02:00
|
|
|
je .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp ecx, 7
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
mov edx, 0x70
|
|
|
|
call startstopclk
|
|
|
|
dec edx
|
|
|
|
mov al, 6
|
|
|
|
out dx, al
|
|
|
|
inc edx
|
|
|
|
mov al, cl
|
|
|
|
out dx, al
|
2023-04-08 23:24:05 +02:00
|
|
|
jmp .endsettime
|
|
|
|
.nosetweek: ;set date
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp ebx, 1
|
2023-04-08 23:24:05 +02:00
|
|
|
jne .nosetdate
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp cl, 0x99;test year
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
shl ecx, 4
|
|
|
|
cmp cl, 0x90
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp ch, 0x99;test month
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
shr ecx, 4
|
|
|
|
test ch, ch
|
2023-04-08 23:24:05 +02:00
|
|
|
je .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp ch, 0x12
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
shl ecx, 8
|
|
|
|
bswap ecx ;ebx=00YYMMDD
|
|
|
|
test cl, cl ;test day
|
2023-04-08 23:24:05 +02:00
|
|
|
je .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
shl ecx, 4
|
|
|
|
cmp cl, 0x90
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
shr ecx, 4
|
|
|
|
cmp ch, 2 ;February
|
2023-04-08 23:24:05 +02:00
|
|
|
jne .testday
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp cl, 0x29
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
|
|
|
jmp .setdate
|
|
|
|
.testday:
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp ch, 8
|
2023-04-08 23:24:05 +02:00
|
|
|
jb .testday1 ;Aug-Dec
|
2011-10-14 23:38:50 +02:00
|
|
|
bt cx, 8
|
2023-04-08 23:24:05 +02:00
|
|
|
jnc .days31
|
|
|
|
jmp .days30
|
|
|
|
.testday1:
|
2011-10-14 23:38:50 +02:00
|
|
|
bt cx, 8 ;Jan-Jul ex.Feb
|
2023-04-08 23:24:05 +02:00
|
|
|
jnc .days30
|
|
|
|
.days31:
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp cl, 0x31
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
|
|
|
jmp .setdate
|
|
|
|
.days30:
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp cl, 0x30
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
|
|
|
.setdate:
|
2011-10-14 23:38:50 +02:00
|
|
|
mov edx, 0x70
|
|
|
|
call startstopclk
|
|
|
|
dec edx
|
|
|
|
mov al, 7 ;set days
|
|
|
|
out dx, al
|
|
|
|
inc edx
|
|
|
|
mov al, cl
|
|
|
|
out dx, al
|
|
|
|
dec edx
|
|
|
|
mov al, 8 ;set months
|
|
|
|
out dx, al
|
|
|
|
inc edx
|
|
|
|
mov al, ch
|
|
|
|
out dx, al
|
|
|
|
dec edx
|
|
|
|
mov al, 9 ;set years
|
|
|
|
out dx, al
|
|
|
|
inc edx
|
|
|
|
shr ecx, 8
|
|
|
|
mov al, ch
|
|
|
|
out dx, al
|
2023-04-08 23:24:05 +02:00
|
|
|
jmp .endsettime
|
|
|
|
.nosetdate: ;set time or alarm-clock
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp ebx, 3
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp cl, 0x23
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp ch, 0x59
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
shl ecx, 4
|
|
|
|
cmp cl, 0x90
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp ch, 0x92
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
shl ecx, 4
|
|
|
|
bswap ecx ;00HHMMSS
|
|
|
|
cmp cl, 0x59
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
shl ecx, 4
|
|
|
|
cmp cl, 0x90
|
2023-04-08 23:24:05 +02:00
|
|
|
ja .wrongtime
|
2011-10-14 23:38:50 +02:00
|
|
|
shr ecx, 4
|
|
|
|
|
|
|
|
mov edx, 0x70
|
|
|
|
call startstopclk
|
|
|
|
dec edx
|
|
|
|
cmp ebx, 3
|
|
|
|
|
2023-04-08 23:24:05 +02:00
|
|
|
je .setalarm
|
2011-10-14 23:38:50 +02:00
|
|
|
xor eax, eax;al=0-set seconds
|
|
|
|
out dx, al
|
|
|
|
inc edx
|
|
|
|
mov al, cl
|
|
|
|
out dx, al
|
|
|
|
dec edx
|
|
|
|
mov al, 2 ;set minutes
|
|
|
|
out dx, al
|
|
|
|
inc edx
|
|
|
|
mov al, ch
|
|
|
|
out dx, al
|
|
|
|
dec edx
|
|
|
|
mov al, 4 ;set hours
|
|
|
|
out dx, al
|
|
|
|
inc edx
|
|
|
|
shr ecx, 8
|
|
|
|
mov al, ch
|
|
|
|
out dx, al
|
2023-04-08 23:24:05 +02:00
|
|
|
jmp .endsettime
|
|
|
|
.setalarm:
|
2011-10-14 23:38:50 +02:00
|
|
|
mov al, 1;set seconds for al.
|
|
|
|
out dx, al
|
|
|
|
inc edx
|
|
|
|
mov al, cl
|
|
|
|
out dx, al
|
|
|
|
dec edx
|
|
|
|
mov al, 3;set minutes for al.
|
|
|
|
out dx, al
|
|
|
|
inc edx
|
|
|
|
mov al, ch
|
|
|
|
out dx, al
|
|
|
|
dec edx
|
|
|
|
mov al, 5;set hours for al.
|
|
|
|
out dx, al
|
|
|
|
inc edx
|
|
|
|
shr ecx, 8
|
|
|
|
mov al, ch
|
|
|
|
out dx, al
|
|
|
|
dec edx
|
|
|
|
mov al, 0x0b;enable irq's
|
|
|
|
out dx, al
|
|
|
|
inc dx
|
|
|
|
in al, dx
|
|
|
|
bts ax, 5;set bit 5
|
|
|
|
out dx, al
|
2023-04-08 23:24:05 +02:00
|
|
|
.endsettime:
|
2011-10-14 23:38:50 +02:00
|
|
|
dec edx
|
|
|
|
call startstopclk
|
|
|
|
sti
|
2023-04-08 23:24:05 +02:00
|
|
|
and [esp + SYSCALL_STACK.eax], dword 0
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2023-04-08 23:24:05 +02:00
|
|
|
.bat_low:
|
2011-10-14 23:38:50 +02:00
|
|
|
sti
|
2023-04-08 23:24:05 +02:00
|
|
|
mov [esp + SYSCALL_STACK.eax], dword 2
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2023-04-08 23:24:05 +02:00
|
|
|
.wrongtime:
|
2011-10-14 23:38:50 +02:00
|
|
|
sti
|
2023-04-08 23:24:05 +02:00
|
|
|
mov [esp + SYSCALL_STACK.eax], dword 1
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
startstopclk:
|
|
|
|
mov al, 0x0b
|
|
|
|
out dx, al
|
|
|
|
inc dx
|
|
|
|
in al, dx
|
|
|
|
btc ax, 7
|
|
|
|
out dx, al
|
|
|
|
ret
|
2022-01-10 23:29:14 +01:00
|
|
|
|
|
|
|
align 4
|
|
|
|
sys_clock:
|
|
|
|
cli
|
|
|
|
; Mikhail Lisovin xx Jan 2005
|
|
|
|
@@:
|
|
|
|
mov al, 10
|
|
|
|
out 0x70, al
|
|
|
|
in al, 0x71
|
|
|
|
test al, al
|
|
|
|
jns @f
|
|
|
|
mov esi, 1
|
|
|
|
call delay_ms
|
|
|
|
jmp @b
|
|
|
|
@@:
|
|
|
|
; end Lisovin's fix
|
|
|
|
|
|
|
|
xor al, al ; seconds
|
|
|
|
out 0x70, al
|
|
|
|
in al, 0x71
|
|
|
|
movzx ecx, al
|
|
|
|
mov al, 02 ; minutes
|
|
|
|
shl ecx, 16
|
|
|
|
out 0x70, al
|
|
|
|
in al, 0x71
|
|
|
|
movzx edx, al
|
|
|
|
mov al, 04 ; hours
|
|
|
|
shl edx, 8
|
|
|
|
out 0x70, al
|
|
|
|
in al, 0x71
|
|
|
|
add ecx, edx
|
|
|
|
movzx edx, al
|
|
|
|
add ecx, edx
|
|
|
|
sti
|
2023-04-08 23:24:05 +02:00
|
|
|
mov [esp + SYSCALL_STACK.eax], ecx
|
2022-01-10 23:29:14 +01:00
|
|
|
ret
|
|
|
|
|
|
|
|
align 4
|
|
|
|
sys_date:
|
|
|
|
cli
|
|
|
|
@@:
|
|
|
|
mov al, 10
|
|
|
|
out 0x70, al
|
|
|
|
in al, 0x71
|
|
|
|
test al, al
|
|
|
|
jns @f
|
|
|
|
mov esi, 1
|
|
|
|
call delay_ms
|
|
|
|
jmp @b
|
|
|
|
@@:
|
|
|
|
mov ch, 0
|
|
|
|
mov al, 7 ; date
|
|
|
|
out 0x70, al
|
|
|
|
in al, 0x71
|
|
|
|
mov cl, al
|
|
|
|
mov al, 8 ; month
|
|
|
|
shl ecx, 16
|
|
|
|
out 0x70, al
|
|
|
|
in al, 0x71
|
|
|
|
mov ch, al
|
|
|
|
mov al, 9 ; year
|
|
|
|
out 0x70, al
|
|
|
|
in al, 0x71
|
|
|
|
mov cl, al
|
|
|
|
sti
|
2023-04-08 23:24:05 +02:00
|
|
|
mov [esp + SYSCALL_STACK.eax], ecx
|
2022-01-10 23:29:14 +01:00
|
|
|
ret
|