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