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