Subversion Repositories Kolibri OS

Rev

Rev 2455 | Rev 9715 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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