Subversion Repositories Kolibri OS

Rev

Rev 4429 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. ;**************************************************************************
  9. ;
  10. ;   [cache_ide[X]_pointer]
  11. ;   or [cache_ide[X]_data_pointer]  first entry in cache list
  12. ;
  13. ;            +0   - lba sector
  14. ;            +4   - state of cache sector
  15. ;                   0 = empty
  16. ;                   1 = used for read  ( same as in hd )
  17. ;                   2 = used for write ( differs from hd )
  18. ;
  19. ;  [cache_ide[X]_system_data]
  20. ;  or [cache_ide[x]_appl_data] - cache entries
  21. ;
  22. ;**************************************************************************
  23.  
  24. $Revision: 3742 $
  25.  
  26. align 4
  27. find_empty_slot_CD_cache:
  28. ;-----------------------------------------------------------
  29. ; find empty or read slot, flush cache if next 10% is used by write
  30. ; output : edi = cache slot
  31. ;-----------------------------------------------------------
  32. .search_again:
  33.         call    cd_calculate_cache_3
  34. .search_for_empty:
  35.         inc     edi
  36.         call    cd_calculate_cache_4
  37.         jbe     .inside_cache
  38.         mov     edi, 1
  39. .inside_cache:
  40.         call    cd_calculate_cache_5
  41.         ret
  42. ;--------------------------------------------------------------------
  43. clear_CD_cache:
  44.         DEBUGF  1, 'K : clear_CD_cache\n'
  45.         pusha
  46.  
  47.         mov     esi, [cdpos]
  48.         dec     esi
  49.         imul    esi, sizeof.IDE_CACHE
  50.         add     esi, cache_ide0
  51.  
  52.         xor     eax, eax
  53.  
  54.         mov     [esi+IDE_CACHE.search_start], eax
  55.         mov     ecx, [esi+IDE_CACHE.system_sad_size]
  56.         mov     edi, [esi+IDE_CACHE.pointer]
  57.         call    .clear
  58.  
  59.         mov     [esi+IDE_CACHE.appl_search_start], eax
  60.         mov     ecx, [esi+IDE_CACHE.appl_sad_size]
  61.         mov     edi, [esi+IDE_CACHE.data_pointer]
  62.         call    .clear
  63.  
  64.         popa
  65.         ret
  66. ;--------------------------------------
  67. .clear:
  68.         shl     ecx, 1
  69.         cld
  70.         rep stosd
  71.         ret
  72. ;--------------------------------------------------------------------
  73. align 4
  74. cd_calculate_cache:
  75. ; 1 - IDE0 ... 12 - IDE11
  76.         push    eax
  77.  
  78.         mov     eax, [cdpos]
  79.         dec     eax
  80.         imul    eax, sizeof.IDE_CACHE
  81.         add     eax, cache_ide0
  82.  
  83.         cmp     [cd_appl_data], 0
  84.         jne     @f
  85.  
  86.         mov     ecx, [eax+IDE_CACHE.system_sad_size]
  87.         mov     esi, [eax+IDE_CACHE.pointer]
  88.         pop     eax
  89.         ret
  90. ;--------------------------------------
  91. @@:
  92.         mov     ecx, [eax+IDE_CACHE.appl_sad_size]
  93.         mov     esi, [eax+IDE_CACHE.data_pointer]
  94.         pop     eax
  95.         ret
  96. ;--------------------------------------------------------------------
  97. align 4
  98. cd_calculate_cache_1:
  99. ; 1 - IDE0 ... 12 - IDE11
  100.         push    eax
  101.  
  102.         mov     eax, [cdpos]
  103.         dec     eax
  104.         imul    eax, sizeof.IDE_CACHE
  105.         add     eax, cache_ide0
  106.  
  107.         cmp     [cd_appl_data], 0
  108.         jne     @f
  109.  
  110.         mov     esi, [eax+IDE_CACHE.pointer]
  111.         pop     eax
  112.         ret
  113. ;--------------------------------------
  114. @@:
  115.         mov     esi, [eax+IDE_CACHE.data_pointer]
  116.         pop     eax
  117.         ret
  118. ;--------------------------------------------------------------------
  119. align 4
  120. cd_calculate_cache_2:
  121. ; 1 - IDE0 ... 12 - IDE11
  122.         mov     eax, [cdpos]
  123.         dec     eax
  124.         imul    eax, sizeof.IDE_CACHE
  125.         add     eax, cache_ide0
  126.  
  127.         cmp     [cd_appl_data], 0
  128.         jne     @f
  129.  
  130.         mov     eax, [eax+IDE_CACHE.system_data]
  131.         ret
  132. ;--------------------------------------
  133. @@:
  134.         mov     eax, [eax+IDE_CACHE.appl_data]
  135.         ret
  136. ;--------------------------------------------------------------------
  137. align 4
  138. cd_calculate_cache_3:
  139. ; 1 - IDE0 ... 12 - IDE11
  140.         push    eax
  141.  
  142.         mov     eax, [cdpos]
  143.         dec     eax
  144.         imul    eax, sizeof.IDE_CACHE
  145.         add     eax, cache_ide0
  146.  
  147.         cmp     [cd_appl_data], 0
  148.         jne     @f
  149.  
  150.         mov     edi, [eax+IDE_CACHE.search_start]
  151.         pop     eax
  152.         ret
  153. ;--------------------------------------
  154. @@:
  155.         mov     edi, [eax+IDE_CACHE.appl_search_start]
  156.         pop     eax
  157.         ret
  158. ;--------------------------------------------------------------------
  159. align 4
  160. cd_calculate_cache_4:
  161. ; 1 - IDE0 ... 12 - IDE11
  162.         push    eax
  163.  
  164.         mov     eax, [cdpos]
  165.         dec     eax
  166.         imul    eax, sizeof.IDE_CACHE
  167.         add     eax, cache_ide0
  168.  
  169.         cmp     [cd_appl_data], 0
  170.         jne     @f
  171.  
  172.         cmp     edi, [eax+IDE_CACHE.system_sad_size]
  173.         pop     eax
  174.         ret
  175. ;--------------------------------------
  176. @@:
  177.         cmp     edi, [eax+IDE_CACHE.appl_sad_size]
  178.         pop     eax
  179.         ret
  180. ;--------------------------------------------------------------------
  181. align 4
  182. cd_calculate_cache_5:
  183. ; 1 - IDE0 ... 12 - IDE11
  184.         push    eax
  185.  
  186.         mov     eax, [cdpos]
  187.         dec     eax
  188.         imul    eax, sizeof.IDE_CACHE
  189.         add     eax, cache_ide0
  190.  
  191.         cmp     [cd_appl_data], 0
  192.         jne     @f
  193.  
  194.         mov     [eax+IDE_CACHE.search_start], edi
  195.         pop     eax
  196.         ret
  197. ;--------------------------------------
  198. @@:
  199.         mov     [eax+IDE_CACHE.appl_search_start], edi
  200.         pop     eax
  201.         ret
  202. ;--------------------------------------------------------------------
  203.