Subversion Repositories Kolibri OS

Rev

Rev 4711 | 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.         pusha
  12.  
  13.         mov     eax, [pg_data.pages_free]
  14. ;   1/32
  15.         shr     eax, 5
  16. ;   round off up to 8 pages
  17.         shr     eax, 3
  18.         shl     eax, 3
  19. ;   translate pages in butes *4096
  20.         shl     eax, 12
  21. ;       check a upper size of the cache, no more than 1 Mb on the physical device
  22.         cmp     eax, 1024*1024
  23.         jbe     @f
  24.  
  25.         mov     eax, 1024*1024
  26.         jmp     .continue
  27. ;--------------------------------------
  28. @@:
  29. ;       check a lower size of the cache, not less than 128 Kb on the physical device
  30.         cmp     eax, 128*1024
  31.         jae     .continue
  32.  
  33.         mov     eax, 128*1024
  34. ;--------------------------------------
  35. .continue:
  36.         push    ecx
  37.         mov     ecx, 12
  38.         mov     esi, cache_ide0+IDE_CACHE.size
  39.         cld
  40. @@:
  41.         mov     [esi], eax
  42.         add     esi, sizeof.IDE_CACHE
  43.         loop    @b
  44.  
  45.         pop     ecx
  46.  
  47.         xor     eax, eax
  48.         mov     [hdd_appl_data], 1 ;al
  49.         mov     [cd_appl_data], 1
  50. ;--------------------------------------
  51.         test    byte [DRIVE_DATA+1], 0x80
  52.         je      @f
  53.  
  54.         mov     esi, cache_ide0
  55.         call    get_cache_ide
  56. ;--------------------------------------
  57. @@:
  58.         test    byte [DRIVE_DATA+1], 0x20
  59.         je      @f
  60.  
  61.         mov     esi, cache_ide1
  62.         call    get_cache_ide
  63. ;--------------------------------------
  64. @@:
  65.         test    byte [DRIVE_DATA+1], 8
  66.         je      @f
  67.  
  68.         mov     esi, cache_ide2
  69.         call    get_cache_ide
  70. ;--------------------------------------
  71. @@:
  72.         test    byte [DRIVE_DATA+1], 2
  73.         je      @f
  74.  
  75.         mov     esi, cache_ide3
  76.         call    get_cache_ide
  77. ;--------------------------------------
  78. @@:
  79.         test    byte [DRIVE_DATA+6], 0x80
  80.         je      @f
  81.  
  82.         mov     esi, cache_ide4
  83.         call    get_cache_ide
  84. ;--------------------------------------
  85. @@:
  86.         test    byte [DRIVE_DATA+6], 0x20
  87.         je      @f
  88.  
  89.         mov     esi, cache_ide5
  90.         call    get_cache_ide
  91. ;--------------------------------------
  92. @@:
  93.         test    byte [DRIVE_DATA+6], 8
  94.         je      @f
  95.  
  96.         mov     esi, cache_ide6
  97.         call    get_cache_ide
  98. ;--------------------------------------
  99. @@:
  100.         test    byte [DRIVE_DATA+6], 2
  101.         je      @f
  102.  
  103.         mov     esi, cache_ide7
  104.         call    get_cache_ide
  105. ;--------------------------------------
  106. @@:
  107.         test    byte [DRIVE_DATA+11], 0x80
  108.         je      @f
  109.  
  110.         mov     esi, cache_ide8
  111.         call    get_cache_ide
  112. ;--------------------------------------
  113. @@:
  114.         test    byte [DRIVE_DATA+11], 0x20
  115.         je      @f
  116.  
  117.         mov     esi, cache_ide9
  118.         call    get_cache_ide
  119. ;--------------------------------------
  120. @@:
  121.         test    byte [DRIVE_DATA+11], 8
  122.         je      @f
  123.  
  124.         mov     esi, cache_ide10
  125.         call    get_cache_ide
  126. ;--------------------------------------
  127. @@:
  128.         test    byte [DRIVE_DATA+11], 2
  129.         je      end_get_cache
  130.  
  131.         mov     esi, cache_ide11
  132.         call    get_cache_ide
  133.  
  134.         jmp     end_get_cache
  135. ;-----------------------------------------------------------------------------
  136. get_cache_ide:
  137.         and     [esi+IDE_CACHE.search_start], 0
  138.         and     [esi+IDE_CACHE.appl_search_start], 0
  139.  
  140.         push    ecx
  141. ;        DEBUGF  1, "K : IDE_CACHE.size %x\n", [esi+IDE_CACHE.size]
  142.         stdcall kernel_alloc, [esi+IDE_CACHE.size]
  143.         mov     [esi+IDE_CACHE.pointer], eax
  144.         pop     ecx
  145.  
  146.         mov     edx, eax
  147.         mov     eax, [esi+IDE_CACHE.size]
  148.         shr     eax, 3
  149. ;        DEBUGF  1, "K : IDE_CACHE.system_data_size %x\n", eax
  150.         mov     [esi+IDE_CACHE.system_data_size], eax
  151.         mov     ebx, eax
  152.         imul    eax, 7
  153. ;        DEBUGF  1, "K : IDE_CACHE.appl_data_size %x\n", eax
  154.         mov     [esi+IDE_CACHE.appl_data_size], eax
  155.         add     ebx, edx
  156.         mov     [esi+IDE_CACHE.data_pointer], ebx
  157.  
  158. .cd:
  159.         push    ecx
  160.         mov     eax, [esi+IDE_CACHE.system_data_size]
  161.         call    calculate_for_cd
  162.         add     eax, [esi+IDE_CACHE.pointer]
  163.         mov     [esi+IDE_CACHE.system_data], eax
  164.         mov     [esi+IDE_CACHE.system_sad_size], ecx
  165.  
  166.         push    edi
  167.         mov     edi, [esi+IDE_CACHE.pointer]
  168.         call    clear_ide_cache
  169.         pop     edi
  170.  
  171.         mov     eax, [esi+IDE_CACHE.appl_data_size]
  172.         call    calculate_for_cd
  173.         add     eax, [esi+IDE_CACHE.data_pointer]
  174.         mov     [esi+IDE_CACHE.appl_data], eax
  175.         mov     [esi+IDE_CACHE.appl_sad_size], ecx
  176.  
  177.         push    edi
  178.         mov     edi, [esi+IDE_CACHE.data_pointer]
  179.         call    clear_ide_cache
  180.         pop     edi
  181.  
  182.         pop     ecx
  183.         ret
  184. ;-----------------------------------------------------------------------------
  185. calculate_for_cd:
  186.         push    eax
  187.         mov     ebx, eax
  188.         shr     eax, 11
  189.         shl     eax, 3
  190.         sub     ebx, eax
  191.         shr     ebx, 11
  192.         mov     ecx, ebx
  193.         shl     ebx, 11
  194.         pop     eax
  195.         sub     eax, ebx
  196.         dec     ecx
  197.         ret
  198. ;-----------------------------------------------------------------------------
  199. clear_ide_cache:
  200.         push    eax
  201.         shl     ecx, 1
  202.         xor     eax, eax
  203.         cld
  204.         rep stosd
  205.         pop     eax
  206.         ret
  207. ;-----------------------------------------------------------------------------
  208. end_get_cache:
  209.         popa
  210.