forked from KolibriOS/kolibrios
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
|
MaxRetr equ 10
|
||||||
; Предельное время ожидания готовности к приему команды
|
; Предельное время ожидания готовности к приему команды
|
||||||
@ -35,74 +34,138 @@ NoTickWaitTime equ 0xfffff
|
|||||||
;* Данные считывается в массив CDDataBuf. *
|
;* Данные считывается в массив CDDataBuf. *
|
||||||
;*************************************************
|
;*************************************************
|
||||||
ReadCD:
|
ReadCD:
|
||||||
pusha
|
pusha
|
||||||
; Задать размер сектора
|
; Задать размер сектора
|
||||||
mov [CDBlockSize],2048 ;2352
|
mov [CDBlockSize],2048 ;2352
|
||||||
; Очистить буфер пакетной команды
|
; Очистить буфер пакетной команды
|
||||||
call clear_packet_buffer
|
call clear_packet_buffer
|
||||||
; Сформировать пакетную команду для считывания
|
; Сформировать пакетную команду для считывания
|
||||||
; сектора данных
|
; сектора данных
|
||||||
; Çàäàòü êîä êîìàíäû Read CD
|
; Çàäàòü êîä êîìàíäû Read CD
|
||||||
mov [PacketCommand],byte 0x28 ;0xBE
|
mov [PacketCommand],byte 0x28 ;0xBE
|
||||||
; Çàäàòü àäðåñ ñåêòîðà
|
; Çàäàòü àäðåñ ñåêòîðà
|
||||||
mov AX,word [CDSectorAddress+2]
|
mov AX,word [CDSectorAddress+2]
|
||||||
xchg AL,AH
|
xchg AL,AH
|
||||||
mov word [PacketCommand+2],AX
|
mov word [PacketCommand+2],AX
|
||||||
mov AX,word [CDSectorAddress]
|
mov AX,word [CDSectorAddress]
|
||||||
xchg AL,AH
|
xchg AL,AH
|
||||||
mov word [PacketCommand+4],AX
|
mov word [PacketCommand+4],AX
|
||||||
; mov eax,[CDSectorAddress]
|
; mov eax,[CDSectorAddress]
|
||||||
; mov [PacketCommand+2],eax
|
; mov [PacketCommand+2],eax
|
||||||
; Çàäàòü êîëè÷åñòâî ñ÷èòûâàåìûõ ñåêòîðîâ
|
; Çàäàòü êîëè÷åñòâî ñ÷èòûâàåìûõ ñåêòîðîâ
|
||||||
mov [PacketCommand+8],byte 1
|
mov [PacketCommand+8],byte 1
|
||||||
; Çàäàòü ñ÷èòûâàíèå äàííûõ â ïîëíîì îáúåìå
|
; Çàäàòü ñ÷èòûâàíèå äàííûõ â ïîëíîì îáúåìå
|
||||||
; mov [PacketCommand+9],byte 0xF8
|
; mov [PacketCommand+9],byte 0xF8
|
||||||
; Подать команду
|
; Подать команду
|
||||||
call SendPacketDatCommand
|
call SendPacketDatCommand
|
||||||
; call test_mario79
|
; call test_mario79
|
||||||
popa
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;********************************************
|
;********************************************
|
||||||
;* ЧТЕНИЕ СЕКТОРА С ПОВТОРАМИ *
|
;* ЧТЕНИЕ СЕКТОРА С ПОВТОРАМИ *
|
||||||
;* Многократное повторение чтения при сбоях *
|
;* Многократное повторение чтения при сбоях *
|
||||||
;********************************************
|
;********************************************
|
||||||
ReadCDWRetr:
|
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:
|
@@NextRetr:
|
||||||
; Подать команду
|
; Подать команду
|
||||||
call ReadCD
|
call ReadCD
|
||||||
cmp [DevErrorCode],0
|
cmp [DevErrorCode],0
|
||||||
je @@End_4
|
je @@End_4
|
||||||
|
|
||||||
or ecx,ecx ;{SPraid.simba} (for cd load)
|
or ecx,ecx ;{SPraid.simba} (for cd load)
|
||||||
jz @@End_4
|
jz @@End_4
|
||||||
dec ecx
|
dec ecx
|
||||||
|
|
||||||
cmp [timer_ticks_enable],0
|
cmp [timer_ticks_enable],0
|
||||||
jne @f
|
jne @f
|
||||||
mov eax,NoTickWaitTime
|
mov eax,NoTickWaitTime
|
||||||
.wait:
|
.wait:
|
||||||
dec eax
|
dec eax
|
||||||
cmp eax,0
|
cmp eax,0
|
||||||
je @@NextRetr
|
je @@NextRetr
|
||||||
jmp .wait
|
jmp .wait
|
||||||
@@:
|
@@:
|
||||||
; Задержка на 2,5 секунды
|
; Задержка на 2,5 секунды
|
||||||
mov EAX,[timer_ticks]
|
mov EAX,[timer_ticks]
|
||||||
add EAX,250 ;50
|
add EAX,250 ;50
|
||||||
@@Wait:
|
@@Wait:
|
||||||
call change_task
|
call change_task
|
||||||
cmp EAX,[timer_ticks]
|
cmp EAX,[timer_ticks]
|
||||||
ja @@Wait
|
ja @@Wait
|
||||||
loop @@NextRetr
|
loop @@NextRetr
|
||||||
@@End_4:
|
@@End_4:
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
; Универсальные процедуры, обеспечивающие выполнение
|
; Универсальные процедуры, обеспечивающие выполнение
|
||||||
@ -115,11 +178,11 @@ ReadCDWRetr:
|
|||||||
MaxCDWaitTime equ 1000 ;200 ;10 секунд
|
MaxCDWaitTime equ 1000 ;200 ;10 секунд
|
||||||
|
|
||||||
; Область памяти для формирования пакетной команды
|
; Область памяти для формирования пакетной команды
|
||||||
PacketCommand: rb 12 ;DB 12 DUP (?)
|
PacketCommand: rb 12 ;DB 12 DUP (?)
|
||||||
; Область памяти для приема данных от дисковода
|
; Область памяти для приема данных от дисковода
|
||||||
;CDDataBuf DB 4096 DUP (0)
|
;CDDataBuf DB 4096 DUP (0)
|
||||||
; Размер принимаемого блока данных в байтах
|
; Размер принимаемого блока данных в байтах
|
||||||
CDBlockSize DW ?
|
CDBlockSize DW ?
|
||||||
; Адрес считываемого сектора данных
|
; Адрес считываемого сектора данных
|
||||||
CDSectorAddress: DD ?
|
CDSectorAddress: DD ?
|
||||||
; Время начала очередной операции с диском
|
; Время начала очередной операции с диском
|
||||||
@ -141,123 +204,123 @@ CDDataBuf_pointer dd 0
|
|||||||
;* CDBlockSize - размер принимаемого блока данных. *
|
;* CDBlockSize - размер принимаемого блока данных. *
|
||||||
;****************************************************
|
;****************************************************
|
||||||
SendPacketDatCommand:
|
SendPacketDatCommand:
|
||||||
pushad
|
pushad
|
||||||
; Задать режим CHS
|
; Задать режим CHS
|
||||||
mov [ATAAddressMode],0
|
mov [ATAAddressMode],0
|
||||||
; Послать ATA-команду передачи пакетной команды
|
; Послать ATA-команду передачи пакетной команды
|
||||||
mov [ATAFeatures],0
|
mov [ATAFeatures],0
|
||||||
mov [ATASectorCount],0
|
mov [ATASectorCount],0
|
||||||
mov [ATASectorNumber],0
|
mov [ATASectorNumber],0
|
||||||
; Çàãðóçèòü ðàçìåð ïåðåäàâàåìîãî áëîêà
|
; Çàãðóçèòü ðàçìåð ïåðåäàâàåìîãî áëîêà
|
||||||
mov AX,[CDBlockSize]
|
mov AX,[CDBlockSize]
|
||||||
mov [ATACylinder],AX
|
mov [ATACylinder],AX
|
||||||
mov [ATAHead],0
|
mov [ATAHead],0
|
||||||
mov [ATACommand],0A0h
|
mov [ATACommand],0A0h
|
||||||
call SendCommandToHDD_1
|
call SendCommandToHDD_1
|
||||||
cmp [DevErrorCode],0 ;ïðîâåðèòü êîä îøèáêè
|
cmp [DevErrorCode],0 ;ïðîâåðèòü êîä îøèáêè
|
||||||
jne @@End_8 ;çàêîí÷èòü, ñîõðàíèâ êîä îøèáêè
|
jne @@End_8 ;çàêîí÷èòü, ñîõðàíèâ êîä îøèáêè
|
||||||
|
|
||||||
; Ожидание готовности дисковода к приему
|
; Ожидание готовности дисковода к приему
|
||||||
; пакетной команды
|
; пакетной команды
|
||||||
mov DX,[ATABasePortAddr]
|
mov DX,[ATABasePortAddr]
|
||||||
add DX,7 ;ïîðò 1õ7h
|
add DX,7 ;ïîðò 1õ7h
|
||||||
mov ecx,NoTickWaitTime
|
mov ecx,NoTickWaitTime
|
||||||
@@WaitDevice0:
|
@@WaitDevice0:
|
||||||
cmp [timer_ticks_enable],0
|
cmp [timer_ticks_enable],0
|
||||||
jne @f
|
jne @f
|
||||||
dec ecx
|
dec ecx
|
||||||
cmp ecx,0
|
cmp ecx,0
|
||||||
je @@Err1_1
|
je @@Err1_1
|
||||||
jmp .test
|
jmp .test
|
||||||
@@:
|
@@:
|
||||||
call change_task
|
call change_task
|
||||||
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
||||||
mov EAX,[timer_ticks]
|
mov EAX,[timer_ticks]
|
||||||
sub EAX,[TickCounter_1]
|
sub EAX,[TickCounter_1]
|
||||||
cmp EAX,BSYWaitTime
|
cmp EAX,BSYWaitTime
|
||||||
ja @@Err1_1 ;îøèáêà òàéì-àóòà
|
ja @@Err1_1 ;îøèáêà òàéì-àóòà
|
||||||
; Ïðîâåðèòü ãîòîâíîñòü
|
; Ïðîâåðèòü ãîòîâíîñòü
|
||||||
.test:
|
.test:
|
||||||
in AL,DX
|
in AL,DX
|
||||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||||
jnz @@WaitDevice0
|
jnz @@WaitDevice0
|
||||||
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
||||||
jz @@WaitDevice0
|
jz @@WaitDevice0
|
||||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||||
jnz @@Err6
|
jnz @@Err6
|
||||||
; Послать пакетную команду
|
; Послать пакетную команду
|
||||||
cli
|
cli
|
||||||
mov DX,[ATABasePortAddr]
|
mov DX,[ATABasePortAddr]
|
||||||
mov AX,[PacketCommand]
|
mov AX,[PacketCommand]
|
||||||
out DX,AX
|
out DX,AX
|
||||||
mov AX,[PacketCommand+2]
|
mov AX,[PacketCommand+2]
|
||||||
out DX,AX
|
out DX,AX
|
||||||
mov AX,[PacketCommand+4]
|
mov AX,[PacketCommand+4]
|
||||||
out DX,AX
|
out DX,AX
|
||||||
mov AX,[PacketCommand+6]
|
mov AX,[PacketCommand+6]
|
||||||
out DX,AX
|
out DX,AX
|
||||||
mov AX,[PacketCommand+8]
|
mov AX,[PacketCommand+8]
|
||||||
out DX,AX
|
out DX,AX
|
||||||
mov AX,[PacketCommand+10]
|
mov AX,[PacketCommand+10]
|
||||||
out DX,AX
|
out DX,AX
|
||||||
sti
|
sti
|
||||||
; Ожидание готовности данных
|
; Ожидание готовности данных
|
||||||
mov DX,[ATABasePortAddr]
|
mov DX,[ATABasePortAddr]
|
||||||
add DX,7 ;ïîðò 1õ7h
|
add DX,7 ;ïîðò 1õ7h
|
||||||
mov ecx,NoTickWaitTime
|
mov ecx,NoTickWaitTime
|
||||||
@@WaitDevice1:
|
@@WaitDevice1:
|
||||||
cmp [timer_ticks_enable],0
|
cmp [timer_ticks_enable],0
|
||||||
jne @f
|
jne @f
|
||||||
dec ecx
|
dec ecx
|
||||||
cmp ecx,0
|
cmp ecx,0
|
||||||
je @@Err1_1
|
je @@Err1_1
|
||||||
jmp .test_1
|
jmp .test_1
|
||||||
@@:
|
@@:
|
||||||
call change_task
|
call change_task
|
||||||
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
||||||
mov EAX,[timer_ticks]
|
mov EAX,[timer_ticks]
|
||||||
sub EAX,[TickCounter_1]
|
sub EAX,[TickCounter_1]
|
||||||
cmp EAX,MaxCDWaitTime
|
cmp EAX,MaxCDWaitTime
|
||||||
ja @@Err1_1 ;îøèáêà òàéì-àóòà
|
ja @@Err1_1 ;îøèáêà òàéì-àóòà
|
||||||
; Ïðîâåðèòü ãîòîâíîñòü
|
; Ïðîâåðèòü ãîòîâíîñòü
|
||||||
.test_1:
|
.test_1:
|
||||||
in AL,DX
|
in AL,DX
|
||||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||||
jnz @@WaitDevice1
|
jnz @@WaitDevice1
|
||||||
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
||||||
jz @@WaitDevice1
|
jz @@WaitDevice1
|
||||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||||
jnz @@Err6_temp
|
jnz @@Err6_temp
|
||||||
; Принять блок данных от контроллера
|
; Принять блок данных от контроллера
|
||||||
mov EDI,[CDDataBuf_pointer] ;0x7000 ;CDDataBuf
|
mov EDI,[CDDataBuf_pointer] ;0x7000 ;CDDataBuf
|
||||||
; Çàãðóçèòü àäðåñ ðåãèñòðà äàííûõ êîíòðîëëåðà
|
; Çàãðóçèòü àäðåñ ðåãèñòðà äàííûõ êîíòðîëëåðà
|
||||||
mov DX,[ATABasePortAddr] ;ïîðò 1x0h
|
mov DX,[ATABasePortAddr] ;ïîðò 1x0h
|
||||||
; Çàãðóçèòü â ñ÷åò÷èê ðàçìåð áëîêà â áàéòàõ
|
; Çàãðóçèòü â ñ÷åò÷èê ðàçìåð áëîêà â áàéòàõ
|
||||||
xor ecx,ecx
|
xor ecx,ecx
|
||||||
mov CX,[CDBlockSize]
|
mov CX,[CDBlockSize]
|
||||||
; Âû÷èñëèòü ðàçìåð áëîêà â 16-ðàçðÿäíûõ ñëîâàõ
|
; Âû÷èñëèòü ðàçìåð áëîêà â 16-ðàçðÿäíûõ ñëîâàõ
|
||||||
shr CX,1 ;ðàçäåëèòü ðàçìåð áëîêà íà 2
|
shr CX,1 ;ðàçäåëèòü ðàçìåð áëîêà íà 2
|
||||||
; Ïðèíÿòü áëîê äàííûõ
|
; Ïðèíÿòü áëîê äàííûõ
|
||||||
cli
|
cli
|
||||||
cld
|
cld
|
||||||
rep insw
|
rep insw
|
||||||
sti
|
sti
|
||||||
; Óñïåøíîå çàâåðøåíèå ïðèåìà äàííûõ
|
; Óñïåøíîå çàâåðøåíèå ïðèåìà äàííûõ
|
||||||
jmp @@End_8
|
jmp @@End_8
|
||||||
|
|
||||||
; Записать код ошибки
|
; Записать код ошибки
|
||||||
@@Err1_1:
|
@@Err1_1:
|
||||||
mov [DevErrorCode],1
|
mov [DevErrorCode],1
|
||||||
jmp @@End_8
|
jmp @@End_8
|
||||||
@@Err6_temp:
|
@@Err6_temp:
|
||||||
mov [DevErrorCode],7
|
mov [DevErrorCode],7
|
||||||
jmp @@End_8
|
jmp @@End_8
|
||||||
@@Err6:
|
@@Err6:
|
||||||
mov [DevErrorCode],6
|
mov [DevErrorCode],6
|
||||||
|
|
||||||
@@End_8:
|
@@End_8:
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -271,83 +334,83 @@ SendPacketDatCommand:
|
|||||||
;* PacketCommand - 12-байтный командный пакет. *
|
;* PacketCommand - 12-байтный командный пакет. *
|
||||||
;***********************************************
|
;***********************************************
|
||||||
SendPacketNoDatCommand:
|
SendPacketNoDatCommand:
|
||||||
pushad
|
pushad
|
||||||
; Задать режим CHS
|
; Задать режим CHS
|
||||||
mov [ATAAddressMode],0
|
mov [ATAAddressMode],0
|
||||||
; Послать ATA-команду передачи пакетной команды
|
; Послать ATA-команду передачи пакетной команды
|
||||||
mov [ATAFeatures],0
|
mov [ATAFeatures],0
|
||||||
mov [ATASectorCount],0
|
mov [ATASectorCount],0
|
||||||
mov [ATASectorNumber],0
|
mov [ATASectorNumber],0
|
||||||
mov [ATACylinder],0
|
mov [ATACylinder],0
|
||||||
mov [ATAHead],0
|
mov [ATAHead],0
|
||||||
mov [ATACommand],0A0h
|
mov [ATACommand],0A0h
|
||||||
call SendCommandToHDD_1
|
call SendCommandToHDD_1
|
||||||
cmp [DevErrorCode],0 ;ïðîâåðèòü êîä îøèáêè
|
cmp [DevErrorCode],0 ;ïðîâåðèòü êîä îøèáêè
|
||||||
jne @@End_9 ;çàêîí÷èòü, ñîõðàíèâ êîä îøèáêè
|
jne @@End_9 ;çàêîí÷èòü, ñîõðàíèâ êîä îøèáêè
|
||||||
; Ожидание готовности дисковода к приему
|
; Ожидание готовности дисковода к приему
|
||||||
; пакетной команды
|
; пакетной команды
|
||||||
mov DX,[ATABasePortAddr]
|
mov DX,[ATABasePortAddr]
|
||||||
add DX,7 ;ïîðò 1õ7h
|
add DX,7 ;ïîðò 1õ7h
|
||||||
@@WaitDevice0_1:
|
@@WaitDevice0_1:
|
||||||
call change_task
|
call change_task
|
||||||
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ
|
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ
|
||||||
mov EAX,[timer_ticks]
|
mov EAX,[timer_ticks]
|
||||||
sub EAX,[TickCounter_1]
|
sub EAX,[TickCounter_1]
|
||||||
cmp EAX,BSYWaitTime
|
cmp EAX,BSYWaitTime
|
||||||
ja @@Err1_3 ;îøèáêà òàéì-àóòà
|
ja @@Err1_3 ;îøèáêà òàéì-àóòà
|
||||||
; Ïðîâåðèòü ãîòîâíîñòü
|
; Ïðîâåðèòü ãîòîâíîñòü
|
||||||
in AL,DX
|
in AL,DX
|
||||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||||
jnz @@WaitDevice0_1
|
jnz @@WaitDevice0_1
|
||||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||||
jnz @@Err6_1
|
jnz @@Err6_1
|
||||||
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
||||||
jz @@WaitDevice0_1
|
jz @@WaitDevice0_1
|
||||||
; Послать пакетную команду
|
; Послать пакетную команду
|
||||||
; cli
|
; cli
|
||||||
mov DX,[ATABasePortAddr]
|
mov DX,[ATABasePortAddr]
|
||||||
mov AX,word [PacketCommand]
|
mov AX,word [PacketCommand]
|
||||||
out DX,AX
|
out DX,AX
|
||||||
mov AX,word [PacketCommand+2]
|
mov AX,word [PacketCommand+2]
|
||||||
out DX,AX
|
out DX,AX
|
||||||
mov AX,word [PacketCommand+4]
|
mov AX,word [PacketCommand+4]
|
||||||
out DX,AX
|
out DX,AX
|
||||||
mov AX,word [PacketCommand+6]
|
mov AX,word [PacketCommand+6]
|
||||||
out DX,AX
|
out DX,AX
|
||||||
mov AX,word [PacketCommand+8]
|
mov AX,word [PacketCommand+8]
|
||||||
out DX,AX
|
out DX,AX
|
||||||
mov AX,word [PacketCommand+10]
|
mov AX,word [PacketCommand+10]
|
||||||
out DX,AX
|
out DX,AX
|
||||||
; sti
|
; sti
|
||||||
; Ожидание подтверждения приема команды
|
; Ожидание подтверждения приема команды
|
||||||
mov DX,[ATABasePortAddr]
|
mov DX,[ATABasePortAddr]
|
||||||
add DX,7 ;ïîðò 1õ7h
|
add DX,7 ;ïîðò 1õ7h
|
||||||
@@WaitDevice1_1:
|
@@WaitDevice1_1:
|
||||||
call change_task
|
call change_task
|
||||||
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
||||||
mov EAX,[timer_ticks]
|
mov EAX,[timer_ticks]
|
||||||
sub EAX,[TickCounter_1]
|
sub EAX,[TickCounter_1]
|
||||||
cmp EAX,MaxCDWaitTime
|
cmp EAX,MaxCDWaitTime
|
||||||
ja @@Err1_3 ;îøèáêà òàéì-àóòà
|
ja @@Err1_3 ;îøèáêà òàéì-àóòà
|
||||||
; Îæèäàòü îñâîáîæäåíèÿ óñòðîéñòâà
|
; Îæèäàòü îñâîáîæäåíèÿ óñòðîéñòâà
|
||||||
in AL,DX
|
in AL,DX
|
||||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||||
jnz @@WaitDevice1_1
|
jnz @@WaitDevice1_1
|
||||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||||
jnz @@Err6_1
|
jnz @@Err6_1
|
||||||
test AL,40h ;ñîñòîÿíèå ñèãíàëà DRDY
|
test AL,40h ;ñîñòîÿíèå ñèãíàëà DRDY
|
||||||
jz @@WaitDevice1_1
|
jz @@WaitDevice1_1
|
||||||
jmp @@End_9
|
jmp @@End_9
|
||||||
|
|
||||||
; Записать код ошибки
|
; Записать код ошибки
|
||||||
@@Err1_3:
|
@@Err1_3:
|
||||||
mov [DevErrorCode],1
|
mov [DevErrorCode],1
|
||||||
jmp @@End_9
|
jmp @@End_9
|
||||||
@@Err6_1:
|
@@Err6_1:
|
||||||
mov [DevErrorCode],6
|
mov [DevErrorCode],6
|
||||||
@@End_9:
|
@@End_9:
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;****************************************************
|
;****************************************************
|
||||||
;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ *
|
;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ *
|
||||||
@ -369,119 +432,119 @@ SendPacketNoDatCommand:
|
|||||||
;* возвращен код ошибки. *
|
;* возвращен код ошибки. *
|
||||||
;****************************************************
|
;****************************************************
|
||||||
SendCommandToHDD_1:
|
SendCommandToHDD_1:
|
||||||
pushad
|
pushad
|
||||||
; Проверить значение кода режима
|
; Проверить значение кода режима
|
||||||
cmp [ATAAddressMode],1
|
cmp [ATAAddressMode],1
|
||||||
ja @@Err2_4
|
ja @@Err2_4
|
||||||
; Проверить корректность номера канала
|
; Проверить корректность номера канала
|
||||||
mov BX,[ChannelNumber]
|
mov BX,[ChannelNumber]
|
||||||
cmp BX,1
|
cmp BX,1
|
||||||
jb @@Err3_4
|
jb @@Err3_4
|
||||||
cmp BX,2
|
cmp BX,2
|
||||||
ja @@Err3_4
|
ja @@Err3_4
|
||||||
; Установить базовый адрес
|
; Установить базовый адрес
|
||||||
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_4
|
ja @@Err4_4
|
||||||
shl AL,4
|
shl AL,4
|
||||||
or AL,10100000b
|
or AL,10100000b
|
||||||
out DX,AL
|
out DX,AL
|
||||||
; Îæèäàòü, ïîêà äèñê íå áóäåò ãîòîâ
|
; Îæèäàòü, ïîêà äèñê íå áóäåò ãîòîâ
|
||||||
inc DX
|
inc DX
|
||||||
mov eax,[timer_ticks]
|
mov eax,[timer_ticks]
|
||||||
mov [TickCounter_1],eax
|
mov [TickCounter_1],eax
|
||||||
mov ecx,NoTickWaitTime
|
mov ecx,NoTickWaitTime
|
||||||
@@WaitHDReady_2:
|
@@WaitHDReady_2:
|
||||||
cmp [timer_ticks_enable],0
|
cmp [timer_ticks_enable],0
|
||||||
jne @f
|
jne @f
|
||||||
dec ecx
|
dec ecx
|
||||||
cmp ecx,0
|
cmp ecx,0
|
||||||
je @@Err1_4
|
je @@Err1_4
|
||||||
jmp .test
|
jmp .test
|
||||||
@@:
|
@@:
|
||||||
call change_task
|
call change_task
|
||||||
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ
|
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ
|
||||||
mov eax,[timer_ticks]
|
mov eax,[timer_ticks]
|
||||||
sub eax,[TickCounter_1]
|
sub eax,[TickCounter_1]
|
||||||
cmp eax,BSYWaitTime ;300 ;îæèäàòü 3 ñåê.
|
cmp eax,BSYWaitTime ;300 ;îæèäàòü 3 ñåê.
|
||||||
ja @@Err1_4 ;îøèáêà òàéì-àóòà
|
ja @@Err1_4 ;îøèáêà òàéì-àóòà
|
||||||
; Ïðî÷èòàòü ðåãèñòð ñîñòîÿíèÿ
|
; Ïðî÷èòàòü ðåãèñòð ñîñòîÿíèÿ
|
||||||
.test:
|
.test:
|
||||||
in AL,DX
|
in AL,DX
|
||||||
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà BSY
|
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà BSY
|
||||||
test AL,80h
|
test AL,80h
|
||||||
jnz @@WaitHDReady_2
|
jnz @@WaitHDReady_2
|
||||||
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà DRQ
|
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà DRQ
|
||||||
test AL,08h
|
test AL,08h
|
||||||
jnz @@WaitHDReady_2
|
jnz @@WaitHDReady_2
|
||||||
|
|
||||||
; Загрузить команду в регистры контроллера
|
; Загрузить команду в регистры контроллера
|
||||||
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],0Fh ;ïðîâåðèòü íîìåð ãîëîâêè
|
||||||
ja @@Err5_4
|
ja @@Err5_4
|
||||||
or AL,[ATAHead]
|
or AL,[ATAHead]
|
||||||
or AL,10100000b
|
or AL,10100000b
|
||||||
mov AH,[ATAAddressMode]
|
mov AH,[ATAAddressMode]
|
||||||
shl AH,6
|
shl AH,6
|
||||||
or AL,AH
|
or AL,AH
|
||||||
out DX,AL
|
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
|
||||||
jmp @@End_10
|
jmp @@End_10
|
||||||
; Записать код ошибки
|
; Записать код ошибки
|
||||||
@@Err1_4:
|
@@Err1_4:
|
||||||
mov [DevErrorCode],1
|
mov [DevErrorCode],1
|
||||||
jmp @@End_10
|
jmp @@End_10
|
||||||
@@Err2_4:
|
@@Err2_4:
|
||||||
mov [DevErrorCode],2
|
mov [DevErrorCode],2
|
||||||
jmp @@End_10
|
jmp @@End_10
|
||||||
@@Err3_4:
|
@@Err3_4:
|
||||||
mov [DevErrorCode],3
|
mov [DevErrorCode],3
|
||||||
jmp @@End_10
|
jmp @@End_10
|
||||||
@@Err4_4:
|
@@Err4_4:
|
||||||
mov [DevErrorCode],4
|
mov [DevErrorCode],4
|
||||||
jmp @@End_10
|
jmp @@End_10
|
||||||
@@Err5_4:
|
@@Err5_4:
|
||||||
mov [DevErrorCode],5
|
mov [DevErrorCode],5
|
||||||
; Завершение работы программы
|
; Завершение работы программы
|
||||||
@@End_10:
|
@@End_10:
|
||||||
; sti
|
; sti
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;*************************************************
|
;*************************************************
|
||||||
;* ОЖИДАНИЕ ГОТОВНОСТИ УСТРОЙСТВА К РАБОТЕ *
|
;* ОЖИДАНИЕ ГОТОВНОСТИ УСТРОЙСТВА К РАБОТЕ *
|
||||||
;* Входные параметры передаются через глобальные *
|
;* Входные параметры передаются через глобальные *
|
||||||
@ -490,34 +553,73 @@ SendCommandToHDD_1:
|
|||||||
;* DiskNumber - номер диска на канале. *
|
;* DiskNumber - номер диска на канале. *
|
||||||
;*************************************************
|
;*************************************************
|
||||||
WaitUnitReady:
|
WaitUnitReady:
|
||||||
pusha
|
pusha
|
||||||
; Запомнить время начала операции
|
; Запомнить время начала операции
|
||||||
mov EAX,[timer_ticks]
|
mov EAX,[timer_ticks]
|
||||||
mov [WURStartTime],EAX
|
mov [WURStartTime],EAX
|
||||||
; Очистить буфер пакетной команды
|
; Очистить буфер пакетной команды
|
||||||
call clear_packet_buffer
|
call clear_packet_buffer
|
||||||
; Сформировать команду TEST UNIT READY
|
; Сформировать команду TEST UNIT READY
|
||||||
mov [PacketCommand],word 00h
|
mov [PacketCommand],word 00h
|
||||||
; ЦИКЛ ОЖИДАНИЯ ГОТОВНОСТИ УСТРОЙСТВА
|
; ЦИКЛ ОЖИДАНИЯ ГОТОВНОСТИ УСТРОЙСТВА
|
||||||
@@SendCommand:
|
@@SendCommand:
|
||||||
; Ïîäàòü êîìàíäó ïðîâåðêè ãîòîâíîñòè
|
; Ïîäàòü êîìàíäó ïðîâåðêè ãîòîâíîñòè
|
||||||
call SendPacketNoDatCommand
|
call SendPacketNoDatCommand
|
||||||
call change_task
|
call change_task
|
||||||
; Ïðîâåðèòü êîä îøèáêè
|
; Ïðîâåðèòü êîä îøèáêè
|
||||||
cmp [DevErrorCode],0
|
cmp [DevErrorCode],0
|
||||||
je @@End_11
|
je @@End_11
|
||||||
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ ãîòîâíîñòè
|
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ ãîòîâíîñòè
|
||||||
mov EAX,[timer_ticks]
|
mov EAX,[timer_ticks]
|
||||||
sub EAX,[WURStartTime]
|
sub EAX,[WURStartTime]
|
||||||
cmp EAX,MaxCDWaitTime
|
cmp EAX,MaxCDWaitTime
|
||||||
jb @@SendCommand
|
jb @@SendCommand
|
||||||
; Îøèáêà òàéì-àóòà
|
; Îøèáêà òàéì-àóòà
|
||||||
mov [DevErrorCode],1
|
mov [DevErrorCode],1
|
||||||
@@End_11:
|
@@End_11:
|
||||||
popa
|
popa
|
||||||
ret
|
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 - номер диска на канале. *
|
;* DiskNumber - номер диска на канале. *
|
||||||
;*************************************************
|
;*************************************************
|
||||||
LoadMedium:
|
LoadMedium:
|
||||||
pusha
|
pusha
|
||||||
; Очистить буфер пакетной команды
|
; Очистить буфер пакетной команды
|
||||||
call clear_packet_buffer
|
call clear_packet_buffer
|
||||||
; Сформировать команду START/STOP UNIT
|
; Сформировать команду START/STOP UNIT
|
||||||
; Çàäàòü êîä êîìàíäû
|
; Çàäàòü êîä êîìàíäû
|
||||||
mov [PacketCommand],word 1Bh
|
mov [PacketCommand],word 1Bh
|
||||||
; Çàäàòü îïåðàöèþ çàãðóçêè íîñèòåëÿ
|
; Çàäàòü îïåðàöèþ çàãðóçêè íîñèòåëÿ
|
||||||
mov [PacketCommand+4],word 00000011b
|
mov [PacketCommand+4],word 00000011b
|
||||||
; Подать команду
|
; Подать команду
|
||||||
call SendPacketNoDatCommand
|
call SendPacketNoDatCommand
|
||||||
popa
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;*************************************************
|
;*************************************************
|
||||||
;* ИЗВЛЕЧЬ НОСИТЕЛЬ ИЗ ДИСКОВОДА *
|
;* ИЗВЛЕЧЬ НОСИТЕЛЬ ИЗ ДИСКОВОДА *
|
||||||
@ -546,19 +648,19 @@ LoadMedium:
|
|||||||
;* ChannelNumber - номер канала; *
|
;* ChannelNumber - номер канала; *
|
||||||
;* DiskNumber - номер диска на канале. *
|
;* DiskNumber - номер диска на канале. *
|
||||||
;*************************************************
|
;*************************************************
|
||||||
UnloadMedium:
|
EjectMedium:
|
||||||
pusha
|
pusha
|
||||||
; Очистить буфер пакетной команды
|
; Очистить буфер пакетной команды
|
||||||
call clear_packet_buffer
|
call clear_packet_buffer
|
||||||
; Сформировать команду START/STOP UNIT
|
; Сформировать команду START/STOP UNIT
|
||||||
; Çàäàòü êîä êîìàíäû
|
; Çàäàòü êîä êîìàíäû
|
||||||
mov [PacketCommand],word 1Bh
|
mov [PacketCommand],word 1Bh
|
||||||
; Çàäàòü îïåðàöèþ èçâëå÷åíèÿ íîñèòåëÿ
|
; Çàäàòü îïåðàöèþ èçâëå÷åíèÿ íîñèòåëÿ
|
||||||
mov [PacketCommand+4],word 00000010b
|
mov [PacketCommand+4],word 00000010b
|
||||||
; Подать команду
|
; Подать команду
|
||||||
call SendPacketNoDatCommand
|
call SendPacketNoDatCommand
|
||||||
popa
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;*************************************************
|
;*************************************************
|
||||||
;* ОПРЕДЕЛИТЬ ОБЩЕЕ КОЛИЧЕСТВО СЕКТОРОВ НА ДИСКЕ *
|
;* ОПРЕДЕЛИТЬ ОБЩЕЕ КОЛИЧЕСТВО СЕКТОРОВ НА ДИСКЕ *
|
||||||
@ -568,22 +670,22 @@ UnloadMedium:
|
|||||||
;* DiskNumber - номер диска на канале. *
|
;* DiskNumber - номер диска на канале. *
|
||||||
;*************************************************
|
;*************************************************
|
||||||
ReadCapacity:
|
ReadCapacity:
|
||||||
pusha
|
pusha
|
||||||
; Очистить буфер пакетной команды
|
; Очистить буфер пакетной команды
|
||||||
call clear_packet_buffer
|
call clear_packet_buffer
|
||||||
; Задать размер буфера в байтах
|
; Задать размер буфера в байтах
|
||||||
mov [CDBlockSize],8
|
mov [CDBlockSize],8
|
||||||
; Сформировать команду READ CAPACITY
|
; Сформировать команду READ CAPACITY
|
||||||
mov [PacketCommand],word 25h
|
mov [PacketCommand],word 25h
|
||||||
; Подать команду
|
; Подать команду
|
||||||
call SendPacketDatCommand
|
call SendPacketDatCommand
|
||||||
popa
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
||||||
clear_packet_buffer:
|
clear_packet_buffer:
|
||||||
; Очистить буфер пакетной команды
|
; Очистить буфер пакетной команды
|
||||||
mov [PacketCommand],dword 0
|
mov [PacketCommand],dword 0
|
||||||
mov [PacketCommand+4],dword 0
|
mov [PacketCommand+4],dword 0
|
||||||
mov [PacketCommand+8],dword 0
|
mov [PacketCommand+8],dword 0
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -21,85 +21,73 @@ write_cache:
|
|||||||
push eax ecx edx esi edi
|
push eax ecx edx esi edi
|
||||||
|
|
||||||
; write difference ( 2 ) from cache to hd
|
; write difference ( 2 ) from cache to hd
|
||||||
|
|
||||||
; mov ecx,cache_max
|
|
||||||
; mov esi,HD_CACHE+8
|
|
||||||
call calculate_cache
|
call calculate_cache
|
||||||
add esi,8
|
add esi,8
|
||||||
|
|
||||||
mov edi,1
|
mov edi,1
|
||||||
|
write_cache_more:
|
||||||
write_cache_more:
|
cmp dword [esi+4],2 ; if cache slot is not different
|
||||||
|
|
||||||
cmp dword [esi+4],2 ; if cache slot is not different
|
|
||||||
jne .write_chain
|
jne .write_chain
|
||||||
|
mov dword [esi+4],1 ; same as in hd
|
||||||
mov dword [esi+4],1 ; same as in hd
|
mov eax,[esi] ; eax = sector to write
|
||||||
mov eax,[esi] ; eax = sector to write
|
|
||||||
|
|
||||||
cmp eax,[PARTITION_START]
|
cmp eax,[PARTITION_START]
|
||||||
jb danger
|
jb danger
|
||||||
cmp eax,[PARTITION_END]
|
cmp eax,[PARTITION_END]
|
||||||
ja danger
|
ja danger
|
||||||
|
|
||||||
; 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
|
cmp [dma_hdd], 1
|
||||||
jnz .nodma
|
jnz .nodma
|
||||||
; Ž¡ê¥¤¨ï¥¬ § ¯¨áì 楯®çª¨ ¯®á«¥¤®¢ ⥫ìëå ᥪâ®à®¢ ¢ ®¤® ®¡à 饨¥ ª ¤¨áªã
|
; Ž¡ê¥¤¨ï¥¬ § ¯¨áì 楯®çª¨ ¯®á«¥¤®¢ ⥫ìëå ᥪâ®à®¢ ¢ ®¤® ®¡à 饨¥ ª ¤¨áªã
|
||||||
cmp ecx, 1
|
cmp ecx, 1
|
||||||
jz .nonext
|
jz .nonext
|
||||||
cmp dword [esi+8+4], 2
|
cmp dword [esi+8+4], 2
|
||||||
jnz .nonext
|
jnz .nonext
|
||||||
push eax
|
push eax
|
||||||
inc eax
|
inc eax
|
||||||
cmp eax, [esi+8]
|
cmp eax, [esi+8]
|
||||||
pop eax
|
pop eax
|
||||||
jnz .nonext
|
jnz .nonext
|
||||||
cmp [cache_chain_started], 1
|
cmp [cache_chain_started], 1
|
||||||
jz @f
|
jz @f
|
||||||
mov [cache_chain_started], 1
|
mov [cache_chain_started], 1
|
||||||
mov [cache_chain_size], 0
|
mov [cache_chain_size], 0
|
||||||
mov [cache_chain_pos], edi
|
mov [cache_chain_pos], edi
|
||||||
mov [cache_chain_ptr], esi
|
mov [cache_chain_ptr], esi
|
||||||
@@:
|
@@:
|
||||||
inc [cache_chain_size]
|
inc [cache_chain_size]
|
||||||
cmp [cache_chain_size], 64
|
cmp [cache_chain_size], 64
|
||||||
jnz .continue
|
jnz .continue
|
||||||
jmp .write_chain
|
jmp .write_chain
|
||||||
.nonext:
|
.nonext:
|
||||||
call flush_cache_chain
|
call flush_cache_chain
|
||||||
mov [cache_chain_size], 1
|
mov [cache_chain_size], 1
|
||||||
mov [cache_chain_ptr], esi
|
mov [cache_chain_ptr], esi
|
||||||
call write_cache_sector
|
call write_cache_sector
|
||||||
jmp .continue
|
jmp .continue
|
||||||
.nodma:
|
.nodma:
|
||||||
call cache_write_pio
|
call cache_write_pio
|
||||||
.write_chain:
|
.write_chain:
|
||||||
call flush_cache_chain
|
call flush_cache_chain
|
||||||
|
|
||||||
.continue:
|
.continue:
|
||||||
danger:
|
danger:
|
||||||
|
|
||||||
add esi,8
|
add esi,8
|
||||||
inc edi
|
inc edi
|
||||||
dec ecx
|
dec ecx
|
||||||
jnz write_cache_more
|
jnz write_cache_more
|
||||||
call flush_cache_chain
|
call flush_cache_chain
|
||||||
return_02:
|
return_02:
|
||||||
pop edi esi edx ecx eax
|
pop edi esi edx ecx eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
flush_cache_chain:
|
flush_cache_chain:
|
||||||
cmp [cache_chain_started], 0
|
cmp [cache_chain_started], 0
|
||||||
jz @f
|
jz @f
|
||||||
call write_cache_chain
|
call write_cache_chain
|
||||||
mov [cache_chain_started], 0
|
mov [cache_chain_started], 0
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
|
;--------------------------------------------------------------------
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
find_empty_slot:
|
find_empty_slot:
|
||||||
;-----------------------------------------------------------
|
;-----------------------------------------------------------
|
||||||
@ -108,68 +96,36 @@ find_empty_slot:
|
|||||||
;-----------------------------------------------------------
|
;-----------------------------------------------------------
|
||||||
; push ecx esi
|
; push ecx esi
|
||||||
|
|
||||||
search_again:
|
search_again:
|
||||||
|
|
||||||
; mov ecx,cache_max*10/100
|
|
||||||
; mov edi,[cache_search_start]
|
|
||||||
call calculate_cache_3
|
call calculate_cache_3
|
||||||
; push eax edx
|
shr ecx,3
|
||||||
; mov eax,ecx
|
search_for_empty:
|
||||||
; mov ecx,10
|
|
||||||
; xor edx,edx
|
|
||||||
; div ecx
|
|
||||||
; mov ecx,eax
|
|
||||||
; pop edx eax
|
|
||||||
shr ecx,3
|
|
||||||
search_for_empty:
|
|
||||||
|
|
||||||
inc edi
|
inc edi
|
||||||
; cmp edi,cache_max
|
|
||||||
; push eax
|
|
||||||
call calculate_cache_4
|
call calculate_cache_4
|
||||||
; cmp edi,eax
|
|
||||||
; pop eax
|
|
||||||
jbe inside_cache
|
jbe inside_cache
|
||||||
mov edi,1
|
mov edi,1
|
||||||
|
inside_cache:
|
||||||
inside_cache:
|
|
||||||
|
|
||||||
; cmp dword [edi*8+HD_CACHE+4],2 ; get cache slot info
|
|
||||||
push esi
|
push esi
|
||||||
call calculate_cache_1
|
call calculate_cache_1
|
||||||
cmp dword [edi*8+esi+4],2
|
cmp dword [edi*8+esi+4],2
|
||||||
pop esi
|
pop esi
|
||||||
jb found_slot ; it's empty or read
|
jb found_slot ; it's empty or read
|
||||||
dec ecx
|
dec ecx
|
||||||
jnz search_for_empty
|
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
|
cmp [hd_error],0
|
||||||
jne found_slot_access_denied
|
jne found_slot_access_denied
|
||||||
|
jmp search_again ; and start again
|
||||||
jmp search_again ; and start again
|
found_slot:
|
||||||
|
|
||||||
found_slot:
|
|
||||||
|
|
||||||
; mov [cache_search_start],edi
|
|
||||||
call calculate_cache_5
|
call calculate_cache_5
|
||||||
found_slot_access_denied:
|
found_slot_access_denied:
|
||||||
ret
|
ret
|
||||||
|
;--------------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
clear_hd_cache:
|
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_in_cache],-1
|
||||||
mov [fat_change],0
|
mov [fat_change],0
|
||||||
; pop edi ecx eax
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;--------------------------------------------------------------------
|
;--------------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
calculate_cache:
|
calculate_cache:
|
||||||
@ -207,7 +163,7 @@ calculate_cache:
|
|||||||
cmp [hdd_appl_data],0
|
cmp [hdd_appl_data],0
|
||||||
jne .ide2_appl_data
|
jne .ide2_appl_data
|
||||||
mov ecx,[cache_ide2_system_sad_size]
|
mov ecx,[cache_ide2_system_sad_size]
|
||||||
mov esi,[cache_ide2_pointer]
|
mov esi,[cache_ide2_pointer]
|
||||||
ret
|
ret
|
||||||
.ide2_appl_data:
|
.ide2_appl_data:
|
||||||
mov ecx,[cache_ide2_appl_sad_size]
|
mov ecx,[cache_ide2_appl_sad_size]
|
||||||
@ -217,7 +173,7 @@ calculate_cache:
|
|||||||
cmp [hdd_appl_data],0
|
cmp [hdd_appl_data],0
|
||||||
jne .ide3_appl_data
|
jne .ide3_appl_data
|
||||||
mov ecx,[cache_ide3_system_sad_size]
|
mov ecx,[cache_ide3_system_sad_size]
|
||||||
mov esi,[cache_ide3_pointer]
|
mov esi,[cache_ide3_pointer]
|
||||||
ret
|
ret
|
||||||
.ide3_appl_data:
|
.ide3_appl_data:
|
||||||
mov ecx,[cache_ide3_appl_sad_size]
|
mov ecx,[cache_ide3_appl_sad_size]
|
||||||
@ -261,7 +217,7 @@ calculate_cache_1:
|
|||||||
.ide3:
|
.ide3:
|
||||||
cmp [hdd_appl_data],0
|
cmp [hdd_appl_data],0
|
||||||
jne .ide3_appl_data
|
jne .ide3_appl_data
|
||||||
mov esi,[cache_ide3_pointer]
|
mov esi,[cache_ide3_pointer]
|
||||||
ret
|
ret
|
||||||
.ide3_appl_data:
|
.ide3_appl_data:
|
||||||
mov esi,[cache_ide3_data_pointer]
|
mov esi,[cache_ide3_data_pointer]
|
||||||
@ -276,7 +232,7 @@ calculate_cache_2:
|
|||||||
jne .ide1
|
jne .ide1
|
||||||
cmp [hdd_appl_data],0
|
cmp [hdd_appl_data],0
|
||||||
jne .ide0_appl_data
|
jne .ide0_appl_data
|
||||||
mov eax,[cache_ide0_system_data]
|
mov eax,[cache_ide0_system_data]
|
||||||
ret
|
ret
|
||||||
.ide0_appl_data:
|
.ide0_appl_data:
|
||||||
mov eax,[cache_ide0_appl_data]
|
mov eax,[cache_ide0_appl_data]
|
||||||
@ -304,7 +260,7 @@ calculate_cache_2:
|
|||||||
.ide3:
|
.ide3:
|
||||||
cmp [hdd_appl_data],0
|
cmp [hdd_appl_data],0
|
||||||
jne .ide3_appl_data
|
jne .ide3_appl_data
|
||||||
mov eax,[cache_ide3_system_data]
|
mov eax,[cache_ide3_system_data]
|
||||||
ret
|
ret
|
||||||
.ide3_appl_data:
|
.ide3_appl_data:
|
||||||
mov eax,[cache_ide3_appl_data]
|
mov eax,[cache_ide3_appl_data]
|
||||||
@ -346,7 +302,7 @@ calculate_cache_3:
|
|||||||
cmp [hdd_appl_data],0
|
cmp [hdd_appl_data],0
|
||||||
jne .ide2_appl_data
|
jne .ide2_appl_data
|
||||||
mov ecx,[cache_ide2_system_sad_size]
|
mov ecx,[cache_ide2_system_sad_size]
|
||||||
mov edi,[cache_ide2_search_start]
|
mov edi,[cache_ide2_search_start]
|
||||||
ret
|
ret
|
||||||
.ide2_appl_data:
|
.ide2_appl_data:
|
||||||
mov ecx,[cache_ide2_appl_sad_size]
|
mov ecx,[cache_ide2_appl_sad_size]
|
||||||
@ -356,7 +312,7 @@ calculate_cache_3:
|
|||||||
cmp [hdd_appl_data],0
|
cmp [hdd_appl_data],0
|
||||||
jne .ide3_appl_data
|
jne .ide3_appl_data
|
||||||
mov ecx,[cache_ide3_system_sad_size]
|
mov ecx,[cache_ide3_system_sad_size]
|
||||||
mov edi,[cache_ide3_search_start]
|
mov edi,[cache_ide3_search_start]
|
||||||
ret
|
ret
|
||||||
.ide3_appl_data:
|
.ide3_appl_data:
|
||||||
mov ecx,[cache_ide3_appl_sad_size]
|
mov ecx,[cache_ide3_appl_sad_size]
|
||||||
@ -415,7 +371,7 @@ calculate_cache_5:
|
|||||||
jne .ide1
|
jne .ide1
|
||||||
cmp [hdd_appl_data],0
|
cmp [hdd_appl_data],0
|
||||||
jne .ide0_appl_data
|
jne .ide0_appl_data
|
||||||
mov [cache_ide0_search_start],edi
|
mov [cache_ide0_search_start],edi
|
||||||
ret
|
ret
|
||||||
.ide0_appl_data:
|
.ide0_appl_data:
|
||||||
mov [cache_ide0_appl_search_start],edi
|
mov [cache_ide0_appl_search_start],edi
|
||||||
@ -443,15 +399,357 @@ calculate_cache_5:
|
|||||||
.ide3:
|
.ide3:
|
||||||
cmp [hdd_appl_data],0
|
cmp [hdd_appl_data],0
|
||||||
jne .ide3_appl_data
|
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
|
ret
|
||||||
.ide3_appl_data:
|
.ide3_appl_data:
|
||||||
mov [cache_ide3_appl_search_start],edi
|
mov [cache_ide3_appl_search_start],edi
|
||||||
ret
|
ret
|
||||||
;--------------------------------------------------------------------
|
;--------------------------------------------------------------------
|
||||||
align 4
|
;align 4
|
||||||
calculate_linear_to_real:
|
;calculate_linear_to_real:
|
||||||
shr eax, 12
|
; shr eax, 12
|
||||||
mov eax, [page_tabs+eax*4]
|
; mov eax, [page_tabs+eax*4]
|
||||||
and eax, 0xFFFFF000
|
; and eax, 0xFFFFF000
|
||||||
ret
|
; ret
|
||||||
|
@ -306,6 +306,7 @@ hdbase rd 1 ; for boot 0x1f0
|
|||||||
hdid rd 1
|
hdid rd 1
|
||||||
hdpos rd 1 ; for boot 0x1
|
hdpos rd 1 ; for boot 0x1
|
||||||
fat32part rd 1 ; for boot 0x1
|
fat32part rd 1 ; for boot 0x1
|
||||||
|
cdpos rd 1
|
||||||
|
|
||||||
sb16 rd 1
|
sb16 rd 1
|
||||||
|
|
||||||
@ -387,6 +388,7 @@ cache_ide3_appl_search_start rd 1
|
|||||||
|
|
||||||
debug_step_pointer rd 1
|
debug_step_pointer rd 1
|
||||||
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
|
||||||
|
|
||||||
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
|
||||||
|
@ -18,13 +18,13 @@
|
|||||||
shl eax,3
|
shl eax,3
|
||||||
; translate pages in butes *4096
|
; translate pages in butes *4096
|
||||||
shl eax,12
|
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
|
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 @f
|
||||||
mov eax,128*1024
|
mov eax,128*1024
|
||||||
@ -44,30 +44,31 @@
|
|||||||
mov [cache_ide3_search_start],eax
|
mov [cache_ide3_search_start],eax
|
||||||
mov [cache_ide3_appl_search_start],eax
|
mov [cache_ide3_appl_search_start],eax
|
||||||
mov [hdd_appl_data],1 ;al
|
mov [hdd_appl_data],1 ;al
|
||||||
|
mov [cd_appl_data],1
|
||||||
|
|
||||||
mov cl,[DRIVE_DATA+1]
|
mov cl,[DRIVE_DATA+1]
|
||||||
mov ch,cl
|
mov ch,cl
|
||||||
and cl,11b
|
and cl,11b
|
||||||
cmp cl,0
|
cmp cl,0
|
||||||
je .ide2
|
je .ide2
|
||||||
call get_cache_ide3
|
call get_cache_ide3
|
||||||
.ide2:
|
.ide2:
|
||||||
mov cl,ch
|
mov cl,ch
|
||||||
and cl,1100b
|
and cl,1100b
|
||||||
cmp cl,0
|
cmp cl,0
|
||||||
je .ide1
|
je .ide1
|
||||||
call get_cache_ide2
|
call get_cache_ide2
|
||||||
.ide1:
|
.ide1:
|
||||||
mov cl,ch
|
mov cl,ch
|
||||||
and cl,110000b
|
and cl,110000b
|
||||||
cmp cl,0
|
cmp cl,0
|
||||||
je .ide0
|
je .ide0
|
||||||
call get_cache_ide1
|
call get_cache_ide1
|
||||||
.ide0:
|
.ide0:
|
||||||
mov cl,ch
|
mov cl,ch
|
||||||
and cl,11000000b
|
and cl,11000000b
|
||||||
cmp cl,0
|
cmp cl,0
|
||||||
je end_get_cache
|
je end_get_cache
|
||||||
call get_cache_ide0
|
call get_cache_ide0
|
||||||
jmp end_get_cache
|
jmp end_get_cache
|
||||||
|
|
||||||
@ -85,21 +86,21 @@ get_cache_ide0:
|
|||||||
mov [cache_ide0_appl_data_size],eax
|
mov [cache_ide0_appl_data_size],eax
|
||||||
add ebx,edx
|
add ebx,edx
|
||||||
mov [cache_ide0_data_pointer],ebx
|
mov [cache_ide0_data_pointer],ebx
|
||||||
|
|
||||||
cmp cl,10000000b
|
cmp cl,10000000b
|
||||||
je .cd
|
je .cd
|
||||||
push ecx
|
push ecx
|
||||||
mov eax,[cache_ide0_system_data_size]
|
mov eax,[cache_ide0_system_data_size]
|
||||||
call calculate_for_hd
|
call calculate_for_hd
|
||||||
add eax,[cache_ide0_pointer]
|
add eax,[cache_ide0_pointer]
|
||||||
mov [cache_ide0_system_data],eax
|
mov [cache_ide0_system_data],eax
|
||||||
mov [cache_ide0_system_sad_size],ecx
|
mov [cache_ide0_system_sad_size],ecx
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
mov edi,[cache_ide0_pointer]
|
mov edi,[cache_ide0_pointer]
|
||||||
call clear_ide_cache
|
call clear_ide_cache
|
||||||
pop edi
|
pop edi
|
||||||
|
|
||||||
mov eax,[cache_ide0_appl_data_size]
|
mov eax,[cache_ide0_appl_data_size]
|
||||||
call calculate_for_hd
|
call calculate_for_hd
|
||||||
add eax,[cache_ide0_data_pointer]
|
add eax,[cache_ide0_data_pointer]
|
||||||
@ -110,7 +111,7 @@ get_cache_ide0:
|
|||||||
mov edi,[cache_ide0_data_pointer]
|
mov edi,[cache_ide0_data_pointer]
|
||||||
call clear_ide_cache
|
call clear_ide_cache
|
||||||
pop edi
|
pop edi
|
||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
.cd:
|
.cd:
|
||||||
@ -125,21 +126,21 @@ get_cache_ide0:
|
|||||||
mov edi,[cache_ide0_pointer]
|
mov edi,[cache_ide0_pointer]
|
||||||
call clear_ide_cache
|
call clear_ide_cache
|
||||||
pop edi
|
pop edi
|
||||||
|
|
||||||
mov eax,[cache_ide0_appl_data_size]
|
mov eax,[cache_ide0_appl_data_size]
|
||||||
call calculate_for_cd
|
call calculate_for_cd
|
||||||
add eax,[cache_ide0_data_pointer]
|
add eax,[cache_ide0_data_pointer]
|
||||||
mov [cache_ide0_appl_data],eax
|
mov [cache_ide0_appl_data],eax
|
||||||
mov [cache_ide0_appl_sad_size],ecx
|
mov [cache_ide0_appl_sad_size],ecx
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
mov edi,[cache_ide0_data_pointer]
|
mov edi,[cache_ide0_data_pointer]
|
||||||
call clear_ide_cache
|
call clear_ide_cache
|
||||||
pop edi
|
pop edi
|
||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
get_cache_ide1:
|
get_cache_ide1:
|
||||||
push ecx
|
push ecx
|
||||||
stdcall kernel_alloc,[cache_ide1_size]
|
stdcall kernel_alloc,[cache_ide1_size]
|
||||||
@ -154,9 +155,9 @@ get_cache_ide1:
|
|||||||
mov [cache_ide1_appl_data_size],eax
|
mov [cache_ide1_appl_data_size],eax
|
||||||
add ebx,edx
|
add ebx,edx
|
||||||
mov [cache_ide1_data_pointer],ebx
|
mov [cache_ide1_data_pointer],ebx
|
||||||
|
|
||||||
cmp cl,100000b
|
cmp cl,100000b
|
||||||
je .cd
|
je .cd
|
||||||
push ecx
|
push ecx
|
||||||
mov eax,[cache_ide1_system_data_size]
|
mov eax,[cache_ide1_system_data_size]
|
||||||
call calculate_for_hd
|
call calculate_for_hd
|
||||||
@ -174,12 +175,12 @@ get_cache_ide1:
|
|||||||
add eax,[cache_ide1_data_pointer]
|
add eax,[cache_ide1_data_pointer]
|
||||||
mov [cache_ide1_appl_data],eax
|
mov [cache_ide1_appl_data],eax
|
||||||
mov [cache_ide1_appl_sad_size],ecx
|
mov [cache_ide1_appl_sad_size],ecx
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
mov edi,[cache_ide1_data_pointer]
|
mov edi,[cache_ide1_data_pointer]
|
||||||
call clear_ide_cache
|
call clear_ide_cache
|
||||||
pop edi
|
pop edi
|
||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
.cd:
|
.cd:
|
||||||
@ -200,12 +201,12 @@ get_cache_ide1:
|
|||||||
add eax,[cache_ide1_data_pointer]
|
add eax,[cache_ide1_data_pointer]
|
||||||
mov [cache_ide1_appl_data],eax
|
mov [cache_ide1_appl_data],eax
|
||||||
mov [cache_ide1_appl_sad_size],ecx
|
mov [cache_ide1_appl_sad_size],ecx
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
mov edi,[cache_ide1_data_pointer]
|
mov edi,[cache_ide1_data_pointer]
|
||||||
call clear_ide_cache
|
call clear_ide_cache
|
||||||
pop edi
|
pop edi
|
||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -223,9 +224,9 @@ get_cache_ide2:
|
|||||||
mov [cache_ide2_appl_data_size],eax
|
mov [cache_ide2_appl_data_size],eax
|
||||||
add ebx,edx
|
add ebx,edx
|
||||||
mov [cache_ide2_data_pointer],ebx
|
mov [cache_ide2_data_pointer],ebx
|
||||||
|
|
||||||
cmp cl,1000b
|
cmp cl,1000b
|
||||||
je .cd
|
je .cd
|
||||||
push ecx
|
push ecx
|
||||||
mov eax,[cache_ide2_system_data_size]
|
mov eax,[cache_ide2_system_data_size]
|
||||||
call calculate_for_hd
|
call calculate_for_hd
|
||||||
@ -243,12 +244,12 @@ get_cache_ide2:
|
|||||||
add eax,[cache_ide2_data_pointer]
|
add eax,[cache_ide2_data_pointer]
|
||||||
mov [cache_ide2_appl_data],eax
|
mov [cache_ide2_appl_data],eax
|
||||||
mov [cache_ide2_appl_sad_size],ecx
|
mov [cache_ide2_appl_sad_size],ecx
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
mov edi,[cache_ide2_data_pointer]
|
mov edi,[cache_ide2_data_pointer]
|
||||||
call clear_ide_cache
|
call clear_ide_cache
|
||||||
pop edi
|
pop edi
|
||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
.cd:
|
.cd:
|
||||||
@ -269,12 +270,12 @@ get_cache_ide2:
|
|||||||
add eax,[cache_ide2_data_pointer]
|
add eax,[cache_ide2_data_pointer]
|
||||||
mov [cache_ide2_appl_data],eax
|
mov [cache_ide2_appl_data],eax
|
||||||
mov [cache_ide2_appl_sad_size],ecx
|
mov [cache_ide2_appl_sad_size],ecx
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
mov edi,[cache_ide2_data_pointer]
|
mov edi,[cache_ide2_data_pointer]
|
||||||
call clear_ide_cache
|
call clear_ide_cache
|
||||||
pop edi
|
pop edi
|
||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -292,9 +293,9 @@ get_cache_ide3:
|
|||||||
mov [cache_ide3_appl_data_size],eax
|
mov [cache_ide3_appl_data_size],eax
|
||||||
add ebx,edx
|
add ebx,edx
|
||||||
mov [cache_ide3_data_pointer],ebx
|
mov [cache_ide3_data_pointer],ebx
|
||||||
|
|
||||||
cmp cl,10b
|
cmp cl,10b
|
||||||
je .cd
|
je .cd
|
||||||
push ecx
|
push ecx
|
||||||
mov eax,[cache_ide3_system_data_size]
|
mov eax,[cache_ide3_system_data_size]
|
||||||
call calculate_for_hd
|
call calculate_for_hd
|
||||||
@ -312,12 +313,12 @@ get_cache_ide3:
|
|||||||
add eax,[cache_ide3_data_pointer]
|
add eax,[cache_ide3_data_pointer]
|
||||||
mov [cache_ide3_appl_data],eax
|
mov [cache_ide3_appl_data],eax
|
||||||
mov [cache_ide3_appl_sad_size],ecx
|
mov [cache_ide3_appl_sad_size],ecx
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
mov edi,[cache_ide3_data_pointer]
|
mov edi,[cache_ide3_data_pointer]
|
||||||
call clear_ide_cache
|
call clear_ide_cache
|
||||||
pop edi
|
pop edi
|
||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
.cd:
|
.cd:
|
||||||
@ -338,12 +339,12 @@ get_cache_ide3:
|
|||||||
add eax,[cache_ide3_data_pointer]
|
add eax,[cache_ide3_data_pointer]
|
||||||
mov [cache_ide3_appl_data],eax
|
mov [cache_ide3_appl_data],eax
|
||||||
mov [cache_ide3_appl_sad_size],ecx
|
mov [cache_ide3_appl_sad_size],ecx
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
mov edi,[cache_ide3_data_pointer]
|
mov edi,[cache_ide3_data_pointer]
|
||||||
call clear_ide_cache
|
call clear_ide_cache
|
||||||
pop edi
|
pop edi
|
||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -374,7 +375,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
|
||||||
@ -383,7 +384,7 @@ clear_ide_cache:
|
|||||||
rep stosd
|
rep stosd
|
||||||
pop eax
|
pop eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
end_get_cache:
|
end_get_cache:
|
||||||
; mov [cache_ide0_pointer],HD_CACHE
|
; mov [cache_ide0_pointer],HD_CACHE
|
||||||
; mov [cache_ide0_system_data],HD_CACHE+65536
|
; mov [cache_ide0_system_data],HD_CACHE+65536
|
||||||
|
@ -4114,6 +4114,10 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
|
|||||||
„«ο CD-―ΰ¨Ά®¤®Ά Ά αΆο§¨ α ―― ΰ β묨 ®£ΰ ¨η¥¨ο¬¨ ¤®αβγ―λ
|
„«ο CD-―ΰ¨Ά®¤®Ά Ά αΆο§¨ α ―― ΰ β묨 ®£ΰ ¨η¥¨ο¬¨ ¤®αβγ―λ
|
||||||
β®«μ<EFBFBD>® ―®¤δγ<CEB3>樨 0,1,5 ¨ 7, Άλ§®Ά ¤ΰγ£¨ε ―®¤δγ<CEB3>権 § Ά¥ΰθ¨βαο
|
β®«μ<EFBFBD>® ―®¤δγ<CEB3>樨 0,1,5 ¨ 7, Άλ§®Ά ¤ΰγ£¨ε ―®¤δγ<CEB3>権 § Ά¥ΰθ¨βαο
|
||||||
®θ¨΅<EFBFBD>®© α <20>®¤®¬ 2.
|
®θ¨΅<EFBFBD>®© α <20>®¤®¬ 2.
|
||||||
|
<EFBFBD>ਠ¯¥à¢®¬ ®¡à 饨¨ ¯®¤äãªæ¨© 0,1,5,7 ª ãáâனá⢠¬ ATAPI (CD ¨ DVD)
|
||||||
|
¯à®¨§¢®¤¨âáï ¡«®ª¨à®¢ª àã箣® ã¯à ¢«¥¨ï ¬¥å ¨§¬®¬ «®âª . <20>â® á¢ï§ ®
|
||||||
|
á «£®à¨â¬®¬ ªíè¨à®¢ ¨ï ¤ ëå ¯®«ãç¥ëå ®â ¯à¨¢®¤ . <20> §¡«®ª¨à®¢ª
|
||||||
|
¯à®¨§¢®¤¨âáï ®¡à 饨¥¬ ¯®¤äãªæ¨¥© 10 ª ᮮ⢥âáâ¢ãî饬ã ãáâனáâ¢ã.
|
||||||
|
|
||||||
======================================================================
|
======================================================================
|
||||||
= ”γ<CEB3>ζ¨ο 70, ―®¤δγ<CEB3>ζ¨ο 0 - η⥨¥ δ ©« α ―®¤¤¥ΰ¦<CEB0>®© ¤«¨λε ¨¬ρ. =
|
= ”γ<CEB3>ζ¨ο 70, ―®¤δγ<CEB3>ζ¨ο 0 - η⥨¥ δ ©« α ―®¤¤¥ΰ¦<CEB0>®© ¤«¨λε ¨¬ρ. =
|
||||||
@ -4473,6 +4477,66 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
|
|||||||
* <20>®¤¨β¥«μα<CEBC> ο ― ―<C2A0> ¤®«¦ 㦥 αγι¥αβΆ®Ά βμ.
|
* <20>®¤¨β¥«μα<CEBC> ο ― ―<C2A0> ¤®«¦ 㦥 αγι¥αβΆ®Ά βμ.
|
||||||
* …᫨ ― ―<C2A0> 㦥 αγι¥αβΆγ¥β, δγ<CEB3>ζ¨ο § Ά¥ΰθ¨βαο γα―¥θ® (eax=0).
|
* …᫨ ― ―<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> ®<> ―ΰ®£ΰ ¬¬λ. ==
|
=== ”γ<CEB3>ζ¨ο 71, ―®¤δγ<CEB3>ζ¨ο 1 - γαβ ®Ά¨βμ § £®«®Ά®<CE86> ®<> ―ΰ®£ΰ ¬¬λ. ==
|
||||||
======================================================================
|
======================================================================
|
||||||
|
@ -4075,6 +4075,10 @@ Available subfunctions:
|
|||||||
For CD-drives due to hardware limitations only subfunctions
|
For CD-drives due to hardware limitations only subfunctions
|
||||||
0,1,5 and 7 are available, other subfunctions return error
|
0,1,5 and 7 are available, other subfunctions return error
|
||||||
with code 2.
|
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. ==
|
=== Function 70, subfunction 0 - read file with long names support. ==
|
||||||
@ -4429,6 +4433,64 @@ Remarks:
|
|||||||
* The parent folder must already exist.
|
* The parent folder must already exist.
|
||||||
* If target folder already exists, function returns success (eax=0).
|
* 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. ==========
|
========== Function 71, subfunction 1 - set window caption. ==========
|
||||||
======================================================================
|
======================================================================
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -9,17 +9,17 @@ $Revision$
|
|||||||
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_1 db 0
|
||||||
IDE_Channel_2 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
|
||||||
|
|
||||||
sti
|
sti
|
||||||
call change_task
|
call change_task
|
||||||
@ -42,14 +42,14 @@ reserve_cd_channel:
|
|||||||
.IDE_Channel_1:
|
.IDE_Channel_1:
|
||||||
cli
|
cli
|
||||||
cmp [IDE_Channel_1],0
|
cmp [IDE_Channel_1],0
|
||||||
je .reserve_ok_1
|
je .reserve_ok_1
|
||||||
sti
|
sti
|
||||||
call change_task
|
call change_task
|
||||||
jmp .IDE_Channel_1
|
jmp .IDE_Channel_1
|
||||||
.IDE_Channel_2:
|
.IDE_Channel_2:
|
||||||
cli
|
cli
|
||||||
cmp [IDE_Channel_2],0
|
cmp [IDE_Channel_2],0
|
||||||
je .reserve_ok_2
|
je .reserve_ok_2
|
||||||
sti
|
sti
|
||||||
call change_task
|
call change_task
|
||||||
jmp .IDE_Channel_1
|
jmp .IDE_Channel_1
|
||||||
@ -95,7 +95,7 @@ fs_CdRead:
|
|||||||
.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
|
||||||
|
|
||||||
@ -109,19 +109,19 @@ fs_CdRead:
|
|||||||
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
|
||||||
@ -129,31 +129,31 @@ fs_CdRead:
|
|||||||
@@:
|
@@:
|
||||||
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] ; ðåàëüíûé ðàçìåð ôàéëîâîé ñåêöèè
|
||||||
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 ; ÷èòàåì ñåêòîð ôàéëà
|
||||||
cmp [DevErrorCode],0
|
cmp [DevErrorCode],0
|
||||||
jne .noaccess_3
|
jne .noaccess_3
|
||||||
add edx, 2048
|
add edx, 2048
|
||||||
@ -164,7 +164,7 @@ fs_CdRead:
|
|||||||
.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 ; ÷èòàåì ñåêòîð ôàéëà
|
||||||
cmp [DevErrorCode],0
|
cmp [DevErrorCode],0
|
||||||
jne .noaccess_3
|
jne .noaccess_3
|
||||||
push ecx
|
push ecx
|
||||||
@ -176,7 +176,7 @@ fs_CdRead:
|
|||||||
sub ecx, ebx
|
sub ecx, ebx
|
||||||
push edi esi ecx
|
push edi esi ecx
|
||||||
mov edi,edx
|
mov edi,edx
|
||||||
lea esi, [CDDataBuf + ebx]
|
lea esi, [CDDataBuf + ebx]
|
||||||
cld
|
cld
|
||||||
rep movsb
|
rep movsb
|
||||||
pop ecx esi edi
|
pop ecx esi edi
|
||||||
@ -187,15 +187,15 @@ fs_CdRead:
|
|||||||
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
|
||||||
|
|
||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
;
|
;
|
||||||
@ -213,79 +213,79 @@ fs_CdRead:
|
|||||||
;
|
;
|
||||||
;--------------------------------------------------------------
|
;--------------------------------------------------------------
|
||||||
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] ; ðàçìåð äèðåêòðîðèè
|
||||||
.doit:
|
.doit:
|
||||||
; init header
|
; init header
|
||||||
push eax ecx
|
push eax ecx
|
||||||
mov edi, edx
|
mov edi, edx
|
||||||
mov ecx, 32/4
|
mov ecx, 32/4
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
rep stosd
|
rep stosd
|
||||||
pop ecx eax
|
pop ecx eax
|
||||||
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 ; ÷èòàåì ñåêòîð äèðåêòîðèè
|
||||||
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
|
||||||
; äèðåêòîðèÿ çàêîí÷èëàñü?
|
; äèðåêòîðèÿ çàêîí÷èëàñü?
|
||||||
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]
|
||||||
sub [edx+4], edi
|
sub [edx+4], edi
|
||||||
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
|
||||||
@ -307,18 +307,18 @@ fs_CdReadFolder:
|
|||||||
; ïðîâåðêà êîíöà ôàéëà
|
; ïðîâåðêà êîíöà ôàéëà
|
||||||
mov ax,[esi]
|
mov ax,[esi]
|
||||||
cmp ax,word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
cmp ax,word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
||||||
je .cd_get_parameters_of_file_1
|
je .cd_get_parameters_of_file_1
|
||||||
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
||||||
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
|
||||||
; ïðîâåðêà êîíöà ïàïêè
|
; ïðîâåðêà êîíöà ïàïêè
|
||||||
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
|
||||||
@ -327,7 +327,7 @@ fs_CdReadFolder:
|
|||||||
|
|
||||||
.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
|
||||||
@ -344,18 +344,18 @@ fs_CdReadFolder:
|
|||||||
; ïðîâåðêà êîíöà ôàéëà
|
; ïðîâåðêà êîíöà ôàéëà
|
||||||
mov ax,[esi]
|
mov ax,[esi]
|
||||||
cmp ax,word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
cmp ax,word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
||||||
je .cd_get_parameters_of_file_2
|
je .cd_get_parameters_of_file_2
|
||||||
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
||||||
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
|
||||||
; ïðîâåðêà êîíöà ïàïêè
|
; ïðîâåðêà êîíöà ïàïêè
|
||||||
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
|
||||||
@ -364,7 +364,7 @@ fs_CdReadFolder:
|
|||||||
|
|
||||||
.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
|
||||||
@ -387,7 +387,7 @@ cd_get_parameters_of_file_1:
|
|||||||
shl eax,1
|
shl eax,1
|
||||||
; ýòî êàòàëîã?
|
; ýòî êàòàëîã?
|
||||||
test [ebp-8],byte 2
|
test [ebp-8],byte 2
|
||||||
jz .file
|
jz .file
|
||||||
inc eax
|
inc eax
|
||||||
.file:
|
.file:
|
||||||
; ìåòêà òîìà íå êàê â FAT, â ýòîì âèäå îòñóòñâóåò
|
; ìåòêà òîìà íå êàê â FAT, â ýòîì âèäå îòñóòñâóåò
|
||||||
@ -395,7 +395,7 @@ cd_get_parameters_of_file_1:
|
|||||||
shl eax,3
|
shl eax,3
|
||||||
; ôàéë ÿâëÿåòñÿ ñêðûòûì? (àòðèáóò ñóùåñòâîâàíèå)
|
; ôàéë ÿâëÿåòñÿ ñêðûòûì? (àòðèáóò ñóùåñòâîâàíèå)
|
||||||
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
|
||||||
@ -457,153 +457,168 @@ cd_get_parameters_of_file_1:
|
|||||||
;
|
;
|
||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
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
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, [cd_current_pointer_of_input]
|
mov ebp, [cd_current_pointer_of_input]
|
||||||
add ebp, 33
|
add ebp, 33
|
||||||
call cd_get_parameters_of_file_1
|
call cd_get_parameters_of_file_1
|
||||||
pop ebp
|
pop ebp
|
||||||
and dword [edi+4], 0
|
and dword [edi+4], 0
|
||||||
pop edi
|
pop edi
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
;----------------------------------------------------------------
|
||||||
|
fs_EjectDeviceTray:
|
||||||
|
call clear_CD_cache
|
||||||
|
call allow_medium_removal
|
||||||
|
call EjectMedium
|
||||||
|
ret
|
||||||
|
;----------------------------------------------------------------
|
||||||
|
fs_LoadDeviceTray:
|
||||||
|
call LoadMedium
|
||||||
|
ret
|
||||||
|
;----------------------------------------------------------------
|
||||||
|
|
||||||
cd_find_lfn:
|
cd_find_lfn:
|
||||||
|
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 ñåêòîð íà÷àëî íàáîðà äåñêðèïòîðîâ òîìîâ
|
; 16 ñåêòîð íà÷àëî íàáîðà äåñêðèïòîðîâ òîìîâ
|
||||||
mov [CDSectorAddress],dword 15
|
mov [CDSectorAddress],dword 15
|
||||||
.start:
|
|
||||||
inc dword [CDSectorAddress]
|
|
||||||
mov [CDDataBuf_pointer],CDDataBuf
|
mov [CDDataBuf_pointer],CDDataBuf
|
||||||
call ReadCDWRetr
|
call prevent_medium_removal
|
||||||
|
.start:
|
||||||
|
inc dword [CDSectorAddress]
|
||||||
|
call ReadCDWRetr ;_1
|
||||||
cmp [DevErrorCode],0
|
cmp [DevErrorCode],0
|
||||||
jne .access_denied
|
jne .access_denied
|
||||||
; ïðîâåðêà íà âøèâîñòü
|
; ïðîâåðêà íà âøèâîñòü
|
||||||
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
|
||||||
; ñåêòîð ÿâëÿåòñÿ òåðìèíàòîðîì íàáîð äåñêðèïòîðîâ òîìîâ?
|
; ñåêòîð ÿâëÿåòñÿ òåðìèíàòîðîì íàáîð äåñêðèïòîðîâ òîìîâ?
|
||||||
cmp [CDDataBuf],byte 0xff
|
cmp [CDDataBuf],byte 0xff
|
||||||
je .access_denied
|
je .access_denied
|
||||||
; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì è óëó÷øåííûì äåñêðèïòîðîì òîìà?
|
; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì è óëó÷øåííûì äåñêðèïòîðîì òîìà?
|
||||||
cmp [CDDataBuf],byte 0x2
|
cmp [CDDataBuf],byte 0x2
|
||||||
jne .start
|
jne .start
|
||||||
; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì äåñêðèïòîðîì òîìà?
|
; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì äåñêðèïòîðîì òîìà?
|
||||||
cmp [CDDataBuf+6],byte 0x1
|
cmp [CDDataBuf+6],byte 0x1
|
||||||
jne .start
|
jne .start
|
||||||
; ïàðàìåòðû root äèðåêòðîðèè
|
; ïàðàìåòðû root äèðåêòðîðèè
|
||||||
mov eax,[CDDataBuf+0x9c+2] ; íà÷àëî root äèðåêòðîðèè
|
mov eax,[CDDataBuf+0x9c+2] ; íà÷àëî root äèðåêòðîðèè
|
||||||
mov [CDSectorAddress],eax
|
mov [CDSectorAddress],eax
|
||||||
mov eax,[CDDataBuf+0x9c+10] ; ðàçìåð root äèðåêòðîðèè
|
mov eax,[CDDataBuf+0x9c+10] ; ðàçìåð root äèðåêòðîðèè
|
||||||
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
|
||||||
@@:
|
@@:
|
||||||
; íà÷èíàåì ïîèñê
|
; íà÷èíàåì ïîèñê
|
||||||
.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 ; ÷èòàåì ñåêòîð äèðåêòîðèè
|
||||||
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
|
||||||
; äèðåêòîðèÿ çàêîí÷èëàñü?
|
; äèðåêòîðèÿ çàêîí÷èëàñü?
|
||||||
cmp eax,0
|
cmp eax,0
|
||||||
ja .read_to_buffer
|
ja .read_to_buffer
|
||||||
; íåò èñêîìîãî ýëåìåíòà öåïî÷êè
|
; íåò èñêîìîãî ýëåìåíòà öåïî÷êè
|
||||||
.access_denied:
|
.access_denied:
|
||||||
pop esi eax
|
pop esi eax
|
||||||
stc
|
mov [cd_appl_data],1
|
||||||
ret
|
stc
|
||||||
|
ret
|
||||||
; èñêîìûé ýëåìåíò öåïî÷êè íàéäåí
|
; èñêîìûé ýëåìåíò öåïî÷êè íàéäåí
|
||||||
.found:
|
.found:
|
||||||
; êîíåö ïóòè ôàéëà
|
; êîíåö ïóòè ôàéëà
|
||||||
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] ; íà÷àëî äèðåêòîðèè
|
||||||
mov eax,[eax+2+8] ; ðàçìåð äèðåêòîðèè
|
mov eax,[eax+2+8] ; ðàçìåð äèðåêòîðèè
|
||||||
jmp .mainloop
|
jmp .mainloop
|
||||||
; óêàçàòåëü ôàéëà íàéäåí
|
; óêàçàòåëü ôàéëà íàéäåí
|
||||||
.done:
|
.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
|
||||||
clc
|
mov [cd_appl_data],1
|
||||||
ret
|
clc
|
||||||
|
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]
|
||||||
cmp eax,0 ; âõîäû çàêîí÷èëèñü?
|
cmp eax,0 ; âõîäû çàêîí÷èëèñü?
|
||||||
je .next_sector
|
je .next_sector
|
||||||
cmp ebp,CDDataBuf+2048 ; áóôåð çàêîí÷èëñÿ?
|
cmp ebp,CDDataBuf+2048 ; áóôåð çàêîí÷èëñÿ?
|
||||||
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 ; ñëåäóþùèé âõîä êàòàëîãà
|
||||||
add ebp,33 ; óêàçàòåëü óñòàíîâëåí íà íà÷àëî èìåíè
|
add ebp,33 ; óêàçàòåëü óñòàíîâëåí íà íà÷àëî èìåíè
|
||||||
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)
|
||||||
@ -622,7 +637,7 @@ cd_compare_name:
|
|||||||
xchg ah,al
|
xchg ah,al
|
||||||
scasw
|
scasw
|
||||||
pop eax
|
pop eax
|
||||||
je .coincides
|
je .coincides
|
||||||
call char_toupper
|
call char_toupper
|
||||||
call ansi2uni_char
|
call ansi2uni_char
|
||||||
xchg ah,al
|
xchg ah,al
|
||||||
@ -631,9 +646,9 @@ cd_compare_name:
|
|||||||
jne .name_not_coincide
|
jne .name_not_coincide
|
||||||
.coincides:
|
.coincides:
|
||||||
cmp [esi],byte '/' ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà
|
cmp [esi],byte '/' ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà
|
||||||
je .done
|
je .done
|
||||||
cmp [esi],byte 0 ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà
|
cmp [esi],byte 0 ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà
|
||||||
je .done
|
je .done
|
||||||
jmp .loop
|
jmp .loop
|
||||||
.name_not_coincide:
|
.name_not_coincide:
|
||||||
pop edi eax esi
|
pop edi eax esi
|
||||||
@ -642,13 +657,13 @@ cd_compare_name:
|
|||||||
.done:
|
.done:
|
||||||
; ïðîâåðêà êîíöà ôàéëà
|
; ïðîâåðêà êîíöà ôàéëà
|
||||||
cmp [edi],word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
cmp [edi],word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
||||||
je .done_1
|
je .done_1
|
||||||
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
||||||
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
|
||||||
; ïðîâåðêà êîíöà ïàïêè
|
; ïðîâåðêà êîíöà ïàïêè
|
||||||
movzx eax,byte [ebp-1]
|
movzx eax,byte [ebp-1]
|
||||||
add eax,ebp
|
add eax,ebp
|
||||||
@ -665,58 +680,58 @@ 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, '€'
|
cmp al, '€'
|
||||||
jb .ret
|
jb .ret
|
||||||
cmp al, '<27>'
|
cmp al, '<27>'
|
||||||
jb .rus1
|
jb .rus1
|
||||||
cmp al, 'Ÿ'
|
cmp al, 'Ÿ'
|
||||||
ja .ret
|
ja .ret
|
||||||
; 0x90-0x9F -> 0xE0-0xEF
|
; 0x90-0x9F -> 0xE0-0xEF
|
||||||
add al, 'à'-'<27>'
|
add al, 'à'-'<27>'
|
||||||
.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, 'ð'
|
mov al, 'ð'
|
||||||
jmp .doit
|
jmp .doit
|
||||||
.yo2:
|
.yo2:
|
||||||
mov al, 'ñ'
|
mov al, 'ñ'
|
||||||
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
|
||||||
|
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