Subversion Repositories Kolibri OS

Rev

Rev 7638 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7638 Rev 7642
Line 59... Line 59...
59
	call	[con_init]
59
	call	[con_init]
60
  ;test	eax, eax
60
  ;test	eax, eax
61
  ; fatal error(console error)
61
  ; fatal error(console error)
62
	;jnz	exit
62
	;jnz	exit
Line 63... Line -...
63
 
-
 
64
  
63
 
65
  ; setup params
64
  ; setup params
66
  call parse_params
65
  call parse_params
67
  
66
  ;clear eax
68
  call tz_validate
67
  call tz_validate
69
  ; is TZ correct?
68
  ; is TZ correct?
70
  cmp ebx,0
69
  cmp ebx,0
71
  je @f
70
  je @f
Line 187... Line 186...
187
  
186
  
188
  cmp [tz_h],0
187
  cmp [tz_h],0
189
  jne @f
188
  jne @f
190
  cmp [tz_m],0
189
  cmp [tz_m],0
-
 
190
  jne @f
-
 
191
  mov eax, str_tz
-
 
192
  add eax, 9  
191
  jne @f
193
  cinvoke con_printf, eax ; \n\0 
Line 192... Line 194...
192
  jmp .no_bias
194
  jmp .no_bias
193
  
195
  
194
@@:
196
@@:
Line 210... Line 212...
210
  mov bl, [tz_m]
212
  mov bl, [tz_m]
Line 211... Line 213...
211
   
213
   
Line 212... Line 214...
212
  cinvoke con_printf, str_tz, eax, ebx
214
  cinvoke con_printf, str_tz, eax, ebx
213
  
-
 
214
.no_bias:
215
  
215
  
216
.no_bias:
216
  cmp [sync],0
217
  cmp [sync],0
217
  je  exit
218
  je  exit
218
  cmp [sync], SYNC_S
219
  cmp [sync], SYNC_S
Line 223... Line 224...
223
  cmp [sync], SYNC_ST
224
  cmp [sync], SYNC_ST
224
  jne @f
225
  jne @f
225
  mov eax, str_st
226
  mov eax, str_st
226
  jmp .sync_ok
227
  jmp .sync_ok
227
  @@:
228
  @@:
228
  cmp [sync], SYNC_ST
229
  cmp [sync], SYNC_SS
229
  jne .sync_ok
230
  jne exit ; Fixed (24.04.2019): incorrect display with -ss
230
  mov eax, str_ss
231
  mov eax, str_ss
Line 231... Line 232...
231
  
232
  
232
  .sync_ok:
233
.sync_ok:
Line 314... Line 315...
314
SYNC_ST   = 3
315
SYNC_ST   = 3
Line 315... Line 316...
315
 
316
 
316
parse_params:
317
parse_params:
317
  mov	  esi, params
318
  mov	  esi, params
-
 
319
  mov   ebx, esi
318
  mov   ebx, esi 
320
  clear ecx ; 26.04.2018 Fixed 
319
.f00:
321
.f00:
320
	lodsb
322
	lodsb
321
  cmp	 al, 0
323
  cmp	 al, 0
Line 327... Line 329...
327
  ;no params
329
  ;no params
328
  mov eax, -1
330
  mov eax, -1
329
  ret
331
  ret
Line 330... Line 332...
330
    
332
    
-
 
333
.exit:
-
 
334
  cmp ecx,0 ; 26.04.2018 Fixed
331
.exit:
335
  je @f 
332
  ; mark end of TZ
336
  ; mark end of TZ
333
  mov	  byte [ecx+1],  0
337
  mov	  byte [ecx+1],  0
334
  ; now esi = start of TZ
338
  ; now esi = start of TZ
Line 391... Line 395...
391
;	call	c2n
395
;	call	c2n
392
;	test	ebx, ebx
396
;	test	ebx, ebx
393
; jz	  .invalid
397
; jz	  .invalid
394
; mov	  [port], bx
398
; mov	  [port], bx
395
;	jmp .param_loop
399
;	jmp .param_loop
-
 
