kolibri-process:

1)update
2)create v86 process


git-svn-id: svn://kolibrios.org@4923 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2014-05-12 19:41:55 +00:00
parent 5386a3ea58
commit 2518ed40a1
61 changed files with 2606 additions and 2043 deletions

File diff suppressed because it is too large Load Diff

View File

@ -379,10 +379,16 @@ RecalibrateFDD:
mov al, 8 mov al, 8
call FDCDataOutput call FDCDataOutput
call FDCDataInput call FDCDataInput
push eax
; DEBUGF 1,' %x',al ; DEBUGF 1,' %x',al
call FDCDataInput call FDCDataInput
; DEBUGF 1,' %x',al ; DEBUGF 1,' %x',al
; DEBUGF 1,'\n' ; DEBUGF 1,'\n'
pop eax
test al, 0xC0
jz @f
mov [FDC_Status], FDC_DiskNotFound
@@:
.fail: .fail:
call save_timer_fdd_motor call save_timer_fdd_motor
popa popa

View File

@ -17,7 +17,7 @@ hdbase dd ?
hdid dd ? hdid dd ?
hdpos dd ? hdpos dd ?
ends ends
;-----------------------------------------------------------------------------
iglobal iglobal
align 4 align 4
ide_callbacks: ide_callbacks:
@ -35,18 +35,34 @@ hd0_data HD_DATA ?, 0, 1
hd1_data HD_DATA ?, 0x10, 2 hd1_data HD_DATA ?, 0x10, 2
hd2_data HD_DATA ?, 0, 3 hd2_data HD_DATA ?, 0, 3
hd3_data HD_DATA ?, 0x10, 4 hd3_data HD_DATA ?, 0x10, 4
hd4_data HD_DATA ?, 0, 5
hd5_data HD_DATA ?, 0x10, 6
hd6_data HD_DATA ?, 0, 7
hd7_data HD_DATA ?, 0x10, 8
hd8_data HD_DATA ?, 0, 9
hd9_data HD_DATA ?, 0x10, 10
hd10_data HD_DATA ?, 0, 11
hd11_data HD_DATA ?, 0x10, 12
hd_address_table: ide_mutex_table:
dd 0x1f0, 0x00, 0x1f0, 0x10 dd ide_channel1_mutex
dd 0x170, 0x00, 0x170, 0x10 dd ide_channel2_mutex
dd ide_channel3_mutex
dd ide_channel4_mutex
dd ide_channel5_mutex
dd ide_channel6_mutex
endg endg
;-----------------------------------------------------------------------------
uglobal uglobal
ide_mutex MUTEX ide_mutex MUTEX
ide_channel1_mutex MUTEX ide_channel1_mutex MUTEX
ide_channel2_mutex MUTEX ide_channel2_mutex MUTEX
ide_channel3_mutex MUTEX
ide_channel4_mutex MUTEX
ide_channel5_mutex MUTEX
ide_channel6_mutex MUTEX
endg endg
;-----------------------------------------------------------------------------
proc ide_read stdcall uses edi, \ proc ide_read stdcall uses edi, \
hd_data, buffer, startsector:qword, numsectors hd_data, buffer, startsector:qword, numsectors
; hd_data = pointer to hd*_data ; hd_data = pointer to hd*_data
@ -67,15 +83,13 @@ endl
; 2. Acquire the global lock. ; 2. Acquire the global lock.
mov ecx, ide_mutex mov ecx, ide_mutex
call mutex_lock call mutex_lock
mov ecx, ide_channel2_mutex
mov eax, [hd_data] mov ecx, [hd_data]
push ecx mov ecx, [ecx+HD_DATA.hdpos]
mov ecx, [hd_address_table] dec ecx
cmp [eax+HD_DATA.hdbase], ecx ; 0x1F0 shr ecx, 1
pop ecx shl ecx, 2
jne .IDE_Channel_2 mov ecx, [ecx + ide_mutex_table]
mov ecx, ide_channel1_mutex
.IDE_Channel_2:
mov [channel_lock], ecx mov [channel_lock], ecx
call mutex_lock call mutex_lock
; 3. Convert parameters to the form suitable for worker procedures. ; 3. Convert parameters to the form suitable for worker procedures.
@ -83,6 +97,7 @@ endl
; Worker procedures use global variables and edi for [buffer]. ; Worker procedures use global variables and edi for [buffer].
cmp dword [startsector+4], 0 cmp dword [startsector+4], 0
jnz .fail jnz .fail
and [hd_error], 0 and [hd_error], 0
mov ecx, [hd_data] mov ecx, [hd_data]
mov eax, [ecx+HD_DATA.hdbase] mov eax, [ecx+HD_DATA.hdbase]
@ -98,55 +113,65 @@ endl
; DMA read is permitted if [allow_dma_access]=1 or 2 ; DMA read is permitted if [allow_dma_access]=1 or 2
cmp [allow_dma_access], 2 cmp [allow_dma_access], 2
ja .nodma ja .nodma
cmp [dma_hdd], 1
jnz .nodma
;--------------------------------------
push eax
mov eax, [hd_address_table]
cmp [hdbase], eax ; 0x1F0
pop eax
jnz @f
test [DRIVE_DATA+1], byte 10100000b push eax ecx
mov ecx, [hdpos]
dec ecx
shr ecx, 2
imul ecx, sizeof.IDE_DATA
add ecx, IDE_controller_1
mov [IDE_controller_pointer], ecx
mov eax, [hdpos]
dec eax
and eax, 11b
shr eax, 1
add eax, ecx
cmp [eax+IDE_DATA.dma_hdd_channel_1], 1
pop ecx eax
jnz .nodma jnz .nodma
jmp .dma
@@:
test [DRIVE_DATA+1], byte 1010b
jnz .nodma
.dma:
;--------------------------------------
call hd_read_dma call hd_read_dma
jmp @f jmp @f
;--------------------------------------
.nodma: .nodma:
call hd_read_pio call hd_read_pio
;--------------------------------------
@@: @@:
cmp [hd_error], 0 cmp [hd_error], 0
jnz .fail jnz .fail
mov ecx, [numsectors] mov ecx, [numsectors]
inc dword [ecx] ; one more sector is read inc dword [ecx] ; one more sector is read
dec [sectors_todo] dec [sectors_todo]
jz .done jz .done
inc eax inc eax
jnz .sectors_loop jnz .sectors_loop
;--------------------------------------
; 5. Loop is done, either due to error or because everything is done. ; 5. Loop is done, either due to error or because everything is done.
; Release the global lock and return the corresponding status. ; Release the global lock and return the corresponding status.
.fail: .fail:
mov ecx, [channel_lock] mov ecx, [channel_lock]
call mutex_unlock call mutex_unlock
mov ecx, ide_mutex mov ecx, ide_mutex
call mutex_unlock call mutex_unlock
or eax, -1 or eax, -1
ret ret
;--------------------------------------
.done: .done:
mov ecx, [channel_lock] mov ecx, [channel_lock]
call mutex_unlock call mutex_unlock
mov ecx, ide_mutex mov ecx, ide_mutex
call mutex_unlock call mutex_unlock
xor eax, eax xor eax, eax
ret ret
endp endp
;-----------------------------------------------------------------------------
proc ide_write stdcall uses esi edi, \ proc ide_write stdcall uses esi edi, \
hd_data, buffer, startsector:qword, numsectors hd_data, buffer, startsector:qword, numsectors
; hd_data = pointer to hd*_data ; hd_data = pointer to hd*_data
@ -167,15 +192,13 @@ endl
; 2. Acquire the global lock. ; 2. Acquire the global lock.
mov ecx, ide_mutex mov ecx, ide_mutex
call mutex_lock call mutex_lock
mov ecx, ide_channel2_mutex
mov eax, [hd_data] mov ecx, [hd_data]
push ecx mov ecx, [ecx+HD_DATA.hdpos]
mov ecx, [hd_address_table] dec ecx
cmp [eax+HD_DATA.hdbase], ecx ; 0x1F0 shr ecx, 1
pop ecx shl ecx, 2
jne .IDE_Channel_2 mov ecx, [ecx + ide_mutex_table]
mov ecx, ide_channel1_mutex
.IDE_Channel_2:
mov [channel_lock], ecx mov [channel_lock], ecx
call mutex_lock call mutex_lock
; 3. Convert parameters to the form suitable for worker procedures. ; 3. Convert parameters to the form suitable for worker procedures.
@ -183,6 +206,7 @@ endl
; Worker procedures use global variables and esi for [buffer]. ; Worker procedures use global variables and esi for [buffer].
cmp dword [startsector+4], 0 cmp dword [startsector+4], 0
jnz .fail jnz .fail
and [hd_error], 0 and [hd_error], 0
mov ecx, [hd_data] mov ecx, [hd_data]
mov eax, [ecx+HD_DATA.hdbase] mov eax, [ecx+HD_DATA.hdbase]
@ -200,66 +224,79 @@ endl
mov ecx, 16 mov ecx, 16
cmp ecx, [sectors_todo] cmp ecx, [sectors_todo]
jbe @f jbe @f
mov ecx, [sectors_todo] mov ecx, [sectors_todo]
;--------------------------------------
@@: @@:
mov [cache_chain_size], cl mov [cache_chain_size], cl
; DMA write is permitted only if [allow_dma_access]=1 ; DMA write is permitted only if [allow_dma_access]=1
cmp [allow_dma_access], 2 cmp [allow_dma_access], 2
jae .nodma jae .nodma
cmp [dma_hdd], 1
jnz .nodma
;--------------------------------------
push eax
mov eax, [hd_address_table]
cmp [hdbase], eax ; 0x1F0
pop eax
jnz @f
test [DRIVE_DATA+1], byte 10100000b push eax ecx
mov ecx, [hdpos]
dec ecx
shr ecx, 2
imul ecx, sizeof.IDE_DATA
add ecx, IDE_controller_1
mov [IDE_controller_pointer], ecx
mov eax, [hdpos]
dec eax
and eax, 11b
shr eax, 1
add eax, ecx
cmp [eax+IDE_DATA.dma_hdd_channel_1], 1
pop ecx eax
jnz .nodma jnz .nodma
jmp .dma
@@:
test [DRIVE_DATA+1], byte 1010b
jnz .nodma
.dma:
;--------------------------------------
call cache_write_dma call cache_write_dma
jmp .common jmp .common
;--------------------------------------
.nodma: .nodma:
mov [cache_chain_size], 1 mov [cache_chain_size], 1
call cache_write_pio call cache_write_pio
;--------------------------------------
.common: .common:
cmp [hd_error], 0 cmp [hd_error], 0
jnz .fail jnz .fail
movzx ecx, [cache_chain_size] movzx ecx, [cache_chain_size]
mov eax, [numsectors] mov eax, [numsectors]
add [eax], ecx add [eax], ecx
sub [sectors_todo], ecx sub [sectors_todo], ecx
jz .done jz .done
add [edi], ecx add [edi], ecx
jc .fail jc .fail
shl ecx, 9 shl ecx, 9
add esi, ecx add esi, ecx
jmp .sectors_loop jmp .sectors_loop
;--------------------------------------
; 5. Loop is done, either due to error or because everything is done. ; 5. Loop is done, either due to error or because everything is done.
; Release the global lock and return the corresponding status. ; Release the global lock and return the corresponding status.
.fail: .fail:
mov ecx, [channel_lock] mov ecx, [channel_lock]
call mutex_unlock call mutex_unlock
mov ecx, ide_mutex mov ecx, ide_mutex
call mutex_unlock call mutex_unlock
or eax, -1 or eax, -1
ret ret
;--------------------------------------
.done: .done:
mov ecx, [channel_lock] mov ecx, [channel_lock]
call mutex_unlock call mutex_unlock
mov ecx, ide_mutex mov ecx, ide_mutex
call mutex_unlock call mutex_unlock
xor eax, eax xor eax, eax
ret ret
endp endp
;-----------------------------------------------------------------------------
; This is a stub. ; This is a stub.
proc ide_querymedia stdcall, hd_data, mediainfo proc ide_querymedia stdcall, hd_data, mediainfo
mov eax, [mediainfo] mov eax, [mediainfo]
@ -270,14 +307,12 @@ proc ide_querymedia stdcall, hd_data, mediainfo
xor eax, eax xor eax, eax
ret ret
endp endp
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4
; input: eax = sector, edi -> buffer ; input: eax = sector, edi -> buffer
; output: edi = edi + 512 ; output: edi = edi + 512
hd_read_pio: hd_read_pio:
push eax edx push eax edx
; Select the desired drive ; Select the desired drive
mov edx, [hdbase] mov edx, [hdbase]
add edx, 6 ;адрес регистра головок add edx, 6 ;адрес регистра головок
@ -286,9 +321,9 @@ hd_read_pio:
out dx, al; номер головки/номер диска out dx, al; номер головки/номер диска
call wait_for_hd_idle call wait_for_hd_idle
cmp [hd_error], 0 cmp [hd_error], 0
jne hd_read_error jne hd_read_error
; ATA with 28 or 48 bit for sector number? ; ATA with 28 or 48 bit for sector number?
mov eax, [esp+4] mov eax, [esp+4]
cmp eax, 0x10000000 cmp eax, 0x10000000
@ -372,7 +407,6 @@ hd_read_pio:
pushfd pushfd
cli cli
mov ecx, 256 mov ecx, 256
mov edx, [hdbase] mov edx, [hdbase]
cld cld
@ -393,6 +427,7 @@ cache_write_pio:
out dx, al ; номер головки/номер диска out dx, al ; номер головки/номер диска
call wait_for_hd_idle call wait_for_hd_idle
cmp [hd_error], 0 cmp [hd_error], 0
jne hd_write_error jne hd_write_error
@ -550,13 +585,14 @@ wait_for_hd_idle:
align 4 align 4
wfhil1: wfhil1:
call check_hd_wait_timeout call check_hd_wait_timeout
cmp [hd_error], 0 cmp [hd_error], 0
jne @f jne @f
in al, dx in al, dx
test al, 128 test al, 128
jnz wfhil1 jnz wfhil1
;--------------------------------------
@@: @@:
pop edx eax pop edx eax
ret ret
@ -573,6 +609,7 @@ wait_for_sector_buffer:
align 4 align 4
hdwait_sbuf: ; wait for sector buffer to be ready hdwait_sbuf: ; wait for sector buffer to be ready
call check_hd_wait_timeout call check_hd_wait_timeout
cmp [hd_error], 0 cmp [hd_error], 0
jne @f jne @f
@ -587,9 +624,10 @@ hdwait_sbuf: ; wait for sector buffer to be ready
test al, 1 ; previous command ended up with an error test al, 1 ; previous command ended up with an error
jz buf_wait_ok jz buf_wait_ok
;--------------------------------------
@@: @@:
mov [hd_error], 1 mov [hd_error], 1
;--------------------------------------
buf_wait_ok: buf_wait_ok:
pop edx eax pop edx eax
ret ret
@ -606,22 +644,17 @@ wait_for_sector_dma_ide0:
align 4 align 4
.wait: .wait:
call change_task call change_task
cmp [IDE_common_irq_param], 0 cmp [IDE_common_irq_param], 0
jz .done jz .done
call check_hd_wait_timeout call check_hd_wait_timeout
cmp [hd_error], 0 cmp [hd_error], 0
jz .wait jz .wait
; clear Bus Master IDE Command register
pushfd
cli
mov [IDE_common_irq_param], 0 mov [IDE_common_irq_param], 0
mov dx, [IDEContrRegsBaseAddr]
mov al, 0
out dx, al
popfd
;-------------------------------------- ;--------------------------------------
align 4
.done: .done:
pop edx pop edx
pop eax pop eax
@ -636,23 +669,17 @@ wait_for_sector_dma_ide1:
align 4 align 4
.wait: .wait:
call change_task call change_task
cmp [IDE_common_irq_param], 0 cmp [IDE_common_irq_param], 0
jz .done jz .done
call check_hd_wait_timeout call check_hd_wait_timeout
cmp [hd_error], 0 cmp [hd_error], 0
jz .wait jz .wait
; clear Bus Master IDE Command register
pushfd
cli
mov [IDE_common_irq_param], 0 mov [IDE_common_irq_param], 0
mov dx, [IDEContrRegsBaseAddr]
add dx, 8
mov al, 0
out dx, al
popfd
;-------------------------------------- ;--------------------------------------
align 4
.done: .done:
pop edx pop edx
pop eax pop eax
@ -660,7 +687,8 @@ align 4
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
iglobal iglobal
align 4 align 4
; note that IDE descriptor table must be 4-byte aligned and do not cross 4K boundary ; note that IDE descriptor table must be 4-byte aligned
; and do not cross 4K boundary
IDE_descriptor_table: IDE_descriptor_table:
dd IDE_DMA dd IDE_DMA
dw 0x2000 dw 0x2000
@ -673,19 +701,14 @@ endg
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
uglobal uglobal
; all uglobals are zeroed at boot ; all uglobals are zeroed at boot
dma_process dd 0
dma_slot_ptr dd 0
cache_chain_pos dd 0
cache_chain_ptr dd 0 cache_chain_ptr dd 0
cache_chain_size db 0 cache_chain_size db 0
cache_chain_started db 0
dma_task_switched db 0
dma_hdd db 0
allow_dma_access db 0 allow_dma_access db 0
endg endg
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4
IDE_irq_14_handler: IDE_irq_14_handler:
; DEBUGF 1, 'K : IDE_irq_14_handler %x\n', [IDE_common_irq_param]:2
cmp [IDE_common_irq_param], irq14_num cmp [IDE_common_irq_param], irq14_num
jne .exit jne .exit
@ -693,7 +716,8 @@ IDE_irq_14_handler:
cli cli
pushad pushad
mov [IDE_common_irq_param], 0 mov [IDE_common_irq_param], 0
mov dx, [IDEContrRegsBaseAddr] mov ecx, [IDE_controller_pointer]
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
; test whether it is our interrupt? ; test whether it is our interrupt?
add edx, 2 add edx, 2
in al, dx in al, dx
@ -715,18 +739,17 @@ IDE_irq_14_handler:
mov al, 1 mov al, 1
ret ret
;-------------------------------------- ;--------------------------------------
align 4
@@: @@:
popad popad
popfd popfd
;-------------------------------------- ;--------------------------------------
align 4
.exit: .exit:
mov al, 0 mov al, 0
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4
IDE_irq_15_handler: IDE_irq_15_handler:
; DEBUGF 1, 'K : IDE_irq_15_handler %x\n', [IDE_common_irq_param]:2
cmp [IDE_common_irq_param], irq15_num cmp [IDE_common_irq_param], irq15_num
jne .exit jne .exit
@ -734,7 +757,8 @@ IDE_irq_15_handler:
cli cli
pushad pushad
mov [IDE_common_irq_param], 0 mov [IDE_common_irq_param], 0
mov dx, [IDEContrRegsBaseAddr] mov ecx, [IDE_controller_pointer]
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
add dx, 8 add dx, 8
; test whether it is our interrupt? ; test whether it is our interrupt?
add edx, 2 add edx, 2
@ -757,26 +781,26 @@ IDE_irq_15_handler:
mov al, 1 mov al, 1
ret ret
;-------------------------------------- ;--------------------------------------
align 4
@@: @@:
popad popad
popfd popfd
;-------------------------------------- ;--------------------------------------
align 4
.exit: .exit:
mov al, 0 mov al, 0
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4
IDE_common_irq_handler: IDE_common_irq_handler:
; DEBUGF 1, 'K : IDE_common_irq_handler %x\n', [IDE_common_irq_param]:2
pushfd
cli
cmp [IDE_common_irq_param], 0 cmp [IDE_common_irq_param], 0
je .exit je .exit
pushfd
cli
pushad pushad
xor ebx, ebx xor ebx, ebx
mov dx, [IDEContrRegsBaseAddr] mov ecx, [IDE_controller_pointer]
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
mov eax, IDE_common_irq_param mov eax, IDE_common_irq_param
cmp [eax], irq14_num cmp [eax], irq14_num
mov [eax], bl mov [eax], bl
@ -784,7 +808,6 @@ IDE_common_irq_handler:
add dx, 8 add dx, 8
;-------------------------------------- ;--------------------------------------
align 4
@@: @@:
; test whether it is our interrupt? ; test whether it is our interrupt?
add edx, 2 add edx, 2
@ -807,13 +830,11 @@ align 4
mov al, 1 mov al, 1
ret ret
;-------------------------------------- ;--------------------------------------
align 4
@@: @@:
popad popad
popfd
;-------------------------------------- ;--------------------------------------
align 4
.exit: .exit:
popfd
mov al, 0 mov al, 0
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@ -824,26 +845,31 @@ hd_read_dma:
mov edx, [dma_hdpos] mov edx, [dma_hdpos]
cmp edx, [hdpos] cmp edx, [hdpos]
jne .notread jne .notread
mov edx, [dma_cur_sector] mov edx, [dma_cur_sector]
cmp eax, edx cmp eax, edx
jb .notread jb .notread
add edx, 15 add edx, 15
cmp [esp+4], edx cmp [esp+4], edx
ja .notread ja .notread
mov eax, [esp+4] mov eax, [esp+4]
sub eax, [dma_cur_sector] sub eax, [dma_cur_sector]
shl eax, 9 shl eax, 9
add eax, (OS_BASE+IDE_DMA) add eax, (OS_BASE+IDE_DMA)
push ecx esi push ecx esi
mov esi, eax mov esi, eax
mov ecx, 512/4 mov ecx, 512/4
cld cld
rep movsd rep movsd
pop esi ecx pop esi ecx
pop edx pop edx
pop eax pop eax
ret ret
;--------------------------------------
.notread: .notread:
; set data for PRD Table ; set data for PRD Table
mov eax, IDE_descriptor_table mov eax, IDE_descriptor_table
@ -851,13 +877,18 @@ hd_read_dma:
mov word [eax+4], 0x2000 mov word [eax+4], 0x2000
sub eax, OS_BASE sub eax, OS_BASE
; select controller Primary or Secondary ; select controller Primary or Secondary
mov dx, [IDEContrRegsBaseAddr] mov ecx, [IDE_controller_pointer]
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
push eax push eax
mov eax, [hd_address_table] mov eax, [hdpos]
cmp [hdbase], eax ; 0x1F0 dec eax
test eax, 10b
pop eax pop eax
jz @f jz @f
add edx, 8 add edx, 8
;--------------------------------------
@@: @@:
push edx push edx
; Bus Master IDE PRD Table Address ; Bus Master IDE PRD Table Address
@ -881,9 +912,9 @@ hd_read_dma:
out dx, al ; номер головки/номер диска out dx, al ; номер головки/номер диска
call wait_for_hd_idle call wait_for_hd_idle
cmp [hd_error], 0 cmp [hd_error], 0
jnz hd_read_error jnz hd_read_error
; ATA with 28 or 48 bit for sector number? ; ATA with 28 or 48 bit for sector number?
mov eax, [esp+4] mov eax, [esp+4]
; -10h because the PreCache hits the boundary between lba28 and lba48 ; -10h because the PreCache hits the boundary between lba28 and lba48
@ -961,47 +992,55 @@ hd_read_dma:
;-------------------------------------- ;--------------------------------------
.continue: .continue:
; select controller Primary or Secondary ; select controller Primary or Secondary
mov dx, [IDEContrRegsBaseAddr] mov ecx, [IDE_controller_pointer]
mov eax, [hd_address_table] mov dx, [ecx+IDE_DATA.RegsBaseAddres]
cmp [hdbase], eax ; 0x1F0
mov eax, [hdpos]
dec eax
test eax, 10b
jz @f jz @f
add dx, 8 add dx, 8
;--------------------------------------
@@: @@:
; set write to memory and Start Bus Master ; set write to memory and Start Bus Master
mov al, 9 mov al, 9
out dx, al out dx, al
mov eax, [CURRENT_TASK] mov eax, [hdpos]
mov [dma_process], eax dec eax
test eax, 10b
mov eax, [TASK_BASE]
mov [dma_slot_ptr], eax
mov eax, [hd_address_table]
cmp [hdbase], eax ; 0x1F0
jnz .ide1 jnz .ide1
mov [IDE_common_irq_param], irq14_num mov [IDE_common_irq_param], irq14_num
jmp @f jmp @f
;--------------------------------------
.ide1: .ide1:
mov [IDE_common_irq_param], irq15_num mov [IDE_common_irq_param], irq15_num
;--------------------------------------
@@: @@:
popfd popfd
; wait for interrupt ; wait for interrupt
mov eax, [hd_address_table] mov eax, [hdpos]
cmp [hdbase], eax ; 0x1F0 dec eax
test eax, 10b
jnz .wait_ide1 jnz .wait_ide1
call wait_for_sector_dma_ide0 call wait_for_sector_dma_ide0
jmp @f jmp @f
;--------------------------------------
.wait_ide1: .wait_ide1:
call wait_for_sector_dma_ide1 call wait_for_sector_dma_ide1
;--------------------------------------
@@: @@:
cmp [hd_error], 0 cmp [hd_error], 0
jnz hd_read_error jnz hd_read_error
mov eax, [hdpos] mov eax, [hdpos]
mov [dma_hdpos], eax mov [dma_hdpos], eax
pop edx pop edx
pop eax pop eax
mov [dma_cur_sector], eax mov [dma_cur_sector], eax
jmp hd_read_dma jmp hd_read_dma
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@ -1011,6 +1050,7 @@ cache_write_dma:
; set data for PRD Table ; set data for PRD Table
mov eax, IDE_descriptor_table mov eax, IDE_descriptor_table
mov edx, eax mov edx, eax
pusha pusha
mov edi, (OS_BASE+IDE_DMA) mov edi, (OS_BASE+IDE_DMA)
mov dword [edx], IDE_DMA mov dword [edx], IDE_DMA
@ -1021,15 +1061,21 @@ cache_write_dma:
cld cld
rep movsd rep movsd
popa popa
sub eax, OS_BASE sub eax, OS_BASE
; select controller Primary or Secondary ; select controller Primary or Secondary
mov dx, [IDEContrRegsBaseAddr] mov ecx, [IDE_controller_pointer]
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
push eax push eax
mov eax, [hd_address_table] mov eax, [hdpos]
cmp [hdbase], eax ; 0x1F0 dec eax
test eax, 10b
pop eax pop eax
jz @f jz @f
add edx, 8 add edx, 8
;--------------------------------------
@@: @@:
push edx push edx
; Bus Master IDE PRD Table Address ; Bus Master IDE PRD Table Address
@ -1053,9 +1099,9 @@ cache_write_dma:
out dx, al ; номер головки/номер диска out dx, al ; номер головки/номер диска
call wait_for_hd_idle call wait_for_hd_idle
cmp [hd_error], 0 cmp [hd_error], 0
jnz hd_write_error_dma jnz hd_write_error_dma
; ATA with 28 or 48 bit for sector number? ; ATA with 28 or 48 bit for sector number?
mov esi, [cache_chain_ptr] mov esi, [cache_chain_ptr]
mov eax, [esi] mov eax, [esi]
@ -1134,69 +1180,76 @@ cache_write_dma:
;-------------------------------------- ;--------------------------------------
.continue: .continue:
; select controller Primary or Secondary ; select controller Primary or Secondary
mov dx, [IDEContrRegsBaseAddr] mov ecx, [IDE_controller_pointer]
mov eax, [hd_address_table] mov dx, [ecx+IDE_DATA.RegsBaseAddres]
cmp [hdbase], eax ; 0x1F0
mov eax, [hdpos]
dec eax
test eax, 10b
jz @f jz @f
add dx, 8 add dx, 8
;--------------------------------------
@@: @@:
; set write to device and Start Bus Master ; set write to device and Start Bus Master
mov al, 1 mov al, 1
out dx, al out dx, al
mov eax, [CURRENT_TASK]
mov [dma_process], eax mov eax, [hdpos]
mov eax, [TASK_BASE] dec eax
mov [dma_slot_ptr], eax test eax, 10b
mov eax, [hd_address_table]
cmp [hdbase], eax ; 0x1F0
jnz .ide1 jnz .ide1
mov [IDE_common_irq_param], irq14_num mov [IDE_common_irq_param], irq14_num
jmp @f jmp @f
;--------------------------------------
.ide1: .ide1:
mov [IDE_common_irq_param], irq15_num mov [IDE_common_irq_param], irq15_num
;--------------------------------------
@@: @@:
popfd popfd
; wait for interrupt ; wait for interrupt
mov [dma_cur_sector], not 0x40 mov [dma_cur_sector], not 0x40
mov eax, [hd_address_table]
cmp [hdbase], eax ; 0x1F0 mov eax, [hdpos]
dec eax
test eax, 10b
jnz .wait_ide1 jnz .wait_ide1
call wait_for_sector_dma_ide0 call wait_for_sector_dma_ide0
jmp @f jmp @f
;--------------------------------------
.wait_ide1: .wait_ide1:
call wait_for_sector_dma_ide1 call wait_for_sector_dma_ide1
;--------------------------------------
@@: @@:
cmp [hd_error], 0 cmp [hd_error], 0
jnz hd_write_error_dma jnz hd_write_error_dma
pop esi pop esi
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
uglobal
align 4
IDE_Interrupt dw ?
IDEContrRegsBaseAddr dw ?
IDEContrProgrammingInterface dw ?
IDE_BAR0_val dw ?
IDE_BAR1_val dw ?
IDE_BAR2_val dw ?
IDE_BAR3_val dw ?
endg
;-----------------------------------------------------------------------------
proc clear_pci_ide_interrupts proc clear_pci_ide_interrupts
mov esi, pcidev_list mov esi, pcidev_list
;--------------------------------------
align 4
.loop: .loop:
mov esi, [esi+PCIDEV.fd] mov esi, [esi+PCIDEV.fd]
cmp esi, pcidev_list cmp esi, pcidev_list
jz .done jz .done
cmp [esi+PCIDEV.class], 0x01018F
; cmp [esi+PCIDEV.class], 0x01018F
mov eax, [esi+PCIDEV.class]
shr eax, 4
cmp eax, 0x01018
jnz .loop jnz .loop
mov ah, [esi+PCIDEV.bus] mov ah, [esi+PCIDEV.bus]
mov al, 2 mov al, 2
mov bh, [esi+PCIDEV.devfn] mov bh, [esi+PCIDEV.devfn]
mov bl, 0x20 mov bl, 0x20
call pci_read_reg call pci_read_reg
and eax, 0FFFCh and eax, 0FFFCh
mov edx, eax mov edx, eax
add edx, 2 add edx, 2
@ -1212,6 +1265,8 @@ proc clear_pci_ide_interrupts
in al, dx in al, dx
DEBUGF 1,'-> %x\n',al DEBUGF 1,'-> %x\n',al
jmp .loop jmp .loop
;--------------------------------------
.done: .done:
ret ret
endp endp
;-----------------------------------------------------------------------------

