/kernel/trunk/blkdev/hd_drv.inc |
---|
9,20 → 9,6 |
; Low-level driver for HDD access |
; DMA support by Mario79 |
;************************************************************************** |
; |
; 0x600008 - first entry in cache list |
; |
; +0 - lba sector |
; +4 - state of cache sector |
; 0 = empty |
; 1 = used for read ( same as in hd ) |
; 2 = used for write ( differs from hd ) |
; |
; +65536 - cache entries |
; |
;************************************************************************** |
align 4 |
hd_read: |
;----------------------------------------------------------- |
32,8 → 18,11 |
and [hd_error], 0 |
push ecx esi edi ; scan cache |
mov ecx,cache_max ; entries in cache |
mov esi,HD_CACHE+8 |
; mov ecx,cache_max ; entries in cache |
; mov esi,HD_CACHE+8 |
call calculate_cache |
add esi,8 |
mov edi,1 |
hdreadcache: |
64,8 → 53,12 |
.nodma: |
call hd_read_pio |
@@: |
; lea esi,[edi*8+HD_CACHE] |
; push eax |
call calculate_cache_1 |
lea esi,[edi*8+esi] |
; pop eax |
lea esi,[edi*8+HD_CACHE] |
mov [esi],eax ; sector number |
mov dword [esi+4],1 ; hd read - mark as same as in hd |
73,7 → 66,12 |
mov esi,edi |
shl esi,9 |
add esi,HD_CACHE+65536 |
; add esi,HD_CACHE+65536 |
push eax |
call calculate_cache_2 |
add esi,eax |
pop eax |
mov edi,ebx |
mov ecx,512/4 |
cld |
126,7 → 124,12 |
cli |
push edi |
shl edi,9 |
add edi,HD_CACHE+65536 |
; add edi,HD_CACHE+65536 |
push eax |
call calculate_cache_2 |
add edi,eax |
pop eax |
mov ecx,256 |
mov edx,[hdbase] |
cld |
163,8 → 166,11 |
; check if the cache already has the sector and overwrite it |
mov ecx,cache_max |
mov esi,HD_CACHE+8 |
; mov ecx,cache_max |
; mov esi,HD_CACHE+8 |
call calculate_cache |
add esi,8 |
mov edi,1 |
hdwritecache: |
189,7 → 195,12 |
cmp [hd_error],0 |
jne hd_write_access_denied |
lea esi,[edi*8+HD_CACHE] |
; lea esi,[edi*8+HD_CACHE] |
; push eax |
call calculate_cache_1 |
lea esi,[edi*8+esi] |
; pop eax |
mov [esi],eax ; sector number |
yes_in_cache_write: |
197,7 → 208,12 |
mov dword [esi+4],2 ; write - differs from hd |
shl edi,9 |
add edi,HD_CACHE+65536 |
; add edi,HD_CACHE+65536 |
push eax |
call calculate_cache_2 |
add edi,eax |
pop eax |
mov esi,ebx |
mov ecx,512/4 |
cld |
206,98 → 222,15 |
pop edi esi ecx |
ret |
write_cache: |
;----------------------------------------------------------- |
; write all changed sectors to disk |
;----------------------------------------------------------- |
push eax ecx edx esi edi |
; write difference ( 2 ) from cache to hd |
mov ecx,cache_max |
mov esi,HD_CACHE+8 |
mov edi,1 |
write_cache_more: |
cmp dword [esi+4],2 ; if cache slot is not different |
jne .write_chain |
mov dword [esi+4],1 ; same as in hd |
mov eax,[esi] ; eax = sector to write |
cmp eax,[PARTITION_START] |
jb danger |
cmp eax,[PARTITION_END] |
ja danger |
; DMA write is permitted only if [allow_dma_access]=1 |
cmp [allow_dma_access], 2 |
jae .nodma |
cmp [dma_hdd], 1 |
jnz .nodma |
; ¡ê¥¤¨ï¥¬ § ¯¨áì 楯®çª¨ ¯®á«¥¤®¢ ⥫ìëå ᥪâ®à®¢ ¢ ®¤® ®¡à 饨¥ ª ¤¨áªã |
cmp ecx, 1 |
jz .nonext |
cmp dword [esi+8+4], 2 |
jnz .nonext |
push eax |
inc eax |
cmp eax, [esi+8] |
pop eax |
jnz .nonext |
cmp [cache_chain_started], 1 |
jz @f |
mov [cache_chain_started], 1 |
mov [cache_chain_size], 0 |
mov [cache_chain_pos], edi |
mov [cache_chain_ptr], esi |
@@: |
inc [cache_chain_size] |
cmp [cache_chain_size], 64 |
jnz .continue |
jmp .write_chain |
.nonext: |
call flush_cache_chain |
mov [cache_chain_size], 1 |
mov [cache_chain_ptr], esi |
call write_cache_sector |
jmp .continue |
.nodma: |
call cache_write_pio |
.write_chain: |
call flush_cache_chain |
.continue: |
danger: |
add esi,8 |
inc edi |
dec ecx |
jnz write_cache_more |
call flush_cache_chain |
return_02: |
pop edi esi edx ecx eax |
ret |
flush_cache_chain: |
cmp [cache_chain_started], 0 |
jz @f |
call write_cache_chain |
mov [cache_chain_started], 0 |
@@: |
ret |
align 4 |
cache_write_pio: |
call disable_ide_int |
; call disable_ide_int |
call wait_for_hd_idle |
cmp [hd_error],0 |
jne hd_write_error |
; cli |
cli |
xor eax,eax |
mov edx,[hdbase] |
inc edx |
323,7 → 256,7 |
inc edx |
mov al,30h |
out dx,al |
; sti |
sti |
call wait_for_sector_buffer |
332,75 → 265,26 |
push ecx esi |
; cli |
cli |
mov esi,edi |
shl esi,9 |
add esi,HD_CACHE+65536 ; esi = from memory position |
; add esi,HD_CACHE+65536 ; esi = from memory position |
push eax |
call calculate_cache_2 |
add esi,eax |
pop eax |
mov ecx,256 |
mov edx,[hdbase] |
cld |
rep outsw |
; sti |
sti |
call enable_ide_int |
; call enable_ide_int |
pop esi ecx |
ret |
align 4 |
find_empty_slot: |
;----------------------------------------------------------- |
; find empty or read slot, flush cache if next 10% is used by write |
; output : edi = cache slot |
;----------------------------------------------------------- |
; push ecx esi |
search_again: |
mov ecx,cache_max*10/100 |
mov edi,[cache_search_start] |
search_for_empty: |
inc edi |
cmp edi,cache_max |
jbe inside_cache |
mov edi,1 |
inside_cache: |
cmp dword [edi*8+HD_CACHE+4],2 ; get cache slot info |
jb found_slot ; it's empty or read |
dec ecx |
jnz search_for_empty |
call write_cache ; no empty slots found, write all |
cmp [hd_error],0 |
jne found_slot_access_denied |
jmp search_again ; and start again |
found_slot: |
mov [cache_search_start],edi |
found_slot_access_denied: |
ret |
align 4 |
clear_hd_cache: |
push eax ecx edi |
mov edi, HD_CACHE |
mov ecx,16384 |
xor eax,eax |
cld |
rep stosd ; clear hd cache with 0 |
mov [cache_search_start],eax |
mov [fat_in_cache],-1 |
mov [fat_change],0 |
pop edi ecx eax |
ret |
save_hd_wait_timeout: |
push eax |
684,7 → 568,12 |
push ecx esi edi |
mov esi, eax |
shl edi, 9 |
add edi, HD_CACHE+0x10000 |
; add edi, HD_CACHE+0x10000 |
push eax |
call calculate_cache_2 |
add edi,eax |
pop eax |
mov ecx, 512/4 |
cld |
rep movsd |
774,26 → 663,27 |
jmp hd_read_dma |
align 4 |
write_cache_sector: |
mov [cache_chain_size],1 |
mov [cache_chain_pos],edi |
write_cache_chain: |
push esi |
mov eax, IDE_descriptor_table |
mov edx, [cache_chain_pos] |
shl edx, 9 |
add edx, DMA_HD_MEM+0x10000 |
mov [eax], edx |
movzx edx, [cache_chain_size] |
shl edx, 9 |
mov [eax+4], dx |
jmp do_write_dma |
write_cache_sector: |
push esi |
mov eax, IDE_descriptor_table |
mov edx, edi |
shl edx, 9 |
add edx, DMA_HD_MEM+0x10000 |
mov [eax], edx |
mov word [eax+4], 0x200 |
do_write_dma: |
mov edx,eax |
pusha |
mov esi,[cache_chain_pos] |
shl esi, 9 |
call calculate_cache_2 |
add esi,eax |
mov edi,OS_BASE+0x284000 ;HD_CACHE |
mov dword [edx], 0x284000 ;DMA_HD_MEM |
movzx ecx, [cache_chain_size] |
shl ecx, 9 |
mov word [edx+4], cx |
shr ecx,2 |
cld |
rep movsd |
popa |
sub eax, OS_BASE |
mov dx, [IDEContrRegsBaseAddr] |
cmp [hdbase], 0x1F0 |
/kernel/trunk/blkdev/ide_cache.inc |
---|
0,0 → 1,457 |
;************************************************************************** |
; |
; [cache_ide[X]_pointer] |
; or [cache_ide[X]_data_pointer] first entry in cache list |
; |
; +0 - lba sector |
; +4 - state of cache sector |
; 0 = empty |
; 1 = used for read ( same as in hd ) |
; 2 = used for write ( differs from hd ) |
; |
; [cache_ide[X]_system_data] |
; or [cache_ide[x]_appl_data] - cache entries |
; |
;************************************************************************** |
align 4 |
write_cache: |
;----------------------------------------------------------- |
; write all changed sectors to disk |
;----------------------------------------------------------- |
push eax ecx edx esi edi |
; write difference ( 2 ) from cache to hd |
; mov ecx,cache_max |
; mov esi,HD_CACHE+8 |
call calculate_cache |
add esi,8 |
mov edi,1 |
write_cache_more: |
cmp dword [esi+4],2 ; if cache slot is not different |
jne .write_chain |
mov dword [esi+4],1 ; same as in hd |
mov eax,[esi] ; eax = sector to write |
cmp eax,[PARTITION_START] |
jb danger |
cmp eax,[PARTITION_END] |
ja danger |
; DMA write is permitted only if [allow_dma_access]=1 |
cmp [allow_dma_access], 2 |
jae .nodma |
cmp [dma_hdd], 1 |
jnz .nodma |
; ¡ê¥¤¨ï¥¬ § ¯¨áì 楯®çª¨ ¯®á«¥¤®¢ ⥫ìëå ᥪâ®à®¢ ¢ ®¤® ®¡à 饨¥ ª ¤¨áªã |
cmp ecx, 1 |
jz .nonext |
cmp dword [esi+8+4], 2 |
jnz .nonext |
push eax |
inc eax |
cmp eax, [esi+8] |
pop eax |
jnz .nonext |
cmp [cache_chain_started], 1 |
jz @f |
mov [cache_chain_started], 1 |
mov [cache_chain_size], 0 |
mov [cache_chain_pos], edi |
mov [cache_chain_ptr], esi |
@@: |
inc [cache_chain_size] |
cmp [cache_chain_size], 64 |
jnz .continue |
jmp .write_chain |
.nonext: |
call flush_cache_chain |
mov [cache_chain_size], 1 |
mov [cache_chain_ptr], esi |
call write_cache_sector |
jmp .continue |
.nodma: |
call cache_write_pio |
.write_chain: |
call flush_cache_chain |
.continue: |
danger: |
add esi,8 |
inc edi |
dec ecx |
jnz write_cache_more |
call flush_cache_chain |
return_02: |
pop edi esi edx ecx eax |
ret |
flush_cache_chain: |
cmp [cache_chain_started], 0 |
jz @f |
call write_cache_chain |
mov [cache_chain_started], 0 |
@@: |
ret |
align 4 |
find_empty_slot: |
;----------------------------------------------------------- |
; find empty or read slot, flush cache if next 10% is used by write |
; output : edi = cache slot |
;----------------------------------------------------------- |
; push ecx esi |
search_again: |
; mov ecx,cache_max*10/100 |
; mov edi,[cache_search_start] |
call calculate_cache_3 |
; push eax edx |
; mov eax,ecx |
; mov ecx,10 |
; xor edx,edx |
; div ecx |
; mov ecx,eax |
; pop edx eax |
shr ecx,3 |
search_for_empty: |
inc edi |
; cmp edi,cache_max |
; push eax |
call calculate_cache_4 |
; cmp edi,eax |
; pop eax |
jbe inside_cache |
mov edi,1 |
inside_cache: |
; cmp dword [edi*8+HD_CACHE+4],2 ; get cache slot info |
push esi |
call calculate_cache_1 |
cmp dword [edi*8+esi+4],2 |
pop esi |
jb found_slot ; it's empty or read |
dec ecx |
jnz search_for_empty |
call write_cache ; no empty slots found, write all |
cmp [hd_error],0 |
jne found_slot_access_denied |
jmp search_again ; and start again |
found_slot: |
; mov [cache_search_start],edi |
call calculate_cache_5 |
found_slot_access_denied: |
ret |
align 4 |
clear_hd_cache: |
; push eax ecx edi |
; mov edi, HD_CACHE |
; mov ecx,16384 |
; xor eax,eax |
; cld |
; rep stosd ; clear hd cache with 0 |
; mov [cache_search_start],eax |
mov [fat_in_cache],-1 |
mov [fat_change],0 |
; pop edi ecx eax |
ret |
;-------------------------------------------------------------------- |
align 4 |
calculate_cache: |
; mov ecx,cache_max ; entries in cache |
; mov esi,HD_CACHE+8 |
; 1 - IDE0 ... 4 - IDE3 |
.ide0: |
cmp [hdpos],1 |
jne .ide1 |
cmp [hdd_appl_data],0 |
jne .ide0_appl_data |
mov ecx,[cache_ide0_system_sad_size] |
mov esi,[cache_ide0_pointer] |
ret |
.ide0_appl_data: |
mov ecx,[cache_ide0_appl_sad_size] |
mov esi,[cache_ide0_data_pointer] |
ret |
.ide1: |
cmp [hdpos],2 |
jne .ide2 |
cmp [hdd_appl_data],0 |
jne .ide1_appl_data |
mov ecx,[cache_ide1_system_sad_size] |
mov esi,[cache_ide1_pointer] |
ret |
.ide1_appl_data: |
mov ecx,[cache_ide1_appl_sad_size] |
mov esi,[cache_ide1_data_pointer] |
ret |
.ide2: |
cmp [hdpos],3 |
jne .ide3 |
cmp [hdd_appl_data],0 |
jne .ide2_appl_data |
mov ecx,[cache_ide2_system_sad_size] |
mov esi,[cache_ide2_pointer] |
ret |
.ide2_appl_data: |
mov ecx,[cache_ide2_appl_sad_size] |
mov esi,[cache_ide2_data_pointer] |
ret |
.ide3: |
cmp [hdd_appl_data],0 |
jne .ide3_appl_data |
mov ecx,[cache_ide3_system_sad_size] |
mov esi,[cache_ide3_pointer] |
ret |
.ide3_appl_data: |
mov ecx,[cache_ide3_appl_sad_size] |
mov esi,[cache_ide3_data_pointer] |
ret |
;-------------------------------------------------------------------- |
align 4 |
calculate_cache_1: |
; lea esi,[edi*8+HD_CACHE] |
; 1 - IDE0 ... 4 - IDE3 |
.ide0: |
cmp [hdpos],1 |
jne .ide1 |
cmp [hdd_appl_data],0 |
jne .ide0_appl_data |
mov esi,[cache_ide0_pointer] |
ret |
.ide0_appl_data: |
mov esi,[cache_ide0_data_pointer] |
ret |
.ide1: |
cmp [hdpos],2 |
jne .ide2 |
cmp [hdd_appl_data],0 |
jne .ide1_appl_data |
mov esi,[cache_ide1_pointer] |
ret |
.ide1_appl_data: |
mov esi,[cache_ide1_data_pointer] |
ret |
.ide2: |
cmp [hdpos],3 |
jne .ide3 |
cmp [hdd_appl_data],0 |
jne .ide2_appl_data |
mov esi,[cache_ide2_pointer] |
ret |
.ide2_appl_data: |
mov esi,[cache_ide2_data_pointer] |
ret |
.ide3: |
cmp [hdd_appl_data],0 |
jne .ide3_appl_data |
mov esi,[cache_ide3_pointer] |
ret |
.ide3_appl_data: |
mov esi,[cache_ide3_data_pointer] |
ret |
;-------------------------------------------------------------------- |
align 4 |
calculate_cache_2: |
; add esi,HD_CACHE+65536 |
; 1 - IDE0 ... 4 - IDE3 |
.ide0: |
cmp [hdpos],1 |
jne .ide1 |
cmp [hdd_appl_data],0 |
jne .ide0_appl_data |
mov eax,[cache_ide0_system_data] |
ret |
.ide0_appl_data: |
mov eax,[cache_ide0_appl_data] |
ret |
.ide1: |
cmp [hdpos],2 |
jne .ide2 |
cmp [hdd_appl_data],0 |
jne .ide1_appl_data |
mov eax,[cache_ide1_system_data] |
ret |
.ide1_appl_data: |
mov eax,[cache_ide1_appl_data] |
ret |
.ide2: |
cmp [hdpos],3 |
jne .ide3 |
cmp [hdd_appl_data],0 |
jne .ide2_appl_data |
mov eax,[cache_ide2_system_data] |
ret |
.ide2_appl_data: |
mov eax,[cache_ide2_appl_data] |
ret |
.ide3: |
cmp [hdd_appl_data],0 |
jne .ide3_appl_data |
mov eax,[cache_ide3_system_data] |
ret |
.ide3_appl_data: |
mov eax,[cache_ide3_appl_data] |
ret |
;-------------------------------------------------------------------- |
align 4 |
calculate_cache_3: |
; mov ecx,cache_max*10/100 |
; mov edi,[cache_search_start] |
; 1 - IDE0 ... 4 - IDE3 |
.ide0: |
cmp [hdpos],1 |
jne .ide1 |
cmp [hdd_appl_data],0 |
jne .ide0_appl_data |
mov ecx,[cache_ide0_system_sad_size] |
mov edi,[cache_ide0_search_start] |
ret |
.ide0_appl_data: |
mov ecx,[cache_ide0_appl_sad_size] |
mov edi,[cache_ide0_appl_search_start] |
ret |
.ide1: |
cmp [hdpos],2 |
jne .ide2 |
cmp [hdd_appl_data],0 |
jne .ide1_appl_data |
mov ecx,[cache_ide1_system_sad_size] |
mov edi,[cache_ide1_search_start] |
ret |
.ide1_appl_data: |
mov ecx,[cache_ide1_appl_sad_size] |
mov edi,[cache_ide1_appl_search_start] |
ret |
.ide2: |
cmp [hdpos],3 |
jne .ide3 |
cmp [hdd_appl_data],0 |
jne .ide2_appl_data |
mov ecx,[cache_ide2_system_sad_size] |
mov edi,[cache_ide2_search_start] |
ret |
.ide2_appl_data: |
mov ecx,[cache_ide2_appl_sad_size] |
mov edi,[cache_ide2_appl_search_start] |
ret |
.ide3: |
cmp [hdd_appl_data],0 |
jne .ide3_appl_data |
mov ecx,[cache_ide3_system_sad_size] |
mov edi,[cache_ide3_search_start] |
ret |
.ide3_appl_data: |
mov ecx,[cache_ide3_appl_sad_size] |
mov edi,[cache_ide3_appl_search_start] |
ret |
;-------------------------------------------------------------------- |
align 4 |
calculate_cache_4: |
; cmp edi,cache_max |
; 1 - IDE0 ... 4 - IDE3 |
.ide0: |
cmp [hdpos],1 |
jne .ide1 |
cmp [hdd_appl_data],0 |
jne .ide0_appl_data |
cmp edi,[cache_ide0_system_sad_size] |
ret |
.ide0_appl_data: |
cmp edi,[cache_ide0_appl_sad_size] |
ret |
.ide1: |
cmp [hdpos],2 |
jne .ide2 |
cmp [hdd_appl_data],0 |
jne .ide1_appl_data |
cmp edi,[cache_ide1_system_sad_size] |
ret |
.ide1_appl_data: |
cmp edi,[cache_ide1_appl_sad_size] |
ret |
.ide2: |
cmp [hdpos],3 |
jne .ide3 |
cmp [hdd_appl_data],0 |
jne .ide2_appl_data |
cmp edi,[cache_ide2_system_sad_size] |
ret |
.ide2_appl_data: |
cmp edi,[cache_ide2_appl_sad_size] |
ret |
.ide3: |
cmp [hdd_appl_data],0 |
jne .ide3_appl_data |
cmp edi,[cache_ide3_system_sad_size] |
ret |
.ide3_appl_data: |
cmp edi,[cache_ide3_appl_sad_size] |
ret |
;-------------------------------------------------------------------- |
align 4 |
calculate_cache_5: |
; mov [cache_search_start],edi |
; 1 - IDE0 ... 4 - IDE3 |
.ide0: |
cmp [hdpos],1 |
jne .ide1 |
cmp [hdd_appl_data],0 |
jne .ide0_appl_data |
mov [cache_ide0_search_start],edi |
ret |
.ide0_appl_data: |
mov [cache_ide0_appl_search_start],edi |
ret |
.ide1: |
cmp [hdpos],2 |
jne .ide2 |
cmp [hdd_appl_data],0 |
jne .ide1_appl_data |
mov [cache_ide1_search_start],edi |
ret |
.ide1_appl_data: |
mov [cache_ide1_appl_search_start],edi |
ret |
.ide2: |
cmp [hdpos],3 |
jne .ide3 |
cmp [hdd_appl_data],0 |
jne .ide2_appl_data |
mov [cache_ide2_search_start],edi |
ret |
.ide2_appl_data: |
mov [cache_ide2_appl_search_start],edi |
ret |
.ide3: |
cmp [hdd_appl_data],0 |
jne .ide3_appl_data |
mov [cache_ide3_search_start],edi |
ret |
.ide3_appl_data: |
mov [cache_ide3_appl_search_start],edi |
ret |
;-------------------------------------------------------------------- |
align 4 |
calculate_linear_to_real: |
shr eax, 12 |
mov eax, [page_tabs+eax*4] |
and eax, 0xFFFFF000 |
ret |
/kernel/trunk/const.inc |
---|
292,8 → 292,8 |
IRQ_SAVE equ (OS_BASE+0x02E0000) |
BOOT_VAR equ (OS_BASE+0x02f0000) |
DMA_HD_MEM equ 0x0300000 |
HD_CACHE equ (OS_BASE+DMA_HD_MEM) |
; DMA_HD_MEM equ 0x0300000 |
; HD_CACHE equ (OS_BASE+DMA_HD_MEM) |
stack_data_start equ (OS_BASE+0x0400000) |
eth_data_start equ (OS_BASE+0x0400000) |
/kernel/trunk/data32.inc |
---|
337,6 → 337,57 |
mem_BACKGROUND rd 1 |
wraw_bacground_select rb 1 |
cache_ide0_pointer rd 1 |
cache_ide0_size rd 1 ; not use |
cache_ide0_data_pointer rd 1 |
cache_ide0_system_data_size rd 1 ; not use |
cache_ide0_appl_data_size rd 1 ; not use |
cache_ide0_system_data rd 1 |
cache_ide0_appl_data rd 1 |
cache_ide0_system_sad_size rd 1 |
cache_ide0_appl_sad_size rd 1 |
cache_ide0_search_start rd 1 |
cache_ide0_appl_search_start rd 1 |
cache_ide1_pointer rd 1 |
cache_ide1_size rd 1 ; not use |
cache_ide1_data_pointer rd 1 |
cache_ide1_system_data_size rd 1 ; not use |
cache_ide1_appl_data_size rd 1 ; not use |
cache_ide1_system_data rd 1 |
cache_ide1_appl_data rd 1 |
cache_ide1_system_sad_size rd 1 |
cache_ide1_appl_sad_size rd 1 |
cache_ide1_search_start rd 1 |
cache_ide1_appl_search_start rd 1 |
cache_ide2_pointer rd 1 |
cache_ide2_size rd 1 ; not use |
cache_ide2_data_pointer rd 1 |
cache_ide2_system_data_size rd 1 ; not use |
cache_ide2_appl_data_size rd 1 ; not use |
cache_ide2_system_data rd 1 |
cache_ide2_appl_data rd 1 |
cache_ide2_system_sad_size rd 1 |
cache_ide2_appl_sad_size rd 1 |
cache_ide2_search_start rd 1 |
cache_ide2_appl_search_start rd 1 |
cache_ide3_pointer rd 1 |
cache_ide3_size rd 1 ; not use |
cache_ide3_data_pointer rd 1 |
cache_ide3_system_data_size rd 1 ; not use |
cache_ide3_appl_data_size rd 1 ; not use |
cache_ide3_system_data rd 1 |
cache_ide3_appl_data rd 1 |
cache_ide3_system_sad_size rd 1 |
cache_ide3_appl_sad_size rd 1 |
cache_ide3_search_start rd 1 |
cache_ide3_appl_search_start rd 1 |
debug_step_pointer rd 1 |
hdd_appl_data rb 1 ; 0 = system cache, 1 - application cache |
lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled |
pci_access_enabled rd 1 ; 0 = disabled , 1 = enabled |
timer_ticks_enable rb 1 ; for cd driver |
/kernel/trunk/detect/disks.inc |
---|
1,5 → 1,6 |
$Revision$ |
include 'dev_fd.inc' |
include 'dev_hdcd.inc' |
include 'getcache.inc' |
include 'sear_par.inc' |
/kernel/trunk/detect/getcache.inc |
---|
0,0 → 1,389 |
;cache_ide0_pointer dd 0 |
;cache_ide0_size dd 0 ; not use |
;cache_ide0_data_pointer dd 0 |
;cache_ide0_system_data_size dd 0 ; not use |
;cache_ide0_appl_data_size dd 0 ; not use |
;cache_ide0_system_data dd 0 |
;cache_ide0_appl_data dd 0 |
;cache_ide0_system_sad_size dd 0 |
;cache_ide0_appl_sad_size dd 0 |
pusha |
mov eax,[pg_data.pages_free] |
; 1/32 |
shr eax,5 |
; round off up to 8 pages |
shr eax,3 |
shl eax,3 |
; translate pages in butes *4096 |
shl eax,12 |
; check a upper size of the cache, no more than 1 Mb on the physical device |
cmp eax,1024*1024 |
jbe @f |
mov eax,1024*1024 |
jmp .continue |
@@: |
; check a lower size of the cache, not less than 128 Kb on the physical device |
cmp eax,128*1024 |
jae @f |
mov eax,128*1024 |
@@: |
.continue: |
mov [cache_ide0_size],eax |
mov [cache_ide1_size],eax |
mov [cache_ide2_size],eax |
mov [cache_ide3_size],eax |
xor eax,eax |
mov [cache_ide0_search_start],eax |
mov [cache_ide0_appl_search_start],eax |
mov [cache_ide1_search_start],eax |
mov [cache_ide1_appl_search_start],eax |
mov [cache_ide2_search_start],eax |
mov [cache_ide2_appl_search_start],eax |
mov [cache_ide3_search_start],eax |
mov [cache_ide3_appl_search_start],eax |
mov [hdd_appl_data],1 ;al |
mov cl,[DRIVE_DATA+1] |
mov ch,cl |
and cl,11b |
cmp cl,0 |
je .ide2 |
call get_cache_ide3 |
.ide2: |
mov cl,ch |
and cl,1100b |
cmp cl,0 |
je .ide1 |
call get_cache_ide2 |
.ide1: |
mov cl,ch |
and cl,110000b |
cmp cl,0 |
je .ide0 |
call get_cache_ide1 |
.ide0: |
mov cl,ch |
and cl,11000000b |
cmp cl,0 |
je end_get_cache |
call get_cache_ide0 |
jmp end_get_cache |
get_cache_ide0: |
push ecx |
stdcall kernel_alloc,[cache_ide0_size] |
mov [cache_ide0_pointer],eax |
pop ecx |
mov edx,eax |
mov eax,[cache_ide0_size] |
shr eax,3 |
mov [cache_ide0_system_data_size],eax |
mov ebx,eax |
imul eax,7 |
mov [cache_ide0_appl_data_size],eax |
add ebx,edx |
mov [cache_ide0_data_pointer],ebx |
cmp cl,10000000b |
je .cd |
push ecx |
mov eax,[cache_ide0_system_data_size] |
call calculate_for_hd |
add eax,[cache_ide0_pointer] |
mov [cache_ide0_system_data],eax |
mov [cache_ide0_system_sad_size],ecx |
push edi |
mov edi,[cache_ide0_pointer] |
call clear_ide_cache |
pop edi |
mov eax,[cache_ide0_appl_data_size] |
call calculate_for_hd |
add eax,[cache_ide0_data_pointer] |
mov [cache_ide0_appl_data],eax |
mov [cache_ide0_appl_sad_size],ecx |
push edi |
mov edi,[cache_ide0_data_pointer] |
call clear_ide_cache |
pop edi |
pop ecx |
ret |
.cd: |
push ecx |
mov eax,[cache_ide0_system_data_size] |
call calculate_for_cd |
add eax,[cache_ide0_pointer] |
mov [cache_ide0_system_data],eax |
mov [cache_ide0_system_sad_size],ecx |
push edi |
mov edi,[cache_ide0_pointer] |
call clear_ide_cache |
pop edi |
mov eax,[cache_ide0_appl_data_size] |
call calculate_for_cd |
add eax,[cache_ide0_data_pointer] |
mov [cache_ide0_appl_data],eax |
mov [cache_ide0_appl_sad_size],ecx |
push edi |
mov edi,[cache_ide0_data_pointer] |
call clear_ide_cache |
pop edi |
pop ecx |
ret |
get_cache_ide1: |
push ecx |
stdcall kernel_alloc,[cache_ide1_size] |
mov [cache_ide1_pointer],eax |
pop ecx |
mov edx,eax |
mov eax,[cache_ide1_size] |
shr eax,3 |
mov [cache_ide1_system_data_size],eax |
mov ebx,eax |
imul eax,7 |
mov [cache_ide1_appl_data_size],eax |
add ebx,edx |
mov [cache_ide1_data_pointer],ebx |
cmp cl,100000b |
je .cd |
push ecx |
mov eax,[cache_ide1_system_data_size] |
call calculate_for_hd |
add eax,[cache_ide1_pointer] |
mov [cache_ide1_system_data],eax |
mov [cache_ide1_system_sad_size],ecx |
push edi |
mov edi,[cache_ide1_pointer] |
call clear_ide_cache |
pop edi |
mov eax,[cache_ide1_appl_data_size] |
call calculate_for_hd |
add eax,[cache_ide1_data_pointer] |
mov [cache_ide1_appl_data],eax |
mov [cache_ide1_appl_sad_size],ecx |
push edi |
mov edi,[cache_ide1_data_pointer] |
call clear_ide_cache |
pop edi |
pop ecx |
ret |
.cd: |
push ecx |
mov eax,[cache_ide1_system_data_size] |
call calculate_for_cd |
add eax,[cache_ide1_pointer] |
mov [cache_ide1_system_data],eax |
mov [cache_ide1_system_sad_size],ecx |
push edi |
mov edi,[cache_ide1_pointer] |
call clear_ide_cache |
pop edi |
mov eax,[cache_ide1_appl_data_size] |
call calculate_for_cd |
add eax,[cache_ide1_data_pointer] |
mov [cache_ide1_appl_data],eax |
mov [cache_ide1_appl_sad_size],ecx |
push edi |
mov edi,[cache_ide1_data_pointer] |
call clear_ide_cache |
pop edi |
pop ecx |
ret |
get_cache_ide2: |
push ecx |
stdcall kernel_alloc,[cache_ide2_size] |
mov [cache_ide2_pointer],eax |
pop ecx |
mov edx,eax |
mov eax,[cache_ide2_size] |
shr eax,3 |
mov [cache_ide2_system_data_size],eax |
mov ebx,eax |
imul eax,7 |
mov [cache_ide2_appl_data_size],eax |
add ebx,edx |
mov [cache_ide2_data_pointer],ebx |
cmp cl,1000b |
je .cd |
push ecx |
mov eax,[cache_ide2_system_data_size] |
call calculate_for_hd |
add eax,[cache_ide2_pointer] |
mov [cache_ide2_system_data],eax |
mov [cache_ide2_system_sad_size],ecx |
push edi |
mov edi,[cache_ide2_pointer] |
call clear_ide_cache |
pop edi |
mov eax,[cache_ide2_appl_data_size] |
call calculate_for_hd |
add eax,[cache_ide2_data_pointer] |
mov [cache_ide2_appl_data],eax |
mov [cache_ide2_appl_sad_size],ecx |
push edi |
mov edi,[cache_ide2_data_pointer] |
call clear_ide_cache |
pop edi |
pop ecx |
ret |
.cd: |
push ecx |
mov eax,[cache_ide2_system_data_size] |
call calculate_for_cd |
add eax,[cache_ide2_pointer] |
mov [cache_ide2_system_data],eax |
mov [cache_ide2_system_sad_size],ecx |
push edi |
mov edi,[cache_ide2_pointer] |
call clear_ide_cache |
pop edi |
mov eax,[cache_ide2_appl_data_size] |
call calculate_for_cd |
add eax,[cache_ide2_data_pointer] |
mov [cache_ide2_appl_data],eax |
mov [cache_ide2_appl_sad_size],ecx |
push edi |
mov edi,[cache_ide2_data_pointer] |
call clear_ide_cache |
pop edi |
pop ecx |
ret |
get_cache_ide3: |
push ecx |
stdcall kernel_alloc,[cache_ide3_size] |
mov [cache_ide3_pointer],eax |
pop ecx |
mov edx,eax |
mov eax,[cache_ide3_size] |
shr eax,3 |
mov [cache_ide3_system_data_size],eax |
mov ebx,eax |
imul eax,7 |
mov [cache_ide3_appl_data_size],eax |
add ebx,edx |
mov [cache_ide3_data_pointer],ebx |
cmp cl,10b |
je .cd |
push ecx |
mov eax,[cache_ide3_system_data_size] |
call calculate_for_hd |
add eax,[cache_ide3_pointer] |
mov [cache_ide3_system_data],eax |
mov [cache_ide3_system_sad_size],ecx |
push edi |
mov edi,[cache_ide3_pointer] |
call clear_ide_cache |
pop edi |
mov eax,[cache_ide3_appl_data_size] |
call calculate_for_hd |
add eax,[cache_ide3_data_pointer] |
mov [cache_ide3_appl_data],eax |
mov [cache_ide3_appl_sad_size],ecx |
push edi |
mov edi,[cache_ide3_data_pointer] |
call clear_ide_cache |
pop edi |
pop ecx |
ret |
.cd: |
push ecx |
mov eax,[cache_ide3_system_data_size] |
call calculate_for_cd |
add eax,[cache_ide3_pointer] |
mov [cache_ide3_system_data],eax |
mov [cache_ide3_system_sad_size],ecx |
push edi |
mov edi,[cache_ide3_pointer] |
call clear_ide_cache |
pop edi |
mov eax,[cache_ide3_appl_data_size] |
call calculate_for_cd |
add eax,[cache_ide3_data_pointer] |
mov [cache_ide3_appl_data],eax |
mov [cache_ide3_appl_sad_size],ecx |
push edi |
mov edi,[cache_ide3_data_pointer] |
call clear_ide_cache |
pop edi |
pop ecx |
ret |
calculate_for_hd: |
push eax |
mov ebx,eax |
shr eax,9 |
shl eax,3 |
sub ebx,eax |
shr ebx,9 |
mov ecx,ebx |
shl ebx,9 |
pop eax |
sub eax,ebx |
ret |
calculate_for_cd: |
push eax |
mov ebx,eax |
shr eax,11 |
shl eax,3 |
sub ebx,eax |
shr ebx,11 |
mov ecx,ebx |
shl ebx,11 |
pop eax |
sub eax,ebx |
ret |
clear_ide_cache: |
push eax |
shl ecx,1 |
xor eax,eax |
cld |
rep stosd |
pop eax |
ret |
end_get_cache: |
; mov [cache_ide0_pointer],HD_CACHE |
; mov [cache_ide0_system_data],HD_CACHE+65536 |
; mov [cache_ide0_system_sad_size],1919 |
popa |
/kernel/trunk/kernel32.inc |
---|
229,6 → 229,9 |
include "blkdev/fdc.inc" |
include "blkdev/flp_drv.inc" |
; IDE cache |
include "blkdev/ide_cache.inc" |
; HD drive controller |
include "blkdev/hd_drv.inc" |
/kernel/trunk/memmap.inc |
---|
176,7 → 176,8 |
; 0x80280000 -> 281FFF ramdisk fat |
; 0x80282000 -> 283FFF floppy fat |
; |
; 0x80284000 -> 297FFF free (80 Kb) |
; 0x80284000 -> 28BFFF HDD DMA AREA |
; 0x8028C000 -> 297FFF free (48 Kb) |
; |
; 0x80298000 -> 29ffff auxiliary table for background smoothing code |
; |