Subversion Repositories Kolibri OS

Rev

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

  1. label  next_usage_update   dword   at  0xB008
  2. label  timer_ticks         dword   at  0xFDF0
  3.  
  4. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5. ;; IRQ0 HANDLER (TIMER INTERRUPT) ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8.  
  9.  
  10. align 32
  11. irq0:
  12.         cmp   [error_interrupt],-1
  13.         je    no_error_in_previous_process
  14.  
  15.         mov   [0xffff],byte 0
  16.  
  17.         mov   [error_interrupt],-1
  18.  
  19.      no_error_in_previous_process:
  20.  
  21.         mov   edi,[0x3000]
  22.         shl   edi, 3
  23.                          ; fields of TSS descriptor:
  24.         mov   [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
  25.  
  26.         inc   dword [timer_ticks]
  27.  
  28.         mov   eax, [timer_ticks]
  29. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  30.         call  playNote           ; <<<--- INSERT THIS LINE !!!!!!!!!!
  31. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  32.  
  33.         cmp   eax,[next_usage_update]
  34.         jb    .nocounter
  35.         add   eax,100
  36.         mov   [next_usage_update],eax
  37.         call  updatecputimes
  38.      .nocounter:
  39.  
  40.         mov   edi, [0x3010]
  41.  
  42.         mov   ebx, [edi+0x18] ; time stamp counter add
  43.         call  _rdtsc
  44.         sub   eax, ebx
  45.         add   eax, [edi+0x14] ; counter sum
  46.         mov   [edi+0x14], eax
  47.  
  48.         mov   ebx,[0x3000]
  49.  
  50.         cmp   [0xffff], byte 1   ;1
  51.         je   do_not_change_task ;je
  52.  
  53.       .waiting_for_termination:
  54.       .waiting_for_reuse:
  55.         add   edi,0x20
  56.         inc   ebx
  57.  
  58.         mov   al, byte [edi+0xA]
  59.         cmp   al, 3
  60.         je    .waiting_for_termination
  61.         cmp   al, 4
  62.         je    .waiting_for_termination
  63.         cmp   al, 9
  64.         je    .waiting_for_reuse
  65.  
  66.         cmp   ebx,[0x3004]
  67.         jbe   nsched0
  68.         mov   ebx,1
  69.         mov   edi,0x3020
  70.  
  71.       nsched0:
  72.  
  73.         mov   [0x3000],ebx
  74.         mov   [0x3010],edi
  75.  
  76.       do_not_change_task:
  77.  
  78.         call  _rdtsc
  79.         mov   [edi+0x18],eax
  80.  
  81.         cmp   [0xffff],byte 0
  82.         je    nodecffff
  83.         dec   byte [0xffff]
  84.       nodecffff:
  85.  
  86.  
  87.         shl   ebx, 3
  88.         xor   eax, eax
  89.         add   ebx, tss0
  90.         mov   word  [0xB004], bx   ; selector    ;mov   [tss_s],bx
  91.         mov   dword [0xB000], eax  ; offset
  92.  
  93.         mov   al,0x20   ; send End Of Interrupt signal
  94.         mov   dx,0x20
  95.         out   dx,al
  96. .switch:
  97.         jmp   pword [0xB000]
  98.         inc [context_counter] ;noname & halyavin
  99.        
  100.         jmp   irq0
  101.  
  102. iglobal
  103. context_counter dd 0 ;noname & halyavin
  104. endg
  105.  
  106.  
  107. align 4
  108. change_task:
  109.  
  110.         mov   [0xffff],byte 2
  111.  
  112.         dec   dword [timer_ticks]  ; because irq0 will increase it
  113.  
  114.         int   0x20   ; irq0 handler
  115.  
  116.         ret
  117.  
  118.  
  119.  
  120. align 4
  121. updatecputimes:
  122.  
  123.         mov  eax,[idleuse]
  124.         mov  [idleusesec],eax
  125.         mov  [idleuse],dword 0
  126.         mov  ecx, [0x3004]
  127.         mov  edi, 0x3020
  128.       .newupdate:
  129.         mov  ebx,[edi+0x14]
  130.         mov  [edi+0x1c],ebx
  131.         mov  [edi+0x14],dword 0
  132.         add  edi,0x20
  133.         dec  ecx
  134.         jnz  .newupdate
  135.  
  136.         ret
  137.