Subversion Repositories Kolibri OS

Rev

Rev 9612 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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