Subversion Repositories Kolibri OS

Rev

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

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