mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-24 23:56:49 +03:00
The universal cache of IDE devices.
Step 2: 1) Realized cache ATAPI device (CD\DVD). 2) Lock\Unlock ATAPI device for working with cache. 3) Eject (F70/10) and Load (F70/11) tray of ATAPI device. 4) Application CD_tray for control of tray ATAPI device. git-svn-id: svn://kolibrios.org@585 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
dfac57a317
commit
93e2c279ba
@ -16,7 +16,6 @@ $Revision$
|
||||
; данных из сектора компакт-диска
|
||||
; Автор текста программы Кулаков Владимир Геннадьевич.
|
||||
|
||||
|
||||
; Максимальное количество повторений операции чтения
|
||||
MaxRetr equ 10
|
||||
; Предельное время ожидания готовности к приему команды
|
||||
@ -35,74 +34,138 @@ NoTickWaitTime equ 0xfffff
|
||||
;* Данные считывается в массив CDDataBuf. *
|
||||
;*************************************************
|
||||
ReadCD:
|
||||
pusha
|
||||
pusha
|
||||
; Задать размер сектора
|
||||
mov [CDBlockSize],2048 ;2352
|
||||
mov [CDBlockSize],2048 ;2352
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
call clear_packet_buffer
|
||||
; Сформировать пакетную команду для считывания
|
||||
; сектора данных
|
||||
; Çàäàòü êîä êîìàíäû Read CD
|
||||
mov [PacketCommand],byte 0x28 ;0xBE
|
||||
; Çàäàòü àäðåñ ñåêòîðà
|
||||
mov AX,word [CDSectorAddress+2]
|
||||
xchg AL,AH
|
||||
mov word [PacketCommand+2],AX
|
||||
mov AX,word [CDSectorAddress]
|
||||
xchg AL,AH
|
||||
mov word [PacketCommand+4],AX
|
||||
; Çàäàòü êîä êîìàíäû Read CD
|
||||
mov [PacketCommand],byte 0x28 ;0xBE
|
||||
; Çàäàòü àäðåñ ñåêòîðà
|
||||
mov AX,word [CDSectorAddress+2]
|
||||
xchg AL,AH
|
||||
mov word [PacketCommand+2],AX
|
||||
mov AX,word [CDSectorAddress]
|
||||
xchg AL,AH
|
||||
mov word [PacketCommand+4],AX
|
||||
; mov eax,[CDSectorAddress]
|
||||
; mov [PacketCommand+2],eax
|
||||
; Çàäàòü êîëè÷åñòâî ñ÷èòûâàåìûõ ñåêòîðîâ
|
||||
mov [PacketCommand+8],byte 1
|
||||
; Çàäàòü ñ÷èòûâàíèå äàííûõ â ïîëíîì îáúåìå
|
||||
; Çàäàòü êîëè÷åñòâî ñ÷èòûâàåìûõ ñåêòîðîâ
|
||||
mov [PacketCommand+8],byte 1
|
||||
; Çàäàòü ñ÷èòûâàíèå äàííûõ â ïîëíîì îáúåìå
|
||||
; mov [PacketCommand+9],byte 0xF8
|
||||
; Подать команду
|
||||
call SendPacketDatCommand
|
||||
call SendPacketDatCommand
|
||||
; call test_mario79
|
||||
popa
|
||||
ret
|
||||
popa
|
||||
ret
|
||||
|
||||
;********************************************
|
||||
;* ЧТЕНИЕ СЕКТОРА С ПОВТОРАМИ *
|
||||
;* Многократное повторение чтения при сбоях *
|
||||
;********************************************
|
||||
ReadCDWRetr:
|
||||
pushad
|
||||
|
||||
;-----------------------------------------------------------
|
||||
; input : eax = block to read
|
||||
; ebx = destination
|
||||
;-----------------------------------------------------------
|
||||
pushad
|
||||
mov eax,[CDSectorAddress]
|
||||
mov ebx,[CDDataBuf_pointer]
|
||||
call cd_calculate_cache
|
||||
add esi,8
|
||||
mov edi,1
|
||||
.hdreadcache:
|
||||
; push esi
|
||||
; mov esi,[esi]
|
||||
; call test_mario79
|
||||
; mov esi,eax
|
||||
; call test_mario79
|
||||
; pop esi
|
||||
|
||||
; cmp dword [esi+4],0 ; empty
|
||||
; je .nohdcache
|
||||
cmp [esi],eax ; correct sector
|
||||
je .yeshdcache
|
||||
.nohdcache:
|
||||
add esi,8
|
||||
inc edi
|
||||
dec ecx
|
||||
jnz .hdreadcache
|
||||
call find_empty_slot_CD_cache ; ret in edi
|
||||
|
||||
push edi
|
||||
push eax
|
||||
call cd_calculate_cache_2
|
||||
shl edi,11
|
||||
add edi,eax
|
||||
mov [CDDataBuf_pointer],edi
|
||||
pop eax
|
||||
pop edi
|
||||
|
||||
call ReadCDWRetr_1
|
||||
mov [CDDataBuf_pointer],ebx
|
||||
call cd_calculate_cache_1
|
||||
lea esi,[edi*8+esi]
|
||||
; push esi
|
||||
; call test_mario79
|
||||
; mov esi,eax
|
||||
; call test_mario79
|
||||
; pop esi
|
||||
mov [esi],eax ; sector number
|
||||
; mov dword [esi+4],1 ; hd read - mark as same as in hd
|
||||
.yeshdcache:
|
||||
mov esi,edi
|
||||
shl esi,11 ;9
|
||||
push eax
|
||||
call cd_calculate_cache_2
|
||||
add esi,eax
|
||||
pop eax
|
||||
mov edi,ebx ;[CDDataBuf_pointer]
|
||||
mov ecx,512 ;/4
|
||||
cld
|
||||
rep movsd ; move data
|
||||
popad
|
||||
ret
|
||||
|
||||
ReadCDWRetr_1:
|
||||
pushad
|
||||
|
||||
; Цикл, пока команда не выполнена успешно или не
|
||||
; исчерпано количество попыток
|
||||
mov ECX,MaxRetr
|
||||
mov ECX,MaxRetr
|
||||
@@NextRetr:
|
||||
; Подать команду
|
||||
call ReadCD
|
||||
cmp [DevErrorCode],0
|
||||
je @@End_4
|
||||
|
||||
or ecx,ecx ;{SPraid.simba} (for cd load)
|
||||
jz @@End_4
|
||||
dec ecx
|
||||
|
||||
cmp [timer_ticks_enable],0
|
||||
jne @f
|
||||
mov eax,NoTickWaitTime
|
||||
call ReadCD
|
||||
cmp [DevErrorCode],0
|
||||
je @@End_4
|
||||
|
||||
or ecx,ecx ;{SPraid.simba} (for cd load)
|
||||
jz @@End_4
|
||||
dec ecx
|
||||
|
||||
cmp [timer_ticks_enable],0
|
||||
jne @f
|
||||
mov eax,NoTickWaitTime
|
||||
.wait:
|
||||
dec eax
|
||||
cmp eax,0
|
||||
je @@NextRetr
|
||||
jmp .wait
|
||||
dec eax
|
||||
cmp eax,0
|
||||
je @@NextRetr
|
||||
jmp .wait
|
||||
@@:
|
||||
; Задержка на 2,5 секунды
|
||||
mov EAX,[timer_ticks]
|
||||
add EAX,250 ;50
|
||||
mov EAX,[timer_ticks]
|
||||
add EAX,250 ;50
|
||||
@@Wait:
|
||||
call change_task
|
||||
cmp EAX,[timer_ticks]
|
||||
ja @@Wait
|
||||
loop @@NextRetr
|
||||
call change_task
|
||||
cmp EAX,[timer_ticks]
|
||||
ja @@Wait
|
||||
loop @@NextRetr
|
||||
@@End_4:
|
||||
popad
|
||||
ret
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
; Универсальные процедуры, обеспечивающие выполнение
|
||||
@ -115,11 +178,11 @@ ReadCDWRetr:
|
||||
MaxCDWaitTime equ 1000 ;200 ;10 секунд
|
||||
|
||||
; Область памяти для формирования пакетной команды
|
||||
PacketCommand: rb 12 ;DB 12 DUP (?)
|
||||
PacketCommand: rb 12 ;DB 12 DUP (?)
|
||||
; Область памяти для приема данных от дисковода
|
||||
;CDDataBuf DB 4096 DUP (0)
|
||||
; Размер принимаемого блока данных в байтах
|
||||
CDBlockSize DW ?
|
||||
CDBlockSize DW ?
|
||||
; Адрес считываемого сектора данных
|
||||
CDSectorAddress: DD ?
|
||||
; Время начала очередной операции с диском
|
||||
@ -141,123 +204,123 @@ CDDataBuf_pointer dd 0
|
||||
;* CDBlockSize - размер принимаемого блока данных. *
|
||||
;****************************************************
|
||||
SendPacketDatCommand:
|
||||
pushad
|
||||
pushad
|
||||
; Задать режим CHS
|
||||
mov [ATAAddressMode],0
|
||||
mov [ATAAddressMode],0
|
||||
; Послать ATA-команду передачи пакетной команды
|
||||
mov [ATAFeatures],0
|
||||
mov [ATASectorCount],0
|
||||
mov [ATASectorNumber],0
|
||||
; Çàãðóçèòü ðàçìåð ïåðåäàâàåìîãî áëîêà
|
||||
mov AX,[CDBlockSize]
|
||||
mov [ATACylinder],AX
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0A0h
|
||||
call SendCommandToHDD_1
|
||||
cmp [DevErrorCode],0 ;ïðîâåðèòü êîä îøèáêè
|
||||
jne @@End_8 ;çàêîí÷èòü, ñîõðàíèâ êîä îøèáêè
|
||||
mov [ATAFeatures],0
|
||||
mov [ATASectorCount],0
|
||||
mov [ATASectorNumber],0
|
||||
; Çàãðóçèòü ðàçìåð ïåðåäàâàåìîãî áëîêà
|
||||
mov AX,[CDBlockSize]
|
||||
mov [ATACylinder],AX
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0A0h
|
||||
call SendCommandToHDD_1
|
||||
cmp [DevErrorCode],0 ;ïðîâåðèòü êîä îøèáêè
|
||||
jne @@End_8 ;çàêîí÷èòü, ñîõðàíèâ êîä îøèáêè
|
||||
|
||||
; Ожидание готовности дисковода к приему
|
||||
; пакетной команды
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;ïîðò 1õ7h
|
||||
mov ecx,NoTickWaitTime
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;ïîðò 1õ7h
|
||||
mov ecx,NoTickWaitTime
|
||||
@@WaitDevice0:
|
||||
cmp [timer_ticks_enable],0
|
||||
jne @f
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Err1_1
|
||||
jmp .test
|
||||
cmp [timer_ticks_enable],0
|
||||
jne @f
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Err1_1
|
||||
jmp .test
|
||||
@@:
|
||||
call change_task
|
||||
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,BSYWaitTime
|
||||
ja @@Err1_1 ;îøèáêà òàéì-àóòà
|
||||
; Ïðîâåðèòü ãîòîâíîñòü
|
||||
call change_task
|
||||
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,BSYWaitTime
|
||||
ja @@Err1_1 ;îøèáêà òàéì-àóòà
|
||||
; Ïðîâåðèòü ãîòîâíîñòü
|
||||
.test:
|
||||
in AL,DX
|
||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||
jnz @@WaitDevice0
|
||||
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
||||
jz @@WaitDevice0
|
||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||
jnz @@Err6
|
||||
in AL,DX
|
||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||
jnz @@WaitDevice0
|
||||
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
||||
jz @@WaitDevice0
|
||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||
jnz @@Err6
|
||||
; Послать пакетную команду
|
||||
cli
|
||||
mov DX,[ATABasePortAddr]
|
||||
mov AX,[PacketCommand]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+2]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+4]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+6]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+8]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+10]
|
||||
out DX,AX
|
||||
sti
|
||||
cli
|
||||
mov DX,[ATABasePortAddr]
|
||||
mov AX,[PacketCommand]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+2]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+4]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+6]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+8]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+10]
|
||||
out DX,AX
|
||||
sti
|
||||
; Ожидание готовности данных
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;ïîðò 1õ7h
|
||||
mov ecx,NoTickWaitTime
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;ïîðò 1õ7h
|
||||
mov ecx,NoTickWaitTime
|
||||
@@WaitDevice1:
|
||||
cmp [timer_ticks_enable],0
|
||||
jne @f
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Err1_1
|
||||
jmp .test_1
|
||||
cmp [timer_ticks_enable],0
|
||||
jne @f
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Err1_1
|
||||
jmp .test_1
|
||||
@@:
|
||||
call change_task
|
||||
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,MaxCDWaitTime
|
||||
ja @@Err1_1 ;îøèáêà òàéì-àóòà
|
||||
; Ïðîâåðèòü ãîòîâíîñòü
|
||||
call change_task
|
||||
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,MaxCDWaitTime
|
||||
ja @@Err1_1 ;îøèáêà òàéì-àóòà
|
||||
; Ïðîâåðèòü ãîòîâíîñòü
|
||||
.test_1:
|
||||
in AL,DX
|
||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||
jnz @@WaitDevice1
|
||||
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
||||
jz @@WaitDevice1
|
||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||
jnz @@Err6_temp
|
||||
in AL,DX
|
||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||
jnz @@WaitDevice1
|
||||
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
||||
jz @@WaitDevice1
|
||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||
jnz @@Err6_temp
|
||||
; Принять блок данных от контроллера
|
||||
mov EDI,[CDDataBuf_pointer] ;0x7000 ;CDDataBuf
|
||||
; Çàãðóçèòü àäðåñ ðåãèñòðà äàííûõ êîíòðîëëåðà
|
||||
mov DX,[ATABasePortAddr] ;ïîðò 1x0h
|
||||
; Çàãðóçèòü â ñ÷åò÷èê ðàçìåð áëîêà â áàéòàõ
|
||||
xor ecx,ecx
|
||||
mov CX,[CDBlockSize]
|
||||
; Âû÷èñëèòü ðàçìåð áëîêà â 16-ðàçðÿäíûõ ñëîâàõ
|
||||
shr CX,1 ;ðàçäåëèòü ðàçìåð áëîêà íà 2
|
||||
; Ïðèíÿòü áëîê äàííûõ
|
||||
cli
|
||||
cld
|
||||
rep insw
|
||||
sti
|
||||
; Óñïåøíîå çàâåðøåíèå ïðèåìà äàííûõ
|
||||
jmp @@End_8
|
||||
mov EDI,[CDDataBuf_pointer] ;0x7000 ;CDDataBuf
|
||||
; Çàãðóçèòü àäðåñ ðåãèñòðà äàííûõ êîíòðîëëåðà
|
||||
mov DX,[ATABasePortAddr] ;ïîðò 1x0h
|
||||
; Çàãðóçèòü â ñ÷åò÷èê ðàçìåð áëîêà â áàéòàõ
|
||||
xor ecx,ecx
|
||||
mov CX,[CDBlockSize]
|
||||
; Âû÷èñëèòü ðàçìåð áëîêà â 16-ðàçðÿäíûõ ñëîâàõ
|
||||
shr CX,1 ;ðàçäåëèòü ðàçìåð áëîêà íà 2
|
||||
; Ïðèíÿòü áëîê äàííûõ
|
||||
cli
|
||||
cld
|
||||
rep insw
|
||||
sti
|
||||
; Óñïåøíîå çàâåðøåíèå ïðèåìà äàííûõ
|
||||
jmp @@End_8
|
||||
|
||||
; Записать код ошибки
|
||||
@@Err1_1:
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_8
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_8
|
||||
@@Err6_temp:
|
||||
mov [DevErrorCode],7
|
||||
jmp @@End_8
|
||||
mov [DevErrorCode],7
|
||||
jmp @@End_8
|
||||
@@Err6:
|
||||
mov [DevErrorCode],6
|
||||
mov [DevErrorCode],6
|
||||
|
||||
@@End_8:
|
||||
popad
|
||||
ret
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
|
||||
@ -271,83 +334,83 @@ SendPacketDatCommand:
|
||||
;* PacketCommand - 12-байтный командный пакет. *
|
||||
;***********************************************
|
||||
SendPacketNoDatCommand:
|
||||
pushad
|
||||
pushad
|
||||
; Задать режим CHS
|
||||
mov [ATAAddressMode],0
|
||||
mov [ATAAddressMode],0
|
||||
; Послать ATA-команду передачи пакетной команды
|
||||
mov [ATAFeatures],0
|
||||
mov [ATASectorCount],0
|
||||
mov [ATASectorNumber],0
|
||||
mov [ATACylinder],0
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0A0h
|
||||
call SendCommandToHDD_1
|
||||
cmp [DevErrorCode],0 ;ïðîâåðèòü êîä îøèáêè
|
||||
jne @@End_9 ;çàêîí÷èòü, ñîõðàíèâ êîä îøèáêè
|
||||
mov [ATAFeatures],0
|
||||
mov [ATASectorCount],0
|
||||
mov [ATASectorNumber],0
|
||||
mov [ATACylinder],0
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0A0h
|
||||
call SendCommandToHDD_1
|
||||
cmp [DevErrorCode],0 ;ïðîâåðèòü êîä îøèáêè
|
||||
jne @@End_9 ;çàêîí÷èòü, ñîõðàíèâ êîä îøèáêè
|
||||
; Ожидание готовности дисковода к приему
|
||||
; пакетной команды
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;ïîðò 1õ7h
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;ïîðò 1õ7h
|
||||
@@WaitDevice0_1:
|
||||
call change_task
|
||||
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,BSYWaitTime
|
||||
ja @@Err1_3 ;îøèáêà òàéì-àóòà
|
||||
; Ïðîâåðèòü ãîòîâíîñòü
|
||||
in AL,DX
|
||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||
jnz @@WaitDevice0_1
|
||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||
jnz @@Err6_1
|
||||
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
||||
jz @@WaitDevice0_1
|
||||
call change_task
|
||||
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,BSYWaitTime
|
||||
ja @@Err1_3 ;îøèáêà òàéì-àóòà
|
||||
; Ïðîâåðèòü ãîòîâíîñòü
|
||||
in AL,DX
|
||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||
jnz @@WaitDevice0_1
|
||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||
jnz @@Err6_1
|
||||
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
||||
jz @@WaitDevice0_1
|
||||
; Послать пакетную команду
|
||||
; cli
|
||||
mov DX,[ATABasePortAddr]
|
||||
mov AX,word [PacketCommand]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+2]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+4]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+6]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+8]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+10]
|
||||
out DX,AX
|
||||
mov DX,[ATABasePortAddr]
|
||||
mov AX,word [PacketCommand]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+2]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+4]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+6]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+8]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+10]
|
||||
out DX,AX
|
||||
; sti
|
||||
; Ожидание подтверждения приема команды
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;ïîðò 1õ7h
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;ïîðò 1õ7h
|
||||
@@WaitDevice1_1:
|
||||
call change_task
|
||||
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,MaxCDWaitTime
|
||||
ja @@Err1_3 ;îøèáêà òàéì-àóòà
|
||||
; Îæèäàòü îñâîáîæäåíèÿ óñòðîéñòâà
|
||||
in AL,DX
|
||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||
jnz @@WaitDevice1_1
|
||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||
jnz @@Err6_1
|
||||
test AL,40h ;ñîñòîÿíèå ñèãíàëà DRDY
|
||||
jz @@WaitDevice1_1
|
||||
jmp @@End_9
|
||||
call change_task
|
||||
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,MaxCDWaitTime
|
||||
ja @@Err1_3 ;îøèáêà òàéì-àóòà
|
||||
; Îæèäàòü îñâîáîæäåíèÿ óñòðîéñòâà
|
||||
in AL,DX
|
||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||
jnz @@WaitDevice1_1
|
||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||
jnz @@Err6_1
|
||||
test AL,40h ;ñîñòîÿíèå ñèãíàëà DRDY
|
||||
jz @@WaitDevice1_1
|
||||
jmp @@End_9
|
||||
|
||||
; Записать код ошибки
|
||||
@@Err1_3:
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_9
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_9
|
||||
@@Err6_1:
|
||||
mov [DevErrorCode],6
|
||||
mov [DevErrorCode],6
|
||||
@@End_9:
|
||||
popad
|
||||
ret
|
||||
popad
|
||||
ret
|
||||
|
||||
;****************************************************
|
||||
;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ *
|
||||
@ -369,119 +432,119 @@ SendPacketNoDatCommand:
|
||||
;* возвращен код ошибки. *
|
||||
;****************************************************
|
||||
SendCommandToHDD_1:
|
||||
pushad
|
||||
pushad
|
||||
; Проверить значение кода режима
|
||||
cmp [ATAAddressMode],1
|
||||
ja @@Err2_4
|
||||
cmp [ATAAddressMode],1
|
||||
ja @@Err2_4
|
||||
; Проверить корректность номера канала
|
||||
mov BX,[ChannelNumber]
|
||||
cmp BX,1
|
||||
jb @@Err3_4
|
||||
cmp BX,2
|
||||
ja @@Err3_4
|
||||
mov BX,[ChannelNumber]
|
||||
cmp BX,1
|
||||
jb @@Err3_4
|
||||
cmp BX,2
|
||||
ja @@Err3_4
|
||||
; Установить базовый адрес
|
||||
dec BX
|
||||
shl BX,1
|
||||
movzx ebx,bx
|
||||
mov AX,[ebx+StandardATABases]
|
||||
mov [ATABasePortAddr],AX
|
||||
dec BX
|
||||
shl BX,1
|
||||
movzx ebx,bx
|
||||
mov AX,[ebx+StandardATABases]
|
||||
mov [ATABasePortAddr],AX
|
||||
; Ожидание готовности HDD к приему команды
|
||||
; Âûáðàòü íóæíûé äèñê
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,6 ;àäðåñ ðåãèñòðà ãîëîâîê
|
||||
mov AL,[DiskNumber]
|
||||
cmp AL,1 ;ïðîâåðèòü íîìåðà äèñêà
|
||||
ja @@Err4_4
|
||||
shl AL,4
|
||||
or AL,10100000b
|
||||
out DX,AL
|
||||
; Îæèäàòü, ïîêà äèñê íå áóäåò ãîòîâ
|
||||
inc DX
|
||||
mov eax,[timer_ticks]
|
||||
mov [TickCounter_1],eax
|
||||
mov ecx,NoTickWaitTime
|
||||
; Âûáðàòü íóæíûé äèñê
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,6 ;àäðåñ ðåãèñòðà ãîëîâîê
|
||||
mov AL,[DiskNumber]
|
||||
cmp AL,1 ;ïðîâåðèòü íîìåðà äèñêà
|
||||
ja @@Err4_4
|
||||
shl AL,4
|
||||
or AL,10100000b
|
||||
out DX,AL
|
||||
; Îæèäàòü, ïîêà äèñê íå áóäåò ãîòîâ
|
||||
inc DX
|
||||
mov eax,[timer_ticks]
|
||||
mov [TickCounter_1],eax
|
||||
mov ecx,NoTickWaitTime
|
||||
@@WaitHDReady_2:
|
||||
cmp [timer_ticks_enable],0
|
||||
jne @f
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Err1_4
|
||||
jmp .test
|
||||
cmp [timer_ticks_enable],0
|
||||
jne @f
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Err1_4
|
||||
jmp .test
|
||||
@@:
|
||||
call change_task
|
||||
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[TickCounter_1]
|
||||
cmp eax,BSYWaitTime ;300 ;îæèäàòü 3 ñåê.
|
||||
ja @@Err1_4 ;îøèáêà òàéì-àóòà
|
||||
; Ïðî÷èòàòü ðåãèñòð ñîñòîÿíèÿ
|
||||
call change_task
|
||||
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[TickCounter_1]
|
||||
cmp eax,BSYWaitTime ;300 ;îæèäàòü 3 ñåê.
|
||||
ja @@Err1_4 ;îøèáêà òàéì-àóòà
|
||||
; Ïðî÷èòàòü ðåãèñòð ñîñòîÿíèÿ
|
||||
.test:
|
||||
in AL,DX
|
||||
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà BSY
|
||||
test AL,80h
|
||||
jnz @@WaitHDReady_2
|
||||
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà DRQ
|
||||
test AL,08h
|
||||
jnz @@WaitHDReady_2
|
||||
in AL,DX
|
||||
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà BSY
|
||||
test AL,80h
|
||||
jnz @@WaitHDReady_2
|
||||
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà DRQ
|
||||
test AL,08h
|
||||
jnz @@WaitHDReady_2
|
||||
|
||||
; Загрузить команду в регистры контроллера
|
||||
cli
|
||||
mov DX,[ATABasePortAddr]
|
||||
inc DX ;ðåãèñòð "îñîáåííîñòåé"
|
||||
mov AL,[ATAFeatures]
|
||||
out DX,AL
|
||||
inc DX ;ñ÷åò÷èê ñåêòîðîâ
|
||||
mov AL,[ATASectorCount]
|
||||
out DX,AL
|
||||
inc DX ;ðåãèñòð íîìåðà ñåêòîðà
|
||||
mov AL,[ATASectorNumber]
|
||||
out DX,AL
|
||||
inc DX ;íîìåð öèëèíäðà (ìëàäøèé áàéò)
|
||||
mov AX,[ATACylinder]
|
||||
out DX,AL
|
||||
inc DX ;íîìåð öèëèíäðà (ñòàðøèé áàéò)
|
||||
mov AL,AH
|
||||
out DX,AL
|
||||
inc DX ;íîìåð ãîëîâêè/íîìåð äèñêà
|
||||
mov AL,[DiskNumber]
|
||||
shl AL,4
|
||||
cmp [ATAHead],0Fh ;ïðîâåðèòü íîìåð ãîëîâêè
|
||||
ja @@Err5_4
|
||||
or AL,[ATAHead]
|
||||
or AL,10100000b
|
||||
mov AH,[ATAAddressMode]
|
||||
shl AH,6
|
||||
or AL,AH
|
||||
out DX,AL
|
||||
cli
|
||||
mov DX,[ATABasePortAddr]
|
||||
inc DX ;ðåãèñòð "îñîáåííîñòåé"
|
||||
mov AL,[ATAFeatures]
|
||||
out DX,AL
|
||||
inc DX ;ñ÷åò÷èê ñåêòîðîâ
|
||||
mov AL,[ATASectorCount]
|
||||
out DX,AL
|
||||
inc DX ;ðåãèñòð íîìåðà ñåêòîðà
|
||||
mov AL,[ATASectorNumber]
|
||||
out DX,AL
|
||||
inc DX ;íîìåð öèëèíäðà (ìëàäøèé áàéò)
|
||||
mov AX,[ATACylinder]
|
||||
out DX,AL
|
||||
inc DX ;íîìåð öèëèíäðà (ñòàðøèé áàéò)
|
||||
mov AL,AH
|
||||
out DX,AL
|
||||
inc DX ;íîìåð ãîëîâêè/íîìåð äèñêà
|
||||
mov AL,[DiskNumber]
|
||||
shl AL,4
|
||||
cmp [ATAHead],0Fh ;ïðîâåðèòü íîìåð ãîëîâêè
|
||||
ja @@Err5_4
|
||||
or AL,[ATAHead]
|
||||
or AL,10100000b
|
||||
mov AH,[ATAAddressMode]
|
||||
shl AH,6
|
||||
or AL,AH
|
||||
out DX,AL
|
||||
; Послать команду
|
||||
mov AL,[ATACommand]
|
||||
inc DX ;ðåãèñòð êîìàíä
|
||||
out DX,AL
|
||||
sti
|
||||
mov AL,[ATACommand]
|
||||
inc DX ;ðåãèñòð êîìàíä
|
||||
out DX,AL
|
||||
sti
|
||||
; Сбросить признак ошибки
|
||||
mov [DevErrorCode],0
|
||||
jmp @@End_10
|
||||
mov [DevErrorCode],0
|
||||
jmp @@End_10
|
||||
; Записать код ошибки
|
||||
@@Err1_4:
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_10
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_10
|
||||
@@Err2_4:
|
||||
mov [DevErrorCode],2
|
||||
jmp @@End_10
|
||||
mov [DevErrorCode],2
|
||||
jmp @@End_10
|
||||
@@Err3_4:
|
||||
mov [DevErrorCode],3
|
||||
jmp @@End_10
|
||||
mov [DevErrorCode],3
|
||||
jmp @@End_10
|
||||
@@Err4_4:
|
||||
mov [DevErrorCode],4
|
||||
jmp @@End_10
|
||||
mov [DevErrorCode],4
|
||||
jmp @@End_10
|
||||
@@Err5_4:
|
||||
mov [DevErrorCode],5
|
||||
mov [DevErrorCode],5
|
||||
; Завершение работы программы
|
||||
@@End_10:
|
||||
; sti
|
||||
popad
|
||||
ret
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ОЖИДАНИЕ ГОТОВНОСТИ УСТРОЙСТВА К РАБОТЕ *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
@ -490,34 +553,73 @@ SendCommandToHDD_1:
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
WaitUnitReady:
|
||||
pusha
|
||||
pusha
|
||||
; Запомнить время начала операции
|
||||
mov EAX,[timer_ticks]
|
||||
mov [WURStartTime],EAX
|
||||
mov EAX,[timer_ticks]
|
||||
mov [WURStartTime],EAX
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
call clear_packet_buffer
|
||||
; Сформировать команду TEST UNIT READY
|
||||
mov [PacketCommand],word 00h
|
||||
mov [PacketCommand],word 00h
|
||||
; ЦИКЛ ОЖИДАНИЯ ГОТОВНОСТИ УСТРОЙСТВА
|
||||
@@SendCommand:
|
||||
; Ïîäàòü êîìàíäó ïðîâåðêè ãîòîâíîñòè
|
||||
call SendPacketNoDatCommand
|
||||
call change_task
|
||||
; Ïðîâåðèòü êîä îøèáêè
|
||||
cmp [DevErrorCode],0
|
||||
je @@End_11
|
||||
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ ãîòîâíîñòè
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[WURStartTime]
|
||||
cmp EAX,MaxCDWaitTime
|
||||
jb @@SendCommand
|
||||
; Îøèáêà òàéì-àóòà
|
||||
mov [DevErrorCode],1
|
||||
; Ïîäàòü êîìàíäó ïðîâåðêè ãîòîâíîñòè
|
||||
call SendPacketNoDatCommand
|
||||
call change_task
|
||||
; Ïðîâåðèòü êîä îøèáêè
|
||||
cmp [DevErrorCode],0
|
||||
je @@End_11
|
||||
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ ãîòîâíîñòè
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[WURStartTime]
|
||||
cmp EAX,MaxCDWaitTime
|
||||
jb @@SendCommand
|
||||
; Îøèáêà òàéì-àóòà
|
||||
mov [DevErrorCode],1
|
||||
@@End_11:
|
||||
popa
|
||||
ret
|
||||
popa
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ÇÀÏÐÅÒÈÒÜ ÑÌÅÍÓ ÄÈÑÊÀ *
|
||||
;* Âõîäíûå ïàðàìåòðû ïåðåäàþòñÿ ÷åðåç ãëîáàëüíûå *
|
||||
;* ïåðìåííûå: *
|
||||
;* ChannelNumber - íîìåð êàíàëà; *
|
||||
;* DiskNumber - íîìåð äèñêà íà êàíàëå. *
|
||||
;*************************************************
|
||||
prevent_medium_removal:
|
||||
pusha
|
||||
; Î÷èñòèòü áóôåð ïàêåòíîé êîìàíäû
|
||||
call clear_packet_buffer
|
||||
; Çàäàòü êîä êîìàíäû
|
||||
mov [PacketCommand],byte 0x1E
|
||||
; Çàäàòü êîä çàïðåòà
|
||||
mov [PacketCommand+4],byte 11b
|
||||
; Ïîäàòü êîìàíäó
|
||||
call SendPacketNoDatCommand
|
||||
popa
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ÐÀÇÐÅØÈÒÜ ÑÌÅÍÓ ÄÈÑÊÀ *
|
||||
;* Âõîäíûå ïàðàìåòðû ïåðåäàþòñÿ ÷åðåç ãëîáàëüíûå *
|
||||
;* ïåðìåííûå: *
|
||||
;* ChannelNumber - íîìåð êàíàëà; *
|
||||
;* DiskNumber - íîìåð äèñêà íà êàíàëå. *
|
||||
;*************************************************
|
||||
allow_medium_removal:
|
||||
pusha
|
||||
; Î÷èñòèòü áóôåð ïàêåòíîé êîìàíäû
|
||||
call clear_packet_buffer
|
||||
; Çàäàòü êîä êîìàíäû
|
||||
mov [PacketCommand],byte 0x1E
|
||||
; Çàäàòü êîä çàïðåòà
|
||||
mov [PacketCommand+4],byte 00b
|
||||
; Ïîäàòü êîìàíäó
|
||||
call SendPacketNoDatCommand
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
;*************************************************
|
||||
;* ЗАГРУЗИТЬ НОСИТЕЛЬ В ДИСКОВОД *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
@ -526,18 +628,18 @@ WaitUnitReady:
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
LoadMedium:
|
||||
pusha
|
||||
pusha
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
call clear_packet_buffer
|
||||
; Сформировать команду START/STOP UNIT
|
||||
; Çàäàòü êîä êîìàíäû
|
||||
mov [PacketCommand],word 1Bh
|
||||
; Çàäàòü îïåðàöèþ çàãðóçêè íîñèòåëÿ
|
||||
mov [PacketCommand+4],word 00000011b
|
||||
; Çàäàòü êîä êîìàíäû
|
||||
mov [PacketCommand],word 1Bh
|
||||
; Çàäàòü îïåðàöèþ çàãðóçêè íîñèòåëÿ
|
||||
mov [PacketCommand+4],word 00000011b
|
||||
; Подать команду
|
||||
call SendPacketNoDatCommand
|
||||
popa
|
||||
ret
|
||||
call SendPacketNoDatCommand
|
||||
popa
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ИЗВЛЕЧЬ НОСИТЕЛЬ ИЗ ДИСКОВОДА *
|
||||
@ -546,19 +648,19 @@ LoadMedium:
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
UnloadMedium:
|
||||
pusha
|
||||
EjectMedium:
|
||||
pusha
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
call clear_packet_buffer
|
||||
; Сформировать команду START/STOP UNIT
|
||||
; Çàäàòü êîä êîìàíäû
|
||||
mov [PacketCommand],word 1Bh
|
||||
; Çàäàòü îïåðàöèþ èçâëå÷åíèÿ íîñèòåëÿ
|
||||
mov [PacketCommand+4],word 00000010b
|
||||
; Çàäàòü êîä êîìàíäû
|
||||
mov [PacketCommand],word 1Bh
|
||||
; Çàäàòü îïåðàöèþ èçâëå÷åíèÿ íîñèòåëÿ
|
||||
mov [PacketCommand+4],word 00000010b
|
||||
; Подать команду
|
||||
call SendPacketNoDatCommand
|
||||
popa
|
||||
ret
|
||||
call SendPacketNoDatCommand
|
||||
popa
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ОПРЕДЕЛИТЬ ОБЩЕЕ КОЛИЧЕСТВО СЕКТОРОВ НА ДИСКЕ *
|
||||
@ -568,22 +670,22 @@ UnloadMedium:
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
ReadCapacity:
|
||||
pusha
|
||||
pusha
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
call clear_packet_buffer
|
||||
; Задать размер буфера в байтах
|
||||
mov [CDBlockSize],8
|
||||
mov [CDBlockSize],8
|
||||
; Сформировать команду READ CAPACITY
|
||||
mov [PacketCommand],word 25h
|
||||
mov [PacketCommand],word 25h
|
||||
; Подать команду
|
||||
call SendPacketDatCommand
|
||||
popa
|
||||
ret
|
||||
call SendPacketDatCommand
|
||||
popa
|
||||
ret
|
||||
|
||||
clear_packet_buffer:
|
||||
clear_packet_buffer:
|
||||
; Очистить буфер пакетной команды
|
||||
mov [PacketCommand],dword 0
|
||||
mov [PacketCommand+4],dword 0
|
||||
mov [PacketCommand+8],dword 0
|
||||
ret
|
||||
mov [PacketCommand],dword 0
|
||||
mov [PacketCommand+4],dword 0
|
||||
mov [PacketCommand+8],dword 0
|
||||
ret
|
||||
|
||||
|
@ -21,85 +21,73 @@ write_cache:
|
||||
push eax ecx edx esi edi
|
||||
|
||||
; write difference ( 2 ) from cache to hd
|
||||
|
||||
; mov ecx,cache_max
|
||||
; mov esi,HD_CACHE+8
|
||||
call calculate_cache
|
||||
add esi,8
|
||||
|
||||
mov edi,1
|
||||
|
||||
write_cache_more:
|
||||
|
||||
cmp dword [esi+4],2 ; if cache slot is not different
|
||||
write_cache_more:
|
||||
cmp dword [esi+4],2 ; if cache slot is not different
|
||||
jne .write_chain
|
||||
|
||||
mov dword [esi+4],1 ; same as in hd
|
||||
mov eax,[esi] ; eax = sector to write
|
||||
|
||||
mov dword [esi+4],1 ; same as in hd
|
||||
mov eax,[esi] ; eax = sector to write
|
||||
cmp eax,[PARTITION_START]
|
||||
jb danger
|
||||
jb danger
|
||||
cmp eax,[PARTITION_END]
|
||||
ja danger
|
||||
|
||||
ja danger
|
||||
; DMA write is permitted only if [allow_dma_access]=1
|
||||
cmp [allow_dma_access], 2
|
||||
jae .nodma
|
||||
cmp [dma_hdd], 1
|
||||
jnz .nodma
|
||||
cmp [allow_dma_access], 2
|
||||
jae .nodma
|
||||
cmp [dma_hdd], 1
|
||||
jnz .nodma
|
||||
; Ž¡ê¥¤¨ï¥¬ § ¯¨áì 楯®çª¨ ¯®á«¥¤®¢ ⥫ìëå ᥪâ®à®¢ ¢ ®¤® ®¡à 饨¥ ª ¤¨áªã
|
||||
cmp ecx, 1
|
||||
jz .nonext
|
||||
cmp dword [esi+8+4], 2
|
||||
jnz .nonext
|
||||
push eax
|
||||
inc eax
|
||||
cmp eax, [esi+8]
|
||||
pop eax
|
||||
jnz .nonext
|
||||
cmp [cache_chain_started], 1
|
||||
jz @f
|
||||
mov [cache_chain_started], 1
|
||||
mov [cache_chain_size], 0
|
||||
mov [cache_chain_pos], edi
|
||||
mov [cache_chain_ptr], esi
|
||||
cmp ecx, 1
|
||||
jz .nonext
|
||||
cmp dword [esi+8+4], 2
|
||||
jnz .nonext
|
||||
push eax
|
||||
inc eax
|
||||
cmp eax, [esi+8]
|
||||
pop eax
|
||||
jnz .nonext
|
||||
cmp [cache_chain_started], 1
|
||||
jz @f
|
||||
mov [cache_chain_started], 1
|
||||
mov [cache_chain_size], 0
|
||||
mov [cache_chain_pos], edi
|
||||
mov [cache_chain_ptr], esi
|
||||
@@:
|
||||
inc [cache_chain_size]
|
||||
cmp [cache_chain_size], 64
|
||||
jnz .continue
|
||||
jmp .write_chain
|
||||
inc [cache_chain_size]
|
||||
cmp [cache_chain_size], 64
|
||||
jnz .continue
|
||||
jmp .write_chain
|
||||
.nonext:
|
||||
call flush_cache_chain
|
||||
mov [cache_chain_size], 1
|
||||
mov [cache_chain_ptr], esi
|
||||
call write_cache_sector
|
||||
jmp .continue
|
||||
call flush_cache_chain
|
||||
mov [cache_chain_size], 1
|
||||
mov [cache_chain_ptr], esi
|
||||
call write_cache_sector
|
||||
jmp .continue
|
||||
.nodma:
|
||||
call cache_write_pio
|
||||
call cache_write_pio
|
||||
.write_chain:
|
||||
call flush_cache_chain
|
||||
|
||||
call flush_cache_chain
|
||||
.continue:
|
||||
danger:
|
||||
|
||||
danger:
|
||||
add esi,8
|
||||
inc edi
|
||||
dec ecx
|
||||
jnz write_cache_more
|
||||
call flush_cache_chain
|
||||
call flush_cache_chain
|
||||
return_02:
|
||||
pop edi esi edx ecx eax
|
||||
ret
|
||||
|
||||
flush_cache_chain:
|
||||
cmp [cache_chain_started], 0
|
||||
jz @f
|
||||
call write_cache_chain
|
||||
mov [cache_chain_started], 0
|
||||
cmp [cache_chain_started], 0
|
||||
jz @f
|
||||
call write_cache_chain
|
||||
mov [cache_chain_started], 0
|
||||
@@:
|
||||
ret
|
||||
|
||||
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
find_empty_slot:
|
||||
;-----------------------------------------------------------
|
||||
@ -108,68 +96,36 @@ find_empty_slot:
|
||||
;-----------------------------------------------------------
|
||||
; push ecx esi
|
||||
|
||||
search_again:
|
||||
|
||||
; mov ecx,cache_max*10/100
|
||||
; mov edi,[cache_search_start]
|
||||
search_again:
|
||||
call calculate_cache_3
|
||||
; push eax edx
|
||||
; mov eax,ecx
|
||||
; mov ecx,10
|
||||
; xor edx,edx
|
||||
; div ecx
|
||||
; mov ecx,eax
|
||||
; pop edx eax
|
||||
shr ecx,3
|
||||
search_for_empty:
|
||||
|
||||
shr ecx,3
|
||||
search_for_empty:
|
||||
inc edi
|
||||
; cmp edi,cache_max
|
||||
; push eax
|
||||
call calculate_cache_4
|
||||
; cmp edi,eax
|
||||
; pop eax
|
||||
jbe inside_cache
|
||||
mov edi,1
|
||||
|
||||
inside_cache:
|
||||
|
||||
; cmp dword [edi*8+HD_CACHE+4],2 ; get cache slot info
|
||||
inside_cache:
|
||||
push esi
|
||||
call calculate_cache_1
|
||||
cmp dword [edi*8+esi+4],2
|
||||
pop esi
|
||||
jb found_slot ; it's empty or read
|
||||
jb found_slot ; it's empty or read
|
||||
dec ecx
|
||||
jnz search_for_empty
|
||||
|
||||
call write_cache ; no empty slots found, write all
|
||||
call write_cache ; no empty slots found, write all
|
||||
cmp [hd_error],0
|
||||
jne found_slot_access_denied
|
||||
|
||||
jmp search_again ; and start again
|
||||
|
||||
found_slot:
|
||||
|
||||
; mov [cache_search_start],edi
|
||||
jmp search_again ; and start again
|
||||
found_slot:
|
||||
call calculate_cache_5
|
||||
found_slot_access_denied:
|
||||
found_slot_access_denied:
|
||||
ret
|
||||
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
clear_hd_cache:
|
||||
; push eax ecx edi
|
||||
; mov edi, HD_CACHE
|
||||
; mov ecx,16384
|
||||
; xor eax,eax
|
||||
; cld
|
||||
; rep stosd ; clear hd cache with 0
|
||||
; mov [cache_search_start],eax
|
||||
mov [fat_in_cache],-1
|
||||
mov [fat_change],0
|
||||
; pop edi ecx eax
|
||||
ret
|
||||
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
calculate_cache:
|
||||
@ -207,7 +163,7 @@ calculate_cache:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
mov ecx,[cache_ide2_system_sad_size]
|
||||
mov esi,[cache_ide2_pointer]
|
||||
mov esi,[cache_ide2_pointer]
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
mov ecx,[cache_ide2_appl_sad_size]
|
||||
@ -217,7 +173,7 @@ calculate_cache:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov ecx,[cache_ide3_system_sad_size]
|
||||
mov esi,[cache_ide3_pointer]
|
||||
mov esi,[cache_ide3_pointer]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov ecx,[cache_ide3_appl_sad_size]
|
||||
@ -261,7 +217,7 @@ calculate_cache_1:
|
||||
.ide3:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov esi,[cache_ide3_pointer]
|
||||
mov esi,[cache_ide3_pointer]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov esi,[cache_ide3_data_pointer]
|
||||
@ -276,7 +232,7 @@ calculate_cache_2:
|
||||
jne .ide1
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov eax,[cache_ide0_system_data]
|
||||
mov eax,[cache_ide0_system_data]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov eax,[cache_ide0_appl_data]
|
||||
@ -304,7 +260,7 @@ calculate_cache_2:
|
||||
.ide3:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov eax,[cache_ide3_system_data]
|
||||
mov eax,[cache_ide3_system_data]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov eax,[cache_ide3_appl_data]
|
||||
@ -346,7 +302,7 @@ calculate_cache_3:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
mov ecx,[cache_ide2_system_sad_size]
|
||||
mov edi,[cache_ide2_search_start]
|
||||
mov edi,[cache_ide2_search_start]
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
mov ecx,[cache_ide2_appl_sad_size]
|
||||
@ -356,7 +312,7 @@ calculate_cache_3:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov ecx,[cache_ide3_system_sad_size]
|
||||
mov edi,[cache_ide3_search_start]
|
||||
mov edi,[cache_ide3_search_start]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov ecx,[cache_ide3_appl_sad_size]
|
||||
@ -415,7 +371,7 @@ calculate_cache_5:
|
||||
jne .ide1
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov [cache_ide0_search_start],edi
|
||||
mov [cache_ide0_search_start],edi
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov [cache_ide0_appl_search_start],edi
|
||||
@ -443,15 +399,357 @@ calculate_cache_5:
|
||||
.ide3:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov [cache_ide3_search_start],edi
|
||||
mov [cache_ide3_search_start],edi
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov [cache_ide3_appl_search_start],edi
|
||||
ret
|
||||
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
find_empty_slot_CD_cache:
|
||||
;-----------------------------------------------------------
|
||||
; find empty or read slot, flush cache if next 10% is used by write
|
||||
; output : edi = cache slot
|
||||
;-----------------------------------------------------------
|
||||
.search_again:
|
||||
call cd_calculate_cache_3
|
||||
.search_for_empty:
|
||||
inc edi
|
||||
call cd_calculate_cache_4
|
||||
jbe .inside_cache
|
||||
mov edi,1
|
||||
.inside_cache:
|
||||
call cd_calculate_cache_5
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
clear_CD_cache:
|
||||
pusha
|
||||
.ide0:
|
||||
xor eax,eax
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
mov [cache_ide0_search_start],eax
|
||||
mov ecx,[cache_ide0_system_sad_size]
|
||||
mov edi,[cache_ide0_pointer]
|
||||
call .clear
|
||||
mov [cache_ide0_appl_search_start],eax
|
||||
mov ecx,[cache_ide0_appl_sad_size]
|
||||
mov edi,[cache_ide0_data_pointer]
|
||||
jmp .continue
|
||||
.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
|
||||
popa
|
||||
ret
|
||||
.clear:
|
||||
shl ecx,1
|
||||
cld
|
||||
rep stosd
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache:
|
||||
; mov ecx,cache_max ; entries in cache
|
||||
; mov esi,HD_CACHE+8
|
||||
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov ecx,[cache_ide0_system_sad_size]
|
||||
mov esi,[cache_ide0_pointer]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov ecx,[cache_ide0_appl_sad_size]
|
||||
mov esi,[cache_ide0_data_pointer]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [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
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_1:
|
||||
; lea esi,[edi*8+HD_CACHE]
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov esi,[cache_ide0_pointer]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov esi,[cache_ide0_data_pointer]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [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
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_2:
|
||||
; add esi,HD_CACHE+65536
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov eax,[cache_ide0_system_data]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov eax,[cache_ide0_appl_data]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [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
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_3:
|
||||
; mov ecx,cache_max*10/100
|
||||
; mov edi,[cache_search_start]
|
||||
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov edi,[cache_ide0_search_start]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov edi,[cache_ide0_appl_search_start]
|
||||
ret
|
||||
.ide1:
|
||||
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
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_4:
|
||||
; cmp edi,cache_max
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
cmp edi,[cache_ide0_system_sad_size]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
cmp edi,[cache_ide0_appl_sad_size]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [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
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_5:
|
||||
; mov [cache_search_start],edi
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov [cache_ide0_search_start],edi
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov [cache_ide0_appl_search_start],edi
|
||||
ret
|
||||
.ide1:
|
||||
cmp [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
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
calculate_linear_to_real:
|
||||
shr eax, 12
|
||||
mov eax, [page_tabs+eax*4]
|
||||
and eax, 0xFFFFF000
|
||||
ret
|
||||
;align 4
|
||||
;calculate_linear_to_real:
|
||||
; shr eax, 12
|
||||
; mov eax, [page_tabs+eax*4]
|
||||
; and eax, 0xFFFFF000
|
||||
; ret
|
||||
|
@ -306,6 +306,7 @@ hdbase rd 1 ; for boot 0x1f0
|
||||
hdid rd 1
|
||||
hdpos rd 1 ; for boot 0x1
|
||||
fat32part rd 1 ; for boot 0x1
|
||||
cdpos rd 1
|
||||
|
||||
sb16 rd 1
|
||||
|
||||
@ -387,6 +388,7 @@ cache_ide3_appl_search_start rd 1
|
||||
|
||||
debug_step_pointer rd 1
|
||||
hdd_appl_data rb 1 ; 0 = system cache, 1 - application cache
|
||||
cd_appl_data rb 1 ; 0 = system cache, 1 - application cache
|
||||
|
||||
lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled
|
||||
pci_access_enabled rd 1 ; 0 = disabled , 1 = enabled
|
||||
|
@ -18,13 +18,13 @@
|
||||
shl eax,3
|
||||
; translate pages in butes *4096
|
||||
shl eax,12
|
||||
; check a upper size of the cache, no more than 1 Mb on the physical device
|
||||
; check a upper size of the cache, no more than 1 Mb on the physical device
|
||||
cmp eax,1024*1024
|
||||
jbe @f
|
||||
mov eax,1024*1024
|
||||
jmp .continue
|
||||
@@:
|
||||
; check a lower size of the cache, not less than 128 Kb on the physical device
|
||||
; check a lower size of the cache, not less than 128 Kb on the physical device
|
||||
cmp eax,128*1024
|
||||
jae @f
|
||||
mov eax,128*1024
|
||||
@ -44,30 +44,31 @@
|
||||
mov [cache_ide3_search_start],eax
|
||||
mov [cache_ide3_appl_search_start],eax
|
||||
mov [hdd_appl_data],1 ;al
|
||||
mov [cd_appl_data],1
|
||||
|
||||
mov cl,[DRIVE_DATA+1]
|
||||
mov ch,cl
|
||||
and cl,11b
|
||||
cmp cl,0
|
||||
je .ide2
|
||||
je .ide2
|
||||
call get_cache_ide3
|
||||
.ide2:
|
||||
mov cl,ch
|
||||
and cl,1100b
|
||||
cmp cl,0
|
||||
je .ide1
|
||||
je .ide1
|
||||
call get_cache_ide2
|
||||
.ide1:
|
||||
mov cl,ch
|
||||
and cl,110000b
|
||||
cmp cl,0
|
||||
je .ide0
|
||||
je .ide0
|
||||
call get_cache_ide1
|
||||
.ide0:
|
||||
mov cl,ch
|
||||
and cl,11000000b
|
||||
cmp cl,0
|
||||
je end_get_cache
|
||||
je end_get_cache
|
||||
call get_cache_ide0
|
||||
jmp end_get_cache
|
||||
|
||||
@ -85,21 +86,21 @@ get_cache_ide0:
|
||||
mov [cache_ide0_appl_data_size],eax
|
||||
add ebx,edx
|
||||
mov [cache_ide0_data_pointer],ebx
|
||||
|
||||
|
||||
cmp cl,10000000b
|
||||
je .cd
|
||||
je .cd
|
||||
push ecx
|
||||
mov eax,[cache_ide0_system_data_size]
|
||||
call calculate_for_hd
|
||||
add eax,[cache_ide0_pointer]
|
||||
mov [cache_ide0_system_data],eax
|
||||
mov [cache_ide0_system_sad_size],ecx
|
||||
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide0_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
|
||||
mov eax,[cache_ide0_appl_data_size]
|
||||
call calculate_for_hd
|
||||
add eax,[cache_ide0_data_pointer]
|
||||
@ -110,7 +111,7 @@ get_cache_ide0:
|
||||
mov edi,[cache_ide0_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
.cd:
|
||||
@ -125,21 +126,21 @@ get_cache_ide0:
|
||||
mov edi,[cache_ide0_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
|
||||
mov eax,[cache_ide0_appl_data_size]
|
||||
call calculate_for_cd
|
||||
add eax,[cache_ide0_data_pointer]
|
||||
mov [cache_ide0_appl_data],eax
|
||||
mov [cache_ide0_appl_sad_size],ecx
|
||||
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide0_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
|
||||
get_cache_ide1:
|
||||
push ecx
|
||||
stdcall kernel_alloc,[cache_ide1_size]
|
||||
@ -154,9 +155,9 @@ get_cache_ide1:
|
||||
mov [cache_ide1_appl_data_size],eax
|
||||
add ebx,edx
|
||||
mov [cache_ide1_data_pointer],ebx
|
||||
|
||||
|
||||
cmp cl,100000b
|
||||
je .cd
|
||||
je .cd
|
||||
push ecx
|
||||
mov eax,[cache_ide1_system_data_size]
|
||||
call calculate_for_hd
|
||||
@ -174,12 +175,12 @@ get_cache_ide1:
|
||||
add eax,[cache_ide1_data_pointer]
|
||||
mov [cache_ide1_appl_data],eax
|
||||
mov [cache_ide1_appl_sad_size],ecx
|
||||
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide1_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
.cd:
|
||||
@ -200,12 +201,12 @@ get_cache_ide1:
|
||||
add eax,[cache_ide1_data_pointer]
|
||||
mov [cache_ide1_appl_data],eax
|
||||
mov [cache_ide1_appl_sad_size],ecx
|
||||
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide1_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
@ -223,9 +224,9 @@ get_cache_ide2:
|
||||
mov [cache_ide2_appl_data_size],eax
|
||||
add ebx,edx
|
||||
mov [cache_ide2_data_pointer],ebx
|
||||
|
||||
|
||||
cmp cl,1000b
|
||||
je .cd
|
||||
je .cd
|
||||
push ecx
|
||||
mov eax,[cache_ide2_system_data_size]
|
||||
call calculate_for_hd
|
||||
@ -243,12 +244,12 @@ get_cache_ide2:
|
||||
add eax,[cache_ide2_data_pointer]
|
||||
mov [cache_ide2_appl_data],eax
|
||||
mov [cache_ide2_appl_sad_size],ecx
|
||||
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide2_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
.cd:
|
||||
@ -269,12 +270,12 @@ get_cache_ide2:
|
||||
add eax,[cache_ide2_data_pointer]
|
||||
mov [cache_ide2_appl_data],eax
|
||||
mov [cache_ide2_appl_sad_size],ecx
|
||||
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide2_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
@ -292,9 +293,9 @@ get_cache_ide3:
|
||||
mov [cache_ide3_appl_data_size],eax
|
||||
add ebx,edx
|
||||
mov [cache_ide3_data_pointer],ebx
|
||||
|
||||
|
||||
cmp cl,10b
|
||||
je .cd
|
||||
je .cd
|
||||
push ecx
|
||||
mov eax,[cache_ide3_system_data_size]
|
||||
call calculate_for_hd
|
||||
@ -312,12 +313,12 @@ get_cache_ide3:
|
||||
add eax,[cache_ide3_data_pointer]
|
||||
mov [cache_ide3_appl_data],eax
|
||||
mov [cache_ide3_appl_sad_size],ecx
|
||||
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide3_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
.cd:
|
||||
@ -338,12 +339,12 @@ get_cache_ide3:
|
||||
add eax,[cache_ide3_data_pointer]
|
||||
mov [cache_ide3_appl_data],eax
|
||||
mov [cache_ide3_appl_sad_size],ecx
|
||||
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide3_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
@ -374,7 +375,7 @@ calculate_for_cd:
|
||||
sub eax,ebx
|
||||
dec ecx
|
||||
ret
|
||||
|
||||
|
||||
clear_ide_cache:
|
||||
push eax
|
||||
shl ecx,1
|
||||
@ -383,7 +384,7 @@ clear_ide_cache:
|
||||
rep stosd
|
||||
pop eax
|
||||
ret
|
||||
|
||||
|
||||
end_get_cache:
|
||||
; mov [cache_ide0_pointer],HD_CACHE
|
||||
; mov [cache_ide0_system_data],HD_CACHE+65536
|
||||
|
@ -4114,6 +4114,10 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
|
||||
„«ο CD-―ΰ¨Ά®¤®Ά Ά αΆο§¨ α ―― ΰ β묨 ®£ΰ ¨η¥¨ο¬¨ ¤®αβγ―λ
|
||||
β®«μ<EFBFBD>® ―®¤δγ<CEB3>樨 0,1,5 ¨ 7, Άλ§®Ά ¤ΰγ£¨ε ―®¤δγ<CEB3>権 § Ά¥ΰθ¨βαο
|
||||
®θ¨΅<EFBFBD>®© α <20>®¤®¬ 2.
|
||||
<EFBFBD>ਠ¯¥à¢®¬ ®¡à 饨¨ ¯®¤äãªæ¨© 0,1,5,7 ª ãáâனá⢠¬ ATAPI (CD ¨ DVD)
|
||||
¯à®¨§¢®¤¨âáï ¡«®ª¨à®¢ª àã箣® ã¯à ¢«¥¨ï ¬¥å ¨§¬®¬ «®âª . <20>â® á¢ï§ ®
|
||||
á «£®à¨â¬®¬ ªíè¨à®¢ ¨ï ¤ ëå ¯®«ãç¥ëå ®â ¯à¨¢®¤ . <20> §¡«®ª¨à®¢ª
|
||||
¯à®¨§¢®¤¨âáï ®¡à 饨¥¬ ¯®¤äãªæ¨¥© 10 ª ᮮ⢥âáâ¢ãî饬ã ãáâனáâ¢ã.
|
||||
|
||||
======================================================================
|
||||
= ”γ<CEB3>ζ¨ο 70, ―®¤δγ<CEB3>ζ¨ο 0 - η⥨¥ δ ©« α ―®¤¤¥ΰ¦<CEB0>®© ¤«¨λε ¨¬ρ. =
|
||||
@ -4473,6 +4477,66 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
|
||||
* <20>®¤¨β¥«μα<CEBC> ο ― ―<C2A0> ¤®«¦ 㦥 αγι¥αβΆ®Ά βμ.
|
||||
* …᫨ ― ―<C2A0> 㦥 αγι¥αβΆγ¥β, δγ<CEB3>ζ¨ο § Ά¥ΰθ¨βαο γα―¥θ® (eax=0).
|
||||
|
||||
======================================================================
|
||||
========== ”ãªæ¨ï 70, ¯®¤äãªæ¨ï 10 - ¨§¢«¥çì «®â®ª ¯à¨¢®¤ ¤¨áª . ============
|
||||
======================================================================
|
||||
<EFBFBD> à ¬¥âàë:
|
||||
* eax = 70 - ®¬¥à äãªæ¨¨
|
||||
* ebx = 㪠§ â¥«ì ¨ä®à¬ 樮ãî áâàãªâãàã
|
||||
”®à¬ â ¨ä®à¬ 樮®© áâàãªâãàë:
|
||||
* +0: dword: 10 = ®¬¥à ¯®¤äãªæ¨¨
|
||||
* +4: dword: 0 (§ १¥à¢¨à®¢ ®)
|
||||
* +8: dword: 0 (§ १¥à¢¨à®¢ ®)
|
||||
* +12 = +0xC: dword: 0 (§ १¥à¢¨à®¢ ®)
|
||||
* +16 = +0x10: dword: 0 (§ १¥à¢¨à®¢ ®)
|
||||
* +20 = +0x14: ASCIIZ-¨¬ï ¯ ¯ª¨, ¯à ¢¨« ä®à¬¨à®¢ ¨ï ¨¬ñ 㪠§ ë ¢
|
||||
®¡é¥¬ ®¯¨á ¨¨
|
||||
¨«¨
|
||||
* +20 = +0x14: db 0
|
||||
* +21 = +0x15: dd 㪠§ ⥫ì ASCIIZ-áâபã á ¨¬¥¥¬ ¯ ¯ª¨
|
||||
‚®§¢à é ¥¬®¥ § 票¥:
|
||||
* <20>¨ç¥£® ¥ ¢®§¢à é ¥âáï.
|
||||
‡ ¬¥ç ¨ï:
|
||||
* ”ãªæ¨ï ¯®¤¤¥à¦¨¢ ¥âáï ⮫쪮 ¤«ï ATAPI ãáâனá⢠(CD ¨ DVD).
|
||||
* <20>ਠ¨§¢«¥ç¥¨¨ «®âª ¯à®¨§¢®¤¨âáï à §¡«®ª¨à®¢ª àã箣® ã¯à ¢«¥¨ï ¬¥å ¨§¬®¬ «®âª .
|
||||
* <20>ਠ¨§¢«¥ç¥¨¨ «®âª ª®¤ ¯à®¨§¢®¤¨â ®ç¨áâªã ªíè ᮮ⢥âáâ¢ãî饣® ãáâனá⢠.
|
||||
* <20>ãâì ¢¢®¤¨âáï ¢ áâ ¤ à⮬ ¤«ï 70 äãªæ¨¨ ¢¨¤¥. „«ï à ¡®â®á¯®á®¡®á⨠¬®¦®
|
||||
®£à ¨ç¨âìáï ¯ãâﬨ ¢¨¤ :
|
||||
db '/cd0/1/',0
|
||||
db '/cd1/1/',0
|
||||
db '/cd2/1/',0
|
||||
db '/cd3/1/',0
|
||||
* <20>ਬ¥à®¬ ¨á¯®«ì§®¢ ¨ï äãªæ¨¨ ï¥âáï ¯à¨«®¦¥¨¥ CD_tray.
|
||||
|
||||
======================================================================
|
||||
========== ”ãªæ¨ï 70, ¯®¤äãªæ¨ï 11 - § £à㧨âì «®â®ª ¯à¨¢®¤ ¤¨áª . ===========
|
||||
======================================================================
|
||||
<EFBFBD> à ¬¥âàë:
|
||||
* eax = 70 - ®¬¥à äãªæ¨¨
|
||||
* ebx = 㪠§ â¥«ì ¨ä®à¬ 樮ãî áâàãªâãàã
|
||||
”®à¬ â ¨ä®à¬ 樮®© áâàãªâãàë:
|
||||
* +0: dword: 11 = ®¬¥à ¯®¤äãªæ¨¨
|
||||
* +4: dword: 0 (§ १¥à¢¨à®¢ ®)
|
||||
* +8: dword: 0 (§ १¥à¢¨à®¢ ®)
|
||||
* +12 = +0xC: dword: 0 (§ १¥à¢¨à®¢ ®)
|
||||
* +16 = +0x10: dword: 0 (§ १¥à¢¨à®¢ ®)
|
||||
* +20 = +0x14: ASCIIZ-¨¬ï ¯ ¯ª¨, ¯à ¢¨« ä®à¬¨à®¢ ¨ï ¨¬ñ 㪠§ ë ¢
|
||||
®¡é¥¬ ®¯¨á ¨¨
|
||||
¨«¨
|
||||
* +20 = +0x14: db 0
|
||||
* +21 = +0x15: dd 㪠§ ⥫ì ASCIIZ-áâபã á ¨¬¥¥¬ ¯ ¯ª¨
|
||||
‚®§¢à é ¥¬®¥ § 票¥:
|
||||
* <20>¨ç¥£® ¥ ¢®§¢à é ¥âáï.
|
||||
‡ ¬¥ç ¨ï:
|
||||
* ”ãªæ¨ï ¯®¤¤¥à¦¨¢ ¥âáï ⮫쪮 ¤«ï ATAPI ãáâனá⢠(CD ¨ DVD)
|
||||
* <20>ãâì ¢¢®¤¨âáï ¢ áâ ¤ à⮬ ¤«ï 70 äãªæ¨¨ ¢¨¤¥. „«ï à ¡®â®á¯®á®¡®á⨠¬®¦®
|
||||
®£à ¨ç¨âìáï ¯ãâﬨ ¢¨¤ :
|
||||
db '/cd0/1/',0
|
||||
db '/cd1/1/',0
|
||||
db '/cd2/1/',0
|
||||
db '/cd3/1/',0
|
||||
* <20>ਬ¥à®¬ ¨á¯®«ì§®¢ ¨ï äãªæ¨¨ ï¥âáï ¯à¨«®¦¥¨¥ CD_tray.
|
||||
|
||||
======================================================================
|
||||
=== ”γ<CEB3>ζ¨ο 71, ―®¤δγ<CEB3>ζ¨ο 1 - γαβ ®Ά¨βμ § £®«®Ά®<CE86> ®<> ―ΰ®£ΰ ¬¬λ. ==
|
||||
======================================================================
|
||||
|
@ -4075,6 +4075,10 @@ Available subfunctions:
|
||||
For CD-drives due to hardware limitations only subfunctions
|
||||
0,1,5 and 7 are available, other subfunctions return error
|
||||
with code 2.
|
||||
At the first call subfunctions 0,1,5,7 to devices ATAPI (CD and DVD) the locking
|
||||
of handle mechanism of a tray is made. It is connected to algorithm of caching
|
||||
given obtained from a drive. Deblocking is made by call subfunction 10
|
||||
to the appropriate device.
|
||||
|
||||
======================================================================
|
||||
=== Function 70, subfunction 0 - read file with long names support. ==
|
||||
@ -4429,6 +4433,64 @@ Remarks:
|
||||
* The parent folder must already exist.
|
||||
* If target folder already exists, function returns success (eax=0).
|
||||
|
||||
======================================================================
|
||||
================ Function 70, subfunction 10 - eject tray of disk drive. ==============
|
||||
======================================================================
|
||||
Parameters:
|
||||
* eax = 70 - function number
|
||||
* ebx = pointer to the information structure
|
||||
Format of the information structure:
|
||||
* +0: dword: 10 = subfunction number
|
||||
* +4: dword: 0 (reserved)
|
||||
* +8: dword: 0 (reserved)
|
||||
* +12 = +0xC: dword: 0 (reserved)
|
||||
* +16 = +0x10: dword: 0 (reserved)
|
||||
* +20 = +0x14: ASCIIZ-name of folder, the rules of names forming are
|
||||
given in the general description
|
||||
or
|
||||
* +20 = +0x14: db 0
|
||||
* +21 = +0x15: dd pointer to ASCIIZ-string with folder name
|
||||
Returned value:
|
||||
* Nothing comes back.
|
||||
Remarks:
|
||||
* The function is supported only for ATAPI devices (CD and DVD).
|
||||
* At extract of a tray is made deblocking of handle mechanism of a tray.
|
||||
* At extract of a tray the code makes clearing the cache of the appropriate device.
|
||||
* The path is standard for 70 functions. For serviceability it is possible to be limited to paths:
|
||||
db '/cd0/1/',0
|
||||
db '/cd1/1/',0
|
||||
db '/cd2/1/',0
|
||||
db '/cd3/1/',0
|
||||
* An example of usage of the function is the application CD_tray.
|
||||
|
||||
======================================================================
|
||||
============== Function 70, subfunction 11 - load tray of disk drive. =================
|
||||
======================================================================
|
||||
Parameters:
|
||||
* eax = 70 - function number
|
||||
* ebx = pointer to the information structure
|
||||
Format of the information structure:
|
||||
* +0: dword: 11 = subfunction number
|
||||
* +4: dword: 0 (reserved)
|
||||
* +8: dword: 0 (reserved)
|
||||
* +12 = +0xC: dword: 0 (reserved)
|
||||
* +16 = +0x10: dword: 0 (reserved)
|
||||
* +20 = +0x14: ASCIIZ-name of folder, the rules of names forming are
|
||||
given in the general description
|
||||
or
|
||||
* +20 = +0x14: db 0
|
||||
* +21 = +0x15: dd pointer to ASCIIZ-string with folder name
|
||||
Returned value:
|
||||
* Nothing comes back.
|
||||
Remarks:
|
||||
* The function is supported only for ATAPI devices (CD and DVD).
|
||||
* The path is standard for 70 functions. For serviceability it is possible to be limited to paths:
|
||||
db '/cd0/1/',0
|
||||
db '/cd1/1/',0
|
||||
db '/cd2/1/',0
|
||||
db '/cd3/1/',0
|
||||
* An example of usage of the function is the application CD_tray.
|
||||
|
||||
======================================================================
|
||||
========== Function 71, subfunction 1 - set window caption. ==========
|
||||
======================================================================
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,17 +9,17 @@ $Revision$
|
||||
uglobal
|
||||
cd_current_pointer_of_input dd 0
|
||||
cd_current_pointer_of_input_2 dd 0
|
||||
cd_mem_location dd 0
|
||||
cd_counter_block dd 0
|
||||
IDE_Channel_1 db 0
|
||||
IDE_Channel_2 db 0
|
||||
cd_mem_location dd 0
|
||||
cd_counter_block dd 0
|
||||
IDE_Channel_1 db 0
|
||||
IDE_Channel_2 db 0
|
||||
endg
|
||||
|
||||
reserve_cd:
|
||||
|
||||
cli
|
||||
cmp [cd_status],0
|
||||
je reserve_ok2
|
||||
je reserve_ok2
|
||||
|
||||
sti
|
||||
call change_task
|
||||
@ -42,14 +42,14 @@ reserve_cd_channel:
|
||||
.IDE_Channel_1:
|
||||
cli
|
||||
cmp [IDE_Channel_1],0
|
||||
je .reserve_ok_1
|
||||
je .reserve_ok_1
|
||||
sti
|
||||
call change_task
|
||||
jmp .IDE_Channel_1
|
||||
.IDE_Channel_2:
|
||||
cli
|
||||
cmp [IDE_Channel_2],0
|
||||
je .reserve_ok_2
|
||||
je .reserve_ok_2
|
||||
sti
|
||||
call change_task
|
||||
jmp .IDE_Channel_1
|
||||
@ -95,7 +95,7 @@ fs_CdRead:
|
||||
.noaccess:
|
||||
pop edi
|
||||
.noaccess_2:
|
||||
or ebx, -1
|
||||
or ebx, -1
|
||||
mov eax, ERROR_ACCESS_DENIED
|
||||
ret
|
||||
|
||||
@ -109,19 +109,19 @@ fs_CdRead:
|
||||
pop edi
|
||||
cmp [DevErrorCode],0
|
||||
jne .noaccess_2
|
||||
or ebx, -1
|
||||
or ebx, -1
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
|
||||
.found:
|
||||
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
|
||||
test ebx, ebx
|
||||
jz .l1
|
||||
jz .l1
|
||||
cmp dword [ebx+4], 0
|
||||
jz @f
|
||||
xor ebx, ebx
|
||||
jz @f
|
||||
xor ebx, ebx
|
||||
.reteof:
|
||||
mov eax, 6 ; end of file
|
||||
pop edi
|
||||
@ -129,31 +129,31 @@ fs_CdRead:
|
||||
@@:
|
||||
mov ebx, [ebx]
|
||||
.l1:
|
||||
push ecx edx
|
||||
push 0
|
||||
mov eax, [edi+10] ; ðåàëüíûé ðàçìåð ôàéëîâîé ñåêöèè
|
||||
sub eax, ebx
|
||||
jb .eof
|
||||
cmp eax, ecx
|
||||
jae @f
|
||||
mov ecx, eax
|
||||
mov byte [esp], 6
|
||||
push ecx edx
|
||||
push 0
|
||||
mov eax, [edi+10] ; ðåàëüíûé ðàçìåð ôàéëîâîé ñåêöèè
|
||||
sub eax, ebx
|
||||
jb .eof
|
||||
cmp eax, ecx
|
||||
jae @f
|
||||
mov ecx, eax
|
||||
mov byte [esp], 6
|
||||
@@:
|
||||
mov eax,[edi+2]
|
||||
mov [CDSectorAddress],eax
|
||||
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
|
||||
.new_sector:
|
||||
test ecx, ecx
|
||||
jz .done
|
||||
jz .done
|
||||
sub ebx, 2048
|
||||
jae .next
|
||||
add ebx, 2048
|
||||
jnz .incomplete_sector
|
||||
cmp ecx, 2048
|
||||
jb .incomplete_sector
|
||||
jb .incomplete_sector
|
||||
; we may read and memmove complete sector
|
||||
mov [CDDataBuf_pointer],edx
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð ôàéëà
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð ôàéëà
|
||||
cmp [DevErrorCode],0
|
||||
jne .noaccess_3
|
||||
add edx, 2048
|
||||
@ -164,7 +164,7 @@ fs_CdRead:
|
||||
.incomplete_sector:
|
||||
; we must read and memmove incomplete sector
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð ôàéëà
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð ôàéëà
|
||||
cmp [DevErrorCode],0
|
||||
jne .noaccess_3
|
||||
push ecx
|
||||
@ -176,7 +176,7 @@ fs_CdRead:
|
||||
sub ecx, ebx
|
||||
push edi esi ecx
|
||||
mov edi,edx
|
||||
lea esi, [CDDataBuf + ebx]
|
||||
lea esi, [CDDataBuf + ebx]
|
||||
cld
|
||||
rep movsb
|
||||
pop ecx esi edi
|
||||
@ -187,15 +187,15 @@ fs_CdRead:
|
||||
jmp .next
|
||||
|
||||
.done:
|
||||
mov ebx, edx
|
||||
pop eax edx ecx edi
|
||||
sub ebx, edx
|
||||
ret
|
||||
mov ebx, edx
|
||||
pop eax edx ecx edi
|
||||
sub ebx, edx
|
||||
ret
|
||||
.eof:
|
||||
mov ebx, edx
|
||||
pop eax edx ecx
|
||||
sub ebx, edx
|
||||
jmp .reteof
|
||||
mov ebx, edx
|
||||
pop eax edx ecx
|
||||
sub ebx, edx
|
||||
jmp .reteof
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;
|
||||
@ -213,79 +213,79 @@ fs_CdRead:
|
||||
;
|
||||
;--------------------------------------------------------------
|
||||
fs_CdReadFolder:
|
||||
push edi
|
||||
call cd_find_lfn
|
||||
jnc .found
|
||||
pop edi
|
||||
cmp [DevErrorCode], 0
|
||||
jne .noaccess_1
|
||||
or ebx, -1
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
push edi
|
||||
call cd_find_lfn
|
||||
jnc .found
|
||||
pop edi
|
||||
cmp [DevErrorCode], 0
|
||||
jne .noaccess_1
|
||||
or ebx, -1
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
.found:
|
||||
mov edi, [cd_current_pointer_of_input]
|
||||
test byte [edi+25], 10b ; do not allow read directories
|
||||
jnz .found_dir
|
||||
pop edi
|
||||
mov edi, [cd_current_pointer_of_input]
|
||||
test byte [edi+25], 10b ; do not allow read directories
|
||||
jnz .found_dir
|
||||
pop edi
|
||||
.noaccess_1:
|
||||
or ebx, -1
|
||||
mov eax, ERROR_ACCESS_DENIED
|
||||
ret
|
||||
or ebx, -1
|
||||
mov eax, ERROR_ACCESS_DENIED
|
||||
ret
|
||||
.found_dir:
|
||||
mov eax, [edi+2] ; eax=cluster
|
||||
mov [CDSectorAddress], eax
|
||||
mov eax, [edi+10] ; ðàçìåð äèðåêòðîðèè
|
||||
mov eax, [edi+2] ; eax=cluster
|
||||
mov [CDSectorAddress], eax
|
||||
mov eax, [edi+10] ; ðàçìåð äèðåêòðîðèè
|
||||
.doit:
|
||||
; init header
|
||||
push eax ecx
|
||||
mov edi, edx
|
||||
mov ecx, 32/4
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
pop ecx eax
|
||||
mov byte [edx], 1 ; version
|
||||
mov [cd_mem_location], edx
|
||||
add [cd_mem_location], 32
|
||||
push eax ecx
|
||||
mov edi, edx
|
||||
mov ecx, 32/4
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
pop ecx eax
|
||||
mov byte [edx], 1 ; version
|
||||
mov [cd_mem_location], edx
|
||||
add [cd_mem_location], 32
|
||||
; íà÷èíàåì ïåðåáðîñêó ÁÄÂÊ â ÓÑÂÊ
|
||||
;.mainloop:
|
||||
mov [cd_counter_block], dword 0
|
||||
dec dword [CDSectorAddress]
|
||||
push ecx
|
||||
mov [cd_counter_block], dword 0
|
||||
dec dword [CDSectorAddress]
|
||||
push ecx
|
||||
.read_to_buffer:
|
||||
inc dword [CDSectorAddress]
|
||||
mov [CDDataBuf_pointer], CDDataBuf
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð äèðåêòîðèè
|
||||
cmp [DevErrorCode], 0
|
||||
jne .noaccess_1
|
||||
call .get_names_from_buffer
|
||||
sub eax,2048
|
||||
inc dword [CDSectorAddress]
|
||||
mov [CDDataBuf_pointer], CDDataBuf
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð äèðåêòîðèè
|
||||
cmp [DevErrorCode], 0
|
||||
jne .noaccess_1
|
||||
call .get_names_from_buffer
|
||||
sub eax,2048
|
||||
; äèðåêòîðèÿ çàêîí÷èëàñü?
|
||||
ja .read_to_buffer
|
||||
mov edi, [cd_counter_block]
|
||||
mov [edx+8], edi
|
||||
mov edi, [ebx]
|
||||
sub [edx+4], edi
|
||||
xor eax, eax
|
||||
dec ecx
|
||||
js @f
|
||||
mov al, ERROR_END_OF_FILE
|
||||
ja .read_to_buffer
|
||||
mov edi, [cd_counter_block]
|
||||
mov [edx+8], edi
|
||||
mov edi, [ebx]
|
||||
sub [edx+4], edi
|
||||
xor eax, eax
|
||||
dec ecx
|
||||
js @f
|
||||
mov al, ERROR_END_OF_FILE
|
||||
@@:
|
||||
pop ecx edi
|
||||
mov ebx, [edx+4]
|
||||
ret
|
||||
pop ecx edi
|
||||
mov ebx, [edx+4]
|
||||
ret
|
||||
|
||||
.get_names_from_buffer:
|
||||
mov [cd_current_pointer_of_input_2],CDDataBuf
|
||||
push eax esi edi edx
|
||||
.get_names_from_buffer_1:
|
||||
call cd_get_name
|
||||
jc .end_buffer
|
||||
jc .end_buffer
|
||||
inc dword [cd_counter_block]
|
||||
mov eax,[cd_counter_block]
|
||||
cmp [ebx],eax
|
||||
jae .get_names_from_buffer_1
|
||||
test ecx, ecx
|
||||
jz .get_names_from_buffer_1
|
||||
jz .get_names_from_buffer_1
|
||||
mov edi,[cd_counter_block]
|
||||
mov [edx+4],edi
|
||||
dec ecx
|
||||
@ -307,18 +307,18 @@ fs_CdReadFolder:
|
||||
; ïðîâåðêà êîíöà ôàéëà
|
||||
mov ax,[esi]
|
||||
cmp ax,word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
||||
je .cd_get_parameters_of_file_1
|
||||
je .cd_get_parameters_of_file_1
|
||||
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
||||
movzx eax,byte [ebp-33]
|
||||
add eax,ebp
|
||||
sub eax,34
|
||||
cmp esi,eax
|
||||
je .cd_get_parameters_of_file_1
|
||||
je .cd_get_parameters_of_file_1
|
||||
; ïðîâåðêà êîíöà ïàïêè
|
||||
movzx eax,byte [ebp-1]
|
||||
add eax,ebp
|
||||
cmp esi,eax
|
||||
jb .ansi
|
||||
jb .ansi
|
||||
.cd_get_parameters_of_file_1:
|
||||
mov [edi],byte 0
|
||||
call cd_get_parameters_of_file
|
||||
@ -327,7 +327,7 @@ fs_CdReadFolder:
|
||||
|
||||
.ansi_parent_directory:
|
||||
cmp [cd_counter_block],2
|
||||
je @f
|
||||
je @f
|
||||
mov [edi],byte '.'
|
||||
inc edi
|
||||
jmp .cd_get_parameters_of_file_1
|
||||
@ -344,18 +344,18 @@ fs_CdReadFolder:
|
||||
; ïðîâåðêà êîíöà ôàéëà
|
||||
mov ax,[esi]
|
||||
cmp ax,word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
||||
je .cd_get_parameters_of_file_2
|
||||
je .cd_get_parameters_of_file_2
|
||||
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
||||
movzx eax,byte [ebp-33]
|
||||
add eax,ebp
|
||||
sub eax,34
|
||||
cmp esi,eax
|
||||
je .cd_get_parameters_of_file_2
|
||||
je .cd_get_parameters_of_file_2
|
||||
; ïðîâåðêà êîíöà ïàïêè
|
||||
movzx eax,byte [ebp-1]
|
||||
add eax,ebp
|
||||
cmp esi,eax
|
||||
jb .unicode
|
||||
jb .unicode
|
||||
.cd_get_parameters_of_file_2:
|
||||
mov [edi],word 0
|
||||
call cd_get_parameters_of_file
|
||||
@ -364,7 +364,7 @@ fs_CdReadFolder:
|
||||
|
||||
.unicode_parent_directory:
|
||||
cmp [cd_counter_block],2
|
||||
je @f
|
||||
je @f
|
||||
mov [edi],word 2E00h ; '.'
|
||||
add edi,2
|
||||
jmp .cd_get_parameters_of_file_2
|
||||
@ -387,7 +387,7 @@ cd_get_parameters_of_file_1:
|
||||
shl eax,1
|
||||
; ýòî êàòàëîã?
|
||||
test [ebp-8],byte 2
|
||||
jz .file
|
||||
jz .file
|
||||
inc eax
|
||||
.file:
|
||||
; ìåòêà òîìà íå êàê â FAT, â ýòîì âèäå îòñóòñâóåò
|
||||
@ -395,7 +395,7 @@ cd_get_parameters_of_file_1:
|
||||
shl eax,3
|
||||
; ôàéë ÿâëÿåòñÿ ñêðûòûì? (àòðèáóò ñóùåñòâîâàíèå)
|
||||
test [ebp-8],byte 1
|
||||
jz .hidden
|
||||
jz .hidden
|
||||
inc eax
|
||||
.hidden:
|
||||
shl eax,1
|
||||
@ -457,153 +457,168 @@ cd_get_parameters_of_file_1:
|
||||
;
|
||||
;----------------------------------------------------------------
|
||||
fs_CdGetFileInfo:
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
mov eax, 2
|
||||
ret
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
mov eax, 2
|
||||
ret
|
||||
@@:
|
||||
push edi
|
||||
call cd_find_lfn
|
||||
pushfd
|
||||
cmp [DevErrorCode], 0
|
||||
jz @f
|
||||
popfd
|
||||
pop edi
|
||||
mov eax, 11
|
||||
ret
|
||||
push edi
|
||||
call cd_find_lfn
|
||||
pushfd
|
||||
cmp [DevErrorCode], 0
|
||||
jz @f
|
||||
popfd
|
||||
pop edi
|
||||
mov eax, 11
|
||||
ret
|
||||
@@:
|
||||
popfd
|
||||
jnc @f
|
||||
pop edi
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
popfd
|
||||
jnc @f
|
||||
pop edi
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
@@:
|
||||
|
||||
mov edi, edx
|
||||
push ebp
|
||||
mov ebp, [cd_current_pointer_of_input]
|
||||
add ebp, 33
|
||||
call cd_get_parameters_of_file_1
|
||||
pop ebp
|
||||
and dword [edi+4], 0
|
||||
pop edi
|
||||
xor eax, eax
|
||||
ret
|
||||
mov edi, edx
|
||||
push ebp
|
||||
mov ebp, [cd_current_pointer_of_input]
|
||||
add ebp, 33
|
||||
call cd_get_parameters_of_file_1
|
||||
pop ebp
|
||||
and dword [edi+4], 0
|
||||
pop edi
|
||||
xor eax, eax
|
||||
ret
|
||||
;----------------------------------------------------------------
|
||||
fs_EjectDeviceTray:
|
||||
call clear_CD_cache
|
||||
call allow_medium_removal
|
||||
call EjectMedium
|
||||
ret
|
||||
;----------------------------------------------------------------
|
||||
fs_LoadDeviceTray:
|
||||
call LoadMedium
|
||||
ret
|
||||
;----------------------------------------------------------------
|
||||
|
||||
cd_find_lfn:
|
||||
mov [cd_appl_data],0
|
||||
; in: esi+ebp -> name
|
||||
; out: CF=1 - file not found
|
||||
; else CF=0 and [cd_current_pointer_of_input] direntry
|
||||
push eax esi
|
||||
push eax esi
|
||||
; 16 ñåêòîð íà÷àëî íàáîðà äåñêðèïòîðîâ òîìîâ
|
||||
mov [CDSectorAddress],dword 15
|
||||
.start:
|
||||
inc dword [CDSectorAddress]
|
||||
mov [CDSectorAddress],dword 15
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
call ReadCDWRetr
|
||||
call prevent_medium_removal
|
||||
.start:
|
||||
inc dword [CDSectorAddress]
|
||||
call ReadCDWRetr ;_1
|
||||
cmp [DevErrorCode],0
|
||||
jne .access_denied
|
||||
; ïðîâåðêà íà âøèâîñòü
|
||||
cmp [CDDataBuf+1],dword 'CD00'
|
||||
jne .access_denied
|
||||
cmp [CDDataBuf+5],byte '1'
|
||||
jne .access_denied
|
||||
cmp [CDDataBuf+1],dword 'CD00'
|
||||
jne .access_denied
|
||||
cmp [CDDataBuf+5],byte '1'
|
||||
jne .access_denied
|
||||
; ñåêòîð ÿâëÿåòñÿ òåðìèíàòîðîì íàáîð äåñêðèïòîðîâ òîìîâ?
|
||||
cmp [CDDataBuf],byte 0xff
|
||||
je .access_denied
|
||||
cmp [CDDataBuf],byte 0xff
|
||||
je .access_denied
|
||||
; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì è óëó÷øåííûì äåñêðèïòîðîì òîìà?
|
||||
cmp [CDDataBuf],byte 0x2
|
||||
jne .start
|
||||
cmp [CDDataBuf],byte 0x2
|
||||
jne .start
|
||||
; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì äåñêðèïòîðîì òîìà?
|
||||
cmp [CDDataBuf+6],byte 0x1
|
||||
jne .start
|
||||
cmp [CDDataBuf+6],byte 0x1
|
||||
jne .start
|
||||
; ïàðàìåòðû root äèðåêòðîðèè
|
||||
mov eax,[CDDataBuf+0x9c+2] ; íà÷àëî root äèðåêòðîðèè
|
||||
mov [CDSectorAddress],eax
|
||||
mov eax,[CDDataBuf+0x9c+10] ; ðàçìåð root äèðåêòðîðèè
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
mov [cd_current_pointer_of_input],CDDataBuf+0x9c
|
||||
jmp .done
|
||||
mov eax,[CDDataBuf+0x9c+2] ; íà÷àëî root äèðåêòðîðèè
|
||||
mov [CDSectorAddress],eax
|
||||
mov eax,[CDDataBuf+0x9c+10] ; ðàçìåð root äèðåêòðîðèè
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
mov [cd_current_pointer_of_input],CDDataBuf+0x9c
|
||||
jmp .done
|
||||
@@:
|
||||
; íà÷èíàåì ïîèñê
|
||||
.mainloop:
|
||||
dec dword [CDSectorAddress]
|
||||
dec dword [CDSectorAddress]
|
||||
.read_to_buffer:
|
||||
inc dword [CDSectorAddress]
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð äèðåêòîðèè
|
||||
cmp [DevErrorCode],0
|
||||
jne .access_denied
|
||||
push ebp
|
||||
call cd_find_name_in_buffer
|
||||
pop ebp
|
||||
jnc .found
|
||||
sub eax,2048
|
||||
inc dword [CDSectorAddress]
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð äèðåêòîðèè
|
||||
cmp [DevErrorCode],0
|
||||
jne .access_denied
|
||||
push ebp
|
||||
call cd_find_name_in_buffer
|
||||
pop ebp
|
||||
jnc .found
|
||||
sub eax,2048
|
||||
; äèðåêòîðèÿ çàêîí÷èëàñü?
|
||||
cmp eax,0
|
||||
ja .read_to_buffer
|
||||
cmp eax,0
|
||||
ja .read_to_buffer
|
||||
; íåò èñêîìîãî ýëåìåíòà öåïî÷êè
|
||||
.access_denied:
|
||||
pop esi eax
|
||||
stc
|
||||
ret
|
||||
pop esi eax
|
||||
mov [cd_appl_data],1
|
||||
stc
|
||||
ret
|
||||
; èñêîìûé ýëåìåíò öåïî÷êè íàéäåí
|
||||
.found:
|
||||
; êîíåö ïóòè ôàéëà
|
||||
cmp byte [esi-1], 0
|
||||
jz .done
|
||||
cmp byte [esi-1], 0
|
||||
jz .done
|
||||
.nested:
|
||||
mov eax,[cd_current_pointer_of_input]
|
||||
push dword [eax+2]
|
||||
pop dword [CDSectorAddress] ; íà÷àëî äèðåêòîðèè
|
||||
mov eax,[eax+2+8] ; ðàçìåð äèðåêòîðèè
|
||||
jmp .mainloop
|
||||
mov eax,[cd_current_pointer_of_input]
|
||||
push dword [eax+2]
|
||||
pop dword [CDSectorAddress] ; íà÷àëî äèðåêòîðèè
|
||||
mov eax,[eax+2+8] ; ðàçìåð äèðåêòîðèè
|
||||
jmp .mainloop
|
||||
; óêàçàòåëü ôàéëà íàéäåí
|
||||
.done:
|
||||
test ebp, ebp
|
||||
jz @f
|
||||
mov esi, ebp
|
||||
xor ebp, ebp
|
||||
jmp .nested
|
||||
test ebp, ebp
|
||||
jz @f
|
||||
mov esi, ebp
|
||||
xor ebp, ebp
|
||||
jmp .nested
|
||||
@@:
|
||||
pop esi eax
|
||||
clc
|
||||
ret
|
||||
pop esi eax
|
||||
mov [cd_appl_data],1
|
||||
clc
|
||||
ret
|
||||
|
||||
cd_find_name_in_buffer:
|
||||
mov [cd_current_pointer_of_input_2],CDDataBuf
|
||||
mov [cd_current_pointer_of_input_2],CDDataBuf
|
||||
.start:
|
||||
call cd_get_name
|
||||
jc .not_found
|
||||
call cd_compare_name
|
||||
jc .start
|
||||
call cd_get_name
|
||||
jc .not_found
|
||||
call cd_compare_name
|
||||
jc .start
|
||||
.found:
|
||||
clc
|
||||
ret
|
||||
clc
|
||||
ret
|
||||
.not_found:
|
||||
stc
|
||||
ret
|
||||
stc
|
||||
ret
|
||||
|
||||
cd_get_name:
|
||||
push eax
|
||||
mov ebp,[cd_current_pointer_of_input_2]
|
||||
mov [cd_current_pointer_of_input],ebp
|
||||
mov eax,[ebp]
|
||||
cmp eax,0 ; âõîäû çàêîí÷èëèñü?
|
||||
je .next_sector
|
||||
cmp ebp,CDDataBuf+2048 ; áóôåð çàêîí÷èëñÿ?
|
||||
jae .next_sector
|
||||
movzx eax, byte [ebp]
|
||||
add [cd_current_pointer_of_input_2],eax ; ñëåäóþùèé âõîä êàòàëîãà
|
||||
add ebp,33 ; óêàçàòåëü óñòàíîâëåí íà íà÷àëî èìåíè
|
||||
pop eax
|
||||
clc
|
||||
ret
|
||||
push eax
|
||||
mov ebp,[cd_current_pointer_of_input_2]
|
||||
mov [cd_current_pointer_of_input],ebp
|
||||
mov eax,[ebp]
|
||||
cmp eax,0 ; âõîäû çàêîí÷èëèñü?
|
||||
je .next_sector
|
||||
cmp ebp,CDDataBuf+2048 ; áóôåð çàêîí÷èëñÿ?
|
||||
jae .next_sector
|
||||
movzx eax, byte [ebp]
|
||||
add [cd_current_pointer_of_input_2],eax ; ñëåäóþùèé âõîä êàòàëîãà
|
||||
add ebp,33 ; óêàçàòåëü óñòàíîâëåí íà íà÷àëî èìåíè
|
||||
pop eax
|
||||
clc
|
||||
ret
|
||||
.next_sector:
|
||||
pop eax
|
||||
stc
|
||||
ret
|
||||
pop eax
|
||||
stc
|
||||
ret
|
||||
|
||||
cd_compare_name:
|
||||
; compares ASCIIZ-names, case-insensitive (cp866 encoding)
|
||||
@ -622,7 +637,7 @@ cd_compare_name:
|
||||
xchg ah,al
|
||||
scasw
|
||||
pop eax
|
||||
je .coincides
|
||||
je .coincides
|
||||
call char_toupper
|
||||
call ansi2uni_char
|
||||
xchg ah,al
|
||||
@ -631,9 +646,9 @@ cd_compare_name:
|
||||
jne .name_not_coincide
|
||||
.coincides:
|
||||
cmp [esi],byte '/' ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà
|
||||
je .done
|
||||
cmp [esi],byte 0 ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà
|
||||
je .done
|
||||
je .done
|
||||
cmp [esi],byte 0 ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà
|
||||
je .done
|
||||
jmp .loop
|
||||
.name_not_coincide:
|
||||
pop edi eax esi
|
||||
@ -642,13 +657,13 @@ cd_compare_name:
|
||||
.done:
|
||||
; ïðîâåðêà êîíöà ôàéëà
|
||||
cmp [edi],word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
||||
je .done_1
|
||||
je .done_1
|
||||
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
||||
movzx eax,byte [ebp-33]
|
||||
add eax,ebp
|
||||
sub eax,34
|
||||
cmp edi,eax
|
||||
je .done_1
|
||||
je .done_1
|
||||
; ïðîâåðêà êîíöà ïàïêè
|
||||
movzx eax,byte [ebp-1]
|
||||
add eax,ebp
|
||||
@ -665,58 +680,58 @@ char_todown:
|
||||
; convert character to uppercase, using cp866 encoding
|
||||
; in: al=symbol
|
||||
; out: al=converted symbol
|
||||
cmp al, 'A'
|
||||
jb .ret
|
||||
cmp al, 'Z'
|
||||
jbe .az
|
||||
cmp al, '€'
|
||||
jb .ret
|
||||
cmp al, '<27>'
|
||||
jb .rus1
|
||||
cmp al, 'Ÿ'
|
||||
ja .ret
|
||||
cmp al, 'A'
|
||||
jb .ret
|
||||
cmp al, 'Z'
|
||||
jbe .az
|
||||
cmp al, '€'
|
||||
jb .ret
|
||||
cmp al, '<27>'
|
||||
jb .rus1
|
||||
cmp al, 'Ÿ'
|
||||
ja .ret
|
||||
; 0x90-0x9F -> 0xE0-0xEF
|
||||
add al, 'à'-'<27>'
|
||||
add al, 'à'-'<27>'
|
||||
.ret:
|
||||
ret
|
||||
ret
|
||||
.rus1:
|
||||
; 0x80-0x8F -> 0xA0-0xAF
|
||||
.az:
|
||||
add al, 0x20
|
||||
ret
|
||||
add al, 0x20
|
||||
ret
|
||||
|
||||
uni2ansi_char:
|
||||
; convert UNICODE character in al to ANSI character in ax, using cp866 encoding
|
||||
; in: ax=UNICODE character
|
||||
; out: al=converted ANSI character
|
||||
cmp ax, 0x80
|
||||
jb .ascii
|
||||
cmp ax, 0x401
|
||||
jz .yo1
|
||||
cmp ax, 0x451
|
||||
jz .yo2
|
||||
cmp ax, 0x410
|
||||
jb .unk
|
||||
cmp ax, 0x440
|
||||
jb .rus1
|
||||
cmp ax, 0x450
|
||||
jb .rus2
|
||||
cmp ax, 0x80
|
||||
jb .ascii
|
||||
cmp ax, 0x401
|
||||
jz .yo1
|
||||
cmp ax, 0x451
|
||||
jz .yo2
|
||||
cmp ax, 0x410
|
||||
jb .unk
|
||||
cmp ax, 0x440
|
||||
jb .rus1
|
||||
cmp ax, 0x450
|
||||
jb .rus2
|
||||
.unk:
|
||||
mov al, '_'
|
||||
jmp .doit
|
||||
mov al, '_'
|
||||
jmp .doit
|
||||
.yo1:
|
||||
mov al, 'ð'
|
||||
jmp .doit
|
||||
mov al, 'ð'
|
||||
jmp .doit
|
||||
.yo2:
|
||||
mov al, 'ñ'
|
||||
jmp .doit
|
||||
mov al, 'ñ'
|
||||
jmp .doit
|
||||
.rus1:
|
||||
; 0x410-0x43F -> 0x80-0xAF
|
||||
add al, 0x70
|
||||
jmp .doit
|
||||
add al, 0x70
|
||||
jmp .doit
|
||||
.rus2:
|
||||
; 0x440-0x44F -> 0xE0-0xEF
|
||||
add al, 0xA0
|
||||
add al, 0xA0
|
||||
.ascii:
|
||||
.doit:
|
||||
ret
|
||||
ret
|
||||
|
186
programs/system/cd_tray/CD_tray.ASM
Normal file
186
programs/system/cd_tray/CD_tray.ASM
Normal file
@ -0,0 +1,186 @@
|
||||
;
|
||||
; Управление лотками дисковых приводов ATAPI
|
||||
; 22.07.2007 Mario79 исходный вариант
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
use32 ; включить 32-битный режим ассемблера
|
||||
org 0x0 ; адресация с нуля
|
||||
|
||||
db 'MENUET01' ; 8-байтный идентификатор MenuetOS
|
||||
dd 0x01 ; версия заголовка (всегда 1)
|
||||
dd START ; адрес первой команды
|
||||
dd I_END ; размер программы
|
||||
dd 0x11000 ; количество памяти
|
||||
dd 0x11000 ; адрес вершины стэка
|
||||
dd 0x0 ; адрес буфера для параметров (не используется)
|
||||
dd 0x0 ; зарезервировано
|
||||
|
||||
include 'MACROS.INC' ; макросы облегчают жизнь ассемблерщиков!
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
;--- НАЧАЛО ПРОГРАММЫ ----------------------------------------------
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
START:
|
||||
|
||||
red: ; перерисовать окно
|
||||
call draw_window ; вызываем процедуру отрисовки окна
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
;--- ЦИКЛ ОБРАБОТКИ СОБЫТИЙ ----------------------------------------
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
still:
|
||||
mcall 10 ; функция 10 - ждать события
|
||||
|
||||
cmp eax,1 ; перерисовать окно ?
|
||||
je red ; если да - на метку red
|
||||
cmp eax,2 ; нажата клавиша ?
|
||||
je key ; если да - на key
|
||||
cmp eax,3 ; нажата кнопка ?
|
||||
je button ; если да - на button
|
||||
|
||||
jmp still ; если другое событие - в начало цикла
|
||||
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
|
||||
key: ; нажата клавиша на клавиатуре
|
||||
mcall 2 ; функция 2 - считать код символа (в ah)
|
||||
|
||||
jmp still ; вернуться к началу цикла
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
button:
|
||||
mcall 17 ; 17 - получить идентификатор нажатой кнопки
|
||||
cmp ah,2
|
||||
jne b3
|
||||
mov dword [load_tray.name],cd0
|
||||
jmp b5.1
|
||||
b3:
|
||||
cmp ah,3
|
||||
jne b4
|
||||
mov dword [load_tray.name],cd1
|
||||
jmp b5.1
|
||||
b4:
|
||||
cmp ah,4
|
||||
jne b5
|
||||
mov dword [load_tray.name],cd2
|
||||
jmp b5.1
|
||||
b5:
|
||||
cmp ah,5
|
||||
jne b6
|
||||
mov dword [load_tray.name],cd3
|
||||
.1:
|
||||
mcall 70, load_tray
|
||||
jmp red
|
||||
b6:
|
||||
cmp ah,6
|
||||
jne b7
|
||||
mov dword [eject_tray.name],cd0
|
||||
jmp b9.1
|
||||
b7:
|
||||
cmp ah,7
|
||||
jne b8
|
||||
mov dword [eject_tray.name],cd1
|
||||
jmp b9.1
|
||||
b8:
|
||||
cmp ah,8
|
||||
jne b9
|
||||
mov dword [eject_tray.name],cd2
|
||||
jmp b9.1
|
||||
b9:
|
||||
cmp ah,9
|
||||
jne b1
|
||||
mov dword [eject_tray.name],cd3
|
||||
.1:
|
||||
mcall 70, eject_tray
|
||||
jmp red
|
||||
b1:
|
||||
cmp ah, 1 ; если НЕ нажата кнопка с номером 1,
|
||||
jne still ; вернуться
|
||||
|
||||
.exit:
|
||||
mcall -1 ; иначе конец программы
|
||||
|
||||
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
;--- ОПРЕДЕЛЕНИЕ И ОТРИСОВКА ОКНА ----------------------------------
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
draw_window:
|
||||
mcall 12, 1 ; функция 12: сообщить ОС об отрисовке окна
|
||||
; 1 - начинаем рисовать
|
||||
; СОЗДАиМ ОКНО
|
||||
|
||||
mcall 0, <100,230>, <100,110>, 0x03AABBCC, 0x805080D0, 0x005080D0
|
||||
mcall 71, 1 ,header
|
||||
mcall 8,<15,42>,<40,20>,2,0xaaaaaa
|
||||
call draw_buttons
|
||||
mov edx,6
|
||||
add ecx,30 shl 16
|
||||
mcall
|
||||
call draw_buttons
|
||||
|
||||
mcall 4, <25,25>, 0x80ffffff,text1
|
||||
mov edx,text2
|
||||
|
||||
add ebx,3 shl 16+20
|
||||
mcall
|
||||
mov edx,text3
|
||||
add ebx,30
|
||||
sub ebx,3 shl 16
|
||||
mcall
|
||||
|
||||
mcall 12, 2 ; функция 12: сообщить ОС об отрисовке окна
|
||||
; 2, закончили рисовать
|
||||
|
||||
ret ; выходим из процедуры
|
||||
|
||||
draw_buttons:
|
||||
pusha
|
||||
add ebx,50 shl 16
|
||||
inc edx
|
||||
mcall
|
||||
add ebx,50 shl 16
|
||||
inc edx
|
||||
mcall
|
||||
add ebx,50 shl 16
|
||||
inc edx
|
||||
mcall
|
||||
popa
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
;--- ДАННЫЕ ПРОГРАММЫ ----------------------------------------------
|
||||
;---------------------------------------------------------------------
|
||||
header db ' ATAPI Device Tray Control',0
|
||||
text3 db 'eject eject eject eject',0
|
||||
text2 db 'load load load load',0
|
||||
text1 db '/cd0/ /cd1/ /cd2/ /cd3/',0
|
||||
cd0: db '/cd0/1/',0
|
||||
cd1: db '/cd1/1/',0
|
||||
cd2: db '/cd2/1/',0
|
||||
cd3: db '/cd3/1/',0
|
||||
;---------------------------------------------------------------------
|
||||
load_tray:
|
||||
.subfunction dd 11
|
||||
.rezerv dd 0
|
||||
.rezerv1 dd 0
|
||||
.rezerv2 dd 0
|
||||
.rezerv3 dd 0
|
||||
db 0
|
||||
.name: dd cd0
|
||||
|
||||
eject_tray:
|
||||
.subfunction dd 10
|
||||
.rezerv dd 0
|
||||
.rezerv1 dd 0
|
||||
.rezerv2 dd 0
|
||||
.rezerv3 dd 0
|
||||
db 0
|
||||
.name: dd cd0
|
||||
|
||||
I_END: ; метка конца программы
|
268
programs/system/cd_tray/MACROS.INC
Normal file
268
programs/system/cd_tray/MACROS.INC
Normal file
@ -0,0 +1,268 @@
|
||||
; new application structure
|
||||
macro meos_app_start
|
||||
{
|
||||
use32
|
||||
org 0x0
|
||||
|
||||
db 'MENUET01'
|
||||
dd 0x01
|
||||
dd __start
|
||||
dd __end
|
||||
dd __memory
|
||||
dd __stack
|
||||
|
||||
if used __params & ~defined __params
|
||||
dd __params
|
||||
else
|
||||
dd 0x0
|
||||
end if
|
||||
|
||||
dd 0x0
|
||||
}
|
||||
MEOS_APP_START fix meos_app_start
|
||||
|
||||
macro code
|
||||
{
|
||||
__start:
|
||||
}
|
||||
CODE fix code
|
||||
|
||||
macro data
|
||||
{
|
||||
__data:
|
||||
}
|
||||
DATA fix data
|
||||
|
||||
macro udata
|
||||
{
|
||||
if used __params & ~defined __params
|
||||
__params:
|
||||
db 0
|
||||
__end:
|
||||
rb 255
|
||||
else
|
||||
__end:
|
||||
end if
|
||||
__udata:
|
||||
}
|
||||
UDATA fix udata
|
||||
|
||||
macro meos_app_end
|
||||
{
|
||||
align 32
|
||||
rb 2048
|
||||
__stack:
|
||||
__memory:
|
||||
}
|
||||
MEOS_APP_END fix meos_app_end
|
||||
|
||||
|
||||
; macro for defining multiline text data
|
||||
struc mstr [sstring]
|
||||
{
|
||||
forward
|
||||
local ssize
|
||||
virtual at 0
|
||||
db sstring
|
||||
ssize = $
|
||||
end virtual
|
||||
dd ssize
|
||||
db sstring
|
||||
common
|
||||
dd -1
|
||||
}
|
||||
|
||||
|
||||
; strings
|
||||
macro sz name,[data] { ; from MFAR [mike.dld]
|
||||
common
|
||||
if used name
|
||||
label name
|
||||
end if
|
||||
forward
|
||||
if used name
|
||||
db data
|
||||
end if
|
||||
common
|
||||
if used name
|
||||
.size = $-name
|
||||
end if
|
||||
}
|
||||
|
||||
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
|
||||
common
|
||||
if used name
|
||||
label name
|
||||
end if
|
||||
forward
|
||||
if (used name)&(lang eq lng)
|
||||
db data
|
||||
end if
|
||||
common
|
||||
if used name
|
||||
.size = $-name
|
||||
end if
|
||||
}
|
||||
|
||||
|
||||
|
||||
; easy system call macro
|
||||
macro mpack dest, hsrc, lsrc
|
||||
{
|
||||
if (hsrc eqtype 0) & (lsrc eqtype 0)
|
||||
mov dest, (hsrc) shl 16 + lsrc
|
||||
else
|
||||
if (hsrc eqtype 0) & (~lsrc eqtype 0)
|
||||
mov dest, (hsrc) shl 16
|
||||
add dest, lsrc
|
||||
else
|
||||
mov dest, hsrc
|
||||
shl dest, 16
|
||||
add dest, lsrc
|
||||
end if
|
||||
end if
|
||||
}
|
||||
|
||||
macro __mov reg,a,b { ; mike.dld
|
||||
if (~a eq)&(~b eq)
|
||||
mpack reg,a,b
|
||||
else if (~a eq)&(b eq)
|
||||
mov reg,a
|
||||
end if
|
||||
}
|
||||
|
||||
macro mcall a,b,c,d,e,f { ; mike.dld
|
||||
__mov eax,a
|
||||
__mov ebx,b
|
||||
__mov ecx,c
|
||||
__mov edx,d
|
||||
__mov esi,e
|
||||
__mov edi,f
|
||||
int 0x40
|
||||
}
|
||||
|
||||
|
||||
|
||||
; language for programs
|
||||
lang fix ru ; ru en fr ge fi
|
||||
|
||||
|
||||
|
||||
; optimize the code for size
|
||||
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
|
||||
|
||||
macro add arg1,arg2
|
||||
{
|
||||
if (arg2 eqtype 0)
|
||||
if (arg2) = 1
|
||||
inc arg1
|
||||
else
|
||||
add arg1,arg2
|
||||
end if
|
||||
else
|
||||
add arg1,arg2
|
||||
end if
|
||||
}
|
||||
|
||||
macro sub arg1,arg2
|
||||
{
|
||||
if (arg2 eqtype 0)
|
||||
if (arg2) = 1
|
||||
dec arg1
|
||||
else
|
||||
sub arg1,arg2
|
||||
end if
|
||||
else
|
||||
sub arg1,arg2
|
||||
end if
|
||||
}
|
||||
|
||||
macro mov arg1,arg2
|
||||
{
|
||||
if (arg1 in __regs) & (arg2 eqtype 0)
|
||||
if (arg2) = 0
|
||||
xor arg1,arg1
|
||||
else if (arg2) = 1
|
||||
xor arg1,arg1
|
||||
inc arg1
|
||||
else if (arg2) = -1
|
||||
or arg1,-1
|
||||
else if (arg2) > -128 & (arg2) < 128
|
||||
push arg2
|
||||
pop arg1
|
||||
else
|
||||
mov arg1,arg2
|
||||
end if
|
||||
else
|
||||
mov arg1,arg2
|
||||
end if
|
||||
}
|
||||
|
||||
|
||||
macro struct name
|
||||
{
|
||||
virtual at 0
|
||||
name name
|
||||
sizeof.#name = $ - name
|
||||
end virtual
|
||||
}
|
||||
|
||||
; structures used in MeOS
|
||||
struc process_information
|
||||
{
|
||||
.cpu_usage dd ? ; +0
|
||||
.window_stack_position dw ? ; +4
|
||||
.window_stack_value dw ? ; +6
|
||||
.not_used1 dw ? ; +8
|
||||
.process_name rb 12 ; +10
|
||||
.memory_start dd ? ; +22
|
||||
.used_memory dd ? ; +26
|
||||
.PID dd ? ; +30
|
||||
.x_start dd ? ; +34
|
||||
.y_start dd ? ; +38
|
||||
.x_size dd ? ; +42
|
||||
.y_size dd ? ; +46
|
||||
.slot_state dw ? ; +50
|
||||
rb (1024-52)
|
||||
}
|
||||
struct process_information
|
||||
|
||||
struc system_colors
|
||||
{
|
||||
.frame dd ?
|
||||
.grab dd ?
|
||||
.grab_button dd ?
|
||||
.grab_button_text dd ?
|
||||
.grab_text dd ?
|
||||
.work dd ?
|
||||
.work_button dd ?
|
||||
.work_button_text dd ?
|
||||
.work_text dd ?
|
||||
.work_graph dd ?
|
||||
}
|
||||
struct system_colors
|
||||
|
||||
|
||||
; constants
|
||||
|
||||
; events
|
||||
EV_IDLE = 0
|
||||
EV_TIMER = 0
|
||||
EV_REDRAW = 1
|
||||
EV_KEY = 2
|
||||
EV_BUTTON = 3
|
||||
EV_EXIT = 4
|
||||
EV_BACKGROUND = 5
|
||||
EV_MOUSE = 6
|
||||
EV_IPC = 7
|
||||
EV_STACK = 8
|
||||
|
||||
; event mask bits for function 40
|
||||
EVM_REDRAW = 1b
|
||||
EVM_KEY = 10b
|
||||
EVM_BUTTON = 100b
|
||||
EVM_EXIT = 1000b
|
||||
EVM_BACKGROUND = 10000b
|
||||
EVM_MOUSE = 100000b
|
||||
EVM_IPC = 1000000b
|
||||
EVM_STACK = 10000000b
|
2
programs/system/cd_tray/build.bat
Normal file
2
programs/system/cd_tray/build.bat
Normal file
@ -0,0 +1,2 @@
|
||||
@fasm CD_tray.ASM CD_tray
|
||||
@pause
|
Loading…
Reference in New Issue
Block a user