View File

@ -41,53 +41,29 @@ find_empty_slot_CD_cache:
ret ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
clear_CD_cache: clear_CD_cache:
DEBUGF 1, 'K : clear_CD_cache\n'
pusha pusha
.ide0:
mov esi, [cdpos]
dec esi
imul esi, sizeof.IDE_CACHE
add esi, cache_ide0
xor eax, eax xor eax, eax
cmp [cdpos], 1
jne .ide1 mov [esi+IDE_CACHE.search_start], eax
mov [cache_ide0_search_start], eax mov ecx, [esi+IDE_CACHE.system_sad_size]
mov ecx, [cache_ide0_system_sad_size] mov edi, [esi+IDE_CACHE.pointer]
mov edi, [cache_ide0_pointer]
call .clear call .clear
mov [cache_ide0_appl_search_start], eax
mov ecx, [cache_ide0_appl_sad_size] mov [esi+IDE_CACHE.appl_search_start], eax
mov edi, [cache_ide0_data_pointer] mov ecx, [esi+IDE_CACHE.appl_sad_size]
jmp .continue mov edi, [esi+IDE_CACHE.data_pointer]
.ide1:
cmp [cdpos], 2
jne .ide2
mov [cache_ide1_search_start], eax
mov ecx, [cache_ide1_system_sad_size]
mov edi, [cache_ide1_pointer]
call .clear
mov [cache_ide1_appl_search_start], eax
mov ecx, [cache_ide1_appl_sad_size]
mov edi, [cache_ide1_data_pointer]
jmp .continue
.ide2:
cmp [cdpos], 3
jne .ide3
mov [cache_ide2_search_start], eax
mov ecx, [cache_ide2_system_sad_size]
mov edi, [cache_ide2_pointer]
call .clear
mov [cache_ide2_appl_search_start], eax
mov ecx, [cache_ide2_appl_sad_size]
mov edi, [cache_ide2_data_pointer]
jmp .continue
.ide3:
mov [cache_ide3_search_start], eax
mov ecx, [cache_ide3_system_sad_size]
mov edi, [cache_ide3_pointer]
call .clear
mov [cache_ide3_appl_search_start], eax
mov ecx, [cache_ide3_appl_sad_size]
mov edi, [cache_ide3_data_pointer]
.continue:
call .clear call .clear
popa popa
ret ret
;--------------------------------------
.clear: .clear:
shl ecx, 1 shl ecx, 1
cld cld
@ -96,272 +72,131 @@ clear_CD_cache:
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
align 4 align 4
cd_calculate_cache: cd_calculate_cache:
; 1 - IDE0 ... 4 - IDE3 ; 1 - IDE0 ... 12 - IDE11
.ide0: push eax
cmp [cdpos], 1
jne .ide1 mov eax, [cdpos]
dec eax
imul eax, sizeof.IDE_CACHE
add eax, cache_ide0
cmp [cd_appl_data], 0 cmp [cd_appl_data], 0
jne .ide0_appl_data jne @f
mov ecx, [cache_ide0_system_sad_size]
mov esi, [cache_ide0_pointer] mov ecx, [eax+IDE_CACHE.system_sad_size]
mov esi, [eax+IDE_CACHE.pointer]
pop eax
ret ret
.ide0_appl_data: ;--------------------------------------
mov ecx, [cache_ide0_appl_sad_size] @@:
mov esi, [cache_ide0_data_pointer] mov ecx, [eax+IDE_CACHE.appl_sad_size]
ret mov esi, [eax+IDE_CACHE.data_pointer]
.ide1: pop eax
cmp [cdpos], 2
jne .ide2
cmp [cd_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 [cdpos], 3
jne .ide3
cmp [cd_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 [cd_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 ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
align 4 align 4
cd_calculate_cache_1: cd_calculate_cache_1:
; 1 - IDE0 ... 4 - IDE3 ; 1 - IDE0 ... 12 - IDE11
.ide0: push eax
cmp [cdpos], 1
jne .ide1 mov eax, [cdpos]
dec eax
imul eax, sizeof.IDE_CACHE
add eax, cache_ide0
cmp [cd_appl_data], 0 cmp [cd_appl_data], 0
jne .ide0_appl_data jne @f
mov esi, [cache_ide0_pointer]
mov esi, [eax+IDE_CACHE.pointer]
pop eax
ret ret
.ide0_appl_data: ;--------------------------------------
mov esi, [cache_ide0_data_pointer] @@:
ret mov esi, [eax+IDE_CACHE.data_pointer]
.ide1: pop eax
cmp [cdpos], 2
jne .ide2
cmp [cd_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 [cdpos], 3
jne .ide3
cmp [cd_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 [cd_appl_data], 0
jne .ide3_appl_data
mov esi, [cache_ide3_pointer]
ret
.ide3_appl_data:
mov esi, [cache_ide3_data_pointer]
ret ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
align 4 align 4
cd_calculate_cache_2: cd_calculate_cache_2:
; 1 - IDE0 ... 4 - IDE3 ; 1 - IDE0 ... 12 - IDE11
.ide0: mov eax, [cdpos]
cmp [cdpos], 1 dec eax
jne .ide1 imul eax, sizeof.IDE_CACHE
add eax, cache_ide0
cmp [cd_appl_data], 0 cmp [cd_appl_data], 0
jne .ide0_appl_data jne @f
mov eax, [cache_ide0_system_data]
mov eax, [eax+IDE_CACHE.system_data]
ret ret
.ide0_appl_data: ;--------------------------------------
mov eax, [cache_ide0_appl_data] @@:
ret mov eax, [eax+IDE_CACHE.appl_data]
.ide1:
cmp [cdpos], 2
jne .ide2
cmp [cd_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 [cdpos], 3
jne .ide3
cmp [cd_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 [cd_appl_data], 0
jne .ide3_appl_data
mov eax, [cache_ide3_system_data]
ret
.ide3_appl_data:
mov eax, [cache_ide3_appl_data]
ret ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
align 4 align 4
cd_calculate_cache_3: cd_calculate_cache_3:
; mov ecx,cache_max*10/100 ; 1 - IDE0 ... 12 - IDE11
; mov edi,[cache_search_start] push eax
mov eax, [cdpos]
dec eax
imul eax, sizeof.IDE_CACHE
add eax, cache_ide0
; 1 - IDE0 ... 4 - IDE3
.ide0:
cmp [cdpos], 1
jne .ide1
cmp [cd_appl_data], 0 cmp [cd_appl_data], 0
jne .ide0_appl_data jne @f
mov edi, [cache_ide0_search_start]
mov edi, [eax+IDE_CACHE.search_start]
pop eax
ret ret
.ide0_appl_data: ;--------------------------------------
mov edi, [cache_ide0_appl_search_start] @@:
ret mov edi, [eax+IDE_CACHE.appl_search_start]
.ide1: pop eax
cmp [cdpos], 2
jne .ide2
cmp [cd_appl_data], 0
jne .ide1_appl_data
mov edi, [cache_ide1_search_start]
ret
.ide1_appl_data:
mov edi, [cache_ide1_appl_search_start]
ret
.ide2:
cmp [cdpos], 3
jne .ide3
cmp [cd_appl_data], 0
jne .ide2_appl_data
mov edi, [cache_ide2_search_start]
ret
.ide2_appl_data:
mov edi, [cache_ide2_appl_search_start]
ret
.ide3:
cmp [cd_appl_data], 0
jne .ide3_appl_data
mov edi, [cache_ide3_search_start]
ret
.ide3_appl_data:
mov edi, [cache_ide3_appl_search_start]
ret ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
align 4 align 4
cd_calculate_cache_4: cd_calculate_cache_4:
; cmp edi,cache_max ; 1 - IDE0 ... 12 - IDE11
; 1 - IDE0 ... 4 - IDE3 push eax
.ide0:
cmp [cdpos], 1 mov eax, [cdpos]
jne .ide1 dec eax
imul eax, sizeof.IDE_CACHE
add eax, cache_ide0
cmp [cd_appl_data], 0 cmp [cd_appl_data], 0
jne .ide0_appl_data jne @f
cmp edi, [cache_ide0_system_sad_size]
cmp edi, [eax+IDE_CACHE.system_sad_size]
pop eax
ret ret
.ide0_appl_data: ;--------------------------------------
cmp edi, [cache_ide0_appl_sad_size] @@:
ret cmp edi, [eax+IDE_CACHE.appl_sad_size]
.ide1: pop eax
cmp [cdpos], 2
jne .ide2
cmp [cd_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 [cdpos], 3
jne .ide3
cmp [cd_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 [cd_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 ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
align 4 align 4
cd_calculate_cache_5: cd_calculate_cache_5:
; mov [cache_search_start],edi ; 1 - IDE0 ... 12 - IDE11
; 1 - IDE0 ... 4 - IDE3 push eax
.ide0:
cmp [cdpos], 1 mov eax, [cdpos]
jne .ide1 dec eax
imul eax, sizeof.IDE_CACHE
add eax, cache_ide0
cmp [cd_appl_data], 0 cmp [cd_appl_data], 0
jne .ide0_appl_data jne @f
mov [cache_ide0_search_start], edi
mov [eax+IDE_CACHE.search_start], edi
pop eax
ret ret
.ide0_appl_data: ;--------------------------------------
mov [cache_ide0_appl_search_start], edi @@:
ret mov [eax+IDE_CACHE.appl_search_start], edi
.ide1: pop eax
cmp [cdpos], 2
jne .ide2
cmp [cd_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 [cdpos], 3
jne .ide3
cmp [cd_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 [cd_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 ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
;align 4
;calculate_linear_to_real:
; shr eax, 12
; mov eax, [page_tabs+eax*4]
; and eax, 0xFFFFF000
; ret

View File

@ -401,128 +401,6 @@ sayerr:
push 0 push 0
pop es pop es
xor ax, ax
and word [es:BOOT_IDE_BASE_ADDR], ax ;0
and word [es:BOOT_IDE_BAR0_16], ax ;0
and word [es:BOOT_IDE_BAR1_16], ax ;0
and word [es:BOOT_IDE_BAR2_16], ax ;0
and word [es:BOOT_IDE_BAR3_16], ax ;0
; \begin{Mario79}
; find HDD IDE DMA PCI device
; check for PCI BIOS
mov ax, 0xB101
int 0x1A
jc .nopci
cmp edx, 'PCI '
jnz .nopci
; find PCI class code
; class 1 = mass storage
; subclass 1 = IDE controller
; a) class 1, subclass 1, programming interface 0x80
; This is a Parallel IDE Controller which uses IRQs 14 and 15.
mov ax, 0xB103
mov ecx, 1*10000h + 1*100h + 0x80
mov [es:BOOT_IDE_PI_16], cx
xor si, si ; device index = 0
int 0x1A
jnc .found_1 ; Parallel IDE Controller
; b) class 1, subclass 1, programming interface 0x8f
mov ax, 0xB103
mov ecx, 1*10000h + 1*100h + 0x8f
mov [es:BOOT_IDE_PI_16], cx
xor si, si ; device index = 0
int 0x1A
jnc .found_1
; c) class 1, subclass 1, programming interface 0x85
mov ax, 0xB103
mov ecx, 1*10000h + 1*100h + 0x85
mov [es:BOOT_IDE_PI_16], cx
xor si, si ; device index = 0
int 0x1A
jnc .found_1
; d) class 1, subclass 1, programming interface 0x8A
; This is a Parallel IDE Controller which uses IRQs 14 and 15.
mov ax, 0xB103
mov ecx, 1*10000h + 1*100h + 0x8A
mov [es:BOOT_IDE_PI_16], cx
xor si, si ; device index = 0
int 0x1A
jnc .found_1 ; Parallel IDE Controller
; Controller not found!
xor ax, ax
mov [es:BOOT_IDE_PI_16], ax
jmp .nopci
;--------------------------------------
.found_1:
; get memory base BAR4
mov ax, 0xB10A
mov di, 0x20 ; memory base is config register at 0x20
push cx
int 0x1A
jc .no_BAR4 ;.nopci
and cx, 0xFFFC ; clear address decode type
mov [es:BOOT_IDE_BASE_ADDR], cx
.no_BAR4:
pop cx
;--------------------------------------
.found:
; get Interrupt Line
mov ax, 0xB10A
mov di, 0x3c ; memory base is config register at 0x3c
push cx
int 0x1A
jc .no_Interrupt ;.nopci
mov [es:BOOT_IDE_INTERR_16], cx
.no_Interrupt:
pop cx
;--------------------------------------
; get memory base BAR0
mov ax, 0xB10A
mov di, 0x10 ; memory base is config register at 0x10
push cx
int 0x1A
jc .no_BAR0 ;.nopci
mov [es:BOOT_IDE_BAR0_16], cx
.no_BAR0:
pop cx
;--------------------------------------
; get memory base BAR1
mov ax, 0xB10A
mov di, 0x14 ; memory base is config register at 0x14
push cx
int 0x1A
jc .no_BAR1 ;.nopci
mov [es:BOOT_IDE_BAR1_16], cx
.no_BAR1:
pop cx
;--------------------------------------
; get memory base BAR2
mov ax, 0xB10A
mov di, 0x18 ; memory base is config register at 0x18
push cx
int 0x1A
jc .no_BAR2 ;.nopci
mov [es:BOOT_IDE_BAR2_16], cx
.no_BAR2:
pop cx
;--------------------------------------
; get memory base BAR3
mov ax, 0xB10A
mov di, 0x1C ; memory base is config register at 0x1c
push cx
int 0x1A
jc .no_BAR3 ;.nopci
mov [es:BOOT_IDE_BAR3_16], cx
.no_BAR3:
pop cx
;--------------------------------------
.nopci:
; \end{Mario79}
mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование
out 0x60, al out 0x60, al

View File

@ -55,7 +55,7 @@ boot_dev db 0 ; 0=floppy, 1=hd
start_msg db "Press [abcde] to change settings, press [Enter] to continue booting",13,10,0 start_msg db "Press [abcde] to change settings, press [Enter] to continue booting",13,10,0
time_msg db " or wait " time_msg db " or wait "
time_str db " 5 seconds" time_str db " 5 seconds"
db " before automatical continuation",13,10,0 db " to continue automatically",13,10,0
current_cfg_msg db "Current settings:",13,10,0 current_cfg_msg db "Current settings:",13,10,0
curvideo_msg db " [a] Videomode: ",0 curvideo_msg db " [a] Videomode: ",0

View File

@ -194,7 +194,7 @@ calc_vmodes_table:
mov word [es:bx], 640 mov word [es:bx], 640
mov word [es:bx+2], 480 mov word [es:bx+2], 480
mov word [es:bx+6], 0x13 mov word [es:bx+6], 0x13
mov word [es:bx+10], 640 mov word [es:bx+10], 640
mov word [es:bx+12], 480 mov word [es:bx+12], 480
mov word [es:bx+16], 0x12 mov word [es:bx+16], 0x12
@ -476,8 +476,8 @@ end if
jne .next jne .next
cmp word [es:si+8], 32 cmp word [es:si+8], 32
je .ok je .ok
cmp word [es:si+8], 24 ; cmp word [es:si+8], 24
je .ok ; je .ok
.next: .next:
add si, size_of_step add si, size_of_step
cmp word [es:si], -1 cmp word [es:si], -1
@ -721,7 +721,7 @@ set_vmode:
mov si, word [preboot_graph] ;[preboot_graph] mov si, word [preboot_graph] ;[preboot_graph]
mov cx, word [es:si+6] ; number of mode mov cx, word [es:si+6] ; number of mode
mov ax, word [es:si+0] ; resolution X mov ax, word [es:si+0] ; resolution X
mov bx, word [es:si+2] ; resolution Y mov bx, word [es:si+2] ; resolution Y

View File

@ -9,10 +9,10 @@ $Revision: 3744 $
read_ramdisk: read_ramdisk:
; READ RAMDISK IMAGE FROM HD ; READ RAMDISK IMAGE FROM HD (only for IDE0, IDE1, IDE2, IDE3)
cmp [boot_dev+OS_BASE+0x10000], 1 cmp [boot_dev+OS_BASE+0x10000], 1
jne no_sys_on_hd jne no_sys_on_hd.1
xor ebp, ebp xor ebp, ebp
.hd_loop: .hd_loop:
@ -69,9 +69,19 @@ read_ramdisk:
jb .hd_loop jb .hd_loop
jmp no_sys_on_hd jmp no_sys_on_hd
.yes: .yes:
DEBUGF 1, "K : RD found: %s\n", read_image_fsinfo.name
pop edi esi eax pop edi esi eax
jmp yes_sys_on_hd
call register_ramdisk
jmp yes_sys_on_hd
;-----------------------------------------------------------------------------
; Register ramdisk file system
register_ramdisk:
mov esi, boot_initramdisk
call boot_log
call ramdisk_init
ret
;-----------------------------------------------------------------------------
iglobal iglobal
align 4 align 4
read_image_fsinfo: read_image_fsinfo:
@ -79,7 +89,7 @@ read_image_fsinfo:
dq 0 ; offset: zero dq 0 ; offset: zero
dd 1474560 ; size dd 1474560 ; size
dd RAMDISK ; buffer dd RAMDISK ; buffer
db '/hd' .name db '/hd'
.name_digit db '0' .name_digit db '0'
db '/' db '/'
.partition: .partition:
@ -99,6 +109,8 @@ read_image:
ret ret
no_sys_on_hd: no_sys_on_hd:
DEBUGF 1, "K : RD not found\n"
.1:
; test_to_format_ram_disk (need if not using ram disk) ; test_to_format_ram_disk (need if not using ram disk)
cmp [boot_dev+OS_BASE+0x10000], 3 cmp [boot_dev+OS_BASE+0x10000], 3
jne not_format_ram_disk jne not_format_ram_disk

View File

@ -165,10 +165,7 @@ pci_read_reg:
call pci_make_config_cmd call pci_make_config_cmd
mov ebx, eax mov ebx, eax
; get current state
mov dx, 0xcf8 mov dx, 0xcf8
in eax, dx
push eax
; set up addressing to config data ; set up addressing to config data
mov eax, ebx mov eax, ebx
and al, 0xfc; make address dword-aligned and al, 0xfc; make address dword-aligned
@ -194,14 +191,7 @@ pci_read_word1:
jmp pci_fin_read1 jmp pci_fin_read1
pci_read_dword1: pci_read_dword1:
in eax, dx in eax, dx
jmp pci_fin_read1
pci_fin_read1: pci_fin_read1:
; restore configuration control
xchg eax, [esp]
mov dx, 0xcf8
out dx, eax
pop eax
pop esi ebx pop esi ebx
ret ret
pci_read_reg_2: pci_read_reg_2:
@ -212,15 +202,8 @@ pci_read_reg_2:
mov esi, eax ; save register size into ESI mov esi, eax ; save register size into ESI
and esi, 3 and esi, 3
push eax mov dx, 0xcfa
;store current state of config space
mov dx, 0xcf8
in al, dx
mov ah, al
mov dl, 0xfa
in al, dx
xchg eax, [esp]
; out 0xcfa,bus ; out 0xcfa,bus
mov al, ah mov al, ah
out dx, al out dx, al
@ -249,18 +232,8 @@ pci_read_word2:
jmp pci_fin_read2 jmp pci_fin_read2
pci_read_dword2: pci_read_dword2:
in eax, dx in eax, dx
; jmp pci_fin_read2
pci_fin_read2: pci_fin_read2:
; restore configuration space
xchg eax, [esp]
mov dx, 0xcfa
out dx, al
mov dl, 0xf8
mov al, ah
out dx, al
pop eax
pop esi ebx pop esi ebx
ret ret
@ -296,10 +269,7 @@ pci_write_reg:
call pci_make_config_cmd call pci_make_config_cmd
mov ebx, eax mov ebx, eax
; get current state into ecx
mov dx, 0xcf8 mov dx, 0xcf8
in eax, dx
push eax
; set up addressing to config data ; set up addressing to config data
mov eax, ebx mov eax, ebx
and al, 0xfc; make address dword-aligned and al, 0xfc; make address dword-aligned
@ -326,14 +296,8 @@ pci_write_word1:
jmp pci_fin_write1 jmp pci_fin_write1
pci_write_dword1: pci_write_dword1:
out dx, eax out dx, eax
jmp pci_fin_write1
pci_fin_write1: pci_fin_write1:
; restore configuration control
pop eax
mov dl, 0xf8
out dx, eax
xor eax, eax xor eax, eax
pop ebx esi pop ebx esi
@ -347,14 +311,7 @@ pci_write_reg_2:
mov esi, eax ; save register size into ESI mov esi, eax ; save register size into ESI
and esi, 3 and esi, 3
push eax mov dx, 0xcfa
;store current state of config space
mov dx, 0xcf8
in al, dx
mov ah, al
mov dl, 0xfa
in al, dx
xchg eax, [esp]
; out 0xcfa,bus ; out 0xcfa,bus
mov al, ah mov al, ah
out dx, al out dx, al
@ -385,15 +342,7 @@ pci_write_word2:
jmp pci_fin_write2 jmp pci_fin_write2
pci_write_dword2: pci_write_dword2:
out dx, eax out dx, eax
jmp pci_fin_write2
pci_fin_write2: pci_fin_write2:
; restore configuration space
pop eax
mov dx, 0xcfa
out dx, al
mov dl, 0xf8
mov al, ah
out dx, al
xor eax, eax xor eax, eax
pop ebx esi pop ebx esi

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
; USB Host Controller support code: hardware-independent part, ; USB Host Controller support code: hardware-independent part,
; common for all controller types. ; common for all controller types.

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
; Support for USB (non-root) hubs: ; Support for USB (non-root) hubs:
; powering up/resetting/disabling ports, ; powering up/resetting/disabling ports,
; watching for adding/removing devices. ; watching for adding/removing devices.

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
; Initialization of the USB subsystem. ; Initialization of the USB subsystem.
; Provides usb_init procedure, includes all needed files. ; Provides usb_init procedure, includes all needed files.

View File

@ -1,3 +1,12 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
; Memory management for USB structures. ; Memory management for USB structures.
; Protocol layer uses the common kernel heap malloc/free. ; Protocol layer uses the common kernel heap malloc/free.
; Hardware layer has special requirements: ; Hardware layer has special requirements:

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
; Functions for USB pipe manipulation: opening/closing, sending data etc. ; Functions for USB pipe manipulation: opening/closing, sending data etc.
; ;
USB_STDCALL_VERIFY = 1 USB_STDCALL_VERIFY = 1

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
; Implementation of the USB protocol for device enumeration. ; Implementation of the USB protocol for device enumeration.
; Manage a USB device when it becomes ready for USB commands: ; Manage a USB device when it becomes ready for USB commands:
; configure, enumerate, load the corresponding driver(s), ; configure, enumerate, load the corresponding driver(s),

View File

@ -179,8 +179,7 @@ struct TSS
_io_map_1 rb 4096 _io_map_1 rb 4096
ends ends
PARTITION_COUNT equ 64 DRIVE_DATA_SIZE equ 16
DRIVE_DATA_SIZE equ (16+PARTITION_COUNT*100)
OS_BASE equ 0x80000000 OS_BASE equ 0x80000000
@ -205,7 +204,7 @@ FDD_BUFF equ (OS_BASE+0x000D000) ;512
WIN_TEMP_XY equ (OS_BASE+0x000F300) WIN_TEMP_XY equ (OS_BASE+0x000F300)
KEY_COUNT equ (OS_BASE+0x000F400) KEY_COUNT equ (OS_BASE+0x000F400)
KEY_BUFF equ (OS_BASE+0x000F401) KEY_BUFF equ (OS_BASE+0x000F401) ; 120*2 + 2*2 = 244 bytes, actually 255 bytes
BTN_COUNT equ (OS_BASE+0x000F500) BTN_COUNT equ (OS_BASE+0x000F500)
BTN_BUFF equ (OS_BASE+0x000F501) BTN_BUFF equ (OS_BASE+0x000F501)
@ -304,7 +303,7 @@ BOOT_DEBUG_PRINT equ 0x901E ;byte If nonzero, duplicates debug output to
BOOT_DMA equ 0x901F ; BOOT_DMA equ 0x901F ;
BOOT_PCI_DATA equ 0x9020 ;8bytes pci data BOOT_PCI_DATA equ 0x9020 ;8bytes pci data
BOOT_VRR equ 0x9030 ;byte VRR start enabled 1, 2-no BOOT_VRR equ 0x9030 ;byte VRR start enabled 1, 2-no
BOOT_IDE_BASE_ADDR equ 0x9031 ;word IDEContrRegsBaseAddr ;BOOT_IDE_BASE_ADDR equ 0x9031 ;word IDEContrRegsBaseAddr ; now free and is not used
BOOT_MEM_AMOUNT equ 0x9034 ;dword memory amount BOOT_MEM_AMOUNT equ 0x9034 ;dword memory amount
BOOT_APM_ENTRY equ 0x9040 BOOT_APM_ENTRY equ 0x9040
@ -313,12 +312,12 @@ BOOT_APM_FLAGS equ 0x9046 ;unused
BOOT_APM_CODE_32 equ 0x9050 BOOT_APM_CODE_32 equ 0x9050
BOOT_APM_CODE_16 equ 0x9052 BOOT_APM_CODE_16 equ 0x9052
BOOT_APM_DATA_16 equ 0x9054 BOOT_APM_DATA_16 equ 0x9054
BOOT_IDE_BAR0_16 equ 0x9056 ;BOOT_IDE_BAR0_16 equ 0x9056 ; now free and is not used
BOOT_IDE_BAR1_16 equ 0x9058 ;BOOT_IDE_BAR1_16 equ 0x9058 ; now free and is not used
BOOT_IDE_BAR2_16 equ 0x905A ;BOOT_IDE_BAR2_16 equ 0x905A ; now free and is not used
BOOT_IDE_BAR3_16 equ 0x905C ;BOOT_IDE_BAR3_16 equ 0x905C ; now free and is not used
BOOT_IDE_PI_16 equ 0x905E ;BOOT_IDE_PI_16 equ 0x905E ; now free and is not used
BOOT_IDE_INTERR_16 equ 0x9060 ;BOOT_IDE_INTERR_16 equ 0x9060 ; now free and is not used
TMP_FILE_NAME equ 0 TMP_FILE_NAME equ 0
TMP_CMD_LINE equ 1024 TMP_CMD_LINE equ 1024

View File

@ -1,10 +1,12 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
iglobal iglobal
IRQ_COUNT dd 24 IRQ_COUNT dd 24

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4 align 4
sys_clipboard: sys_clipboard:

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
; Éste archivo debe ser editado con codificación CP866 ; Éste archivo debe ser editado con codificación CP866
ugui_mouse_speed cp850 'velocidad del ratón',0 ugui_mouse_speed cp850 'velocidad del ratón',0

View File

@ -136,9 +136,18 @@ debug_getcontext:
; ecx=pid ; ecx=pid
; edx=sizeof(CONTEXT) ; edx=sizeof(CONTEXT)
; esi->CONTEXT ; esi->CONTEXT
; destroys eax,ecx,edx,esi,edi ; destroys eax,ebx,ecx,edx,esi,edi
cmp edx, 28h
jnz .ret xor ebx, ebx ; 0 - get only gp regs
cmp edx, 40
je .std_ctx
cmp edx, 48+288
jne .ret
inc ebx ; 1 - get sse context
; TODO legacy 32-bit FPU/MMX context
.std_ctx:
; push ecx ; push ecx
; mov ecx, esi ; mov ecx, esi
call check_region call check_region
@ -147,8 +156,15 @@ debug_getcontext:
jnz .ret jnz .ret
call get_debuggee_slot call get_debuggee_slot
jc .ret jc .ret
shr eax, 5
cmp eax, [fpu_owner]
jne @f
inc bh ; set swap context flag
@@:
shl eax, 8
mov edi, esi mov edi, esi
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack] mov eax, [eax+SLOT_BASE+APPDATA.pl0_stack]
lea esi, [eax+RING0_STACK_SIZE] lea esi, [eax+RING0_STACK_SIZE]
.ring0: .ring0:
@ -178,6 +194,29 @@ debug_getcontext:
mov [edi+4], eax mov [edi+4], eax
lodsd ;esp lodsd ;esp
mov [edi+18h], eax mov [edi+18h], eax
dec bl
js .ret
dec bl
jns .ret
test bh, bh ; check swap flag
jz @F
ffree st0 ; swap context
@@:
add esi, 4 ;top of ring0 stack
;fpu/sse context saved here
add edi, 40
mov eax, 1 ;sse context
stosd
xor eax, eax ;reserved dword
stosd
mov ecx, 288/4
rep movsd ;copy sse context
.ret: .ret:
sti sti
ret ret

View File

@ -1,10 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
IRQ_RESERVED equ 24 IRQ_RESERVED equ 24
IRQ_POOL_SIZE equ 48 IRQ_POOL_SIZE equ 48

View File

@ -1312,113 +1312,6 @@ proc load_pe_driver stdcall, file:dword, cmdline:dword
ret ret
endp endp
align 4
proc init_mtrr
cmp [BOOT_VARS+BOOT_MTRR], byte 2
je .exit
bt [cpu_caps], CAPS_MTRR
jnc .exit
mov eax, cr0
or eax, 0x60000000 ;disable caching
mov cr0, eax
wbinvd ;invalidate cache
mov ecx, 0x2FF
rdmsr ;
; has BIOS already initialized MTRRs?
test ah, 8
jnz .skip_init
; rarely needed, so mainly placeholder
; main memory - cached
push eax
mov eax, [MEM_AMOUNT]
; round eax up to next power of 2
dec eax
bsr ecx, eax
mov ebx, 2
shl ebx, cl
dec ebx
; base of memory range = 0, type of memory range = MEM_WB
xor edx, edx
mov eax, MEM_WB
mov ecx, 0x200
wrmsr
; mask of memory range = 0xFFFFFFFFF - (size - 1), ebx = size - 1
mov eax, 0xFFFFFFFF
mov edx, 0x0000000F
sub eax, ebx
sbb edx, 0
or eax, 0x800
inc ecx
wrmsr
; clear unused MTRRs
xor eax, eax
xor edx, edx
@@:
inc ecx
wrmsr
cmp ecx, 0x20F
jb @b
; enable MTRRs
pop eax
or ah, 8
and al, 0xF0; default memtype = UC
mov ecx, 0x2FF
wrmsr
.skip_init:
stdcall set_mtrr, [LFBAddress], [LFBSize], MEM_WC
wbinvd ;again invalidate
mov eax, cr0
and eax, not 0x60000000
mov cr0, eax ; enable caching
.exit:
ret
endp
align 4
proc set_mtrr stdcall, base:dword,size:dword,mem_type:dword
; find unused register
mov ecx, 0x201
@@:
rdmsr
dec ecx
test ah, 8
jz .found
rdmsr
mov al, 0; clear memory type field
cmp eax, [base]
jz .ret
add ecx, 3
cmp ecx, 0x210
jb @b
; no free registers, ignore the call
.ret:
ret
.found:
; found, write values
xor edx, edx
mov eax, [base]
or eax, [mem_type]
wrmsr
mov ebx, [size]
dec ebx
mov eax, 0xFFFFFFFF
mov edx, 0x00000000
sub eax, ebx
sbb edx, 0
or eax, 0x800
inc ecx
wrmsr
ret
endp
align 4 align 4
proc create_ring_buffer stdcall, size:dword, flags:dword proc create_ring_buffer stdcall, size:dword, flags:dword
locals locals

View File

@ -29,8 +29,7 @@ irq0:
.nocounter: .nocounter:
xor ecx, ecx ; send End Of Interrupt signal xor ecx, ecx ; send End Of Interrupt signal
call irq_eoi call irq_eoi
; btr dword[DONT_SWITCH], 0
; jc .return
mov bl, SCHEDULE_ANY_PRIORITY mov bl, SCHEDULE_ANY_PRIORITY
call find_next_task call find_next_task
jz .return ; if there is only one running process jz .return ; if there is only one running process
@ -44,26 +43,10 @@ change_task:
pushfd pushfd
cli cli
pushad pushad
if 0
; \begin{Mario79} ; <- must be refractoried, if used...
cmp [dma_task_switched], 1
jne .find_next_task
mov [dma_task_switched], 0
mov ebx, [dma_process]
cmp [CURRENT_TASK], ebx
je .return
mov edi, [dma_slot_ptr]
mov [CURRENT_TASK], ebx
mov [TASK_BASE], edi
jmp @f
.find_next_task:
; \end{Mario79}
end if
mov bl, SCHEDULE_ANY_PRIORITY mov bl, SCHEDULE_ANY_PRIORITY
call find_next_task call find_next_task
jz .return ; the same task -> skip switch jz .return ; the same task -> skip switch
@@:
; mov byte[DONT_SWITCH], 1
call do_change_task call do_change_task
.return: .return:
popad popad

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
; Éste archivo debe ser editado con codificación CP866 ; Éste archivo debe ser editado con codificación CP866
msg_sel_ker cp850 "núcleo", 0 msg_sel_ker cp850 "núcleo", 0

View File

@ -418,7 +418,6 @@ destroy_thread:
.slot equ esp+4 ;locals .slot equ esp+4 ;locals
.process equ esp ;ptr to parent process .process equ esp ;ptr to parent process
xchg bx, bx
push esi ;save .slot push esi ;save .slot
@ -453,7 +452,7 @@ destroy_thread:
mov ecx, [esi+8] mov ecx, [esi+8]
mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx
.nov86: .nov86:
;destroy per-thread kerlen objects ;destroy per-thread kernel objects
mov esi, [.slot] mov esi, [.slot]
shl esi, 8 shl esi, 8
add esi, SLOT_BASE+APP_OBJ_OFFSET add esi, SLOT_BASE+APP_OBJ_OFFSET
@ -749,7 +748,6 @@ destroy_thread:
.xd1: .xd1:
;release slot ;release slot
xchg bx, bx
bts [thr_slot_map], esi bts [thr_slot_map], esi

View File

@ -389,7 +389,6 @@ test_app_header:
xor eax, eax xor eax, eax
ret ret
align 4 align 4
alloc_thread_slot: alloc_thread_slot:
;input: ;input:
@ -431,6 +430,10 @@ proc create_process stdcall, app_size:dword,img_base:dword,img_size:dword
app_tabs dd ? app_tabs dd ?
endl endl
push ebx
push esi
push edi
mov ecx, pg_data.mutex mov ecx, pg_data.mutex
call mutex_lock call mutex_lock
@ -552,6 +555,10 @@ proc create_process stdcall, app_size:dword,img_base:dword,img_size:dword
mov ecx, pg_data.mutex mov ecx, pg_data.mutex
call mutex_unlock call mutex_unlock
mov eax, [process] mov eax, [process]
pop edi
pop esi
pop ebx
ret ret
.fail: .fail:
mov ecx, pg_data.mutex mov ecx, pg_data.mutex
@ -561,6 +568,9 @@ proc create_process stdcall, app_size:dword,img_base:dword,img_size:dword
;; stdcall destroy_app_space, [dir_addr], 0 ;; stdcall destroy_app_space, [dir_addr], 0
@@: @@:
xor eax, eax xor eax, eax
pop edi
pop esi
pop ebx
ret ret
endp endp

View File

@ -922,3 +922,74 @@ v86_irq2:
call do_change_task call do_change_task
popad popad
iretd iretd
align 4
v86_entry:
xchg bx, bx
mov ebx, 100000
call delay_hs
jmp v86_entry
align 4
proc v86_init
locals
v86_slot dd ?
v86_cmdline dd ? ;0x00
v86_path dd ? ;0x04
v86_eip dd ? ;0x08
v86_esp dd ? ;0x0C
v86_mem dd ? ;0x10
endl
xor eax, eax
mov [v86_eip], v86_entry
mov [v86_cmdline], eax
mov [v86_esp], eax
mov [v86_path], eax
call lock_application_table
call alloc_thread_slot
test eax, eax
jz .failed
mov [v86_slot], eax
mov edi, eax
shl edi, 8
add edi, SLOT_BASE
mov esi, edi ;edx=edi - pointer to extended infomation about new thread
mov ecx, 256/4
xor eax, eax
cld
rep stosd ;clean extended information about new thread
mov [esi], dword 'V86 '
stdcall create_process, 4096, OS_BASE, 4096
test eax, eax
jz .failed
mov [eax+PROC.mem_used], 4096
mov [esi+APPDATA.process], eax
lea ebx, [esi+APPDATA.list]
lea ecx, [eax+PROC.thr_list]
list_add_tail ebx, ecx ;add thread to process child's list
lea eax, [v86_cmdline]
stdcall set_app_params , [v86_slot], eax, 0, 0, 2
mov eax, [process_number] ;set result
call unlock_application_table
ret
.failed:
xor eax, eax
.failed1:
call unlock_application_table
dec eax ;-1
ret
endp

View File

@ -168,8 +168,10 @@ firstapp db 'LAUNCHER',0
notifyapp db '@notify',0 notifyapp db '@notify',0
if lang eq ru if lang eq ru
ud_user_message cp866 'Ошибка: неподдерживаемая инструкция процессора',0 ud_user_message cp866 'Ошибка: неподдерживаемая инструкция процессора',0
mtrr_user_message cp866 '"Обнаружена проблема с конфигурацией MTRR.\nПроизводительность может быть пониженной" -dW',0
else if ~ lang eq sp else if ~ lang eq sp
ud_user_message db 'Error: unsupported processor instruction',0 ud_user_message db 'Error: unsupported processor instruction',0
mtrr_user_message db '"There is a problem with MTRR configuration.\nPerformance can be low" -dW',0
end if end if
vmode db '/sys/drivers/VMODE.MDR',0 vmode db '/sys/drivers/VMODE.MDR',0
@ -497,63 +499,12 @@ BgrDataHeight rd 1
skin_data rd 1 skin_data rd 1
cache_ide0:
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:
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:
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:
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 debug_step_pointer rd 1
lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled
pci_access_enabled rd 1 ; 0 = disabled , 1 = enabled pci_access_enabled rd 1 ; 0 = disabled , 1 = enabled
cpu_phys_addr_width rb 1 ; also known as MAXPHYADDR in Intel manuals
hdd_appl_data rb 1 ; 0 = system cache, 1 - application cache hdd_appl_data rb 1 ; 0 = system cache, 1 - application cache
cd_appl_data rb 1 ; 0 = system cache, 1 - application cache cd_appl_data rb 1 ; 0 = system cache, 1 - application cache

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
boot_initirq latin1 'Algväärtustan IRQ',0 boot_initirq latin1 'Algväärtustan IRQ',0
boot_picinit latin1 'Algväärtustan PIC',0 boot_picinit latin1 'Algväärtustan PIC',0
boot_v86machine latin1 'Algväärtustan süsteemi V86 masinat',0 boot_v86machine latin1 'Algväärtustan süsteemi V86 masinat',0

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
boot_initirq: cp850 'Inicializar IRQ',0 boot_initirq: cp850 'Inicializar IRQ',0
boot_picinit: cp850 'Inicializar PIC',0 boot_picinit: cp850 'Inicializar PIC',0
boot_v86machine: cp850 'Inicializar sistema V86',0 boot_v86machine: cp850 'Inicializar sistema V86',0
@ -41,3 +51,4 @@ msg_version: cp850 'versión incompatible del controlador',13,10,0
msg_www: cp850 'por favor, visita www.kolibrios.org',13,10,0 msg_www: cp850 'por favor, visita www.kolibrios.org',13,10,0
ud_user_message:cp850 'Error: instrucción no soportada por el procesador',0 ud_user_message:cp850 'Error: instrucción no soportada por el procesador',0
mtrr_user_message cp850 '"There is a problem with MTRR configuration.\nPerformance can be low" -dW',0

View File

@ -1,10 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2008-2011. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2008-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
; Detect all BIOS hard drives. ; Detect all BIOS hard drives.
; diamond, 2008 ; diamond, 2008
; Do not include USB mass storages. CleverMouse, 2013 ; Do not include USB mass storages. CleverMouse, 2013

View File

@ -1,10 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2009-2011. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2009-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
; Query physical memory map from BIOS. ; Query physical memory map from BIOS.
; diamond, 2009 ; diamond, 2009

View File

@ -17,93 +17,190 @@ $Revision: 3881 $
;**************************************************** ;****************************************************
;* ПОИСК HDD и CD * ;* ПОИСК HDD и CD *
;**************************************************** ;****************************************************
cmp [IDEContrProgrammingInterface], 0 cmp [ecx+IDE_DATA.ProgrammingInterface], 0
je EndFindHDD je EndFindHDD
FindHDD: FindHDD:
push ecx
xor ebx, ebx
inc ebx
cmp ecx, IDE_controller_2
jne @f
add bl, 5
jmp .find
@@:
cmp ecx, IDE_controller_3
jne .find
add bl, 10
;--------------------------------------
.find:
mov [ChannelNumber], 1 mov [ChannelNumber], 1
mov [DiskNumber], 0 mov [DiskNumber], 0
call FindHDD_3 call FindHDD_2
; mov ax,[Sector512+176]
; mov [DRIVE_DATA+6],ax
; mov ax,[Sector512+126]
; mov [DRIVE_DATA+8],ax
; mov ax,[Sector512+128]
; mov [DRIVE_DATA+8],ax
mov [DiskNumber], 1 mov [DiskNumber], 1
call FindHDD_3 call FindHDD_2
; mov al,[Sector512+176]
; mov [DRIVE_DATA+7],al
inc [ChannelNumber] inc [ChannelNumber]
mov [DiskNumber], 0 mov [DiskNumber], 0
call FindHDD_3 call FindHDD_2
; mov al,[Sector512+176]
; mov [DRIVE_DATA+8],al
mov [DiskNumber], 1 mov [DiskNumber], 1
call FindHDD_1 call FindHDD_1
; mov al,[Sector512+176]
; mov [DRIVE_DATA+9],al
pop ecx
jmp EndFindHDD jmp EndFindHDD
;-----------------------------------------------------------------------------
FindHDD_2:
call FindHDD_1
shl byte [ebx+DRIVE_DATA], 2
ret
;-----------------------------------------------------------------------------
FindHDD_1: FindHDD_1:
DEBUGF 1, "K : Channel %d ",[ChannelNumber]:2 DEBUGF 1, "K : Channel %d ",[ChannelNumber]:2
DEBUGF 1, "Disk %d\n",[DiskNumber]:1 DEBUGF 1, "Disk %d\n",[DiskNumber]:1
push ebx ecx
call ReadHDD_ID call ReadHDD_ID
pop ecx ebx
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne FindHDD_2 jne .FindCD
cmp [Sector512+6], word 16 cmp [Sector512+6], word 16
ja FindHDD_2 ja .FindCD
cmp [Sector512+12], word 255 cmp [Sector512+12], word 255
ja FindHDD_2 ja .FindCD
inc byte [DRIVE_DATA+1]
jmp Print_Device_Name inc byte [ebx+DRIVE_DATA]
FindHDD_2: jmp .Print_Device_Name
;--------------------------------------
.FindCD:
push ebx ecx
call DeviceReset call DeviceReset
pop ecx ebx
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne FindHDD_2_2 jne .end
push ebx ecx
call ReadCD_ID call ReadCD_ID
pop ecx ebx
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne FindHDD_2_2 jne .end
inc byte [DRIVE_DATA+1]
inc byte [DRIVE_DATA+1] add [ebx+DRIVE_DATA], byte 2
Print_Device_Name: ;--------------------------------------
.Print_Device_Name:
pushad pushad
pushfd pushfd
xor ebx, ebx
mov bx, [ChannelNumber]
dec ebx
shl ebx, 1
add bl, [DiskNumber]
shl ebx, 1
call calculate_IDE_device_values_storage
;--------------------------------------
.copy_dev_name:
mov esi, Sector512+27*2 mov esi, Sector512+27*2
mov edi, dev_name mov edi, dev_name
mov ecx, 20 mov ecx, 20
cld cld
;--------------------------------------
@@: @@:
lodsw lodsw
xchg ah, al xchg ah, al
stosw stosw
loop @b loop @b
popfd
popad
DEBUGF 1, "K : Dev: %s \n", dev_name DEBUGF 1, "K : Dev: %s \n", dev_name
xor eax, eax xor eax, eax
mov ax, [Sector512+64*2] mov ax, [Sector512+64*2]
DEBUGF 1, "K : PIO mode %x\n", eax DEBUGF 1, "K : PIO possible modes %x\n", al
mov ax, [Sector512+51*2]
mov al, ah
call convert_Sector512_value
DEBUGF 1, "K : PIO set mode %x\n", ah
mov ax, [Sector512+63*2] mov ax, [Sector512+63*2]
DEBUGF 1, "K : Multiword DMA mode %x\n", eax DEBUGF 1, "K : Multiword DMA possible modes %x\n", al
mov al, ah
call convert_Sector512_value
DEBUGF 1, "K : Multiword DMA set mode %x\n", ah
mov ax, [Sector512+88*2] mov ax, [Sector512+88*2]
DEBUGF 1, "K : Ultra DMA mode %x\n", eax DEBUGF 1, "K : Ultra DMA possible modes %x\n", al
FindHDD_2_2:
ret
FindHDD_3: mov [ebx+IDE_DEVICE.UDMA_possible_modes], al
call FindHDD_1
shl byte [DRIVE_DATA+1], 2
ret
mov al, ah
call convert_Sector512_value
DEBUGF 1, "K : Ultra DMA set mode %x\n", ah
mov [ebx+IDE_DEVICE.UDMA_set_mode], ah
popfd
popad
ret
;--------------------------------------
.end:
DEBUGF 1, "K : Device not found\n"
ret
;-----------------------------------------------------------------------------
calculate_IDE_device_values_storage:
cmp ecx, IDE_controller_1
jne @f
add ebx, IDE_device_1
jmp .exit
;--------------------------------------
@@:
cmp ecx, IDE_controller_2
jne @f
add ebx, IDE_device_2
jmp .exit
;--------------------------------------
@@:
add ebx, IDE_device_3
;--------------------------------------
.exit:
ret
;-----------------------------------------------------------------------------
convert_Sector512_value:
mov ecx, 8
xor ah, ah
;--------------------------------------
@@:
test al, 1b
jnz .end
shr al, 1
inc ah
loop @b
xor ah, ah
;--------------------------------------
.end:
ret
;-----------------------------------------------------------------------------
; Адрес считываемого сектора в режиме LBA ; Адрес считываемого сектора в режиме LBA
uglobal uglobal
SectorAddress DD ? SectorAddress dd ?
dev_name: dev_name:
rb 41 rb 41
endg endg
;-----------------------------------------------------------------------------
;************************************************* ;*************************************************
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА ЖЕСТКОГО ДИСКА * ;* ЧТЕНИЕ ИДЕНТИФИКАТОРА ЖЕСТКОГО ДИСКА *
;* Входные параметры передаются через глобальные * ;* Входные параметры передаются через глобальные *
@ -119,32 +216,32 @@ ReadHDD_ID:
; Послать команду идентификации устройства ; Послать команду идентификации устройства
mov [ATAFeatures], 0 mov [ATAFeatures], 0
mov [ATAHead], 0 mov [ATAHead], 0
mov [ATACommand], 0ECh mov [ATACommand], 0xEC
call SendCommandToHDD call SendCommandToHDD
cmp [DevErrorCode], 0;проверить код ошибки cmp [DevErrorCode], 0 ;проверить код ошибки
jne @@End ;закончить, сохранив код ошибки jne @@End ;закончить, сохранив код ошибки
mov DX, [ATABasePortAddr]
add DX, 7 ;адрес регистра состояни mov dx, [ATABasePortAddr]
add dx, 7 ;адрес регистра состояни
mov ecx, 0xffff mov ecx, 0xffff
@@WaitCompleet: @@WaitCompleet:
; Проверить время выполнения команды ; Проверить время выполнения команды
dec ecx dec ecx
; cmp ecx,0
jz @@Error1 ;ошибка тайм-аута jz @@Error1 ;ошибка тайм-аута
; Проверить готовность ; Проверить готовность
in AL, DX in al, dx
test AL, 80h ;состояние сигнала BSY test al, 80h ;состояние сигнала BSY
jnz @@WaitCompleet jnz @@WaitCompleet
test AL, 1 ;состояние сигнала ERR
test al, 1 ;состояние сигнала ERR
jnz @@Error6 jnz @@Error6
test AL, 08h ;состояние сигнала DRQ
test al, 08h ;состояние сигнала DRQ
jz @@WaitCompleet jz @@WaitCompleet
; Принять блок данных от контроллера ; Принять блок данных от контроллера
; mov AX,DS mov edi, Sector512
; mov ES,AX mov dx, [ATABasePortAddr];регистр данных
mov EDI, Sector512 ;offset Sector512 mov cx, 256 ;число считываемых слов
mov DX, [ATABasePortAddr];регистр данных
mov CX, 256 ;число считываемых слов
rep insw ;принять блок данных rep insw ;принять блок данных
ret ret
; Записать код ошибки ; Записать код ошибки
@ -155,27 +252,24 @@ ReadHDD_ID:
mov [DevErrorCode], 6 mov [DevErrorCode], 6
@@End: @@End:
ret ret
;-----------------------------------------------------------------------------
iglobal
; Стандартные базовые адреса каналов 1 и 2
StandardATABases DW 1F0h, 170h
endg
uglobal uglobal
; Стандартные базовые адреса каналов 1 и 2
StandardATABases dw ?, ? ; 1F0h, 170h
; Номер канала ; Номер канала
ChannelNumber DW ? ChannelNumber dw ?
; Номер диска ; Номер диска
DiskNumber DB ? DiskNumber db ?
; Базовый адрес группы портов контроллера ATA ; Базовый адрес группы портов контроллера ATA
ATABasePortAddr DW ? ATABasePortAddr dw ?
; Параметры ATA-команды ; Параметры ATA-команды
ATAFeatures DB ? ;особенности ATAFeatures db ? ;особенности
ATASectorCount DB ? ;количество обрабатываемых секторов ATASectorCount db ? ;количество обрабатываемых секторов
ATASectorNumber DB ? ;номер начального сектора ATASectorNumber db ? ;номер начального сектора
ATACylinder DW ? ;номер начального цилиндра ATACylinder dw ? ;номер начального цилиндра
ATAHead DB ? ;номер начальной головки ATAHead db ? ;номер начальной головки
ATAAddressMode DB ? ;режим адресации (0 - CHS, 1 - LBA) ATAAddressMode db ? ;режим адресации (0 - CHS, 1 - LBA)
ATACommand DB ? ;код команды, подлежащей выполнению ATACommand db ? ;код команды, подлежащей выполнению
; Код ошибки (0 - нет ошибок, 1 - превышен допустимый ; Код ошибки (0 - нет ошибок, 1 - превышен допустимый
; интервал ожидания, 2 - неверный код режима адресации, ; интервал ожидания, 2 - неверный код режима адресации,
; 3 - неверный номер канала, 4 - неверный номер диска, ; 3 - неверный номер канала, 4 - неверный номер диска,
@ -183,6 +277,7 @@ ATACommand DB ? ;код команды, подлежащей выполне
; команды) ; команды)
DevErrorCode dd ? DevErrorCode dd ?
endg endg
;-----------------------------------------------------------------------------
;**************************************************** ;****************************************************
;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ * ;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ *
;* Входные параметры передаются через глобальные * ;* Входные параметры передаются через глобальные *
@ -207,82 +302,78 @@ SendCommandToHDD:
cmp [ATAAddressMode], 1 cmp [ATAAddressMode], 1
ja @@Err2 ja @@Err2
; Проверить корректность номера канала ; Проверить корректность номера канала
mov BX, [ChannelNumber] mov bx, [ChannelNumber]
cmp BX, 1 cmp bx, 1
jb @@Err3 jb @@Err3
cmp BX, 2
cmp bx, 2
ja @@Err3 ja @@Err3
; Установить базовый адрес ; Установить базовый адрес
dec BX dec bx
shl BX, 1 shl bx, 1
movzx ebx, bx movzx ebx, bx
mov AX, [ebx+StandardATABases] mov ax, [ebx+StandardATABases]
mov [ATABasePortAddr], AX mov [ATABasePortAddr], ax
; Ожидание готовности HDD к приему команды ; Ожидание готовности HDD к приему команды
; Выбрать нужный диск ; Выбрать нужный диск
mov DX, [ATABasePortAddr] mov dx, [ATABasePortAddr]
add DX, 6 ;адрес регистра головок add dx, 6 ;адрес регистра головок
mov AL, [DiskNumber] mov al, [DiskNumber]
cmp AL, 1 ;проверить номера диска cmp al, 1 ;проверить номера диска
ja @@Err4 ja @@Err4
shl AL, 4
or AL, 10100000b shl al, 4
out DX, AL or al, 10100000b
out dx, al
; Ожидать, пока диск не будет готов ; Ожидать, пока диск не будет готов
inc DX inc dx
mov ecx, 0xfff mov ecx, 0xfff
; mov eax,[timer_ticks]
; mov [TickCounter_1],eax
@@WaitHDReady: @@WaitHDReady:
; Проверить время ожидани ; Проверить время ожидани
dec ecx dec ecx
; cmp ecx,0
jz @@Err1 jz @@Err1
; mov eax,[timer_ticks]
; sub eax,[TickCounter_1]
; cmp eax,300 ;ожидать 300 тиков
; ja @@Err1 ;ошибка тайм-аута
; Прочитать регистр состояни ; Прочитать регистр состояни
in AL, DX in al, dx
; Проверить состояние сигнала BSY ; Проверить состояние сигнала BSY
test AL, 80h test al, 80h
jnz @@WaitHDReady jnz @@WaitHDReady
; Проверить состояние сигнала DRQ ; Проверить состояние сигнала DRQ
test AL, 08h test al, 08h
jnz @@WaitHDReady jnz @@WaitHDReady
; Загрузить команду в регистры контроллера ; Загрузить команду в регистры контроллера
cli cli
mov DX, [ATABasePortAddr] mov dx, [ATABasePortAddr]
inc DX ;регистр "особенностей" inc dx ;регистр "особенностей"
mov AL, [ATAFeatures] mov al, [ATAFeatures]
out DX, AL out dx, AL
inc DX ;счетчик секторов inc dx ;счетчик секторов
mov AL, [ATASectorCount] mov al, [ATASectorCount]
out DX, AL out dx, AL
inc DX ;регистр номера сектора inc dx ;регистр номера сектора
mov AL, [ATASectorNumber] mov al, [ATASectorNumber]
out DX, AL out dx, AL
inc DX ;номер цилиндра (младший байт) inc dx ;номер цилиндра (младший байт)
mov AX, [ATACylinder] mov ax, [ATACylinder]
out DX, AL out dx, AL
inc DX ;номер цилиндра (старший байт) inc dx ;номер цилиндра (старший байт)
mov AL, AH mov al, AH
out DX, AL out dx, AL
inc DX ;номер головки/номер диска inc dx ;номер головки/номер диска
mov AL, [DiskNumber] mov al, [DiskNumber]
shl AL, 4 shl al, 4
cmp [ATAHead], 0Fh;проверить номер головки cmp [ATAHead], 0xF ;проверить номер головки
ja @@Err5 ja @@Err5
or AL, [ATAHead]
or AL, 10100000b or al, [ATAHead]
mov AH, [ATAAddressMode] or al, 10100000b
shl AH, 6 mov ah, [ATAAddressMode]
or AL, AH shl ah, 6
out DX, AL or al, ah
out dx, al
; Послать команду ; Послать команду
mov AL, [ATACommand] mov al, [ATACommand]
inc DX ;регистр команд inc dx ;регистр команд
out DX, AL out dx, al
sti sti
; Сбросить признак ошибки ; Сбросить признак ошибки
mov [DevErrorCode], 0 mov [DevErrorCode], 0
@ -304,7 +395,7 @@ SendCommandToHDD:
mov [DevErrorCode], 5 mov [DevErrorCode], 5
; Завершение работы программы ; Завершение работы программы
ret ret
;-----------------------------------------------------------------------------
;************************************************* ;*************************************************
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА УСТРОЙСТВА ATAPI * ;* ЧТЕНИЕ ИДЕНТИФИКАТОРА УСТРОЙСТВА ATAPI *
;* Входные параметры передаются через глобальные * ;* Входные параметры передаются через глобальные *
@ -323,33 +414,32 @@ ReadCD_ID:
mov [ATASectorNumber], 0 mov [ATASectorNumber], 0
mov [ATACylinder], 0 mov [ATACylinder], 0
mov [ATAHead], 0 mov [ATAHead], 0
mov [ATACommand], 0A1h mov [ATACommand], 0xA1
call SendCommandToHDD call SendCommandToHDD
cmp [DevErrorCode], 0;проверить код ошибки cmp [DevErrorCode], 0;проверить код ошибки
jne @@End_1 ;закончить, сохранив код ошибки jne @@End_1 ;закончить, сохранив код ошибки
; Ожидать готовность данных HDD ; Ожидать готовность данных HDD
mov DX, [ATABasePortAddr] mov dx, [ATABasePortAddr]
add DX, 7 ;порт 1х7h add dx, 7 ;порт 1х7h
mov ecx, 0xffff mov ecx, 0xffff
@@WaitCompleet_1: @@WaitCompleet_1:
; Проверить врем ; Проверить врем
dec ecx dec ecx
; cmp ecx,0
jz @@Error1_1 ;ошибка тайм-аута jz @@Error1_1 ;ошибка тайм-аута
; Проверить готовность ; Проверить готовность
in AL, DX in al, dx
test AL, 80h ;состояние сигнала BSY test al, 80h ;состояние сигнала BSY
jnz @@WaitCompleet_1 jnz @@WaitCompleet_1
test AL, 1 ;состояние сигнала ERR
test al, 1 ;состояние сигнала ERR
jnz @@Error6_1 jnz @@Error6_1
test AL, 08h ;состояние сигнала DRQ
test al, 08h ;состояние сигнала DRQ
jz @@WaitCompleet_1 jz @@WaitCompleet_1
; Принять блок данных от контроллера ; Принять блок данных от контроллера
; mov AX,DS mov edi, Sector512 ;offset Sector512
; mov ES,AX mov dx, [ATABasePortAddr];порт 1x0h
mov EDI, Sector512 ;offset Sector512 mov cx, 256;число считываемых слов
mov DX, [ATABasePortAddr];порт 1x0h
mov CX, 256;число считываемых слов
rep insw rep insw
ret ret
; Записать код ошибки ; Записать код ошибки
@ -360,7 +450,7 @@ ReadCD_ID:
mov [DevErrorCode], 6 mov [DevErrorCode], 6
@@End_1: @@End_1:
ret ret
;-----------------------------------------------------------------------------
;************************************************* ;*************************************************
;* СБРОС УСТРОЙСТВА * ;* СБРОС УСТРОЙСТВА *
;* Входные параметры передаются через глобальные * ;* Входные параметры передаются через глобальные *
@ -370,39 +460,40 @@ ReadCD_ID:
;************************************************* ;*************************************************
DeviceReset: DeviceReset:
; Проверить корректность номера канала ; Проверить корректность номера канала
mov BX, [ChannelNumber] mov bx, [ChannelNumber]
cmp BX, 1 cmp bx, 1
jb @@Err3_2 jb @@Err3_2
cmp BX, 2
cmp bx, 2
ja @@Err3_2 ja @@Err3_2
; Установить базовый адрес ; Установить базовый адрес
dec BX dec bx
shl BX, 1 shl bx, 1
movzx ebx, bx movzx ebx, bx
mov DX, [ebx+StandardATABases] mov dx, [ebx+StandardATABases]
mov [ATABasePortAddr], DX mov [ATABasePortAddr], dx
; Выбрать нужный диск ; Выбрать нужный диск
add DX, 6 ;адрес регистра головок add dx, 6 ;адрес регистра головок
mov AL, [DiskNumber] mov al, [DiskNumber]
cmp AL, 1 ;проверить номера диска cmp al, 1 ;проверить номера диска
ja @@Err4_2 ja @@Err4_2
shl AL, 4
or AL, 10100000b shl al, 4
out DX, AL or al, 10100000b
out dx, al
; Послать команду "Сброс" ; Послать команду "Сброс"
mov AL, 08h mov al, 0x8
inc DX ;регистр команд inc dx ;регистр команд
out DX, AL out dx, al
mov ecx, 0x80000 mov ecx, 0x80000
@@WaitHDReady_1: @@WaitHDReady_1:
; Проверить время ожидани ; Проверить время ожидани
dec ecx dec ecx
; cmp ecx,0
je @@Err1_2 ;ошибка тайм-аута je @@Err1_2 ;ошибка тайм-аута
; Прочитать регистр состояни ; Прочитать регистр состояни
in AL, DX in al, dx
; Проверить состояние сигнала BSY ; Проверить состояние сигнала BSY
test AL, 80h test al, 80h
jnz @@WaitHDReady_1 jnz @@WaitHDReady_1
; Сбросить признак ошибки ; Сбросить признак ошибки
mov [DevErrorCode], 0 mov [DevErrorCode], 0
@ -418,6 +509,5 @@ DeviceReset:
mov [DevErrorCode], 4 mov [DevErrorCode], 4
; Записать код ошибки ; Записать код ошибки
ret ret
;-----------------------------------------------------------------------------
EndFindHDD: EndFindHDD:

View File

@ -7,6 +7,7 @@
$Revision: 3742 $ $Revision: 3742 $
;-----------------------------------------------------------------------------
pusha pusha
mov eax, [pg_data.pages_free] mov eax, [pg_data.pages_free]
@ -20,89 +21,167 @@ $Revision: 3742 $
; check a upper size of the cache, no more than 1 Mb on the physical device ; check a upper size of the cache, no more than 1 Mb on the physical device
cmp eax, 1024*1024 cmp eax, 1024*1024
jbe @f jbe @f
mov eax, 1024*1024 mov eax, 1024*1024
jmp .continue jmp .continue
;--------------------------------------
@@: @@:
; check a lower size of the cache, not less than 128 Kb on the physical device ; check a lower size of the cache, not less than 128 Kb on the physical device
cmp eax, 128*1024 cmp eax, 128*1024
jae @f jae .continue
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 [hdd_appl_data], 1;al
mov [cd_appl_data], 1
test byte [DRIVE_DATA+1], 2 mov eax, 128*1024
je .ide2 ;--------------------------------------
mov esi, cache_ide3 .continue:
call get_cache_ide push ecx
.ide2: mov ecx, 12
test byte [DRIVE_DATA+1], 8 mov esi, cache_ide0+IDE_CACHE.size
je .ide1 cld
mov esi, cache_ide2 @@:
call get_cache_ide mov [esi], eax
.ide1: add esi, sizeof.IDE_CACHE
test byte [DRIVE_DATA+1], 0x20 loop @b
je .ide0
mov esi, cache_ide1 pop ecx
call get_cache_ide
.ide0: xor eax, eax
mov [hdd_appl_data], 1 ;al
mov [cd_appl_data], 1
;--------------------------------------
test byte [DRIVE_DATA+1], 0x80 test byte [DRIVE_DATA+1], 0x80
je @f je @f
mov esi, cache_ide0 mov esi, cache_ide0
call get_cache_ide call get_cache_ide
;--------------------------------------
@@: @@:
jmp end_get_cache test byte [DRIVE_DATA+1], 0x20
je @f
mov esi, cache_ide1
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+1], 8
je @f
mov esi, cache_ide2
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+1], 2
je @f
mov esi, cache_ide3
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+6], 0x80
je @f
mov esi, cache_ide4
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+6], 0x20
je @f
mov esi, cache_ide5
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+6], 8
je @f
mov esi, cache_ide6
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+6], 2
je @f
mov esi, cache_ide7
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+11], 0x80
je @f
mov esi, cache_ide8
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+11], 0x20
je @f
mov esi, cache_ide9
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+11], 8
je @f
mov esi, cache_ide10
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+11], 2
je end_get_cache
mov esi, cache_ide11
call get_cache_ide
jmp end_get_cache
;-----------------------------------------------------------------------------
get_cache_ide: get_cache_ide:
and [esi+cache_ide0_search_start-cache_ide0], 0 and [esi+IDE_CACHE.search_start], 0
and [esi+cache_ide0_appl_search_start-cache_ide0], 0 and [esi+IDE_CACHE.appl_search_start], 0
push ecx push ecx
stdcall kernel_alloc, [esi+cache_ide0_size-cache_ide0] ; DEBUGF 1, "K : IDE_CACHE.size %x\n", [esi+IDE_CACHE.size]
mov [esi+cache_ide0_pointer-cache_ide0], eax stdcall kernel_alloc, [esi+IDE_CACHE.size]
mov [esi+IDE_CACHE.pointer], eax
pop ecx pop ecx
mov edx, eax mov edx, eax
mov eax, [esi+cache_ide0_size-cache_ide0] mov eax, [esi+IDE_CACHE.size]
shr eax, 3 shr eax, 3
mov [esi+cache_ide0_system_data_size-cache_ide0], eax ; DEBUGF 1, "K : IDE_CACHE.system_data_size %x\n", eax
mov [esi+IDE_CACHE.system_data_size], eax
mov ebx, eax mov ebx, eax
imul eax, 7 imul eax, 7
mov [esi+cache_ide0_appl_data_size-cache_ide0], eax ; DEBUGF 1, "K : IDE_CACHE.appl_data_size %x\n", eax
mov [esi+IDE_CACHE.appl_data_size], eax
add ebx, edx add ebx, edx
mov [esi+cache_ide0_data_pointer-cache_ide0], ebx mov [esi+IDE_CACHE.data_pointer], ebx
.cd: .cd:
push ecx push ecx
mov eax, [esi+cache_ide0_system_data_size-cache_ide0] mov eax, [esi+IDE_CACHE.system_data_size]
call calculate_for_cd call calculate_for_cd
add eax, [esi+cache_ide0_pointer-cache_ide0] add eax, [esi+IDE_CACHE.pointer]
mov [esi+cache_ide0_system_data-cache_ide0], eax mov [esi+IDE_CACHE.system_data], eax
mov [esi+cache_ide0_system_sad_size-cache_ide0], ecx mov [esi+IDE_CACHE.system_sad_size], ecx
push edi push edi
mov edi, [esi+cache_ide0_pointer-cache_ide0] mov edi, [esi+IDE_CACHE.pointer]
call clear_ide_cache call clear_ide_cache
pop edi pop edi
mov eax, [esi+cache_ide0_appl_data_size-cache_ide0] mov eax, [esi+IDE_CACHE.appl_data_size]
call calculate_for_cd call calculate_for_cd
add eax, [esi+cache_ide0_data_pointer-cache_ide0] add eax, [esi+IDE_CACHE.data_pointer]
mov [esi+cache_ide0_appl_data-cache_ide0], eax mov [esi+IDE_CACHE.appl_data], eax
mov [esi+cache_ide0_appl_sad_size-cache_ide0], ecx mov [esi+IDE_CACHE.appl_sad_size], ecx
push edi push edi
mov edi, [esi+cache_ide0_data_pointer-cache_ide0] mov edi, [esi+IDE_CACHE.data_pointer]
call clear_ide_cache call clear_ide_cache
pop edi pop edi
pop ecx pop ecx
ret ret
;-----------------------------------------------------------------------------
calculate_for_cd: calculate_for_cd:
push eax push eax
mov ebx, eax mov ebx, eax
@ -116,7 +195,7 @@ calculate_for_cd:
sub eax, ebx sub eax, ebx
dec ecx dec ecx
ret ret
;-----------------------------------------------------------------------------
clear_ide_cache: clear_ide_cache:
push eax push eax
shl ecx, 1 shl ecx, 1
@ -125,6 +204,6 @@ clear_ide_cache:
rep stosd rep stosd
pop eax pop eax
ret ret
;-----------------------------------------------------------------------------
end_get_cache: end_get_cache:
popa popa

