Rev 9715 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2288 | clevermous | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
9715 | Doczom | 3 | ;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;; |
2288 | clevermous | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
8 | $Revision: 9910 $ |
||
9 | |||
10 | |||
11 | ;setting date,time,clock and alarm-clock |
||
12 | ;add sys_settime at servetable as for ex. 22 fcn: |
||
13 | ; 22 - SETTING DATE TIME, CLOCK AND ALARM-CLOCK |
||
14 | ; ebx =0 - set time ecx - 00SSMMHH |
||
15 | ; ebx =1 - set date ecx=00DDMMYY |
||
16 | ; ebx =2 - set day of week ecx- 1-7 |
||
17 | ; ebx =3 - set alarm-clock ecx - 00SSMMHH |
||
18 | ; out: 0 -Ok 1 -wrong format 2 -battery low |
||
19 | sys_settime: |
||
20 | cli |
||
21 | mov al, 0x0d |
||
22 | out 0x70, al |
||
23 | in al, 0x71 |
||
24 | bt ax, 7 |
||
9910 | Doczom | 25 | jnc .bat_low |
26 | cmp ebx, 2 ;day of week |
||
27 | jne .nosetweek |
||
2288 | clevermous | 28 | test ecx, ecx ;test day of week |
9910 | Doczom | 29 | je .wrongtime |
2288 | clevermous | 30 | cmp ecx, 7 |
9910 | Doczom | 31 | ja .wrongtime |
2288 | clevermous | 32 | mov edx, 0x70 |
33 | call startstopclk |
||
34 | dec edx |
||
35 | mov al, 6 |
||
36 | out dx, al |
||
37 | inc edx |
||
38 | mov al, cl |
||
39 | out dx, al |
||
9910 | Doczom | 40 | jmp .endsettime |
41 | .nosetweek: ;set date |
||
2288 | clevermous | 42 | cmp ebx, 1 |
9910 | Doczom | 43 | jne .nosetdate |
2288 | clevermous | 44 | cmp cl, 0x99;test year |
9910 | Doczom | 45 | ja .wrongtime |
2288 | clevermous | 46 | shl ecx, 4 |
47 | cmp cl, 0x90 |
||
9910 | Doczom | 48 | ja .wrongtime |
2288 | clevermous | 49 | cmp ch, 0x99;test month |
9910 | Doczom | 50 | ja .wrongtime |
2288 | clevermous | 51 | shr ecx, 4 |
52 | test ch, ch |
||
9910 | Doczom | 53 | je .wrongtime |
2288 | clevermous | 54 | cmp ch, 0x12 |
9910 | Doczom | 55 | ja .wrongtime |
2288 | clevermous | 56 | shl ecx, 8 |
57 | bswap ecx ;ebx=00YYMMDD |
||
58 | test cl, cl ;test day |
||
9910 | Doczom | 59 | je .wrongtime |
2288 | clevermous | 60 | shl ecx, 4 |
61 | cmp cl, 0x90 |
||
9910 | Doczom | 62 | ja .wrongtime |
2288 | clevermous | 63 | shr ecx, 4 |
64 | cmp ch, 2 ;February |
||
9910 | Doczom | 65 | jne .testday |
2288 | clevermous | 66 | cmp cl, 0x29 |
9910 | Doczom | 67 | ja .wrongtime |
68 | jmp .setdate |
||
69 | .testday: |
||
2288 | clevermous | 70 | cmp ch, 8 |
9910 | Doczom | 71 | jb .testday1 ;Aug-Dec |
2288 | clevermous | 72 | bt cx, 8 |
9910 | Doczom | 73 | jnc .days31 |
74 | jmp .days30 |
||
75 | .testday1: |
||
2288 | clevermous | 76 | bt cx, 8 ;Jan-Jul ex.Feb |
9910 | Doczom | 77 | jnc .days30 |
78 | .days31: |
||
2288 | clevermous | 79 | cmp cl, 0x31 |
9910 | Doczom | 80 | ja .wrongtime |
81 | jmp .setdate |
||
82 | .days30: |
||
2288 | clevermous | 83 | cmp cl, 0x30 |
9910 | Doczom | 84 | ja .wrongtime |
85 | .setdate: |
||
2288 | clevermous | 86 | mov edx, 0x70 |
87 | call startstopclk |
||
88 | dec edx |
||
89 | mov al, 7 ;set days |
||
90 | out dx, al |
||
91 | inc edx |
||
92 | mov al, cl |
||
93 | out dx, al |
||
94 | dec edx |
||
95 | mov al, 8 ;set months |
||
96 | out dx, al |
||
97 | inc edx |
||
98 | mov al, ch |
||
99 | out dx, al |
||
100 | dec edx |
||
101 | mov al, 9 ;set years |
||
102 | out dx, al |
||
103 | inc edx |
||
104 | shr ecx, 8 |
||
105 | mov al, ch |
||
106 | out dx, al |
||
9910 | Doczom | 107 | jmp .endsettime |
108 | .nosetdate: ;set time or alarm-clock |
||
2288 | clevermous | 109 | cmp ebx, 3 |
9910 | Doczom | 110 | ja .wrongtime |
2288 | clevermous | 111 | cmp cl, 0x23 |
9910 | Doczom | 112 | ja .wrongtime |
2288 | clevermous | 113 | cmp ch, 0x59 |
9910 | Doczom | 114 | ja .wrongtime |
2288 | clevermous | 115 | shl ecx, 4 |
116 | cmp cl, 0x90 |
||
9910 | Doczom | 117 | ja .wrongtime |
2288 | clevermous | 118 | cmp ch, 0x92 |
9910 | Doczom | 119 | ja .wrongtime |
2288 | clevermous | 120 | shl ecx, 4 |
121 | bswap ecx ;00HHMMSS |
||
122 | cmp cl, 0x59 |
||
9910 | Doczom | 123 | ja .wrongtime |
2288 | clevermous | 124 | shl ecx, 4 |
125 | cmp cl, 0x90 |
||
9910 | Doczom | 126 | ja .wrongtime |
2288 | clevermous | 127 | shr ecx, 4 |
128 | |||
129 | mov edx, 0x70 |
||
130 | call startstopclk |
||
131 | dec edx |
||
132 | cmp ebx, 3 |
||
133 | |||
9910 | Doczom | 134 | je .setalarm |
2288 | clevermous | 135 | xor eax, eax;al=0-set seconds |
136 | out dx, al |
||
137 | inc edx |
||
138 | mov al, cl |
||
139 | out dx, al |
||
140 | dec edx |
||
141 | mov al, 2 ;set minutes |
||
142 | out dx, al |
||
143 | inc edx |
||
144 | mov al, ch |
||
145 | out dx, al |
||
146 | dec edx |
||
147 | mov al, 4 ;set hours |
||
148 | out dx, al |
||
149 | inc edx |
||
150 | shr ecx, 8 |
||
151 | mov al, ch |
||
152 | out dx, al |
||
9910 | Doczom | 153 | jmp .endsettime |
154 | .setalarm: |
||
2288 | clevermous | 155 | mov al, 1;set seconds for al. |
156 | out dx, al |
||
157 | inc edx |
||
158 | mov al, cl |
||
159 | out dx, al |
||
160 | dec edx |
||
161 | mov al, 3;set minutes for al. |
||
162 | out dx, al |
||
163 | inc edx |
||
164 | mov al, ch |
||
165 | out dx, al |
||
166 | dec edx |
||
167 | mov al, 5;set hours for al. |
||
168 | out dx, al |
||
169 | inc edx |
||
170 | shr ecx, 8 |
||
171 | mov al, ch |
||
172 | out dx, al |
||
173 | dec edx |
||
174 | mov al, 0x0b;enable irq's |
||
175 | out dx, al |
||
176 | inc dx |
||
177 | in al, dx |
||
178 | bts ax, 5;set bit 5 |
||
179 | out dx, al |
||
9910 | Doczom | 180 | .endsettime: |
2288 | clevermous | 181 | dec edx |
182 | call startstopclk |
||
183 | sti |
||
9910 | Doczom | 184 | and [esp + SYSCALL_STACK.eax], dword 0 |
2288 | clevermous | 185 | ret |
9910 | Doczom | 186 | .bat_low: |
2288 | clevermous | 187 | sti |
9910 | Doczom | 188 | mov [esp + SYSCALL_STACK.eax], dword 2 |
2288 | clevermous | 189 | ret |
9910 | Doczom | 190 | .wrongtime: |
2288 | clevermous | 191 | sti |
9910 | Doczom | 192 | mov [esp + SYSCALL_STACK.eax], dword 1 |
2288 | clevermous | 193 | ret |
194 | |||
195 | startstopclk: |
||
196 | mov al, 0x0b |
||
197 | out dx, al |
||
198 | inc dx |
||
199 | in al, dx |
||
200 | btc ax, 7 |
||
201 | out dx, al |
||
202 | ret |
||
9612 | Doczom | 203 | |
204 | align 4 |
||
205 | sys_clock: |
||
206 | cli |
||
207 | ; Mikhail Lisovin xx Jan 2005 |
||
208 | @@: |
||
209 | mov al, 10 |
||
210 | out 0x70, al |
||
211 | in al, 0x71 |
||
212 | test al, al |
||
213 | jns @f |
||
214 | mov esi, 1 |
||
215 | call delay_ms |
||
216 | jmp @b |
||
217 | @@: |
||
218 | ; end Lisovin's fix |
||
219 | |||
220 | xor al, al ; seconds |
||
221 | out 0x70, al |
||
222 | in al, 0x71 |
||
223 | movzx ecx, al |
||
224 | mov al, 02 ; minutes |
||
225 | shl ecx, 16 |
||
226 | out 0x70, al |
||
227 | in al, 0x71 |
||
228 | movzx edx, al |
||
229 | mov al, 04 ; hours |
||
230 | shl edx, 8 |
||
231 | out 0x70, al |
||
232 | in al, 0x71 |
||
233 | add ecx, edx |
||
234 | movzx edx, al |
||
235 | add ecx, edx |
||
236 | sti |
||
9910 | Doczom | 237 | mov [esp + SYSCALL_STACK.eax], ecx |
9612 | Doczom | 238 | ret |
239 | |||
240 | align 4 |
||
241 | sys_date: |
||
242 | cli |
||
243 | @@: |
||
244 | mov al, 10 |
||
245 | out 0x70, al |
||
246 | in al, 0x71 |
||
247 | test al, al |
||
248 | jns @f |
||
249 | mov esi, 1 |
||
250 | call delay_ms |
||
251 | jmp @b |
||
252 | @@: |
||
253 | mov ch, 0 |
||
254 | mov al, 7 ; date |
||
255 | out 0x70, al |
||
256 | in al, 0x71 |
||
257 | mov cl, al |
||
258 | mov al, 8 ; month |
||
259 | shl ecx, 16 |
||
260 | out 0x70, al |
||
261 | in al, 0x71 |
||
262 | mov ch, al |
||
263 | mov al, 9 ; year |
||
264 | out 0x70, al |
||
265 | in al, 0x71 |
||
266 | mov cl, al |
||
267 | sti |
||
9910 | Doczom | 268 | mov [esp + SYSCALL_STACK.eax], ecx |
9612 | Doczom | 269 | ret |