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