View File

@ -8,63 +8,203 @@
$Revision: 3742 $ $Revision: 3742 $
search_partitions: search_partitions:
push ecx
; 1. Fill missing parameters in HD_DATA structures. ; 1. Fill missing parameters in HD_DATA structures.
mov eax, [hd_address_table] xor eax, eax
mov [hd0_data.hdbase], eax ;0x1f0 mov edx, IDE_controller_1
mov ax, [edx + IDE_DATA.BAR0_val]
mov [hd0_data.hdbase], eax
mov [hd1_data.hdbase], eax mov [hd1_data.hdbase], eax
mov eax, [hd_address_table+16] mov ax, [edx + IDE_DATA.BAR2_val]
mov [hd2_data.hdbase], eax mov [hd2_data.hdbase], eax
mov [hd3_data.hdbase], eax mov [hd3_data.hdbase], eax
mov edx, IDE_controller_2
mov ax, [edx + IDE_DATA.BAR0_val]
mov [hd4_data.hdbase], eax
mov [hd5_data.hdbase], eax
mov ax, [edx + IDE_DATA.BAR2_val]
mov [hd6_data.hdbase], eax
mov [hd7_data.hdbase], eax
mov edx, IDE_controller_3
mov ax, [edx + IDE_DATA.BAR0_val]
mov [hd8_data.hdbase], eax
mov [hd9_data.hdbase], eax
mov ax, [edx + IDE_DATA.BAR2_val]
mov [hd10_data.hdbase], eax
mov [hd11_data.hdbase], eax
; 2. Notify the system about /hd* disks. ; 2. Notify the system about /hd* disks.
; For every existing disk, call ide_disk_add with correct parameters. ; For every existing disk, call ide_disk_add with correct parameters.
; Generate name "hdN" on the stack; this is 4 bytes including terminating zero. ; Generate name "hdN" on the stack; this is 4 bytes including terminating zero.
;-----------------------------------------------------------------------------
; 2a. /hd0: exists if mask 0x40 in [DRIVE_DATA+1] is set, ; 2a. /hd0: exists if mask 0x40 in [DRIVE_DATA+1] is set,
; data: hd0_data, ; data: hd0_data,
; number of partitions: [DRIVE_DATA+2] ; number of partitions: [DRIVE_DATA+2]
test [DRIVE_DATA+1], byte 0x40 test [DRIVE_DATA+1], byte 0x40
jz @f jz @f
push 'hd0' push 'hd0'
mov eax, esp ; name mov eax, esp ; name
mov edx, hd0_data mov edx, hd0_data
call ide_disk_add call ide_disk_add
mov [DRIVE_DATA+2], al mov [DRIVE_DATA+2], al
pop ecx ; restore the stack pop ecx ; restore the stack
;-----------------------------------------------------------------------------
@@: @@:
; 2b. /hd1: exists if mask 0x10 in [DRIVE_DATA+1] is set, ; 2b. /hd1: exists if mask 0x10 in [DRIVE_DATA+1] is set,
; data: hd1_data, ; data: hd1_data,
; number of partitions: [DRIVE_DATA+3] ; number of partitions: [DRIVE_DATA+3]
test [DRIVE_DATA+1], byte 0x10 test [DRIVE_DATA+1], byte 0x10
jz @f jz @f
push 'hd1' push 'hd1'
mov eax, esp mov eax, esp
mov edx, hd1_data mov edx, hd1_data
call ide_disk_add call ide_disk_add
mov [DRIVE_DATA+3], al mov [DRIVE_DATA+3], al
pop ecx pop ecx
;-----------------------------------------------------------------------------
@@: @@:
; 2c. /hd2: exists if mask 4 in [DRIVE_DATA+1] is set, ; 2c. /hd2: exists if mask 4 in [DRIVE_DATA+1] is set,
; data: hd2_data, ; data: hd2_data,
; number of partitions: [DRIVE_DATA+4] ; number of partitions: [DRIVE_DATA+4]
test [DRIVE_DATA+1], byte 4 test [DRIVE_DATA+1], byte 4
jz @f jz @f
push 'hd2' push 'hd2'
mov eax, esp mov eax, esp
mov edx, hd2_data mov edx, hd2_data
call ide_disk_add call ide_disk_add
mov [DRIVE_DATA+4], al mov [DRIVE_DATA+4], al
pop ecx pop ecx
;-----------------------------------------------------------------------------
@@: @@:
; 2d. /hd3: exists if mask 1 in [DRIVE_DATA+1] is set, ; 2d. /hd3: exists if mask 1 in [DRIVE_DATA+1] is set,
; data: hd3_data, ; data: hd3_data,
; number of partitions: [DRIVE_DATA+5] ; number of partitions: [DRIVE_DATA+5]
test [DRIVE_DATA+1], byte 1 test [DRIVE_DATA+1], byte 1
jz @f jz @f
push 'hd3' push 'hd3'
mov eax, esp mov eax, esp
mov edx, hd3_data mov edx, hd3_data
call ide_disk_add call ide_disk_add
mov [DRIVE_DATA+5], al mov [DRIVE_DATA+5], al
pop ecx pop ecx
;-----------------------------------------------------------------------------
@@:
; 2e. /hd4: exists if mask 0x40 in [DRIVE_DATA+6] is set,
; data: hd4_data,
; number of partitions: [DRIVE_DATA+7]
test [DRIVE_DATA+6], byte 0x40
jz @f
push 'hd4'
mov eax, esp ; name
mov edx, hd4_data
call ide_disk_add
mov [DRIVE_DATA+7], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2f. /hd5: exists if mask 0x10 in [DRIVE_DATA+6] is set,
; data: hd5_data,
; number of partitions: [DRIVE_DATA+8]
test [DRIVE_DATA+6], byte 0x10
jz @f
push 'hd5'
mov eax, esp
mov edx, hd5_data
call ide_disk_add
mov [DRIVE_DATA+8], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2g. /hd6: exists if mask 4 in [DRIVE_DATA+6] is set,
; data: hd6_data,
; number of partitions: [DRIVE_DATA+9]
test [DRIVE_DATA+6], byte 4
jz @f
push 'hd6'
mov eax, esp
mov edx, hd6_data
call ide_disk_add
mov [DRIVE_DATA+9], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2h. /hd7: exists if mask 1 in [DRIVE_DATA+6] is set,
; data: hd7_data,
; number of partitions: [DRIVE_DATA+10]
test [DRIVE_DATA+6], byte 1
jz @f
push 'hd7'
mov eax, esp
mov edx, hd7_data
call ide_disk_add
mov [DRIVE_DATA+10], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2i. /hd8: exists if mask 0x40 in [DRIVE_DATA+11] is set,
; data: hd8_data,
; number of partitions: [DRIVE_DATA+12]
test [DRIVE_DATA+11], byte 0x40
jz @f
push 'hd8'
mov eax, esp ; name
mov edx, hd8_data
call ide_disk_add
mov [DRIVE_DATA+12], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2j. /hd9: exists if mask 0x10 in [DRIVE_DATA+11] is set,
; data: hd9_data,
; number of partitions: [DRIVE_DATA+13]
test [DRIVE_DATA+11], byte 0x10
jz @f
push 'hd9'
mov eax, esp
mov edx, hd9_data
call ide_disk_add
mov [DRIVE_DATA+13], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2k. /hd10: exists if mask 4 in [DRIVE_DATA+11] is set,
; data: hd10_data,
; number of partitions: [DRIVE_DATA+14]
test [DRIVE_DATA+14], byte 4
jz @f
push 'hd10'
mov eax, esp
mov edx, hd10_data
call ide_disk_add
mov [DRIVE_DATA+9], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2l. /hd11: exists if mask 1 in [DRIVE_DATA+11] is set,
; data: hd11_data,
; number of partitions: [DRIVE_DATA+15]
test [DRIVE_DATA+11], byte 1
jz @f
push 'hd11'
mov eax, esp
mov edx, hd11_data
call ide_disk_add
mov [DRIVE_DATA+15], al
pop ecx
;-----------------------------------------------------------------------------
@@: @@:
; 3. Notify the system about /bd* disks. ; 3. Notify the system about /bd* disks.
; 3a. Check whether there are BIOS disks. If no, skip step 3. ; 3a. Check whether there are BIOS disks. If no, skip step 3.
@ -115,10 +255,10 @@ endg
pop ecx ecx ; restore stack after name pop ecx ecx ; restore stack after name
.nobd: .nobd:
jmp end_search_partitions jmp end_search_partitions
;-----------------------------------------------------------------------------
; Helper procedure for search_partitions, adds one IDE disk. ; Helper procedure for search_partitions, adds one IDE disk.
; For compatibility, number of partitions for IDE disks is kept in a separate variable, ; For compatibility, number of partitions for IDE disks is kept in a separate
; so the procedure returns number of partitions. ; variable, so the procedure returns number of partitions.
; eax -> name, edx -> disk data ; eax -> name, edx -> disk data
proc ide_disk_add proc ide_disk_add
stdcall disk_add, ide_callbacks, eax, edx, 0 stdcall disk_add, ide_callbacks, eax, edx, 0
@ -134,6 +274,6 @@ proc ide_disk_add
@@: @@:
ret ret
endp endp
;-----------------------------------------------------------------------------
end_search_partitions: end_search_partitions:
pop ecx

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
; fetch the UTF-8 character in string+offs to char ; fetch the UTF-8 character in string+offs to char
; common part for all encodings: translate pseudographics ; common part for all encodings: translate pseudographics
; Pseudographics for the boot screen: ; Pseudographics for the boot screen:

