Rev 425 | Rev 593 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
425 | victor | 1 | $Revision: 431 $ |
431 | serge | 2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
3 | ;; ;; |
||
4 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
||
5 | ;; Distributed under terms of the GNU General Public License ;; |
||
6 | ;; ;; |
||
7 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
8 | |||
1 | ha | 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 | mov ecx,eax |
||
19 | cli |
||
20 | mov al,0x0d |
||
21 | out 0x70,al |
||
22 | in al,0x71 |
||
23 | bt ax,7 |
||
24 | jnc bat_low |
||
25 | cmp ecx,2 ;day of week |
||
26 | jne nosetweek |
||
27 | test ebx,ebx ;test day of week |
||
28 | je wrongtime |
||
29 | cmp ebx,7 |
||
30 | ja wrongtime |
||
31 | mov dx,0x70 |
||
32 | call startstopclk |
||
33 | dec edx |
||
34 | mov al,6 |
||
35 | out dx,al |
||
36 | inc edx |
||
37 | mov al,bl |
||
38 | out dx,al |
||
39 | jmp endsettime |
||
40 | nosetweek: ;set date |
||
41 | cmp ecx,1 |
||
42 | jne nosetdate |
||
43 | cmp bl,0x99 ;test year |
||
44 | ja wrongtime |
||
45 | shl ebx,4 |
||
46 | cmp bl,0x90 |
||
47 | ja wrongtime |
||
48 | cmp bh,0x99 ;test month |
||
49 | ja wrongtime |
||
50 | shr ebx,4 |
||
51 | test bh,bh |
||
52 | je wrongtime |
||
53 | cmp bh,0x12 |
||
54 | ja wrongtime |
||
55 | shl ebx,8 |
||
56 | bswap ebx ;ebx=00YYMMDD |
||
57 | test bl,bl ;test day |
||
58 | je wrongtime |
||
59 | shl ebx,4 |
||
60 | cmp bl,0x90 |
||
61 | ja wrongtime |
||
62 | shr ebx,4 |
||
63 | cmp bh,2 ;February |
||
64 | jne testday |
||
65 | cmp bl,0x29 |
||
66 | ja wrongtime |
||
67 | jmp setdate |
||
68 | testday: |
||
69 | cmp bh,8 |
||
70 | jb testday1 ;Aug-Dec |
||
71 | bt bx,8 |
||
72 | jnc days31 |
||
73 | jmp days30 |
||
74 | testday1: |
||
75 | bt bx,8 ;Jan-Jul ex.Feb |
||
76 | jnc days30 |
||
77 | days31: |
||
78 | cmp bl,0x31 |
||
79 | ja wrongtime |
||
80 | jmp setdate |
||
81 | days30: |
||
82 | cmp bl,0x30 |
||
83 | ja wrongtime |
||
84 | setdate: |
||
85 | mov dx,0x70 |
||
86 | call startstopclk |
||
87 | dec edx |
||
88 | mov al,7 ;set days |
||
89 | out dx,al |
||
90 | inc edx |
||
91 | mov al,bl |
||
92 | out dx,al |
||
93 | dec edx |
||
94 | mov al,8 ;set months |
||
95 | out dx,al |
||
96 | inc edx |
||
97 | mov al,bh |
||
98 | out dx,al |
||
99 | dec edx |
||
100 | mov al,9 ;set years |
||
101 | out dx,al |
||
102 | inc edx |
||
103 | shr ebx,8 |
||
104 | mov al,bh |
||
105 | out dx,al |
||
106 | jmp endsettime |
||
107 | nosetdate: ;set time or alarm-clock |
||
108 | cmp ecx,3 |
||
109 | ja wrongtime |
||
110 | cmp bl,0x23 |
||
111 | ja wrongtime |
||
112 | cmp bh,0x59 |
||
113 | ja wrongtime |
||
114 | shl ebx,4 |
||
115 | cmp bl,0x90 |
||
116 | ja wrongtime |
||
117 | cmp bh,0x92 |
||
118 | ja wrongtime |
||
119 | shl ebx,4 |
||
120 | bswap ebx ;00HHMMSS |
||
121 | cmp bl,0x59 |
||
122 | ja wrongtime |
||
123 | shl ebx,4 |
||
124 | cmp bl,0x90 |
||
125 | ja wrongtime |
||
126 | shr ebx,4 |
||
127 | mov dx,0x70 |
||
128 | call startstopclk |
||
129 | dec edx |
||
130 | cmp ecx,3 |
||
131 | je setalarm |
||
132 | xor eax,eax ;al=0-set seconds |
||
133 | out dx,al |
||
134 | inc edx |
||
135 | mov al,bl |
||
136 | out dx,al |
||
137 | dec edx |
||
138 | mov al,2 ;set minutes |
||
139 | out dx,al |
||
140 | inc edx |
||
141 | mov al,bh |
||
142 | out dx,al |
||
143 | dec edx |
||
144 | mov al,4 ;set hours |
||
145 | out dx,al |
||
146 | inc edx |
||
147 | shr ebx,8 |
||
148 | mov al,bh |
||
149 | out dx,al |
||
150 | jmp endsettime |
||
151 | setalarm: |
||
152 | mov al,1 ;set seconds for al. |
||
153 | out dx,al |
||
154 | inc edx |
||
155 | mov al,bl |
||
156 | out dx,al |
||
157 | dec edx |
||
158 | mov al,3 ;set minutes for al. |
||
159 | out dx,al |
||
160 | inc edx |
||
161 | mov al,bh |
||
162 | out dx,al |
||
163 | dec edx |
||
164 | mov al,5 ;set hours for al. |
||
165 | out dx,al |
||
166 | inc edx |
||
167 | shr ebx,8 |
||
168 | mov al,bh |
||
169 | out dx,al |
||
170 | dec edx |
||
171 | mov al,0x0b ;enable irq's |
||
172 | out dx,al |
||
173 | inc dx |
||
174 | in al,dx |
||
175 | bts ax,5 ;set bit 5 |
||
176 | out dx,al |
||
177 | endsettime: |
||
178 | dec edx |
||
179 | call startstopclk |
||
180 | sti |
||
181 | mov [esp+36],dword 0 |
||
182 | ret |
||
183 | bat_low: |
||
184 | sti |
||
185 | mov [esp+36],dword 2 |
||
186 | ret |
||
187 | wrongtime: |
||
188 | sti |
||
189 | mov [esp+36],dword 1 |
||
190 | ret |
||
431 | serge | 191 | |
1 | ha | 192 | startstopclk: |
193 | mov al,0x0b |
||
194 | out dx,al |
||
195 | inc dx |
||
196 | in al,dx |
||
197 | btc ax,7 |
||
198 | out dx,al |
||
199 | ret |