400
jmp .invalid
Line 396... Line 401...
396
  
401
  
397
.tz:  
402
.tz:  
398
  ; tz setup
403
  ; tz setup
399
	lodsb
404
	lodsb
Line 442... Line 447...
442
 
447
 
443
.invalid:
448
.invalid:
444
	mov eax, 10
449
	mov eax, 10
Line -... Line 450...
-
 
450
	ret
445
	ret
451
  
446
 
452
 
447
; Helper to convert char to number
453
; Helper to convert char to number
448
; Input:
454
; Input:
449
; esi  - ptr to char of digit
455
; esi  - ptr to char of digit
Line 496... Line 502...
496
  ret
502
  ret
Line 497... Line 503...
497
 
503
 
498
 
504
 
499
; Sync worker
505
; Sync worker
500
; Input:
506
; Input:
501
; eax  - in_addr (IPv4)
507
; setuped sockaddr1
502
; Output:
508
; Output:
503
; eax - error_code
509
; eax - error_code
504
; ebx - error_string
510
; ebx - error_string
Line 508... Line 514...
508
;  
514
;  
509
;sntp_sync_time:
515
;sntp_sync_time:
510
  ;mov	   edx, eax  
516
  ;mov	   edx, eax  
511
sntp_query_time:
517
sntp_query_time:
Line -... Line 518...
-
 
518
 
-
 
519
  ; if -ss & 59:59 => waiting for new hour
-
 
520
  cmp [sync], SYNC_SS
-
 
521
  jne @f
-
 
522
.new_hour?:  
-
 
523
  ; Query system time
-
 
524
  mcall   3
-
 
525
  cmp ah, 59h ; 59 min. ?
-
 
526
  jne @f
-
 
527
  shr eax, 16
-
 
528
  cmp al, 59h ; 59 sec. ?
-
 
529
  jne @f
-
 
530
  ;DEBUGF  1, "SNTP: Waiting for new hour.\n"
-
 
531
  ; Wait 100 msec.
512
 
532
  mcall 5,10
513
;  jmp .test 
533
  jmp .new_hour? 
514
 
534
@@:  
515
  ; Create socket
535
  ; Create socket
516
  mcall   socket, AF_INET4, SOCK_DGRAM, IPPROTO_IP
536
  mcall   socket, AF_INET4, SOCK_DGRAM, IPPROTO_IP
517
  cmp	  eax, -1
537
  cmp	  eax, -1
518
  jne   @f
538
  jne   @f
Line 532... Line 552...
532
  mov   edi, str_err4
552
  mov   edi, str_err4
533
  jmp .error ; Connection error (2)
553
  jmp .error ; Connection error (2)
534
  ;DEBUGF  1, "Socket connected.\n"
554
  ;DEBUGF  1, "Socket connected.\n"
Line 535... Line 555...
535
  
555
  
536
@@:
-
 
537
  ; Query system time
-
 
538
  ;mcall   3
-
 
539
  ;mov [SystemTime], eax  
-
 
540
   
556
@@:   
541
  mcall   send, ebp, sntp_packet, SIZEOF_SNTP_PACKET, 0
557
  mcall   send, ebp, sntp_packet, SIZEOF_SNTP_PACKET, 0
542
  cmp	  eax, -1
558
  cmp	  eax, -1
543
  jne   @f
559
  jne   @f
544
  mov   edx, 43
560
  mov   edx, 43
Line 634... Line 650...
634
  ;mov [TimeZone], cx
650
  ;mov [TimeZone], cx
635
  ;@@:
651
  ;@@:
636
@@:
652
@@:
637
.tz_h:  
653
.tz_h:  
638
  ; correct hour    
654
  ; correct hour    
639
  cmp [sync], SYNC_SS
655
;  cmp [sync], SYNC_SS
640
  ; if -ss ignore timezone for hour
656
  ; if -ss ignore timezone for hour
641
  je .tz_done
657
;  je .tz_done
642
  clear eax
658
  clear eax
643
  mov al, [tz_h]
659
  mov al, [tz_h]
644
  add al, cl   
