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