View File

@ -2,11 +2,14 @@
;; ;; ;; ;;
;; Contains ext2 block handling code. ;; ;; Contains ext2 block handling code. ;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under the terms of the new BSD license. ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4891 $
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
; Write ext2 block from memory to disk. ; Write ext2 block from memory to disk.
; Input: eax = i_block (block number in ext2 terms); ; Input: eax = i_block (block number in ext2 terms);

View File

@ -2,11 +2,14 @@
;; ;; ;; ;;
;; Contains ext2 initialization, plus syscall handling code. ;; ;; Contains ext2 initialization, plus syscall handling code. ;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under the terms of the new BSD license. ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4891 $
include 'ext2.inc' include 'ext2.inc'
include 'blocks.inc' include 'blocks.inc'
include 'inode.inc' include 'inode.inc'

View File

@ -2,11 +2,14 @@
;; ;; ;; ;;
;; Contains ext2 structures, and macros. ;; ;; Contains ext2 structures, and macros. ;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under the terms of the new BSD license. ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4891 $
; Future jobs for driver, in order of preference: ; Future jobs for driver, in order of preference:
; * clean up existing extents support. ; * clean up existing extents support.
; * add b-tree directories support. ; * add b-tree directories support.

View File

@ -2,11 +2,14 @@
;; ;; ;; ;;
;; Contains ext2 inode handling code. ;; ;; Contains ext2 inode handling code. ;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under the terms of the new BSD license. ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4891 $
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
; Receives block number from extent-based inode. ; Receives block number from extent-based inode.
; Input: ecx = number of block in inode ; Input: ecx = number of block in inode

