Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. $Revision: 0 $
  3.  
  4.  
  5. ;cache_ide0_pointer          dd 0
  6. ;cache_ide0_size             dd 0   ; not use
  7. ;cache_ide0_data_pointer     dd 0
  8. ;cache_ide0_system_data_size dd 0   ; not use
  9. ;cache_ide0_appl_data_size   dd 0   ; not use
  10. ;cache_ide0_system_data      dd 0
  11. ;cache_ide0_appl_data        dd 0
  12. ;cache_ide0_system_sad_size  dd 0
  13. ;cache_ide0_appl_sad_size    dd 0
  14.  
  15.     pusha
  16.  
  17.     mov  eax,[pg_data.pages_free]
  18. ;   1/32
  19.     shr eax,5
  20. ;   round off up to 8 pages
  21.     shr eax,3
  22.     shl eax,3
  23. ;   translate pages in butes *4096
  24.     shl eax,12
  25. ;       check a upper size of the cache, no more than 1 Mb on the physical device
  26.     cmp  eax,1024*1024
  27.     jbe  @f
  28.     mov  eax,1024*1024
  29.     jmp  .continue
  30. @@:
  31. ;       check a lower size of the cache, not less than 128 Kb on the physical device
  32.     cmp  eax,128*1024
  33.     jae  @f
  34.     mov  eax,128*1024
  35. @@:
  36. .continue:
  37.     mov  [cache_ide0_size],eax
  38.     mov  [cache_ide1_size],eax
  39.     mov  [cache_ide2_size],eax
  40.     mov  [cache_ide3_size],eax
  41.     xor  eax,eax
  42.     mov  [cache_ide0_search_start],eax
  43.     mov  [cache_ide0_appl_search_start],eax
  44.     mov  [cache_ide1_search_start],eax
  45.     mov  [cache_ide1_appl_search_start],eax
  46.     mov  [cache_ide2_search_start],eax
  47.     mov  [cache_ide2_appl_search_start],eax
  48.     mov  [cache_ide3_search_start],eax
  49.     mov  [cache_ide3_appl_search_start],eax
  50.     mov  [hdd_appl_data],1  ;al
  51.     mov  [cd_appl_data],1
  52.    
  53.     mov  cl,[DRIVE_DATA+1]
  54.     mov  ch,cl
  55.     and  cl,11b
  56.     cmp cl,0
  57.     je  .ide2
  58.     call get_cache_ide3
  59. .ide2:
  60.     mov  cl,ch
  61.     and  cl,1100b
  62.     cmp cl,0
  63.     je  .ide1
  64.     call get_cache_ide2
  65. .ide1:
  66.     mov  cl,ch
  67.     and  cl,110000b
  68.     cmp cl,0
  69.     je  .ide0
  70.     call get_cache_ide1
  71. .ide0:
  72.     mov  cl,ch
  73.     and  cl,11000000b
  74.     cmp cl,0
  75.     je  end_get_cache
  76.     call get_cache_ide0
  77.     jmp  end_get_cache
  78.  
  79. get_cache_ide0:
  80.     push  ecx
  81.     stdcall kernel_alloc,[cache_ide0_size]
  82.     mov [cache_ide0_pointer],eax
  83.     pop   ecx
  84.     mov  edx,eax
  85.     mov  eax,[cache_ide0_size]
  86.     shr  eax,3
  87.     mov  [cache_ide0_system_data_size],eax
  88.     mov  ebx,eax
  89.     imul eax,7
  90.     mov  [cache_ide0_appl_data_size],eax
  91.     add  ebx,edx
  92.     mov  [cache_ide0_data_pointer],ebx
  93.  
  94.     cmp cl,10000000b
  95.     je  .cd
  96.     push ecx
  97.     mov  eax,[cache_ide0_system_data_size]
  98.     call calculate_for_hd
  99.     add  eax,[cache_ide0_pointer]
  100.     mov  [cache_ide0_system_data],eax
  101.     mov  [cache_ide0_system_sad_size],ecx
  102.  
  103.     push  edi
  104.     mov   edi,[cache_ide0_pointer]
  105.     call  clear_ide_cache
  106.     pop   edi
  107.  
  108.     mov  eax,[cache_ide0_appl_data_size]
  109.     call calculate_for_hd
  110.     add  eax,[cache_ide0_data_pointer]
  111.     mov  [cache_ide0_appl_data],eax
  112.     mov  [cache_ide0_appl_sad_size],ecx
  113.  
  114.     push  edi
  115.     mov   edi,[cache_ide0_data_pointer]
  116.     call  clear_ide_cache
  117.     pop   edi
  118.  
  119.     pop  ecx
  120.     ret
  121. .cd:
  122.     push ecx
  123.     mov  eax,[cache_ide0_system_data_size]
  124.     call calculate_for_cd
  125.     add  eax,[cache_ide0_pointer]
  126.     mov  [cache_ide0_system_data],eax
  127.     mov  [cache_ide0_system_sad_size],ecx
  128.  
  129.     push  edi
  130.     mov   edi,[cache_ide0_pointer]
  131.     call  clear_ide_cache
  132.     pop   edi
  133.  
  134.     mov  eax,[cache_ide0_appl_data_size]
  135.     call calculate_for_cd
  136.     add  eax,[cache_ide0_data_pointer]
  137.     mov  [cache_ide0_appl_data],eax
  138.     mov  [cache_ide0_appl_sad_size],ecx
  139.  
  140.     push  edi
  141.     mov   edi,[cache_ide0_data_pointer]
  142.     call  clear_ide_cache
  143.     pop   edi
  144.  
  145.     pop  ecx
  146.     ret
  147.  
  148. get_cache_ide1:
  149.     push  ecx
  150.     stdcall kernel_alloc,[cache_ide1_size]
  151.     mov [cache_ide1_pointer],eax
  152.     pop   ecx
  153.     mov  edx,eax
  154.     mov  eax,[cache_ide1_size]
  155.     shr  eax,3
  156.     mov  [cache_ide1_system_data_size],eax
  157.     mov  ebx,eax
  158.     imul eax,7
  159.     mov  [cache_ide1_appl_data_size],eax
  160.     add  ebx,edx
  161.     mov  [cache_ide1_data_pointer],ebx
  162.  
  163.     cmp cl,100000b
  164.     je  .cd
  165.     push ecx
  166.     mov  eax,[cache_ide1_system_data_size]
  167.     call calculate_for_hd
  168.     add  eax,[cache_ide1_pointer]
  169.     mov  [cache_ide1_system_data],eax
  170.     mov  [cache_ide1_system_sad_size],ecx
  171.  
  172.     push  edi
  173.     mov   edi,[cache_ide1_pointer]
  174.     call  clear_ide_cache
  175.     pop   edi
  176.  
  177.     mov  eax,[cache_ide1_appl_data_size]
  178.     call calculate_for_hd
  179.     add  eax,[cache_ide1_data_pointer]
  180.     mov  [cache_ide1_appl_data],eax
  181.     mov  [cache_ide1_appl_sad_size],ecx
  182.  
  183.     push  edi
  184.     mov   edi,[cache_ide1_data_pointer]
  185.     call  clear_ide_cache
  186.     pop   edi
  187.  
  188.     pop  ecx
  189.     ret
  190. .cd:
  191.     push ecx
  192.     mov  eax,[cache_ide1_system_data_size]
  193.     call calculate_for_cd
  194.     add  eax,[cache_ide1_pointer]
  195.     mov  [cache_ide1_system_data],eax
  196.     mov  [cache_ide1_system_sad_size],ecx
  197.  
  198.     push  edi
  199.     mov   edi,[cache_ide1_pointer]
  200.     call  clear_ide_cache
  201.     pop   edi
  202.  
  203.     mov  eax,[cache_ide1_appl_data_size]
  204.     call calculate_for_cd
  205.     add  eax,[cache_ide1_data_pointer]
  206.     mov  [cache_ide1_appl_data],eax
  207.     mov  [cache_ide1_appl_sad_size],ecx
  208.  
  209.     push  edi
  210.     mov   edi,[cache_ide1_data_pointer]
  211.     call  clear_ide_cache
  212.     pop   edi
  213.  
  214.     pop  ecx
  215.     ret
  216.  
  217. get_cache_ide2:
  218.     push  ecx
  219.     stdcall kernel_alloc,[cache_ide2_size]
  220.     mov [cache_ide2_pointer],eax
  221.     pop   ecx
  222.     mov  edx,eax
  223.     mov  eax,[cache_ide2_size]
  224.     shr  eax,3
  225.     mov  [cache_ide2_system_data_size],eax
  226.     mov  ebx,eax
  227.     imul eax,7
  228.     mov  [cache_ide2_appl_data_size],eax
  229.     add  ebx,edx
  230.     mov  [cache_ide2_data_pointer],ebx
  231.  
  232.     cmp cl,1000b
  233.     je  .cd
  234.     push ecx
  235.     mov  eax,[cache_ide2_system_data_size]
  236.     call calculate_for_hd
  237.     add  eax,[cache_ide2_pointer]
  238.     mov  [cache_ide2_system_data],eax
  239.     mov  [cache_ide2_system_sad_size],ecx
  240.  
  241.     push  edi
  242.     mov   edi,[cache_ide2_pointer]
  243.     call  clear_ide_cache
  244.     pop   edi
  245.  
  246.     mov  eax,[cache_ide2_appl_data_size]
  247.     call calculate_for_hd
  248.     add  eax,[cache_ide2_data_pointer]
  249.     mov  [cache_ide2_appl_data],eax
  250.     mov  [cache_ide2_appl_sad_size],ecx
  251.  
  252.     push  edi
  253.     mov   edi,[cache_ide2_data_pointer]
  254.     call  clear_ide_cache
  255.     pop   edi
  256.  
  257.     pop  ecx
  258.     ret
  259. .cd:
  260.     push ecx
  261.     mov  eax,[cache_ide2_system_data_size]
  262.     call calculate_for_cd
  263.     add  eax,[cache_ide2_pointer]
  264.     mov  [cache_ide2_system_data],eax
  265.     mov  [cache_ide2_system_sad_size],ecx
  266.  
  267.     push  edi
  268.     mov   edi,[cache_ide2_pointer]
  269.     call  clear_ide_cache
  270.     pop   edi
  271.  
  272.     mov  eax,[cache_ide2_appl_data_size]
  273.     call calculate_for_cd
  274.     add  eax,[cache_ide2_data_pointer]
  275.     mov  [cache_ide2_appl_data],eax
  276.     mov  [cache_ide2_appl_sad_size],ecx
  277.  
  278.     push  edi
  279.     mov   edi,[cache_ide2_data_pointer]
  280.     call  clear_ide_cache
  281.     pop   edi
  282.  
  283.     pop  ecx
  284.     ret
  285.  
  286. get_cache_ide3:
  287.     push  ecx
  288.     stdcall kernel_alloc,[cache_ide3_size]
  289.     mov [cache_ide3_pointer],eax
  290.     pop   ecx
  291.     mov  edx,eax
  292.     mov  eax,[cache_ide3_size]
  293.     shr  eax,3
  294.     mov  [cache_ide3_system_data_size],eax
  295.     mov  ebx,eax
  296.     imul eax,7
  297.     mov  [cache_ide3_appl_data_size],eax
  298.     add  ebx,edx
  299.     mov  [cache_ide3_data_pointer],ebx
  300.  
  301.     cmp cl,10b
  302.     je  .cd
  303.     push ecx
  304.     mov  eax,[cache_ide3_system_data_size]
  305.     call calculate_for_hd
  306.     add  eax,[cache_ide3_pointer]
  307.     mov  [cache_ide3_system_data],eax
  308.     mov  [cache_ide3_system_sad_size],ecx
  309.  
  310.     push  edi
  311.     mov   edi,[cache_ide3_pointer]
  312.     call  clear_ide_cache
  313.     pop   edi
  314.  
  315.     mov  eax,[cache_ide3_appl_data_size]
  316.     call calculate_for_hd
  317.     add  eax,[cache_ide3_data_pointer]
  318.     mov  [cache_ide3_appl_data],eax
  319.     mov  [cache_ide3_appl_sad_size],ecx
  320.  
  321.     push  edi
  322.     mov   edi,[cache_ide3_data_pointer]
  323.     call  clear_ide_cache
  324.     pop   edi
  325.  
  326.     pop  ecx
  327.     ret
  328. .cd:
  329.     push ecx
  330.     mov  eax,[cache_ide3_system_data_size]
  331.     call calculate_for_cd
  332.     add  eax,[cache_ide3_pointer]
  333.     mov  [cache_ide3_system_data],eax
  334.     mov  [cache_ide3_system_sad_size],ecx
  335.  
  336.     push  edi
  337.     mov   edi,[cache_ide3_pointer]
  338.     call  clear_ide_cache
  339.     pop   edi
  340.  
  341.     mov  eax,[cache_ide3_appl_data_size]
  342.     call calculate_for_cd
  343.     add  eax,[cache_ide3_data_pointer]
  344.     mov  [cache_ide3_appl_data],eax
  345.     mov  [cache_ide3_appl_sad_size],ecx
  346.  
  347.     push  edi
  348.     mov   edi,[cache_ide3_data_pointer]
  349.     call  clear_ide_cache
  350.     pop   edi
  351.  
  352.     pop  ecx
  353.     ret
  354.  
  355. calculate_for_hd:
  356.     push eax
  357.     mov  ebx,eax
  358.     shr  eax,9
  359.     shl  eax,3
  360.     sub  ebx,eax
  361.     shr  ebx,9
  362.     mov  ecx,ebx
  363.     shl  ebx,9
  364.     pop  eax
  365.     sub  eax,ebx
  366.     dec  ecx
  367.     ret
  368.  
  369. calculate_for_cd:
  370.     push eax
  371.     mov  ebx,eax
  372.     shr  eax,11
  373.     shl  eax,3
  374.     sub  ebx,eax
  375.     shr  ebx,11
  376.     mov  ecx,ebx
  377.     shl  ebx,11
  378.     pop  eax
  379.     sub  eax,ebx
  380.     dec  ecx
  381.     ret
  382.  
  383. clear_ide_cache:
  384.     push   eax
  385.     shl   ecx,1
  386.     xor   eax,eax
  387.     cld
  388.     rep   stosd
  389.     pop   eax
  390.     ret
  391.  
  392. end_get_cache:
  393. ;    mov  [cache_ide0_pointer],HD_CACHE
  394. ;    mov  [cache_ide0_system_data],HD_CACHE+65536
  395. ;    mov  [cache_ide0_system_sad_size],1919
  396.     popa