660
  add al, cl   
645
  add [esi + DateTime.hour], al ;3 ; MSK = GMT +3
661
  add [esi + DateTime.hour], al ;3 ; MSK = GMT +3
Line 679... Line 695...
679
  ;}}
695
  ;}}
Line 680... Line 696...
680
  
696
  
681
  ; FIXED:  do sync before display!!!
697
  ; FIXED:  do sync before display!!!
682
  ;         It's need to do sync fast ASAP 
698
  ;         It's need to do sync fast ASAP 
683
  ;         Take out any printf from sntp_query_time! 
-
 
684
  
699
  ;         Take out any printf from sntp_query_time! 
685
  ; sync > 0 ?
700
  ; sync > 0 ?
686
  cmp [sync], 0
701
  cmp [sync], 0
Line 687... Line 702...
687
  je .nosync
702
  je .nosync
688
  
703
  
689
  ;{{ 
704
  ;{{ 
690
  ; Removed block 2
705
  ; Removed block 2
Line -... Line 706...
-
 
706
  ; FIXME: Go it from sntp_query_time!
-
 
707
  ;}}
691
  ; FIXME: Go it from sntp_query_time!
708
  
692
  ;}}
709
  
693
  
710
  
694
	; Convert time to BCD   
711
	; Convert time to BCD   
695
  clear eax, edx 
712
  clear eax, edx 
696
  mov al, [esi + DateTime.sec]
713
  mov al, [esi + DateTime.sec]
697
  b2bcd
714
  b2bcd
698
  mov ecx, eax
715
  mov ecx, eax
699
  shl ecx, 16
716
  shl ecx, 16
-
 
717
  mov al, [esi + DateTime.min]
-
 
718
  b2bcd  
-
 
719
  mov ch, al
-
 
720
  
-
 
721
  cmp [sync], SYNC_SS
-
 
722
  jne @f
-
 
723
  ; if -ss ignore timezone for hour
-
 
724
  ; Query system time
700
  mov al, [esi + DateTime.min]
725
  mcall   3  
701
  b2bcd
726
  jmp .ss_done
-
 
727
@@:   
702
  mov ch, al 
728
  mov al, [esi + DateTime.hour]
Line 703... Line 729...
703
  mov al, [esi + DateTime.hour]
729
  b2bcd
704
  b2bcd
730
.ss_done:
Line 849... Line 875...
849
.port	dw 0x7b00     ; 123 in network order (big endian)
875
.port	dw 0x7b00     ; 123 in network order (big endian)
850
.ip	dd 0
876
.ip	dd 0
851
	rb 10
877
	rb 10
Line 852... Line 878...
852
 
878
 
853
SIZEOF_SNTP_PACKET  = 48 	
879
SIZEOF_SNTP_PACKET  = 48 	
854
sntp_packet	        db 0x23 ; Li = 0 Vn = 4 Mode = 3 (client) FIX: Why	0x0b?       
880
sntp_packet	        db 0x23 ; Li = 0 Vn = 4 Mode = 3 (client)       
855
  .Stratum	        db 0
881
  .Stratum	        db 0
856
	.Pool		          db 0
882
	.Pool		          db 0
857
	.Precision	      db 0 
883
	.Precision	      db 0 
858
	.RootDelay	      dd 0
884
	.RootDelay	      dd 0
Line 866... Line 892...
866
; import
892
; import
867
align 4
893
align 4
868
@IMPORT:
894
@IMPORT:
Line 869... Line 895...
869
 
895
 
870
library network, 'network.obj', console, 'console.obj'
-
 
871
;library network, 'network.obj', console, 'console.obj'
896
library network, 'network.obj', console, 'console.obj'
872
import network, \
897
import network, \
873
  inet_addr, 'inet_addr',  \
898
  inet_addr, 'inet_addr',  \
874
  getaddrinfo,	'getaddrinfo',	\
899
  getaddrinfo,	'getaddrinfo',	\
875
	freeaddrinfo,	'freeaddrinfo', \
900
	freeaddrinfo,	'freeaddrinfo', \