2010-10-01 11:21:55 +02:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; ;;
|
2015-06-01 21:18:07 +02:00
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
|
;; ;;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;**********************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Непосредственная работа с устройством СD (ATAPI)
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;**********************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Автор части исходного текста Кулаков Владимир Геннадьевич
|
|
|
|
|
; Адаптация, доработка и разработка Mario79,<Lrz>
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Максимальное количество повторений операции чтения
|
2010-10-01 11:21:55 +02:00
|
|
|
|
MaxRetr equ 10
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Предельное время ожидания готовности к приему команды
|
|
|
|
|
; (в тиках)
|
2010-10-01 11:21:55 +02:00
|
|
|
|
BSYWaitTime equ 1000 ;2
|
|
|
|
|
NoTickWaitTime equ 0xfffff
|
|
|
|
|
CDBlockSize equ 2048
|
|
|
|
|
;********************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;* ЧТЕНИЕ СЕКТОРА С ПОВТОРАМИ *
|
|
|
|
|
;* Многократное повторение чтения при сбоях *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;********************************************
|
|
|
|
|
ReadCDWRetr:
|
|
|
|
|
;-----------------------------------------------------------
|
|
|
|
|
; input : eax = block to read
|
|
|
|
|
; ebx = destination
|
|
|
|
|
;-----------------------------------------------------------
|
2013-05-28 21:09:31 +02:00
|
|
|
|
pushad
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, [CDSectorAddress]
|
|
|
|
|
mov ebx, [CDDataBuf_pointer]
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call cd_calculate_cache
|
2012-03-08 09:33:38 +01:00
|
|
|
|
xor edi, edi
|
|
|
|
|
add esi, 8
|
2013-05-28 21:09:31 +02:00
|
|
|
|
inc edi
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.hdreadcache:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [esi], eax ; correct sector
|
2013-05-28 21:09:31 +02:00
|
|
|
|
je .yeshdcache
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
add esi, 8
|
2013-05-28 21:09:31 +02:00
|
|
|
|
inc edi
|
|
|
|
|
dec ecx
|
|
|
|
|
jnz .hdreadcache
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call find_empty_slot_CD_cache ; ret in edi
|
|
|
|
|
|
|
|
|
|
push edi
|
|
|
|
|
push eax
|
|
|
|
|
call cd_calculate_cache_2
|
2012-03-08 09:33:38 +01:00
|
|
|
|
shl edi, 11
|
|
|
|
|
add edi, eax
|
|
|
|
|
mov [CDDataBuf_pointer], edi
|
2013-05-28 21:09:31 +02:00
|
|
|
|
pop eax
|
|
|
|
|
pop edi
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call ReadCDWRetr_1
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [DevErrorCode], 0
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jne .exit
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [CDDataBuf_pointer], ebx
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call cd_calculate_cache_1
|
2012-03-08 09:33:38 +01:00
|
|
|
|
lea esi, [edi*8+esi]
|
|
|
|
|
mov [esi], eax ; sector number
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.yeshdcache:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov esi, edi
|
2014-12-01 04:51:07 +01:00
|
|
|
|
shl esi, 11 ;9
|
2013-05-28 21:09:31 +02:00
|
|
|
|
push eax
|
|
|
|
|
call cd_calculate_cache_2
|
2012-03-08 09:33:38 +01:00
|
|
|
|
add esi, eax
|
2013-05-28 21:09:31 +02:00
|
|
|
|
pop eax
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov edi, ebx ;[CDDataBuf_pointer]
|
|
|
|
|
mov ecx, 512 ;/4
|
2013-05-28 21:09:31 +02:00
|
|
|
|
cld
|
|
|
|
|
rep movsd ; move data
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.exit:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
popad
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
ReadCDWRetr_1:
|
|
|
|
|
pushad
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Цикл, пока команда не выполнена успешно или не
|
|
|
|
|
; исчерпано количество попыток
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov ecx, MaxRetr
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@NextRetr:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Подать команду
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;* ПОЛНОЕ ЧТЕНИЕ СЕКТОРА КОМПАКТ-ДИСКА *
|
|
|
|
|
;* Считываются данные пользователя, информация *
|
|
|
|
|
;* субканала и контрольная информация *
|
|
|
|
|
;* Входные параметры передаются через глобальные *
|
|
|
|
|
;* перменные: *
|
|
|
|
|
;* ChannelNumber - номер канала; *
|
|
|
|
|
;* DiskNumber - номер диска на канале; *
|
|
|
|
|
;* CDSectorAddress - адрес считываемого сектора. *
|
|
|
|
|
;* Данные считывается в массив CDDataBuf. *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
|
|
|
|
;ReadCD:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
push ecx
|
|
|
|
|
; Очистить буфер пакетной команды
|
|
|
|
|
call clear_packet_buffer
|
|
|
|
|
; Сформировать пакетную команду для считывания
|
|
|
|
|
; сектора данных
|
|
|
|
|
; Задать код команды Read CD
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov [PacketCommand], byte 0x28 ;0xBE
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Задать адрес сектора
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov ax, word [CDSectorAddress+2]
|
|
|
|
|
xchg al, ah
|
|
|
|
|
mov word [PacketCommand+2], ax
|
|
|
|
|
mov ax, word [CDSectorAddress]
|
|
|
|
|
xchg al, ah
|
|
|
|
|
mov word [PacketCommand+4], ax
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Задать количество считываемых секторов
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [PacketCommand+8], byte 1
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Подать команду
|
|
|
|
|
call SendPacketDatCommand
|
|
|
|
|
pop ecx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
test eax, eax
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jz @@End_4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
or ecx, ecx ;{SPraid.simba} (for cd load)
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jz @@End_4
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
dec ecx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [timer_ticks_enable], 0
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jne @f
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, NoTickWaitTime
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.wait:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
dec eax
|
|
|
|
|
jz @@NextRetr
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jmp .wait
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
loop @@NextRetr
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@End_4:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov dword [DevErrorCode], eax
|
2010-10-01 11:21:55 +02:00
|
|
|
|
popad
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Универсальные процедуры, обеспечивающие выполнение
|
|
|
|
|
; пакетных команд в режиме PIO
|
|
|
|
|
; Максимально допустимое время ожидания реакции
|
|
|
|
|
; устройства на пакетную команду (в тиках)
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2013-05-28 21:09:31 +02:00
|
|
|
|
MaxCDWaitTime equ 1000 ;200 ;10 секунд
|
2010-10-01 11:21:55 +02:00
|
|
|
|
uglobal
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Область памяти для формирования пакетной команды
|
2012-03-08 09:33:38 +01:00
|
|
|
|
PacketCommand:
|
|
|
|
|
rb 12 ;DB 12 DUP (?)
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Адрес считываемого сектора данных
|
2014-12-01 04:51:07 +01:00
|
|
|
|
CDSectorAddress: dd ?
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Время начала очередной операции с диском
|
2014-12-01 04:51:07 +01:00
|
|
|
|
TickCounter_1 dd 0
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Время начала ожидания готовности устройства
|
2014-12-01 04:51:07 +01:00
|
|
|
|
WURStartTime dd 0
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; указатель буфера для считывания
|
2010-10-01 11:21:55 +02:00
|
|
|
|
CDDataBuf_pointer dd 0
|
|
|
|
|
endg
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;****************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;* ПОСЛАТЬ УСТРОЙСТВУ ATAPI ПАКЕТНУЮ КОМАНДУ, *
|
|
|
|
|
;* ПРЕДУСМАТРИВАЮЩУЮ ПЕРЕДАЧУ ОДНОГО СЕКТОРА ДАННЫХ *
|
|
|
|
|
;* РАЗМЕРОМ 2048 БАЙТ ОТ УСТРОЙСТВА К ХОСТУ *
|
|
|
|
|
;* Входные параметры передаются через глобальные *
|
|
|
|
|
;* перменные: *
|
|
|
|
|
;* ChannelNumber - номер канала; *
|
|
|
|
|
;* DiskNumber - номер диска на канале; *
|
|
|
|
|
;* PacketCommand - 12-байтный командный пакет; *
|
|
|
|
|
;* CDBlockSize - размер принимаемого блока данных. *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; return eax DevErrorCode
|
|
|
|
|
;****************************************************
|
|
|
|
|
SendPacketDatCommand:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
xor eax, eax
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Задать режим CHS
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov byte [ATAAddressMode], al
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Послать ATA-команду передачи пакетной команды
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov byte [ATAFeatures], al
|
|
|
|
|
mov byte [ATASectorCount], al
|
|
|
|
|
mov byte [ATASectorNumber], al
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Загрузить размер передаваемого блока
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [ATAHead], al
|
|
|
|
|
mov [ATACylinder], CDBlockSize
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov [ATACommand], 0xA0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
call SendCommandToHDD_1
|
2012-03-08 09:33:38 +01:00
|
|
|
|
test eax, eax
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jnz @@End_8 ;закончить, сохранив код ошибки
|
|
|
|
|
; Ожидание готовности дисковода к приему
|
|
|
|
|
; пакетной команды
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov dx, [ATABasePortAddr]
|
|
|
|
|
add dx, 7 ;порт 1х7h
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ecx, NoTickWaitTime
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@WaitDevice0:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [timer_ticks_enable], 0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jne @f
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2010-10-01 11:21:55 +02:00
|
|
|
|
dec ecx
|
|
|
|
|
jz @@Err1_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jmp .test
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@:
|
|
|
|
|
call change_task
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Проверить время выполнения команды
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
|
sub eax, [TickCounter_1]
|
|
|
|
|
cmp eax, BSYWaitTime
|
2013-05-28 21:09:31 +02:00
|
|
|
|
ja @@Err1_1 ;ошибка тайм-аута
|
|
|
|
|
; Проверить готовность
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.test:
|
2014-12-01 04:51:07 +01:00
|
|
|
|
in al, dx
|
|
|
|
|
test al, 0x80 ;состояние сигнала BSY
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jnz @@WaitDevice0
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
|
|
|
|
test al, 1 ;состояние сигнала ERR
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jnz @@Err6
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
|
|
|
|
test al, 0x8 ;состояние сигнала DRQ
|
2011-07-22 20:08:47 +02:00
|
|
|
|
jz @@WaitDevice0
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Послать пакетную команду
|
2010-10-01 11:21:55 +02:00
|
|
|
|
cli
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov dx, [ATABasePortAddr]
|
|
|
|
|
mov ax, [PacketCommand]
|
|
|
|
|
out dx, ax
|
|
|
|
|
mov ax, [PacketCommand+2]
|
|
|
|
|
out dx, ax
|
|
|
|
|
mov ax, [PacketCommand+4]
|
|
|
|
|
out dx, ax
|
|
|
|
|
mov ax, [PacketCommand+6]
|
|
|
|
|
out dx, ax
|
|
|
|
|
mov ax, [PacketCommand+8]
|
|
|
|
|
out dx, ax
|
|
|
|
|
mov ax, [PacketCommand+10]
|
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
|
sti
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Ожидание готовности данных
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov dx, [ATABasePortAddr]
|
|
|
|
|
add dx, 7 ;порт 1х7h
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ecx, NoTickWaitTime
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@WaitDevice1:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [timer_ticks_enable], 0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jne @f
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2010-10-01 11:21:55 +02:00
|
|
|
|
dec ecx
|
|
|
|
|
jz @@Err1_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jmp .test_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@:
|
|
|
|
|
call change_task
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Проверить время выполнения команды
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
|
sub eax, [TickCounter_1]
|
|
|
|
|
cmp eax, MaxCDWaitTime
|
2013-05-28 21:09:31 +02:00
|
|
|
|
ja @@Err1_1 ;ошибка тайм-аута
|
|
|
|
|
; Проверить готовность
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.test_1:
|
2014-12-01 04:51:07 +01:00
|
|
|
|
in al, dx
|
|
|
|
|
test al, 0x80 ;состояние сигнала BSY
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jnz @@WaitDevice1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
|
|
|
|
test al, 1 ;состояние сигнала ERR
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jnz @@Err6_temp
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
|
|
|
|
test al, 0x8 ;состояние сигнала DRQ
|
2011-07-22 20:08:47 +02:00
|
|
|
|
jz @@WaitDevice1
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Принять блок данных от контроллера
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov edi, [CDDataBuf_pointer]
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Загрузить адрес регистра данных контроллера
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov dx, [ATABasePortAddr]
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Загрузить в счетчик размер блока в байтах
|
2012-03-08 09:33:38 +01:00
|
|
|
|
xor ecx, ecx
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov cx, CDBlockSize
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Вычислить размер блока в 16-разрядных словах
|
2014-12-01 04:51:07 +01:00
|
|
|
|
shr cx, 1 ;разделить размер блока на 2
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Принять блок данных
|
2010-10-01 11:21:55 +02:00
|
|
|
|
cli
|
|
|
|
|
cld
|
2013-05-28 21:09:31 +02:00
|
|
|
|
rep insw
|
2010-10-01 11:21:55 +02:00
|
|
|
|
sti
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Успешное завершение приема данных
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@End_8:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
xor eax, eax
|
2010-10-01 11:21:55 +02:00
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Записать код ошибки
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@Err1_1:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
xor eax, eax
|
2013-05-28 21:09:31 +02:00
|
|
|
|
inc eax
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@Err6_temp:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, 7
|
2013-05-28 21:09:31 +02:00
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@Err6:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, 6
|
2013-05-28 21:09:31 +02:00
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;***********************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;* ПОСЛАТЬ УСТРОЙСТВУ ATAPI ПАКЕТНУЮ КОМАНДУ, *
|
|
|
|
|
;* НЕ ПРЕДУСМАТРИВАЮЩУЮ ПЕРЕДАЧИ ДАННЫХ *
|
|
|
|
|
;* Входные параметры передаются через *
|
|
|
|
|
;* глобальные перменные: *
|
|
|
|
|
;* ChannelNumber - номер канала; *
|
|
|
|
|
;* DiskNumber - номер диска на канале; *
|
|
|
|
|
;* PacketCommand - 12-байтный командный пакет. *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;***********************************************
|
|
|
|
|
SendPacketNoDatCommand:
|
|
|
|
|
pushad
|
2012-03-08 09:33:38 +01:00
|
|
|
|
xor eax, eax
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Задать режим CHS
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov byte [ATAAddressMode], al
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Послать ATA-команду передачи пакетной команды
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov byte [ATAFeatures], al
|
|
|
|
|
mov byte [ATASectorCount], al
|
|
|
|
|
mov byte [ATASectorNumber], al
|
|
|
|
|
mov word [ATACylinder], ax
|
|
|
|
|
mov byte [ATAHead], al
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov [ATACommand], 0xA0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
call SendCommandToHDD_1
|
2012-03-08 09:33:38 +01:00
|
|
|
|
test eax, eax
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jnz @@End_9 ;закончить, сохранив код ошибки
|
|
|
|
|
; Ожидание готовности дисковода к приему
|
|
|
|
|
; пакетной команды
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov dx, [ATABasePortAddr]
|
|
|
|
|
add dx, 7 ;порт 1х7h
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@WaitDevice0_1:
|
|
|
|
|
call change_task
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Проверить время ожидания
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
|
sub eax, [TickCounter_1]
|
|
|
|
|
cmp eax, BSYWaitTime
|
2013-05-28 21:09:31 +02:00
|
|
|
|
ja @@Err1_3 ;ошибка тайм-аута
|
|
|
|
|
; Проверить готовность
|
2014-12-01 04:51:07 +01:00
|
|
|
|
in al, dx
|
|
|
|
|
test al, 0x80 ;состояние сигнала BSY
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jnz @@WaitDevice0_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
|
|
|
|
test al, 1 ;состояние сигнала ERR
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jnz @@Err6_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
|
|
|
|
test al, 0x8 ;состояние сигнала DRQ
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jz @@WaitDevice0_1
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Послать пакетную команду
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; cli
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov dx, [ATABasePortAddr]
|
|
|
|
|
mov ax, word [PacketCommand]
|
|
|
|
|
out dx, ax
|
|
|
|
|
mov ax, word [PacketCommand+2]
|
|
|
|
|
out dx, ax
|
|
|
|
|
mov ax, word [PacketCommand+4]
|
|
|
|
|
out dx, ax
|
|
|
|
|
mov ax, word [PacketCommand+6]
|
|
|
|
|
out dx, ax
|
|
|
|
|
mov ax, word [PacketCommand+8]
|
|
|
|
|
out dx, ax
|
|
|
|
|
mov ax, word [PacketCommand+10]
|
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; sti
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [ignore_CD_eject_wait], 1
|
2013-05-28 21:09:31 +02:00
|
|
|
|
je @@clear_DEC
|
|
|
|
|
; Ожидание подтверждения приема команды
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov dx, [ATABasePortAddr]
|
|
|
|
|
add dx, 7 ;порт 1х7h
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@WaitDevice1_1:
|
|
|
|
|
call change_task
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Проверить время выполнения команды
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
|
sub eax, [TickCounter_1]
|
|
|
|
|
cmp eax, MaxCDWaitTime
|
2013-05-28 21:09:31 +02:00
|
|
|
|
ja @@Err1_3 ;ошибка тайм-аута
|
|
|
|
|
; Ожидать освобождения устройства
|
2014-12-01 04:51:07 +01:00
|
|
|
|
in al, dx
|
|
|
|
|
test al, 0x80 ;состояние сигнала BSY
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jnz @@WaitDevice1_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
|
|
|
|
test al, 1 ;состояние сигнала ERR
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jnz @@Err6_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
|
|
|
|
test al, 0x40 ;состояние сигнала DRDY
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jz @@WaitDevice1_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@clear_DEC:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
and [DevErrorCode], 0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
popad
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Записать код ошибки
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@Err1_3:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
xor eax, eax
|
2013-05-28 21:09:31 +02:00
|
|
|
|
inc eax
|
|
|
|
|
jmp @@End_9
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@Err6_1:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, 6
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@End_9:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [DevErrorCode], eax
|
2010-10-01 11:21:55 +02:00
|
|
|
|
popad
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;****************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ *
|
|
|
|
|
;* Входные параметры передаются через глобальные *
|
|
|
|
|
;* переменные: *
|
|
|
|
|
;* ChannelNumber - номер канала (1 или 2); *
|
|
|
|
|
;* DiskNumber - номер диска (0 или 1); *
|
|
|
|
|
;* ATAFeatures - "особенности"; *
|
|
|
|
|
;* ATASectorCount - количество секторов; *
|
|
|
|
|
;* ATASectorNumber - номер начального сектора; *
|
|
|
|
|
;* ATACylinder - номер начального цилиндра; *
|
|
|
|
|
;* ATAHead - номер начальной головки; *
|
|
|
|
|
;* ATAAddressMode - режим адресации (0-CHS, 1-LBA); *
|
|
|
|
|
;* ATACommand - код команды. *
|
|
|
|
|
;* После успешного выполнения функции: *
|
|
|
|
|
;* в ATABasePortAddr - базовый адрес HDD; *
|
|
|
|
|
;* в DevErrorCode - ноль. *
|
|
|
|
|
;* При возникновении ошибки в DevErrorCode будет *
|
|
|
|
|
;* возвращен код ошибки в eax *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;****************************************************
|
|
|
|
|
SendCommandToHDD_1:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Проверить значение кода режима
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [ATAAddressMode], 1
|
2010-10-01 11:21:55 +02:00
|
|
|
|
ja @@Err2_4
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Проверить корректность номера канала
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov bx, [ChannelNumber]
|
|
|
|
|
cmp bx, 1
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jb @@Err3_4
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
|
|
|
|
cmp bx, 2
|
2010-10-01 11:21:55 +02:00
|
|
|
|
ja @@Err3_4
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Установить базовый адрес
|
2014-12-01 04:51:07 +01:00
|
|
|
|
dec bx
|
|
|
|
|
shl ebx, 2
|
2012-03-08 09:33:38 +01:00
|
|
|
|
movzx ebx, bx
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov eax, [cdpos]
|
|
|
|
|
dec eax
|
|
|
|
|
shr eax, 2
|
|
|
|
|
imul eax, sizeof.IDE_DATA
|
|
|
|
|
add eax, IDE_controller_1
|
|
|
|
|
add eax, ebx
|
|
|
|
|
mov ax, [eax+IDE_DATA.BAR0_val]
|
|
|
|
|
mov [ATABasePortAddr], ax
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Ожидание готовности HDD к приему команды
|
|
|
|
|
; Выбрать нужный диск
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov dx, [ATABasePortAddr]
|
|
|
|
|
add dx, 6 ;адрес регистра головок
|
|
|
|
|
mov al, [DiskNumber]
|
|
|
|
|
cmp al, 1 ;проверить номера диска
|
2010-10-01 11:21:55 +02:00
|
|
|
|
ja @@Err4_4
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
|
|
|
|
shl al, 4
|
|
|
|
|
or al, 10100000b
|
|
|
|
|
out dx, al
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Ожидать, пока диск не будет готов
|
2014-12-01 04:51:07 +01:00
|
|
|
|
inc dx
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
|
mov [TickCounter_1], eax
|
|
|
|
|
mov ecx, NoTickWaitTime
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@WaitHDReady_2:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [timer_ticks_enable], 0
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jne @f
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
dec ecx
|
|
|
|
|
jz @@Err1_4
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jmp .test
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@:
|
|
|
|
|
call change_task
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Проверить время ожидания
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
|
sub eax, [TickCounter_1]
|
2014-12-01 04:51:07 +01:00
|
|
|
|
cmp eax, BSYWaitTime ;300 ;ожидать 3 сек.
|
2013-05-28 21:09:31 +02:00
|
|
|
|
ja @@Err1_4 ;ошибка тайм-аута
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.test:
|
2014-12-01 04:51:07 +01:00
|
|
|
|
in al, dx ; Прочитать регистр состояния
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Проверить состояние сигнала BSY
|
2014-12-01 04:51:07 +01:00
|
|
|
|
test al, 0x80
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jnz @@WaitHDReady_2
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Проверить состояние сигнала DRQ
|
2014-12-01 04:51:07 +01:00
|
|
|
|
test al, 0x8
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jnz @@WaitHDReady_2
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Загрузить команду в регистры контроллера
|
2010-10-01 11:21:55 +02:00
|
|
|
|
cli
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov dx, [ATABasePortAddr]
|
|
|
|
|
inc dx ;регистр "особенностей"
|
|
|
|
|
mov al, [ATAFeatures]
|
|
|
|
|
out dx, al
|
|
|
|
|
inc dx ;счетчик секторов
|
|
|
|
|
mov al, [ATASectorCount]
|
|
|
|
|
out dx, al
|
|
|
|
|
inc dx ;регистр номера сектора
|
|
|
|
|
mov al, [ATASectorNumber]
|
|
|
|
|
out dx, al
|
|
|
|
|
inc dx ;номер цилиндра (младший байт)
|
|
|
|
|
mov ax, [ATACylinder]
|
|
|
|
|
out dx, al
|
|
|
|
|
inc dx ;номер цилиндра (старший байт)
|
|
|
|
|
mov al, ah
|
|
|
|
|
out dx, al
|
|
|
|
|
inc dx ;номер головки/номер диска
|
|
|
|
|
mov al, [DiskNumber]
|
|
|
|
|
shl al, 4
|
|
|
|
|
cmp [ATAHead], 0xF ;проверить номер головки
|
2010-10-01 11:21:55 +02:00
|
|
|
|
ja @@Err5_4
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
|
|
|
|
or al, [ATAHead]
|
|
|
|
|
or al, 10100000b
|
|
|
|
|
mov ah, [ATAAddressMode]
|
|
|
|
|
shl ah, 6
|
|
|
|
|
or al, ah
|
|
|
|
|
out dx, al
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Послать команду
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov al, [ATACommand]
|
|
|
|
|
inc dx ;регистр команд
|
|
|
|
|
out dx, al
|
2010-10-01 11:21:55 +02:00
|
|
|
|
sti
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@End_10:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
xor eax, eax
|
2013-05-28 21:09:31 +02:00
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Записать код ошибки
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@Err1_4:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
xor eax, eax
|
2013-05-28 21:09:31 +02:00
|
|
|
|
inc eax
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@Err2_4:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, 2
|
2013-05-28 21:09:31 +02:00
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@Err3_4:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, 3
|
2013-05-28 21:09:31 +02:00
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@Err4_4:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, 4
|
2013-05-28 21:09:31 +02:00
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@Err5_4:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, 5
|
2013-05-28 21:09:31 +02:00
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;* ОЖИДАНИЕ ГОТОВНОСТИ УСТРОЙСТВА К РАБОТЕ *
|
|
|
|
|
;* Входные параметры передаются через глобальные *
|
|
|
|
|
;* перменные: *
|
|
|
|
|
;* ChannelNumber - номер канала; *
|
|
|
|
|
;* DiskNumber - номер диска на канале. *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
|
|
|
|
WaitUnitReady:
|
|
|
|
|
pusha
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Запомнить время начала операции
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
|
mov [WURStartTime], eax
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Очистить буфер пакетной команды
|
|
|
|
|
call clear_packet_buffer
|
|
|
|
|
; Сформировать команду TEST UNIT READY
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov [PacketCommand], word 0
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; ЦИКЛ ОЖИДАНИЯ ГОТОВНОСТИ УСТРОЙСТВА
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ecx, NoTickWaitTime
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@SendCommand:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Подать команду проверки готовности
|
2010-10-01 11:21:55 +02:00
|
|
|
|
call SendPacketNoDatCommand
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [timer_ticks_enable], 0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jne @f
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [DevErrorCode], 0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
je @@End_11
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2010-10-01 11:21:55 +02:00
|
|
|
|
dec ecx
|
|
|
|
|
jz .Error
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jmp @@SendCommand
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@:
|
|
|
|
|
call change_task
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Проверить код ошибки
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [DevErrorCode], 0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
je @@End_11
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Проверить время ожидания готовности
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
|
sub eax, [WURStartTime]
|
|
|
|
|
cmp eax, MaxCDWaitTime
|
2010-10-01 11:21:55 +02:00
|
|
|
|
jb @@SendCommand
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.Error:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Ошибка тайм-аута
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [DevErrorCode], 1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@End_11:
|
|
|
|
|
popa
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;* ЗАПРЕТИТЬ СМЕНУ ДИСКА *
|
|
|
|
|
;* Входные параметры передаются через глобальные *
|
|
|
|
|
;* перменные: *
|
|
|
|
|
;* ChannelNumber - номер канала; *
|
|
|
|
|
;* DiskNumber - номер диска на канале. *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
|
|
|
|
prevent_medium_removal:
|
|
|
|
|
pusha
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Очистить буфер пакетной команды
|
|
|
|
|
call clear_packet_buffer
|
|
|
|
|
; Задать код команды
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [PacketCommand], byte 0x1E
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Задать код запрета
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [PacketCommand+4], byte 11b
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Подать команду
|
|
|
|
|
call SendPacketNoDatCommand
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, ATAPI_IDE0_lock
|
|
|
|
|
add eax, [cdpos]
|
2013-05-28 21:09:31 +02:00
|
|
|
|
dec eax
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [eax], byte 1
|
2010-10-01 11:21:55 +02:00
|
|
|
|
popa
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;* РАЗРЕШИТЬ СМЕНУ ДИСКА *
|
|
|
|
|
;* Входные параметры передаются через глобальные *
|
|
|
|
|
;* перменные: *
|
|
|
|
|
;* ChannelNumber - номер канала; *
|
|
|
|
|
;* DiskNumber - номер диска на канале. *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
|
|
|
|
allow_medium_removal:
|
|
|
|
|
pusha
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Очистить буфер пакетной команды
|
|
|
|
|
call clear_packet_buffer
|
|
|
|
|
; Задать код команды
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [PacketCommand], byte 0x1E
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Задать код запрета
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov [PacketCommand+4], byte 0
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Подать команду
|
|
|
|
|
call SendPacketNoDatCommand
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, ATAPI_IDE0_lock
|
|
|
|
|
add eax, [cdpos]
|
2013-05-28 21:09:31 +02:00
|
|
|
|
dec eax
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [eax], byte 0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
popa
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;* ЗАГРУЗИТЬ НОСИТЕЛЬ В ДИСКОВОД *
|
|
|
|
|
;* Входные параметры передаются через глобальные *
|
|
|
|
|
;* перменные: *
|
|
|
|
|
;* ChannelNumber - номер канала; *
|
|
|
|
|
;* DiskNumber - номер диска на канале. *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
|
|
|
|
LoadMedium:
|
|
|
|
|
pusha
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Очистить буфер пакетной команды
|
|
|
|
|
call clear_packet_buffer
|
|
|
|
|
; Сформировать команду START/STOP UNIT
|
|
|
|
|
; Задать код команды
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov [PacketCommand], word 0x1B
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Задать операцию загрузки носителя
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [PacketCommand+4], word 00000011b
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Подать команду
|
2010-10-01 11:21:55 +02:00
|
|
|
|
call SendPacketNoDatCommand
|
|
|
|
|
popa
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;* ИЗВЛЕЧЬ НОСИТЕЛЬ ИЗ ДИСКОВОДА *
|
|
|
|
|
;* Входные параметры передаются через глобальные *
|
|
|
|
|
;* перменные: *
|
|
|
|
|
;* ChannelNumber - номер канала; *
|
|
|
|
|
;* DiskNumber - номер диска на канале. *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
|
|
|
|
EjectMedium:
|
|
|
|
|
pusha
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Очистить буфер пакетной команды
|
|
|
|
|
call clear_packet_buffer
|
|
|
|
|
; Сформировать команду START/STOP UNIT
|
|
|
|
|
; Задать код команды
|
2014-12-01 04:51:07 +01:00
|
|
|
|
mov [PacketCommand], word 0x1B
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Задать операцию извлечения носителя
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [PacketCommand+4], word 00000010b
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Подать команду
|
2010-10-01 11:21:55 +02:00
|
|
|
|
call SendPacketNoDatCommand
|
|
|
|
|
popa
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;* Проверить событие нажатия кнопки извлечения *
|
|
|
|
|
;* диска *
|
|
|
|
|
;* Входные параметры передаются через глобальные *
|
|
|
|
|
;* переменные: *
|
|
|
|
|
;* ChannelNumber - номер канала; *
|
|
|
|
|
;* DiskNumber - номер диска на канале. *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
proc check_ATAPI_device_event_has_work?
|
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
|
sub eax, [timer_ATAPI_check]
|
|
|
|
|
cmp eax, 100
|
|
|
|
|
jb .no
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
xor eax, eax
|
|
|
|
|
inc eax
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2013-05-28 21:09:31 +02:00
|
|
|
|
.no:
|
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
|
|
|
|
endp
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
align 4
|
|
|
|
|
check_ATAPI_device_event:
|
|
|
|
|
pusha
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
|
sub eax, [timer_ATAPI_check]
|
|
|
|
|
cmp eax, 100
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jb .end_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
|
|
|
|
pushfd
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov al, [DRIVE_DATA+1]
|
|
|
|
|
and al, 11b
|
|
|
|
|
cmp al, 10b
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jz .ide3
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.ide2_1:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov al, [DRIVE_DATA+1]
|
|
|
|
|
and al, 1100b
|
|
|
|
|
cmp al, 1000b
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jz .ide2
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.ide1_1:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov al, [DRIVE_DATA+1]
|
|
|
|
|
and al, 110000b
|
|
|
|
|
cmp al, 100000b
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jz .ide1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.ide0_1:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov al, [DRIVE_DATA+1]
|
|
|
|
|
and al, 11000000b
|
|
|
|
|
cmp al, 10000000b
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jz .ide0
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
.ide7_1:
|
|
|
|
|
mov al, [DRIVE_DATA+6]
|
|
|
|
|
and al, 11b
|
|
|
|
|
cmp al, 10b
|
|
|
|
|
jz .ide7
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
.ide6_1:
|
|
|
|
|
mov al, [DRIVE_DATA+6]
|
|
|
|
|
and al, 1100b
|
|
|
|
|
cmp al, 1000b
|
|
|
|
|
jz .ide6
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
.ide5_1:
|
|
|
|
|
mov al, [DRIVE_DATA+6]
|
|
|
|
|
and al, 110000b
|
|
|
|
|
cmp al, 100000b
|
|
|
|
|
jz .ide5
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
.ide4_1:
|
|
|
|
|
mov al, [DRIVE_DATA+6]
|
|
|
|
|
and al, 11000000b
|
|
|
|
|
cmp al, 10000000b
|
|
|
|
|
jz .ide4
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
.ide11_1:
|
|
|
|
|
mov al, [DRIVE_DATA+11]
|
|
|
|
|
and al, 11b
|
|
|
|
|
cmp al, 10b
|
|
|
|
|
jz .ide11
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
.ide10_1:
|
|
|
|
|
mov al, [DRIVE_DATA+11]
|
|
|
|
|
and al, 1100b
|
|
|
|
|
cmp al, 1000b
|
|
|
|
|
jz .ide10
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
.ide9_1:
|
|
|
|
|
mov al, [DRIVE_DATA+11]
|
|
|
|
|
and al, 110000b
|
|
|
|
|
cmp al, 100000b
|
|
|
|
|
jz .ide9
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
.ide8_1:
|
|
|
|
|
mov al, [DRIVE_DATA+11]
|
|
|
|
|
and al, 11000000b
|
|
|
|
|
cmp al, 10000000b
|
|
|
|
|
jz .ide8
|
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.end:
|
2014-12-01 04:51:07 +01:00
|
|
|
|
popfd
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
|
mov [timer_ATAPI_check], eax
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.end_1:
|
|
|
|
|
popa
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.ide3:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
cli
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [ATAPI_IDE3_lock], 1
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jne .ide2_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [cd_status], 0
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jne .end
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2013-09-14 20:55:13 +02:00
|
|
|
|
mov ecx, ide_channel2_mutex
|
|
|
|
|
call mutex_lock
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call reserve_ok2
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [ChannelNumber], 2
|
|
|
|
|
mov [DiskNumber], 1
|
|
|
|
|
mov [cdpos], 4
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call GetEvent_StatusNotification
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [CDDataBuf+4], byte 1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
jne @f
|
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call .eject
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call syscall_cdaudio.free
|
|
|
|
|
jmp .ide2_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.ide2:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
cli
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [ATAPI_IDE2_lock], 1
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jne .ide1_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [cd_status], 0
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jne .end
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2013-09-14 20:55:13 +02:00
|
|
|
|
mov ecx, ide_channel2_mutex
|
|
|
|
|
call mutex_lock
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call reserve_ok2
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [ChannelNumber], 2
|
|
|
|
|
mov [DiskNumber], 0
|
|
|
|
|
mov [cdpos], 3
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call GetEvent_StatusNotification
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [CDDataBuf+4], byte 1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
jne @f
|
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call .eject
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call syscall_cdaudio.free
|
|
|
|
|
jmp .ide1_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.ide1:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
cli
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [ATAPI_IDE1_lock], 1
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jne .ide0_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [cd_status], 0
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jne .end
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2013-09-14 20:55:13 +02:00
|
|
|
|
mov ecx, ide_channel1_mutex
|
|
|
|
|
call mutex_lock
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call reserve_ok2
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [ChannelNumber], 1
|
|
|
|
|
mov [DiskNumber], 1
|
|
|
|
|
mov [cdpos], 2
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call GetEvent_StatusNotification
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [CDDataBuf+4], byte 1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
jne @f
|
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call .eject
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call syscall_cdaudio.free
|
|
|
|
|
jmp .ide0_1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.ide0:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
cli
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [ATAPI_IDE0_lock], 1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
jne .ide7_1
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [cd_status], 0
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jne .end
|
2014-12-01 04:51:07 +01:00
|
|
|
|
|
2013-09-14 20:55:13 +02:00
|
|
|
|
mov ecx, ide_channel1_mutex
|
|
|
|
|
call mutex_lock
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call reserve_ok2
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [ChannelNumber], 1
|
|
|
|
|
mov [DiskNumber], 0
|
|
|
|
|
mov [cdpos], 1
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call GetEvent_StatusNotification
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [CDDataBuf+4], byte 1
|
2014-12-01 04:51:07 +01:00
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
|
|
call .eject
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call syscall_cdaudio.free
|
2014-12-01 04:51:07 +01:00
|
|
|
|
jmp .ide7_1
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
.ide7:
|
|
|
|
|
cli
|
|
|
|
|
cmp [ATAPI_IDE7_lock], 1
|
|
|
|
|
jne .ide6_1
|
|
|
|
|
|
|
|
|
|
cmp [cd_status], 0
|
|
|
|
|
jne .end
|
|
|
|
|
|
|
|
|
|
mov ecx, ide_channel4_mutex
|
|
|
|
|
call mutex_lock
|
|
|
|
|
call reserve_ok2
|
|
|
|
|
mov [ChannelNumber], 2
|
|
|
|
|
mov [DiskNumber], 1
|
|
|
|
|
mov [cdpos], 8
|
|
|
|
|
call GetEvent_StatusNotification
|
|
|
|
|
cmp [CDDataBuf+4], byte 1
|
|
|
|
|
jne @f
|
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call .eject
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call syscall_cdaudio.free
|
2014-12-01 04:51:07 +01:00
|
|
|
|
jmp .ide6_1
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
.ide6:
|
|
|
|
|
cli
|
|
|
|
|
cmp [ATAPI_IDE6_lock], 1
|
|
|
|
|
jne .ide5_1
|
|
|
|
|
|
|
|
|
|
cmp [cd_status], 0
|
|
|
|
|
jne .end
|
|
|
|
|
|
|
|
|
|
mov ecx, ide_channel4_mutex
|
|
|
|
|
call mutex_lock
|
|
|
|
|
call reserve_ok2
|
|
|
|
|
mov [ChannelNumber], 2
|
|
|
|
|
mov [DiskNumber], 0
|
|
|
|
|
mov [cdpos], 7
|
|
|
|
|
call GetEvent_StatusNotification
|
|
|
|
|
cmp [CDDataBuf+4], byte 1
|
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
|
|
call .eject
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
call syscall_cdaudio.free
|
|
|
|
|
jmp .ide5_1
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
.ide5:
|
|
|
|
|
cli
|
|
|
|
|
cmp [ATAPI_IDE5_lock], 1
|
|
|
|
|
jne .ide4_1
|
|
|
|
|
|
|
|
|
|
cmp [cd_status], 0
|
|
|
|
|
jne .end
|
|
|
|
|
|
|
|
|
|
mov ecx, ide_channel3_mutex
|
|
|
|
|
call mutex_lock
|
|
|
|
|
call reserve_ok2
|
|
|
|
|
mov [ChannelNumber], 1
|
|
|
|
|
mov [DiskNumber], 1
|
|
|
|
|
mov [cdpos], 6
|
|
|
|
|
call GetEvent_StatusNotification
|
|
|
|
|
cmp [CDDataBuf+4], byte 1
|
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
|
|
call .eject
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
call syscall_cdaudio.free
|
|
|
|
|
jmp .ide4_1
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
.ide4:
|
|
|
|
|
cli
|
|
|
|
|
cmp [ATAPI_IDE4_lock], 1
|
|
|
|
|
jne .ide11_1
|
|
|
|
|
|
|
|
|
|
cmp [cd_status], 0
|
|
|
|
|
jne .end
|
|
|
|
|
|
|
|
|
|
mov ecx, ide_channel3_mutex
|
|
|
|
|
call mutex_lock
|
|
|
|
|
call reserve_ok2
|
|
|
|
|
mov [ChannelNumber], 1
|
|
|
|
|
mov [DiskNumber], 0
|
|
|
|
|
mov [cdpos], 5
|
|
|
|
|
call GetEvent_StatusNotification
|
|
|
|
|
cmp [CDDataBuf+4], byte 1
|
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
|
|
call .eject
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
call syscall_cdaudio.free
|
|
|
|
|
jmp .ide11_1
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
.ide11:
|
|
|
|
|
cli
|
|
|
|
|
cmp [ATAPI_IDE11_lock], 1
|
|
|
|
|
jne .ide10_1
|
|
|
|
|
|
|
|
|
|
cmp [cd_status], 0
|
|
|
|
|
jne .end
|
|
|
|
|
|
|
|
|
|
mov ecx, ide_channel6_mutex
|
|
|
|
|
call mutex_lock
|
|
|
|
|
call reserve_ok2
|
|
|
|
|
mov [ChannelNumber], 2
|
|
|
|
|
mov [DiskNumber], 1
|
|
|
|
|
mov [cdpos], 12
|
|
|
|
|
call GetEvent_StatusNotification
|
|
|
|
|
cmp [CDDataBuf+4], byte 1
|
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
|
|
call .eject
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
call syscall_cdaudio.free
|
|
|
|
|
jmp .ide10_1
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
.ide10:
|
|
|
|
|
cli
|
|
|
|
|
cmp [ATAPI_IDE10_lock], 1
|
|
|
|
|
jne .ide9_1
|
|
|
|
|
|
|
|
|
|
cmp [cd_status], 0
|
|
|
|
|
jne .end
|
|
|
|
|
|
|
|
|
|
mov ecx, ide_channel6_mutex
|
|
|
|
|
call mutex_lock
|
|
|
|
|
call reserve_ok2
|
|
|
|
|
mov [ChannelNumber], 2
|
|
|
|
|
mov [DiskNumber], 0
|
|
|
|
|
mov [cdpos], 11
|
|
|
|
|
call GetEvent_StatusNotification
|
|
|
|
|
cmp [CDDataBuf+4], byte 1
|
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
|
|
call .eject
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
call syscall_cdaudio.free
|
|
|
|
|
jmp .ide9_1
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
.ide9:
|
|
|
|
|
cli
|
|
|
|
|
cmp [ATAPI_IDE9_lock], 1
|
|
|
|
|
jne .ide8_1
|
|
|
|
|
|
|
|
|
|
cmp [cd_status], 0
|
|
|
|
|
jne .end
|
|
|
|
|
|
|
|
|
|
mov ecx, ide_channel5_mutex
|
|
|
|
|
call mutex_lock
|
|
|
|
|
call reserve_ok2
|
|
|
|
|
mov [ChannelNumber], 1
|
|
|
|
|
mov [DiskNumber], 1
|
|
|
|
|
mov [cdpos], 10
|
|
|
|
|
call GetEvent_StatusNotification
|
|
|
|
|
cmp [CDDataBuf+4], byte 1
|
|
|
|
|
jne @f
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2014-12-01 04:51:07 +01:00
|
|
|
|
call .eject
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
call syscall_cdaudio.free
|
|
|
|
|
jmp .ide8_1
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
.ide8:
|
|
|
|
|
cli
|
|
|
|
|
cmp [ATAPI_IDE8_lock], 1
|
|
|
|
|
jne .end
|
|
|
|
|
|
|
|
|
|
cmp [cd_status], 0
|
|
|
|
|
jne .end
|
|
|
|
|
|
|
|
|
|
mov ecx, ide_channel5_mutex
|
|
|
|
|
call mutex_lock
|
|
|
|
|
call reserve_ok2
|
|
|
|
|
mov [ChannelNumber], 1
|
|
|
|
|
mov [DiskNumber], 0
|
|
|
|
|
mov [cdpos], 9
|
|
|
|
|
call GetEvent_StatusNotification
|
|
|
|
|
cmp [CDDataBuf+4], byte 1
|
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
|
|
call .eject
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
call syscall_cdaudio.free
|
|
|
|
|
jmp .end
|
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.eject:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call clear_CD_cache
|
|
|
|
|
call allow_medium_removal
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [ignore_CD_eject_wait], 1
|
2013-05-28 21:09:31 +02:00
|
|
|
|
call EjectMedium
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [ignore_CD_eject_wait], 0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
iglobal
|
|
|
|
|
timer_ATAPI_check dd 0
|
|
|
|
|
ATAPI_IDE0_lock db 0
|
|
|
|
|
ATAPI_IDE1_lock db 0
|
|
|
|
|
ATAPI_IDE2_lock db 0
|
|
|
|
|
ATAPI_IDE3_lock db 0
|
2014-12-01 04:51:07 +01:00
|
|
|
|
ATAPI_IDE4_lock db 0
|
|
|
|
|
ATAPI_IDE5_lock db 0
|
|
|
|
|
ATAPI_IDE6_lock db 0
|
|
|
|
|
ATAPI_IDE7_lock db 0
|
|
|
|
|
ATAPI_IDE8_lock db 0
|
|
|
|
|
ATAPI_IDE9_lock db 0
|
|
|
|
|
ATAPI_IDE10_lock db 0
|
|
|
|
|
ATAPI_IDE11_lock db 0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
ignore_CD_eject_wait db 0
|
|
|
|
|
endg
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;* Получить сообщение о событии или состоянии *
|
|
|
|
|
;* устройства *
|
|
|
|
|
;* Входные параметры передаются через глобальные *
|
|
|
|
|
;* переменные: *
|
|
|
|
|
;* ChannelNumber - номер канала; *
|
|
|
|
|
;* DiskNumber - номер диска на канале. *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
|
|
|
|
GetEvent_StatusNotification:
|
|
|
|
|
pusha
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [CDDataBuf_pointer], CDDataBuf
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Очистить буфер пакетной команды
|
|
|
|
|
call clear_packet_buffer
|
|
|
|
|
; Задать код команды
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [PacketCommand], byte 4Ah
|
|
|
|
|
mov [PacketCommand+1], byte 00000001b
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Задать запрос класса сообщений
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [PacketCommand+4], byte 00010000b
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Размер выделенной области
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [PacketCommand+7], byte 8h
|
|
|
|
|
mov [PacketCommand+8], byte 0h
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Подать команду
|
2010-10-01 11:21:55 +02:00
|
|
|
|
call SendPacketDatCommand
|
|
|
|
|
popa
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; прочитать информацию из TOC
|
|
|
|
|
;* Входные параметры передаются через глобальные *
|
|
|
|
|
;* переменные: *
|
|
|
|
|
;* ChannelNumber - номер канала; *
|
|
|
|
|
;* DiskNumber - номер диска на канале. *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
|
|
|
|
Read_TOC:
|
|
|
|
|
pusha
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [CDDataBuf_pointer], CDDataBuf
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Очистить буфер пакетной команды
|
|
|
|
|
call clear_packet_buffer
|
|
|
|
|
; Сформировать пакетную команду для считывания
|
|
|
|
|
; сектора данных
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [PacketCommand], byte 0x43
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Задать формат
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [PacketCommand+2], byte 1
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Размер выделенной области
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [PacketCommand+7], byte 0xFF
|
|
|
|
|
mov [PacketCommand+8], byte 0h
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Подать команду
|
|
|
|
|
call SendPacketDatCommand
|
2010-10-01 11:21:55 +02:00
|
|
|
|
popa
|
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;* ОПРЕДЕЛИТЬ ОБЩЕЕ КОЛИЧЕСТВО СЕКТОРОВ НА ДИСКЕ *
|
|
|
|
|
;* Входные параметры передаются через глобальные *
|
|
|
|
|
;* переменные: *
|
|
|
|
|
;* ChannelNumber - номер канала; *
|
|
|
|
|
;* DiskNumber - номер диска на канале. *
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;*************************************************
|
|
|
|
|
;ReadCapacity:
|
|
|
|
|
; pusha
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;; Очистить буфер пакетной команды
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; call clear_packet_buffer
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;; Задать размер буфера в байтах
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; mov [CDBlockSize],8
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;; Сформировать команду READ CAPACITY
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; mov [PacketCommand],word 25h
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;; Подать команду
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; call SendPacketDatCommand
|
|
|
|
|
; popa
|
|
|
|
|
; ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
|
clear_packet_buffer:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; Очистить буфер пакетной команды
|
2012-03-08 09:33:38 +01:00
|
|
|
|
and [PacketCommand], dword 0
|
|
|
|
|
and [PacketCommand+4], dword 0
|
|
|
|
|
and [PacketCommand+8], dword 0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
ret
|
2014-12-01 04:51:07 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|