View File

@ -2,11 +2,14 @@
;; ;; ;; ;;
;; Contains common resource allocation + freeing code. ;; ;; Contains common resource allocation + freeing code. ;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under the terms of the new BSD license. ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4891 $
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
; Frees a resource (block/inode). ; Frees a resource (block/inode).
; Input: eax = resource ID. ; Input: eax = resource ID.

View File

@ -43,6 +43,30 @@ rootdirs:
db 3,'cd3' db 3,'cd3'
dd fs_OnCd3 dd fs_OnCd3
dd fs_NextCd dd fs_NextCd
db 3,'cd4'
dd fs_OnCd4
dd fs_NextCd
db 3,'cd5'
dd fs_OnCd5
dd fs_NextCd
db 3,'cd6'
dd fs_OnCd6
dd fs_NextCd
db 3,'cd7'
dd fs_OnCd7
dd fs_NextCd
db 3,'cd8'
dd fs_OnCd8
dd fs_NextCd
db 3,'cd9'
dd fs_OnCd9
dd fs_NextCd
db 4,'cd10'
dd fs_OnCd10
dd fs_NextCd
db 4,'cd11'
dd fs_OnCd11
dd fs_NextCd
;*********************************************** ;***********************************************
db 0 db 0
@ -57,6 +81,22 @@ virtual_root_query:
db 'cd2',0 db 'cd2',0
dd fs_HasCd3 dd fs_HasCd3
db 'cd3',0 db 'cd3',0
dd fs_HasCd4
db 'cd4',0
dd fs_HasCd5
db 'cd5',0
dd fs_HasCd6
db 'cd6',0
dd fs_HasCd7
db 'cd7',0
dd fs_HasCd8
db 'cd8',0
dd fs_HasCd9
db 'cd9',0
dd fs_HasCd10
db 'cd10',0
dd fs_HasCd11
db 'cd11',0
;********************************************** ;**********************************************
dd 0 dd 0
endg endg
@ -149,8 +189,8 @@ file_system_lfn:
cmp dword [ebx], 1 cmp dword [ebx], 1
jnz .access_denied jnz .access_denied
xor eax, eax xor eax, eax
mov ebp, [ebx+12] ;количество блоков для считывания mov ebp, [ebx+12] ;the number of blocks to read
mov edx, [ebx+16] ;куда записывать рузельтат mov edx, [ebx+16] ;where to write the result
; add edx, std_application_base_address ; add edx, std_application_base_address
push dword [ebx+4] ; first block push dword [ebx+4] ; first block
mov ebx, [ebx+8] ; flags mov ebx, [ebx+8] ; flags
@ -404,8 +444,7 @@ file_system_lfn:
fs_NotImplemented: fs_NotImplemented:
mov eax, 2 mov eax, 2
ret ret
;-----------------------------------------------------------------------------
;*******************************************************
fs_OnCd0: fs_OnCd0:
call reserve_cd call reserve_cd
mov [ChannelNumber], 1 mov [ChannelNumber], 1
@ -413,6 +452,7 @@ fs_OnCd0:
push 6 push 6
push 1 push 1
jmp fs_OnCd jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd1: fs_OnCd1:
call reserve_cd call reserve_cd
mov [ChannelNumber], 1 mov [ChannelNumber], 1
@ -420,6 +460,7 @@ fs_OnCd1:
push 4 push 4
push 2 push 2
jmp fs_OnCd jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd2: fs_OnCd2:
call reserve_cd call reserve_cd
mov [ChannelNumber], 2 mov [ChannelNumber], 2
@ -427,22 +468,96 @@ fs_OnCd2:
push 2 push 2
push 3 push 3
jmp fs_OnCd jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd3: fs_OnCd3:
call reserve_cd call reserve_cd
mov [ChannelNumber], 2 mov [ChannelNumber], 2
mov [DiskNumber], 1 mov [DiskNumber], 1
push 0 push 0
push 4 push 4
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd4:
call reserve_cd
mov [ChannelNumber], 1
mov [DiskNumber], 0
push 6
push 5
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd5:
call reserve_cd
mov [ChannelNumber], 1
mov [DiskNumber], 1
push 4
push 6
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd6:
call reserve_cd
mov [ChannelNumber], 2
mov [DiskNumber], 0
push 2
push 7
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd7:
call reserve_cd
mov [ChannelNumber], 2
mov [DiskNumber], 1
push 0
push 8
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd8:
call reserve_cd
mov [ChannelNumber], 1
mov [DiskNumber], 0
push 6
push 9
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd9:
call reserve_cd
mov [ChannelNumber], 1
mov [DiskNumber], 1
push 4
push 10
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd10:
call reserve_cd
mov [ChannelNumber], 2
mov [DiskNumber], 0
push 2
push 11
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd11:
call reserve_cd
mov [ChannelNumber], 2
mov [DiskNumber], 1
push 0
push 12
;-----------------------------------------------------------------------------
fs_OnCd: fs_OnCd:
call reserve_cd_channel
pop eax pop eax
mov [cdpos], eax mov [cdpos], eax
call reserve_cd_channel
pop eax pop eax
cmp ecx, 0x100 cmp ecx, 0x100
jae .nf jae .nf
push ecx ebx push ecx ebx
mov cl, al mov cl, al
mov bl, [DRIVE_DATA+1]
push eax
mov eax, [cdpos]
dec eax
shr eax, 2
lea eax, [eax*5]
mov bl, [eax+DRIVE_DATA+1]
pop eax
shr bl, cl shr bl, cl
test bl, 2 test bl, 2
pop ebx ecx pop ebx ecx
@ -472,7 +587,7 @@ fs_OnCd:
and [cd_status], 0 and [cd_status], 0
mov dword [image_of_eax], 2 ; not implemented mov dword [image_of_eax], 2 ; not implemented
ret ret
;-----------------------------------------------------------------------------
fs_CdServices: fs_CdServices:
dd fs_CdRead dd fs_CdRead
dd fs_CdReadFolder dd fs_CdReadFolder
@ -485,32 +600,74 @@ fs_CdServices:
dd fs_NotImplemented dd fs_NotImplemented
dd fs_NotImplemented dd fs_NotImplemented
fs_NumCdServices = ($ - fs_CdServices)/4 fs_NumCdServices = ($ - fs_CdServices)/4
;-----------------------------------------------------------------------------
;*******************************************************
fs_HasCd0: fs_HasCd0:
test byte [DRIVE_DATA+1], 10000000b test byte [DRIVE_DATA+1], 10000000b
setnz al setnz al
ret ret
;--------------------------------------
fs_HasCd1: fs_HasCd1:
test byte [DRIVE_DATA+1], 00100000b test byte [DRIVE_DATA+1], 00100000b
setnz al setnz al
ret ret
;--------------------------------------
fs_HasCd2: fs_HasCd2:
test byte [DRIVE_DATA+1], 00001000b test byte [DRIVE_DATA+1], 00001000b
setnz al setnz al
ret ret
;--------------------------------------
fs_HasCd3: fs_HasCd3:
test byte [DRIVE_DATA+1], 00000010b test byte [DRIVE_DATA+1], 00000010b
setnz al setnz al
ret ret
;******************************************************* ;--------------------------------------
fs_HasCd4:
test byte [DRIVE_DATA+6], 10000000b
setnz al
ret
;--------------------------------------
fs_HasCd5:
test byte [DRIVE_DATA+6], 00100000b
setnz al
ret
;--------------------------------------
fs_HasCd6:
test byte [DRIVE_DATA+6], 00001000b
setnz al
ret
;--------------------------------------
fs_HasCd7:
test byte [DRIVE_DATA+6], 00000010b
setnz al
ret
;--------------------------------------
fs_HasCd8:
test byte [DRIVE_DATA+11], 10000000b
setnz al
ret
;--------------------------------------
fs_HasCd9:
test byte [DRIVE_DATA+11], 00100000b
setnz al
ret
;--------------------------------------
fs_HasCd10:
test byte [DRIVE_DATA+11], 00001000b
setnz al
ret
;--------------------------------------
fs_HasCd11:
test byte [DRIVE_DATA+11], 00000010b
setnz al
ret
;-----------------------------------------------------------------------------
;
; fs_NextXXX functions: ; fs_NextXXX functions:
; in: eax = partition number, from which start to scan ; in: eax = partition number, from which start to scan
; out: CF=1 => no more partitions ; out: CF=1 => no more partitions
; CF=0 => eax=next partition number ; CF=0 => eax=next partition number
;
;******************************************************* ;-----------------------------------------------------------------------------
fs_NextCd: fs_NextCd:
; we always have /cdX/1 ; we always have /cdX/1
test eax, eax test eax, eax
@ -520,8 +677,6 @@ fs_NextCd:
clc clc
@@: @@:
ret ret
;*******************************************************
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
process_replace_file_name: process_replace_file_name:
; in ; in

