Subversion Repositories Kolibri OS

Rev

Rev 5363 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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