Subversion Repositories Kolibri OS

Rev

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