View File

@ -5,20 +5,17 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3742 $ $Revision: 4700 $
;-----------------------------------------------------------------------------
uglobal uglobal
cd_current_pointer_of_input dd 0 cd_current_pointer_of_input dd 0
cd_current_pointer_of_input_2 dd 0 cd_current_pointer_of_input_2 dd 0
cd_mem_location dd 0 cd_mem_location dd 0
cd_counter_block dd 0 cd_counter_block dd 0
IDE_Channel_1 db 0
IDE_Channel_2 db 0
endg endg
;-----------------------------------------------------------------------------
reserve_cd: reserve_cd:
cli cli
cmp [cd_status], 0 cmp [cd_status], 0
je reserve_ok2 je reserve_ok2
@ -26,9 +23,8 @@ reserve_cd:
sti sti
call change_task call change_task
jmp reserve_cd jmp reserve_cd
;-----------------------------------------------------------------------------
reserve_ok2: reserve_ok2:
push eax push eax
mov eax, [CURRENT_TASK] mov eax, [CURRENT_TASK]
shl eax, 5 shl eax, 5
@ -37,48 +33,105 @@ reserve_cd:
pop eax pop eax
sti sti
ret ret
;-----------------------------------------------------------------------------
reserve_cd_channel: reserve_cd_channel:
cmp [ChannelNumber], 1
jne .IDE_Channel_2
.IDE_Channel_1:
pushad pushad
mov ecx, ide_channel1_mutex mov eax, [cdpos]
call mutex_lock dec eax
mov [IDE_Channel_1], 1 shr eax, 2
popad
ret
.IDE_Channel_2:
pushad
mov ecx, ide_channel2_mutex
call mutex_lock
mov [IDE_Channel_2], 1
popad
ret
test eax, eax
jnz .1
cmp [ChannelNumber], 1
jne @f
mov ecx, ide_channel1_mutex
jmp .mutex_lock
;--------------------------------------
@@:
mov ecx, ide_channel2_mutex
jmp .mutex_lock
;--------------------------------------
.1:
dec eax
jnz .2
cmp [ChannelNumber], 1
jne @f
mov ecx, ide_channel3_mutex
jmp .mutex_lock
;--------------------------------------
@@:
mov ecx, ide_channel4_mutex
jmp .mutex_lock
;--------------------------------------
.2:
cmp [ChannelNumber], 1
jne @f
mov ecx, ide_channel5_mutex
jmp .mutex_lock
;--------------------------------------
@@:
mov ecx, ide_channel6_mutex
.mutex_lock:
call mutex_lock
popad
ret
;-----------------------------------------------------------------------------
free_cd_channel: free_cd_channel:
cmp [ChannelNumber], 1
jne .IDE_Channel_2
.IDE_Channel_1:
mov [IDE_Channel_1], 0
pushad pushad
mov ecx, ide_channel1_mutex mov eax, [cdpos]
call mutex_unlock dec eax
popad shr eax, 2
ret
.IDE_Channel_2:
mov [IDE_Channel_2], 0
pushad
mov ecx, ide_channel2_mutex
call mutex_unlock
popad
ret
test eax, eax
jnz .1
cmp [ChannelNumber], 1
jne @f
mov ecx, ide_channel1_mutex
jmp .mutex_unlock
;--------------------------------------
@@:
mov ecx, ide_channel2_mutex
jmp .mutex_unlock
;--------------------------------------
.1:
dec eax
jnz .2
cmp [ChannelNumber], 1
jne @f
mov ecx, ide_channel3_mutex
jmp .mutex_unlock
;--------------------------------------
@@:
mov ecx, ide_channel4_mutex
jmp .mutex_unlock
;--------------------------------------
.2:
cmp [ChannelNumber], 1
jne @f
mov ecx, ide_channel5_mutex
jmp .mutex_unlock
;--------------------------------------
@@:
mov ecx, ide_channel6_mutex
.mutex_unlock:
call mutex_unlock
popad
ret
;-----------------------------------------------------------------------------
uglobal uglobal
cd_status dd 0 cd_status dd 0
endg endg
;-----------------------------------------------------------------------------
;----------------------------------------------------------------
; ;
; fs_CdRead - LFN variant for reading CD disk ; fs_CdRead - LFN variant for reading CD disk
; ;
@ -91,91 +144,114 @@ endg
; ret ebx = bytes read or 0xffffffff file not found ; ret ebx = bytes read or 0xffffffff file not found
; eax = 0 ok read or other = errormsg ; eax = 0 ok read or other = errormsg
; ;
;-------------------------------------------------------------- ;-----------------------------------------------------------------------------
fs_CdRead: fs_CdRead:
push edi push edi
cmp byte [esi], 0 cmp byte [esi], 0
jnz @f jnz @f
;--------------------------------------
.noaccess: .noaccess:
pop edi pop edi
;--------------------------------------
.noaccess_2: .noaccess_2:
or ebx, -1 or ebx, -1
mov eax, ERROR_ACCESS_DENIED mov eax, ERROR_ACCESS_DENIED
ret ret
;--------------------------------------
.noaccess_3: .noaccess_3:
pop eax edx ecx edi pop eax edx ecx edi
jmp .noaccess_2 jmp .noaccess_2
;--------------------------------------
@@: @@:
call cd_find_lfn call cd_find_lfn
jnc .found jnc .found
pop edi pop edi
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .noaccess_2 jne .noaccess_2
or ebx, -1 or ebx, -1
mov eax, ERROR_FILE_NOT_FOUND mov eax, ERROR_FILE_NOT_FOUND
ret ret
;--------------------------------------
.found: .found:
mov edi, [cd_current_pointer_of_input] mov edi, [cd_current_pointer_of_input]
test byte [edi+25], 10b; do not allow read directories test byte [edi+25], 10b; do not allow read directories
jnz .noaccess jnz .noaccess
test ebx, ebx test ebx, ebx
jz .l1 jz .l1
cmp dword [ebx+4], 0 cmp dword [ebx+4], 0
jz @f jz @f
xor ebx, ebx xor ebx, ebx
;--------------------------------------
.reteof: .reteof:
mov eax, 6; end of file mov eax, 6; end of file
pop edi pop edi
ret ret
;--------------------------------------
@@: @@:
mov ebx, [ebx] mov ebx, [ebx]
;--------------------------------------
.l1: .l1:
push ecx edx push ecx edx
push 0 push 0
mov eax, [edi+10] ; реальный размер файловой секции mov eax, [edi+10] ; real size of the file section
sub eax, ebx sub eax, ebx
jb .eof jb .eof
cmp eax, ecx cmp eax, ecx
jae @f jae @f
mov ecx, eax mov ecx, eax
mov byte [esp], 6 mov byte [esp], 6
;--------------------------------------
@@: @@:
mov eax, [edi+2] mov eax, [edi+2]
mov [CDSectorAddress], eax mov [CDSectorAddress], eax
;--------------------------------------
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data ; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
.new_sector: .new_sector:
test ecx, ecx test ecx, ecx
jz .done jz .done
sub ebx, 2048 sub ebx, 2048
jae .next jae .next
add ebx, 2048 add ebx, 2048
jnz .incomplete_sector jnz .incomplete_sector
cmp ecx, 2048 cmp ecx, 2048
jb .incomplete_sector jb .incomplete_sector
; we may read and memmove complete sector ; we may read and memmove complete sector
mov [CDDataBuf_pointer], edx mov [CDDataBuf_pointer], edx
call ReadCDWRetr; читаем сектор файла call ReadCDWRetr ; read sector of file
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .noaccess_3 jne .noaccess_3
add edx, 2048 add edx, 2048
sub ecx, 2048 sub ecx, 2048
;--------------------------------------
.next: .next:
inc dword [CDSectorAddress] inc dword [CDSectorAddress]
jmp .new_sector jmp .new_sector
;--------------------------------------
.incomplete_sector: .incomplete_sector:
; we must read and memmove incomplete sector ; we must read and memmove incomplete sector
mov [CDDataBuf_pointer], CDDataBuf mov [CDDataBuf_pointer], CDDataBuf
call ReadCDWRetr; читаем сектор файла call ReadCDWRetr ; read sector of file
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .noaccess_3 jne .noaccess_3
push ecx push ecx
add ecx, ebx add ecx, ebx
cmp ecx, 2048 cmp ecx, 2048
jbe @f jbe @f
mov ecx, 2048 mov ecx, 2048
;--------------------------------------
@@: @@:
sub ecx, ebx sub ecx, ebx
push edi esi ecx push edi esi ecx
@ -189,19 +265,19 @@ fs_CdRead:
pop ecx pop ecx
xor ebx, ebx xor ebx, ebx
jmp .next jmp .next
;--------------------------------------
.done: .done:
mov ebx, edx mov ebx, edx
pop eax edx ecx edi pop eax edx ecx edi
sub ebx, edx sub ebx, edx
ret ret
;--------------------------------------
.eof: .eof:
mov ebx, edx mov ebx, edx
pop eax edx ecx pop eax edx ecx
sub ebx, edx sub ebx, edx
jmp .reteof jmp .reteof
;-----------------------------------------------------------------------------
;----------------------------------------------------------------
; ;
; fs_CdReadFolder - LFN variant for reading CD disk folder ; fs_CdReadFolder - LFN variant for reading CD disk folder
; ;
@ -215,30 +291,37 @@ fs_CdRead:
; ret ebx = blocks read or 0xffffffff folder not found ; ret ebx = blocks read or 0xffffffff folder not found
; eax = 0 ok read or other = errormsg ; eax = 0 ok read or other = errormsg
; ;
;-------------------------------------------------------------- ;-----------------------------------------------------------------------------
fs_CdReadFolder: fs_CdReadFolder:
push edi push edi
call cd_find_lfn call cd_find_lfn
jnc .found jnc .found
pop edi pop edi
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .noaccess_1 jne .noaccess_1
or ebx, -1 or ebx, -1
mov eax, ERROR_FILE_NOT_FOUND mov eax, ERROR_FILE_NOT_FOUND
ret ret
;--------------------------------------
.found: .found:
mov edi, [cd_current_pointer_of_input] mov edi, [cd_current_pointer_of_input]
test byte [edi+25], 10b ; do not allow read directories test byte [edi+25], 10b ; do not allow read directories
jnz .found_dir jnz .found_dir
pop edi pop edi
;--------------------------------------
.noaccess_1: .noaccess_1:
or ebx, -1 or ebx, -1
mov eax, ERROR_ACCESS_DENIED mov eax, ERROR_ACCESS_DENIED
ret ret
;--------------------------------------
.found_dir: .found_dir:
mov eax, [edi+2] ; eax=cluster mov eax, [edi+2] ; eax=cluster
mov [CDSectorAddress], eax mov [CDSectorAddress], eax
mov eax, [edi+10] ; размер директрории mov eax, [edi+10] ; directory size
;--------------------------------------
.doit: .doit:
; init header ; init header
push eax ecx push eax ecx
@ -250,21 +333,23 @@ fs_CdReadFolder:
mov byte [edx], 1 ; version mov byte [edx], 1 ; version
mov [cd_mem_location], edx mov [cd_mem_location], edx
add [cd_mem_location], 32 add [cd_mem_location], 32
; начинаем переброску БДВК в УСВК
;.mainloop: ;.mainloop:
mov [cd_counter_block], dword 0 mov [cd_counter_block], dword 0
dec dword [CDSectorAddress] dec dword [CDSectorAddress]
push ecx push ecx
;--------------------------------------
.read_to_buffer: .read_to_buffer:
inc dword [CDSectorAddress] inc dword [CDSectorAddress]
mov [CDDataBuf_pointer], CDDataBuf mov [CDDataBuf_pointer], CDDataBuf
call ReadCDWRetr ; читаем сектор директории call ReadCDWRetr ; read sector of directory
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .noaccess_1 jne .noaccess_1
call .get_names_from_buffer call .get_names_from_buffer
sub eax, 2048 sub eax, 2048
; директория закончилась? ; directory is over?
ja .read_to_buffer ja .read_to_buffer
mov edi, [cd_counter_block] mov edi, [cd_counter_block]
mov [edx+8], edi mov [edx+8], edi
mov edi, [ebx] mov edi, [ebx]
@ -272,24 +357,30 @@ fs_CdReadFolder:
xor eax, eax xor eax, eax
dec ecx dec ecx
js @f js @f
mov al, ERROR_END_OF_FILE mov al, ERROR_END_OF_FILE
;--------------------------------------
@@: @@:
pop ecx edi pop ecx edi
mov ebx, [edx+4] mov ebx, [edx+4]
ret ret
;--------------------------------------
.get_names_from_buffer: .get_names_from_buffer:
mov [cd_current_pointer_of_input_2], CDDataBuf mov [cd_current_pointer_of_input_2], CDDataBuf
push eax esi edi edx push eax esi edi edx
;--------------------------------------
.get_names_from_buffer_1: .get_names_from_buffer_1:
call cd_get_name call cd_get_name
jc .end_buffer jc .end_buffer
inc dword [cd_counter_block] inc dword [cd_counter_block]
mov eax, [cd_counter_block] mov eax, [cd_counter_block]
cmp [ebx], eax cmp [ebx], eax
jae .get_names_from_buffer_1 jae .get_names_from_buffer_1
test ecx, ecx test ecx, ecx
jz .get_names_from_buffer_1 jz .get_names_from_buffer_1
mov edi, [cd_counter_block] mov edi, [cd_counter_block]
mov [edx+4], edi mov [edx+4], edi
dec ecx dec ecx
@ -298,189 +389,209 @@ fs_CdReadFolder:
add edi, 40 add edi, 40
test dword [ebx+4], 1; 0=ANSI, 1=UNICODE test dword [ebx+4], 1; 0=ANSI, 1=UNICODE
jnz .unicode jnz .unicode
; jmp .unicode ;--------------------------------------
.ansi: .ansi:
cmp [cd_counter_block], 2 cmp [cd_counter_block], 2
jbe .ansi_parent_directory jbe .ansi_parent_directory
cld cld
lodsw lodsw
xchg ah, al xchg ah, al
call uni2ansi_char call uni2ansi_char
cld cld
stosb stosb
; проверка конца файла ; check end of file
mov ax, [esi] mov ax, [esi]
cmp ax, word 3B00h; сепаратор конца файла ';' cmp ax, word 3B00h ; separator end of file ';'
je .cd_get_parameters_of_file_1 je .cd_get_parameters_of_file_1
; проверка для файлов не заканчивающихся сепаратором ; check for files not ending with separator
movzx eax, byte [ebp-33] movzx eax, byte [ebp-33]
add eax, ebp add eax, ebp
sub eax, 34 sub eax, 34
cmp esi, eax cmp esi, eax
je .cd_get_parameters_of_file_1 je .cd_get_parameters_of_file_1
; проверка конца папки ; check the end of the directory
movzx eax, byte [ebp-1] movzx eax, byte [ebp-1]
add eax, ebp add eax, ebp
cmp esi, eax cmp esi, eax
jb .ansi jb .ansi
;--------------------------------------
.cd_get_parameters_of_file_1: .cd_get_parameters_of_file_1:
mov [edi], byte 0 mov [edi], byte 0
call cd_get_parameters_of_file call cd_get_parameters_of_file
add [cd_mem_location], 304 add [cd_mem_location], 304
jmp .get_names_from_buffer_1 jmp .get_names_from_buffer_1
;--------------------------------------
.ansi_parent_directory: .ansi_parent_directory:
cmp [cd_counter_block], 2 cmp [cd_counter_block], 2
je @f je @f
mov [edi], byte '.' mov [edi], byte '.'
inc edi inc edi
jmp .cd_get_parameters_of_file_1 jmp .cd_get_parameters_of_file_1
;--------------------------------------
@@: @@:
mov [edi], word '..' mov [edi], word '..'
add edi, 2 add edi, 2
jmp .cd_get_parameters_of_file_1 jmp .cd_get_parameters_of_file_1
;--------------------------------------
.unicode: .unicode:
cmp [cd_counter_block], 2 cmp [cd_counter_block], 2
jbe .unicode_parent_directory jbe .unicode_parent_directory
cld cld
movsw movsw
; проверка конца файла ; check end of file
mov ax, [esi] mov ax, [esi]
cmp ax, word 3B00h; сепаратор конца файла ';' cmp ax, word 3B00h; separator end of file ';'
je .cd_get_parameters_of_file_2 je .cd_get_parameters_of_file_2
; проверка для файлов не заканчивающихся сепаратором ; check for files not ending with separator
movzx eax, byte [ebp-33] movzx eax, byte [ebp-33]
add eax, ebp add eax, ebp
sub eax, 34 sub eax, 34
cmp esi, eax cmp esi, eax
je .cd_get_parameters_of_file_2 je .cd_get_parameters_of_file_2
; проверка конца папки ; check the end of the directory
movzx eax, byte [ebp-1] movzx eax, byte [ebp-1]
add eax, ebp add eax, ebp
cmp esi, eax cmp esi, eax
jb .unicode jb .unicode
;--------------------------------------
.cd_get_parameters_of_file_2: .cd_get_parameters_of_file_2:
mov [edi], word 0 mov [edi], word 0
call cd_get_parameters_of_file call cd_get_parameters_of_file
add [cd_mem_location], 560 add [cd_mem_location], 560
jmp .get_names_from_buffer_1 jmp .get_names_from_buffer_1
;--------------------------------------
.unicode_parent_directory: .unicode_parent_directory:
cmp [cd_counter_block], 2 cmp [cd_counter_block], 2
je @f je @f
mov [edi], word 2E00h; '.' mov [edi], word 2E00h; '.'
add edi, 2 add edi, 2
jmp .cd_get_parameters_of_file_2 jmp .cd_get_parameters_of_file_2
;--------------------------------------
@@: @@:
mov [edi], dword 2E002E00h; '..' mov [edi], dword 2E002E00h; '..'
add edi, 4 add edi, 4
jmp .cd_get_parameters_of_file_2 jmp .cd_get_parameters_of_file_2
;--------------------------------------
.end_buffer: .end_buffer:
pop edx edi esi eax pop edx edi esi eax
ret ret
;-----------------------------------------------------------------------------
cd_get_parameters_of_file: cd_get_parameters_of_file:
mov edi, [cd_mem_location] mov edi, [cd_mem_location]
cd_get_parameters_of_file_1: cd_get_parameters_of_file_1:
; получаем атрибуты файла ; get file attributes
xor eax, eax xor eax, eax
; файл не архивировался ; file is not archived
inc eax inc eax
shl eax, 1 shl eax, 1
; это каталог? ; is a directory?
test [ebp-8], byte 2 test [ebp-8], byte 2
jz .file jz .file
inc eax inc eax
;--------------------------------------
.file: .file:
; метка тома не как в FAT, в этом виде отсутсвует ; not as a volume label in the FAT, in this form not available
; файл не является системным ; file is not a system
shl eax, 3 shl eax, 3
; файл является скрытым? (атрибут существование) ; file is hidden? (attribute of existence)
test [ebp-8], byte 1 test [ebp-8], byte 1
jz .hidden jz .hidden
inc eax inc eax
;--------------------------------------
.hidden: .hidden:
shl eax, 1 shl eax, 1
; файл всегда только для чтения, так как это CD ; file is always read-only, as this CD
inc eax inc eax
mov [edi], eax mov [edi], eax
; получаем время для файла ; get the time to file
;час ; hour
movzx eax, byte [ebp-12] movzx eax, byte [ebp-12]
shl eax, 8 shl eax, 8
;минута ; minute
mov al, [ebp-11] mov al, [ebp-11]
shl eax, 8 shl eax, 8
;секунда ; second
mov al, [ebp-10] mov al, [ebp-10]
;время создания файла ; file creation time
mov [edi+8], eax mov [edi+8], eax
;время последнего доступа ; last access time
mov [edi+16], eax mov [edi+16], eax
;время последней записи ; last write time
mov [edi+24], eax mov [edi+24], eax
; получаем дату для файла ; get date for file
;год ; year
movzx eax, byte [ebp-15] movzx eax, byte [ebp-15]
add eax, 1900 add eax, 1900
shl eax, 8 shl eax, 8
;месяц ; month
mov al, [ebp-14] mov al, [ebp-14]
shl eax, 8 shl eax, 8
;день ; day
mov al, [ebp-13] mov al, [ebp-13]
;дата создания файла ; file creation date
mov [edi+12], eax mov [edi+12], eax
;время последнего доступа ; last access date
mov [edi+20], eax mov [edi+20], eax
;время последней записи ; last write date
mov [edi+28], eax mov [edi+28], eax
; получаем тип данных имени ; get the data type of name
xor eax, eax xor eax, eax
test dword [ebx+4], 1; 0=ANSI, 1=UNICODE test dword [ebx+4], 1; 0=ANSI, 1=UNICODE
jnz .unicode_1 jnz .unicode_1
mov [edi+4], eax mov [edi+4], eax
jmp @f jmp @f
;--------------------------------------
.unicode_1: .unicode_1:
inc eax inc eax
mov [edi+4], eax mov [edi+4], eax
;--------------------------------------
@@: @@:
; получаем размер файла в байтах ; get the file size in bytes
xor eax, eax xor eax, eax
mov [edi+32+4], eax mov [edi+32+4], eax
mov eax, [ebp-23] mov eax, [ebp-23]
mov [edi+32], eax mov [edi+32], eax
ret ret
;-----------------------------------------------------------------------------
;----------------------------------------------------------------
; ;
; fs_CdGetFileInfo - LFN variant for CD ; fs_CdGetFileInfo - LFN variant for CD
; get file/directory attributes structure ; get file/directory attributes structure
; ;
;---------------------------------------------------------------- ;-----------------------------------------------------------------------------
fs_CdGetFileInfo: fs_CdGetFileInfo:
cmp byte [esi], 0 cmp byte [esi], 0
jnz @f jnz @f
mov eax, 2 mov eax, 2
ret ret
;--------------------------------------
@@: @@:
push edi push edi
call cd_find_lfn call cd_find_lfn
pushfd pushfd
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jz @f jz @f
popfd popfd
pop edi pop edi
mov eax, 11 mov eax, 11
ret ret
;--------------------------------------
@@: @@:
popfd popfd
jnc @f jnc @f
pop edi pop edi
mov eax, ERROR_FILE_NOT_FOUND mov eax, ERROR_FILE_NOT_FOUND
ret ret
;--------------------------------------
@@: @@:
mov edi, edx mov edi, edx
@ -493,32 +604,31 @@ fs_CdGetFileInfo:
pop edi pop edi
xor eax, eax xor eax, eax
ret ret
;-----------------------------------------------------------------------------
;----------------------------------------------------------------
cd_find_lfn: cd_find_lfn:
mov [cd_appl_data], 0 mov [cd_appl_data], 0
; in: esi+ebp -> name ; in: esi+ebp -> name
; out: CF=1 - file not found ; out: CF=1 - file not found
; else CF=0 and [cd_current_pointer_of_input] direntry ; else CF=0 and [cd_current_pointer_of_input] direntry
push eax esi push eax esi
; 16 сектор начало набора дескрипторов томов ; Sector 16 - start set of volume descriptors
call WaitUnitReady call WaitUnitReady
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .access_denied jne .access_denied
call prevent_medium_removal call prevent_medium_removal
; тестовое чтение ; testing of reading
mov [CDSectorAddress], dword 16 mov [CDSectorAddress], dword 16
mov [CDDataBuf_pointer], CDDataBuf mov [CDDataBuf_pointer], CDDataBuf
call ReadCDWRetr;_1 call ReadCDWRetr;_1
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .access_denied jne .access_denied
; вычисление последней сессии ; calculation of the last session
call WaitUnitReady call WaitUnitReady
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .access_denied jne .access_denied
call Read_TOC call Read_TOC
mov ah, [CDDataBuf+4+4] mov ah, [CDDataBuf+4+4]
mov al, [CDDataBuf+4+5] mov al, [CDDataBuf+4+5]
@ -529,7 +639,7 @@ cd_find_lfn:
mov [CDSectorAddress], eax mov [CDSectorAddress], eax
; mov [CDSectorAddress],dword 15 ; mov [CDSectorAddress],dword 15
mov [CDDataBuf_pointer], CDDataBuf mov [CDDataBuf_pointer], CDDataBuf
;--------------------------------------
.start: .start:
inc dword [CDSectorAddress] inc dword [CDSectorAddress]
call ReadCDWRetr;_1 call ReadCDWRetr;_1
@ -537,111 +647,128 @@ cd_find_lfn:
jne .access_denied jne .access_denied
.start_check: .start_check:
; проверка на вшивость ; checking for "lice"
cmp [CDDataBuf+1], dword 'CD00' cmp [CDDataBuf+1], dword 'CD00'
jne .access_denied jne .access_denied
cmp [CDDataBuf+5], byte '1' cmp [CDDataBuf+5], byte '1'
jne .access_denied jne .access_denied
; сектор является терминатором набор дескрипторов томов? ; sector is the terminator of set of descriptors volumes?
cmp [CDDataBuf], byte 0xff cmp [CDDataBuf], byte 0xff
je .access_denied je .access_denied
; сектор является дополнительным и улучшенным дескриптором тома? ; sector is an additional and improved descriptor of volume?
cmp [CDDataBuf], byte 0x2 cmp [CDDataBuf], byte 0x2
jne .start jne .start
; сектор является дополнительным дескриптором тома? ; sector is an additional descriptor of volume?
cmp [CDDataBuf+6], byte 0x1 cmp [CDDataBuf+6], byte 0x1
jne .start jne .start
; параметры root директрории ; parameters of root directory
mov eax, [CDDataBuf+0x9c+2]; начало root директрории mov eax, [CDDataBuf+0x9c+2]; start of root directory
mov [CDSectorAddress], eax mov [CDSectorAddress], eax
mov eax, [CDDataBuf+0x9c+10]; размер root директрории mov eax, [CDDataBuf+0x9c+10]; size of root directory
cmp byte [esi], 0 cmp byte [esi], 0
jnz @f jnz @f
mov [cd_current_pointer_of_input], CDDataBuf+0x9c mov [cd_current_pointer_of_input], CDDataBuf+0x9c
jmp .done jmp .done
;--------------------------------------
@@: @@:
; начинаем поиск ; start the search
.mainloop: .mainloop:
dec dword [CDSectorAddress] dec dword [CDSectorAddress]
;--------------------------------------
.read_to_buffer: .read_to_buffer:
inc dword [CDSectorAddress] inc dword [CDSectorAddress]
mov [CDDataBuf_pointer], CDDataBuf mov [CDDataBuf_pointer], CDDataBuf
call ReadCDWRetr ; читаем сектор директории call ReadCDWRetr ; read sector of directory
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .access_denied jne .access_denied
push ebp push ebp
call cd_find_name_in_buffer call cd_find_name_in_buffer
pop ebp pop ebp
jnc .found jnc .found
sub eax, 2048 sub eax, 2048
; директория закончилась? ; directory is over?
cmp eax, 0 cmp eax, 0
ja .read_to_buffer ja .read_to_buffer
; нет искомого элемента цепочки ; desired element of chain is not found
.access_denied: .access_denied:
pop esi eax pop esi eax
mov [cd_appl_data], 1 mov [cd_appl_data], 1
stc stc
ret ret
; искомый элемент цепочки найден ;--------------------------------------
.found: ; desired element of chain found
; конец пути файла .found:
; the end of the file path
cmp byte [esi-1], 0 cmp byte [esi-1], 0
jz .done jz .done
.nested: .nested:
mov eax, [cd_current_pointer_of_input] mov eax, [cd_current_pointer_of_input]
push dword [eax+2] push dword [eax+2]
pop dword [CDSectorAddress] ; начало директории pop dword [CDSectorAddress] ; beginning of the directory
mov eax, [eax+2+8]; размер директории mov eax, [eax+2+8] ; size of directory
jmp .mainloop jmp .mainloop
; указатель файла найден ;--------------------------------------
.done: ; file pointer found
.done:
test ebp, ebp test ebp, ebp
jz @f jz @f
mov esi, ebp mov esi, ebp
xor ebp, ebp xor ebp, ebp
jmp .nested jmp .nested
;--------------------------------------
@@: @@:
pop esi eax pop esi eax
mov [cd_appl_data], 1 mov [cd_appl_data], 1
clc clc
ret ret
;-----------------------------------------------------------------------------
cd_find_name_in_buffer: cd_find_name_in_buffer:
mov [cd_current_pointer_of_input_2], CDDataBuf mov [cd_current_pointer_of_input_2], CDDataBuf
;--------------------------------------
.start: .start:
call cd_get_name call cd_get_name
jc .not_found jc .not_found
call cd_compare_name call cd_compare_name
jc .start jc .start
;--------------------------------------
.found: .found:
clc clc
ret ret
;--------------------------------------
.not_found: .not_found:
stc stc
ret ret
;-----------------------------------------------------------------------------
cd_get_name: cd_get_name:
push eax push eax
mov ebp, [cd_current_pointer_of_input_2] mov ebp, [cd_current_pointer_of_input_2]
mov [cd_current_pointer_of_input], ebp mov [cd_current_pointer_of_input], ebp
mov eax, [ebp] mov eax, [ebp]
test eax, eax ; входы закончились? test eax, eax ; entry's is over?
jz .next_sector jz .next_sector
cmp ebp, CDDataBuf+2048 ; буфер закончился?
cmp ebp, CDDataBuf+2048 ; buffer is over?
jae .next_sector jae .next_sector
movzx eax, byte [ebp] movzx eax, byte [ebp]
add [cd_current_pointer_of_input_2], eax; следующий вход каталога add [cd_current_pointer_of_input_2], eax ; next entry of directory
add ebp, 33; указатель установлен на начало имени add ebp, 33; pointer is set to the beginning of the name
pop eax pop eax
clc clc
ret ret
;--------------------------------------
.next_sector: .next_sector:
pop eax pop eax
stc stc
ret ret
;-----------------------------------------------------------------------------
cd_compare_name: cd_compare_name:
; compares ASCIIZ-names, case-insensitive (cp866 encoding) ; compares ASCIIZ-names, case-insensitive (cp866 encoding)
; in: esi->name, ebp->name ; in: esi->name, ebp->name
@ -650,6 +777,7 @@ cd_compare_name:
; destroys eax ; destroys eax
push esi eax edi push esi eax edi
mov edi, ebp mov edi, ebp
;--------------------------------------
.loop: .loop:
cld cld
lodsb lodsb
@ -666,94 +794,118 @@ cd_compare_name:
sub edi, 2 sub edi, 2
scasw scasw
jne .name_not_coincide jne .name_not_coincide
;--------------------------------------
.coincides: .coincides:
cmp [esi], byte '/'; разделитель пути, конец имени текущего элемента cmp [esi], byte '/' ; path separator is end of current element
je .done je .done
cmp [esi], byte 0; разделитель пути, конец имени текущего элемента
cmp [esi], byte 0 ; path separator end of name
je .done je .done
jmp .loop jmp .loop
;--------------------------------------
.name_not_coincide: .name_not_coincide:
pop edi eax esi pop edi eax esi
stc stc
ret ret
;--------------------------------------
.done: .done:
; проверка конца файла ; check end of file
cmp [edi], word 3B00h; сепаратор конца файла ';' cmp [edi], word 3B00h; separator end of file ';'
je .done_1 je .done_1
; проверка для файлов не заканчивающихся сепаратором ; check for files not ending with separator
movzx eax, byte [ebp-33] movzx eax, byte [ebp-33]
add eax, ebp add eax, ebp
sub eax, 34 sub eax, 34
cmp edi, eax cmp edi, eax
je .done_1 je .done_1
; проверка конца папки ; check the end of directory
movzx eax, byte [ebp-1] movzx eax, byte [ebp-1]
add eax, ebp add eax, ebp
cmp edi, eax cmp edi, eax
jne .name_not_coincide jne .name_not_coincide
;--------------------------------------
.done_1: .done_1:
pop edi eax pop edi eax
add esp, 4 add esp, 4
inc esi inc esi
clc clc
ret ret
;-----------------------------------------------------------------------------
char_todown: char_todown:
; convert character to uppercase, using cp866 encoding ; convert character to uppercase, using cp866 encoding
; in: al=symbol ; in: al=symbol
; out: al=converted symbol ; out: al=converted symbol
cmp al, 'A' cmp al, 'A'
jb .ret jb .ret
cmp al, 'Z' cmp al, 'Z'
jbe .az jbe .az
cmp al, 0x80 ; 'А' cmp al, 0x80 ; 'А'
jb .ret jb .ret
cmp al, 0x90 ; 'Р' cmp al, 0x90 ; 'Р'
jb .rus1 jb .rus1
cmp al, 0x9F ; 'Я' cmp al, 0x9F ; 'Я'
ja .ret ja .ret
; 0x90-0x9F -> 0xE0-0xEF ; 0x90-0x9F -> 0xE0-0xEF
add al, 0xE0-0x90 add al, 0xE0-0x90
;--------------------------------------
.ret: .ret:
ret ret
;--------------------------------------
.rus1: .rus1:
; 0x80-0x8F -> 0xA0-0xAF ; 0x80-0x8F -> 0xA0-0xAF
.az: .az:
add al, 0x20 add al, 0x20
ret ret
;-----------------------------------------------------------------------------
uni2ansi_char: uni2ansi_char:
; convert UNICODE character in al to ANSI character in ax, using cp866 encoding ; convert UNICODE character in al to ANSI character in ax, using cp866 encoding
; in: ax=UNICODE character ; in: ax=UNICODE character
; out: al=converted ANSI character ; out: al=converted ANSI character
cmp ax, 0x80 cmp ax, 0x80
jb .ascii jb .ascii
cmp ax, 0x401 cmp ax, 0x401
jz .yo1 jz .yo1
cmp ax, 0x451 cmp ax, 0x451
jz .yo2 jz .yo2
cmp ax, 0x410 cmp ax, 0x410
jb .unk jb .unk
cmp ax, 0x440 cmp ax, 0x440
jb .rus1 jb .rus1
cmp ax, 0x450 cmp ax, 0x450
jb .rus2 jb .rus2
;--------------------------------------
.unk: .unk:
mov al, '_' mov al, '_'
jmp .doit jmp .doit
;--------------------------------------
.yo1: .yo1:
mov al, 0xF0 ; 'Ё' in cp866 mov al, 0xF0 ; 'Ё' in cp866
jmp .doit jmp .doit
;--------------------------------------
.yo2: .yo2:
mov al, 0xF1 ; 'ё' in cp866 mov al, 0xF1 ; 'ё' in cp866
jmp .doit jmp .doit
;--------------------------------------
.rus1: .rus1:
; 0x410-0x43F -> 0x80-0xAF ; 0x410-0x43F -> 0x80-0xAF
add al, 0x70 add al, 0x70
jmp .doit jmp .doit
;--------------------------------------
.rus2: .rus2:
; 0x440-0x44F -> 0xE0-0xEF ; 0x440-0x44F -> 0xE0-0xEF
add al, 0xA0 add al, 0xA0
;--------------------------------------
.ascii: .ascii:
.doit: .doit:
ret ret
;-----------------------------------------------------------------------------

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
include 'xfs.inc' include 'xfs.inc'
; ;

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
; from stat.h ; from stat.h
; distinguish file types ; distinguish file types
S_IFMT = 0170000o ; These bits determine file type. S_IFMT = 0170000o ; These bits determine file type.

View File

@ -454,7 +454,11 @@ align 4
cmp al, 120 cmp al, 120
jae .result ;overflow jae .result ;overflow
inc byte[KEY_COUNT] inc byte[KEY_COUNT]
mov [KEY_COUNT+1+eax], dl mov [KEY_BUFF+eax], dl
; store empty scancode
add eax, 120+2
mov [KEY_BUFF+eax], byte 0
sub eax, 120+2
;-------------------------------------- ;--------------------------------------
align 4 align 4
.result: .result:

View File

@ -11,7 +11,7 @@ $Revision: 3711 $
include "skindata.inc" include "skindata.inc"
;skin_data = 0x00778000 ;skin_data = 0x00778000
;------------------------------------------------------------------------------ ;-----------------------------------------------------------------
align 4 align 4
read_skin_file: read_skin_file:
stdcall load_file, ebx stdcall load_file, ebx
@ -121,7 +121,7 @@ parse_skin_data:
lea esi, [ebx+SKIN_PARAMS.dtp.data] lea esi, [ebx+SKIN_PARAMS.dtp.data]
mov edi, common_colours mov edi, common_colours
mov ecx, [ebx+SKIN_PARAMS.dtp.size] mov ecx, [ebx+SKIN_PARAMS.dtp.size]
and ecx, 127 and ecx, 255
rep movsb rep movsb
mov eax, dword[ebx+SKIN_PARAMS.margin.right] mov eax, dword[ebx+SKIN_PARAMS.margin.right]
mov dword[_skinmargins+0], eax mov dword[_skinmargins+0], eax

View File

@ -9,7 +9,7 @@ $Revision: 2455 $
; ;
; WINDOW SKIN DATA ; WINDOW SKIN DATA.
; ;
iglobal iglobal

View File

@ -26,7 +26,7 @@ macro FuncTable name, table_name, [label]
} }
uglobal uglobal
common_colours rd 32 common_colours rd 48
draw_limits RECT draw_limits RECT
endg endg
@ -34,7 +34,7 @@ align 4
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
syscall_draw_window: ;///// system function 0 ///////////////////////////////// syscall_draw_window: ;///// system function 0 /////////////////////////////////
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
;? <description> ;? <description>.
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
mov eax, edx mov eax, edx
shr eax, 24 shr eax, 24
@ -173,7 +173,10 @@ align 4
syscall_display_settings.02: syscall_display_settings.02:
dec ebx dec ebx
mov esi, ecx mov esi, ecx
and edx, 127 cmp edx, 192
jnae @f
mov edx, 192 ; max size
@@:
mov edi, common_colours mov edi, common_colours
mov ecx, edx mov ecx, edx
rep movsb rep movsb
@ -183,7 +186,10 @@ syscall_display_settings.02:
align 4 align 4
syscall_display_settings.03: syscall_display_settings.03:
mov edi, ecx mov edi, ecx
and edx, 127 cmp edx, 192
jnae @f
mov edx, 192 ; max size
@@:
mov esi, common_colours mov esi, common_colours
mov ecx, edx mov ecx, edx
rep movsb rep movsb

View File

@ -488,7 +488,19 @@ send_scancode:
jae .exit.irq1 jae .exit.irq1
inc eax inc eax
mov [KEY_COUNT], al mov [KEY_COUNT], al
mov [KEY_COUNT+eax], bl ; store ascii or scancode
mov [KEY_COUNT+eax], bl ; actually KEY_BUFF + EAX - 1
; store original scancode
add eax, 120+2
push ecx
cmp [keyboard_mode], 0; return from keymap
je @f
xor ch, ch
@@:
mov [KEY_COUNT+eax], ch ; actually KEY_BUFF + EAX - 1
pop ecx
sub eax, 120+2
.exit.irq1: .exit.irq1:
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------

View File

@ -479,54 +479,53 @@ nodmp:
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4
proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
mov eax, [BtnState] mov eax, [BtnState]
and eax, 0x3FFFFFFF ; Top 2 bits are used to flag absolute movements and eax, 0x3FFFFFFF ; Top 2 bits are used to flag absolute movements
mov [BTN_DOWN], eax mov [BTN_DOWN], eax
;--------------------------------------
mov eax, [XMoving] mov eax, [XMoving]
test [BtnState], 0x80000000 test [BtnState], 0x80000000
jnz @@M1 jnz .absolute_x
call mouse_acceleration call mouse_acceleration
add ax, [MOUSE_X];[XCoordinate] add ax, [MOUSE_X]
cmp ax, 0 cmp ax, 0
jge @@M1 jge .check_x
mov eax, 0 mov eax, 0
jmp @@M2 jmp .set_x
.absolute_x:
mov edx, [_display.width]
mul edx
shr eax, 15
.check_x:
cmp ax, word[Screen_Max_X]
jl .set_x
mov ax, word[Screen_Max_X]
.set_x:
mov [MOUSE_X], ax
;-------------------------------------- ;--------------------------------------
align 4
@@M1:
cmp ax, word [Screen_Max_X];ScreenLength
jl @@M2
mov ax, word [Screen_Max_X];ScreenLength-1
;--------------------------------------
align 4
@@M2:
mov [MOUSE_X], ax;[XCoordinate]
mov eax, [YMoving] mov eax, [YMoving]
test [BtnState], 0x40000000 test [BtnState], 0x40000000
jnz @@M3 jnz .absolute_y
neg eax neg eax
call mouse_acceleration call mouse_acceleration
add ax, [MOUSE_Y]
add ax, [MOUSE_Y];[YCoordinate]
cmp ax, 0 cmp ax, 0
jge @@M3 jge .check_y
mov ax, 0 mov ax, 0
jmp @@M4 jmp .set_y
.absolute_y:
mov edx, [_display.height]
mul edx
shr eax, 15
.check_y:
cmp ax, word[Screen_Max_Y]
jl .set_y
mov ax, word[Screen_Max_Y]
.set_y:
mov [MOUSE_Y], ax
;-------------------------------------- ;--------------------------------------
align 4
@@M3:
cmp ax, word [Screen_Max_Y];ScreenHeigth
jl @@M4
mov ax, word [Screen_Max_Y];ScreenHeigth-1
;--------------------------------------
align 4
@@M4:
mov [MOUSE_Y], ax;[YCoordinate]
mov eax, [VScroll] mov eax, [VScroll]
add [MOUSE_SCROLL_V], ax add [MOUSE_SCROLL_V], ax

View File

@ -354,6 +354,7 @@ proc test_cpu
mov [cpu_type], eax mov [cpu_type], eax
mov [cpu_caps-OS_BASE], eax mov [cpu_caps-OS_BASE], eax
mov [cpu_caps+4-OS_BASE], eax mov [cpu_caps+4-OS_BASE], eax
mov [cpu_phys_addr_width-OS_BASE], 32
pushfd pushfd
pop eax pop eax
@ -378,7 +379,6 @@ proc test_cpu
pop eax pop eax
xor eax, ecx xor eax, ecx
je .end_cpuid je .end_cpuid
mov [cpu_id], 1
xor eax, eax xor eax, eax
cpuid cpuid
@ -402,6 +402,20 @@ proc test_cpu
mov [cpu_caps-OS_BASE], edx mov [cpu_caps-OS_BASE], edx
mov [cpu_caps+4-OS_BASE], ecx mov [cpu_caps+4-OS_BASE], ecx
bt edx, CAPS_PAE
jnc @f
mov [cpu_phys_addr_width-OS_BASE], 36
@@:
mov eax, 0x80000000
cpuid
cmp eax, 0x80000008
jb @f
mov eax, 0x80000008
cpuid
mov [cpu_phys_addr_width-OS_BASE], al
@@:
mov eax, [cpu_sign-OS_BASE]
shr eax, 8 shr eax, 8
and eax, 0x0f and eax, 0x0f
ret ret

File diff suppressed because it is too large Load Diff

View File

@ -168,6 +168,36 @@ struct APPDATA
ends ends
struct IDE_DATA
ProgrammingInterface dd ?
Interrupt dw ?
RegsBaseAddres dw ?
BAR0_val dw ?
BAR1_val dw ?
BAR2_val dw ?
BAR3_val dw ?
dma_hdd_channel_1 db ?
dma_hdd_channel_2 db ?
ends
struct IDE_CACHE
pointer dd ?
size dd ? ; not use
data_pointer dd ?
system_data_size dd ? ; not use
appl_data_size dd ? ; not use
system_data dd ?
appl_data dd ?
system_sad_size dd ?
appl_sad_size dd ?
search_start dd ?
appl_search_start dd ?
ends
struct IDE_DEVICE
UDMA_possible_modes db ?
UDMA_set_mode db ?
ends
; Core functions ; Core functions
include "core/sync.inc" ; macros for synhronization objects include "core/sync.inc" ; macros for synhronization objects
@ -176,6 +206,7 @@ include "core/sched.inc" ; process scheduling
include "core/syscall.inc" ; system call include "core/syscall.inc" ; system call
include "core/fpu.inc" ; all fpu/sse support include "core/fpu.inc" ; all fpu/sse support
include "core/memory.inc" include "core/memory.inc"
include "core/mtrr.inc"
include "core/heap.inc" ; kernel and app heap include "core/heap.inc" ; kernel and app heap
include "core/malloc.inc" ; small kernel heap include "core/malloc.inc" ; small kernel heap
include "core/taskman.inc" include "core/taskman.inc"
@ -258,7 +289,6 @@ include "blkdev/bd_drv.inc"
; CD drive controller ; CD drive controller
include "blkdev/cdrom.inc"
include "blkdev/cd_drv.inc" include "blkdev/cd_drv.inc"
; Character devices ; Character devices

View File

@ -1,3 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
; Éste archivo debe ser editado con codificación CP866 ; Éste archivo debe ser editado con codificación CP866
version cp850 'Kolibri OS versión 0.7.7.0+ ',13,10,13,10,0 version cp850 'Kolibri OS versión 0.7.7.0+ ',13,10,13,10,0

View File

@ -14,6 +14,9 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
struct PPPoE_frame struct PPPoE_frame
VersionAndType db ? VersionAndType db ?
Code db ? Code db ?

View File

@ -294,12 +294,12 @@ ICMP_input:
call mutex_unlock call mutex_unlock
popa popa
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: no socket found\n" DEBUGF DEBUG_NETWORK_ERROR, "ICMP_input: no socket found\n"
jmp .dump jmp .dump
.checksum_mismatch: .checksum_mismatch:
DEBUGF DEBUG_NETWORK_VERBOSE, "checksum mismatch\n" DEBUGF DEBUG_NETWORK_ERROR, "ICMP_input: checksum mismatch\n"
.dump: .dump:
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: dumping\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: dumping\n"

View File

@ -14,6 +14,8 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
;------------------------- ;-------------------------
; ;

View File

@ -1,10 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2011-2012. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2011-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
struct BLITTER_BLOCK struct BLITTER_BLOCK
xmin dd ? xmin dd ?
ymin dd ? ymin dd ?

View File

@ -295,15 +295,17 @@ proc set_cursor stdcall, hcursor:dword
; jne .fail ; jne .fail
mov ebx, [current_slot] mov ebx, [current_slot]
xchg eax, [ebx+APPDATA.cursor] xchg eax, [ebx+APPDATA.cursor]
mov [redrawmouse_unconditional], 1 jmp .end
call __sys_draw_pointer
ret
;-------------------------------------- ;--------------------------------------
align 4 align 4
.fail: .fail:
mov eax, [def_cursor] mov eax, [def_cursor]
mov ebx, [current_slot] mov ebx, [current_slot]
xchg eax, [ebx+APPDATA.cursor] xchg eax, [ebx+APPDATA.cursor]
align 4
.end:
mov [redrawmouse_unconditional], 1
call __sys_draw_pointer
ret ret
endp endp
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------

View File

@ -218,8 +218,7 @@ align 4
add eax, [putimg.arg_0] add eax, [putimg.arg_0]
mov [putimg.line_increment], eax mov [putimg.line_increment], eax
; winmap new line increment ; winmap new line increment
mov eax, [Screen_Max_X] mov eax, [_display.width]
inc eax
sub eax, [putimg.real_sx] sub eax, [putimg.real_sx]
mov [putimg.winmap_newline], eax mov [putimg.winmap_newline], eax
; screen new line increment ; screen new line increment
@ -687,10 +686,10 @@ __sys_putpixel:
; edi = 0x00000001 force ; edi = 0x00000001 force
pushad pushad
cmp [Screen_Max_X], eax cmp eax, [_display.width]
jb .exit jae .exit
cmp [Screen_Max_Y], ebx cmp ebx, [_display.height]
jb .exit jae .exit
test edi, 1 ; force ? test edi, 1 ; force ?
jnz .forced jnz .forced
@ -1210,9 +1209,8 @@ align 4
.end_y: .end_y:
mov [drbar.real_sy], ebx mov [drbar.real_sy], ebx
; line_inc_map ; line_inc_map
mov eax, [Screen_Max_X] mov eax, [_display.width]
sub eax, [drbar.real_sx] sub eax, [drbar.real_sx]
inc eax
mov [drbar.line_inc_map], eax mov [drbar.line_inc_map], eax
; line_inc_scr ; line_inc_scr
mov eax, [drbar.real_sx] mov eax, [drbar.real_sx]
@ -1926,8 +1924,7 @@ sdp4:
; advance edi, ebp to next scan line ; advance edi, ebp to next scan line
sub eax, [draw_data+32+RECT.left] sub eax, [draw_data+32+RECT.left]
sub ebp, eax sub ebp, eax
add ebp, [Screen_Max_X] add ebp, [_display.width]
add ebp, 1
sub edi, eax sub edi, eax
sub edi, eax sub edi, eax
sub edi, eax sub edi, eax
@ -1958,8 +1955,7 @@ align 4
push edi push edi
mov esi, bgr_next_line mov esi, bgr_next_line
mov edi, bgr_cur_line mov edi, bgr_cur_line
mov ecx, [Screen_Max_X] mov ecx, [_display.width]
inc ecx
rep movsd rep movsd
jmp bgr_resmooth1 jmp bgr_resmooth1
;-------------------------------------- ;--------------------------------------