2011-10-14 23:38:50 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2024-05-22 17:15:14 +02:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
|
2011-10-14 23:38:50 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
;**********************************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
; Direct work with CD (ATAPI) device
|
2011-10-14 23:38:50 +02:00
|
|
|
;**********************************************************
|
2020-07-16 21:31:16 +02:00
|
|
|
; Author of a part of the source code - Kulakov Vladimir Gennadievich
|
|
|
|
; Adaptation, revision and development - Mario79, <Lrz>
|
2011-10-14 23:38:50 +02:00
|
|
|
|
2020-07-16 21:31:16 +02:00
|
|
|
; Maximum number of repeats of a read operation
|
2017-12-20 02:07:10 +01:00
|
|
|
MaxRetr = 10
|
2020-07-16 21:31:16 +02:00
|
|
|
; Maximum waiting time for ready to receive a command
|
|
|
|
; (in ticks)
|
2017-12-20 02:07:10 +01:00
|
|
|
BSYWaitTime = 1000 ;2
|
|
|
|
NoTickWaitTime = 0xfffff
|
|
|
|
CDBlockSize = 2048
|
2011-10-14 23:38:50 +02:00
|
|
|
;********************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
;* READING SECTOR WITH REPEATS *
|
|
|
|
;* Repeated reads on failures *
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
; Loop until the command is successful or the number of attempts is over
|
2014-03-27 21:44:32 +01:00
|
|
|
mov ecx, MaxRetr
|
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
@@NextRetr:
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send a command
|
2011-10-14 23:38:50 +02:00
|
|
|
;*************************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
;* FULL READ OF COMPACT DISK SECTOR *
|
|
|
|
;* User data, subchannel *
|
|
|
|
;* information and control information are read *
|
|
|
|
;* Input parameters are passed through global *
|
|
|
|
;* variables: *
|
|
|
|
;* ChannelNumber - channel number; *
|
|
|
|
;* DiskNumber - disc number on channel; *
|
|
|
|
;* CDSectorAddress - address of reading sector. *
|
|
|
|
;* The data is read into the CDDataBuf array. *
|
2011-10-14 23:38:50 +02:00
|
|
|
;*************************************************
|
|
|
|
;ReadCD:
|
|
|
|
push ecx
|
2020-07-31 00:28:57 +02:00
|
|
|
; Flush the packet command buffer
|
2011-10-14 23:38:50 +02:00
|
|
|
call clear_packet_buffer
|
2020-07-31 00:28:57 +02:00
|
|
|
; Generate a packet command to read a data sector
|
|
|
|
; Set the command code Read CD
|
2014-03-27 21:44:32 +01:00
|
|
|
mov [PacketCommand], byte 0x28 ;0xBE
|
2020-07-31 00:28:57 +02:00
|
|
|
; Set the sector address
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
; Set the number of sectors to read
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [PacketCommand+8], byte 1
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send a command
|
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
|
|
|
;-----------------------------------------------------------------------------
|
2020-07-31 00:28:57 +02:00
|
|
|
; General purpose procedures to execute packet commands in PIO Mode
|
|
|
|
; Maximum allowable waiting time for the device to respond to a packet command (in ticks)
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2020-07-31 00:28:57 +02:00
|
|
|
MaxCDWaitTime = 1000 ;200 ;10 seconds
|
2011-10-14 23:38:50 +02:00
|
|
|
uglobal
|
2020-07-31 00:28:57 +02:00
|
|
|
; Memory area for generating a packet command
|
2011-10-14 23:38:50 +02:00
|
|
|
PacketCommand:
|
|
|
|
rb 12 ;DB 12 DUP (?)
|
2020-07-31 00:28:57 +02:00
|
|
|
; address of reading data sector
|
2014-03-27 21:44:32 +01:00
|
|
|
CDSectorAddress: dd ?
|
2020-07-31 00:28:57 +02:00
|
|
|
; Start time of the next disk operation
|
2014-03-27 21:44:32 +01:00
|
|
|
TickCounter_1 dd 0
|
2020-07-31 00:28:57 +02:00
|
|
|
; Time to start waiting for device readiness
|
2014-03-27 21:44:32 +01:00
|
|
|
WURStartTime dd 0
|
2020-07-31 00:28:57 +02:00
|
|
|
; pointer to buffer to read data into
|
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
|
|
|
;****************************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
;* SEND TO ATAPI DEVICE PACKET COMMAND, *
|
|
|
|
;* THAT MEANS TRASMIT ONE DATA SECTOR OF SIZE *
|
|
|
|
;* 2048 BYTE FROM DEVICE TO HOST *
|
|
|
|
;* Input parameters are passed through global *
|
|
|
|
;* variables: *
|
|
|
|
;* ChannelNumber - channel number; *
|
|
|
|
;* DiskNumber - disk number on channel. *
|
|
|
|
;* PacketCommand - 12-byte command packet; *
|
|
|
|
;* CDBlockSize - size of receiving data block. *
|
2011-10-14 23:38:50 +02:00
|
|
|
; return eax DevErrorCode
|
|
|
|
;****************************************************
|
|
|
|
SendPacketDatCommand:
|
|
|
|
xor eax, eax
|
2020-07-31 00:28:57 +02:00
|
|
|
; Set CHS mode
|
2011-10-14 23:38:50 +02:00
|
|
|
mov byte [ATAAddressMode], al
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send ATA command to send packet command
|
2011-10-14 23:38:50 +02:00
|
|
|
mov byte [ATAFeatures], al
|
|
|
|
mov byte [ATASectorCount], al
|
|
|
|
mov byte [ATASectorNumber], al
|
2020-07-31 00:28:57 +02:00
|
|
|
; Load the size of the sending block
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
jnz @@End_8 ; finish, saving the error code
|
|
|
|
; Waiting for the drive to be ready to receive a packet command
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ATABasePortAddr]
|
2020-07-31 00:28:57 +02:00
|
|
|
add dx, 7 ; port 1x7h
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
; Check command execution time
|
2014-03-27 21:44:32 +01:00
|
|
|
mov eax, [timer_ticks]
|
|
|
|
sub eax, [TickCounter_1]
|
|
|
|
cmp eax, BSYWaitTime
|
2020-07-31 00:28:57 +02:00
|
|
|
ja @@Err1_1 ; time out error
|
|
|
|
; Check readiness
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
test al, 0x80 ; BSY signal state
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @@WaitDevice0
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2020-07-31 00:28:57 +02:00
|
|
|
test al, 1 ; ERR signal state
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @@Err6
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2020-07-31 00:28:57 +02:00
|
|
|
test al, 0x8 ; DRQ signal state
|
2011-10-14 23:38:50 +02:00
|
|
|
jz @@WaitDevice0
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send a packet command
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
; Waiting for data to be ready
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ATABasePortAddr]
|
2020-07-31 00:28:57 +02:00
|
|
|
add dx, 7 ; port 1x7h
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
; Check command execution time
|
2014-03-27 21:44:32 +01:00
|
|
|
mov eax, [timer_ticks]
|
|
|
|
sub eax, [TickCounter_1]
|
|
|
|
cmp eax, MaxCDWaitTime
|
2020-07-31 00:28:57 +02:00
|
|
|
ja @@Err1_1 ; time out error
|
|
|
|
; Check readiness
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
test al, 0x80 ; BSY signal state
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @@WaitDevice1
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2020-07-31 00:28:57 +02:00
|
|
|
test al, 1 ; ERR signal state
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @@Err6_temp
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2020-07-31 00:28:57 +02:00
|
|
|
test al, 0x8 ; DRQ signal state
|
2011-10-14 23:38:50 +02:00
|
|
|
jz @@WaitDevice1
|
2020-07-31 00:28:57 +02:00
|
|
|
; Receive data block from controller
|
2014-03-27 21:44:32 +01:00
|
|
|
mov edi, [CDDataBuf_pointer]
|
2020-07-31 00:28:57 +02:00
|
|
|
; Load controller's data register address
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ATABasePortAddr]
|
2020-07-31 00:28:57 +02:00
|
|
|
; Load the block size in bytes into the counter
|
2011-10-14 23:38:50 +02:00
|
|
|
xor ecx, ecx
|
2014-03-27 21:44:32 +01:00
|
|
|
mov cx, CDBlockSize
|
2020-07-31 00:28:57 +02:00
|
|
|
; Calculate block size in 16-bit words
|
|
|
|
shr cx, 1 ; divide block size by 2
|
|
|
|
; Receive data block
|
2011-10-14 23:38:50 +02:00
|
|
|
cli
|
|
|
|
cld
|
|
|
|
rep insw
|
|
|
|
sti
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2020-07-31 00:28:57 +02:00
|
|
|
; Successful completion of data receive
|
2011-10-14 23:38:50 +02:00
|
|
|
@@End_8:
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2020-07-31 00:28:57 +02:00
|
|
|
; Write error code
|
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
|
|
|
;***********************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
;* SEND TO ATAPI DEVICE PACKET COMMAND, *
|
|
|
|
;* THAT DOESNT MEAN TRANSMIT DATA *
|
|
|
|
;* Input parameters are passed through global *
|
|
|
|
;* variables: *
|
|
|
|
;* ChannelNumber - channel number; *
|
|
|
|
;* DiskNumber - disk number on channel. *
|
|
|
|
;* PacketCommand - 12-byte command packet. *
|
2011-10-14 23:38:50 +02:00
|
|
|
;***********************************************
|
|
|
|
SendPacketNoDatCommand:
|
|
|
|
pushad
|
|
|
|
xor eax, eax
|
2020-07-31 00:28:57 +02:00
|
|
|
; Set CHS mode
|
2011-10-14 23:38:50 +02:00
|
|
|
mov byte [ATAAddressMode], al
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send ATA command to send packet command
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
jnz @@End_9 ; finish, saving the error code
|
|
|
|
; Waiting for the drive to be ready to receive a packet command
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ATABasePortAddr]
|
2020-07-31 00:28:57 +02:00
|
|
|
add dx, 7 ; port 1x7h
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
@@WaitDevice0_1:
|
|
|
|
call change_task
|
2020-07-31 00:28:57 +02:00
|
|
|
; Check waiting time
|
2014-03-27 21:44:32 +01:00
|
|
|
mov eax, [timer_ticks]
|
|
|
|
sub eax, [TickCounter_1]
|
|
|
|
cmp eax, BSYWaitTime
|
2020-07-31 00:28:57 +02:00
|
|
|
ja @@Err1_3 ; time out error
|
|
|
|
; Check readiness
|
2014-03-27 21:44:32 +01:00
|
|
|
in al, dx
|
2020-07-31 00:28:57 +02:00
|
|
|
test al, 0x80 ; BSY signal state
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @@WaitDevice0_1
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2020-07-31 00:28:57 +02:00
|
|
|
test al, 1 ; ERR signal state
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @@Err6_1
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2020-07-31 00:28:57 +02:00
|
|
|
test al, 0x8 ; DRQ signal state
|
2011-10-14 23:38:50 +02:00
|
|
|
jz @@WaitDevice0_1
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send packet command
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
; Waiting for confirmation of command receive
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ATABasePortAddr]
|
2020-07-31 00:28:57 +02:00
|
|
|
add dx, 7 ; port 1x7h
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
@@WaitDevice1_1:
|
|
|
|
call change_task
|
2020-07-31 00:28:57 +02:00
|
|
|
; Check command execution time
|
2014-03-27 21:44:32 +01:00
|
|
|
mov eax, [timer_ticks]
|
|
|
|
sub eax, [TickCounter_1]
|
|
|
|
cmp eax, MaxCDWaitTime
|
2020-07-31 00:28:57 +02:00
|
|
|
ja @@Err1_3 ; time out error
|
|
|
|
; Wait for device release
|
2014-03-27 21:44:32 +01:00
|
|
|
in al, dx
|
2020-07-31 00:28:57 +02:00
|
|
|
test al, 0x80 ; BSY signal state
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @@WaitDevice1_1
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2020-07-31 00:28:57 +02:00
|
|
|
test al, 1 ; ERR signal state
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @@Err6_1
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2020-07-31 00:28:57 +02:00
|
|
|
test al, 0x40 ; DRDY signal state
|
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
|
|
|
;--------------------------------------
|
2020-07-31 00:28:57 +02:00
|
|
|
; Write error code
|
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
|
|
|
;****************************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
;* SEND COMMAND TO GIVEN DISK *
|
|
|
|
;* Input parameters are passed through the global *
|
|
|
|
;* variables: *
|
|
|
|
;* ChannelNumber - channel number (1 or 2); *
|
|
|
|
;* DiskNumber - disk number (0 or 1); *
|
|
|
|
;* ATAFeatures - "features"; *
|
|
|
|
;* ATASectorCount - sector count; *
|
|
|
|
;* ATASectorNumber - initial sector number; *
|
|
|
|
;* ATACylinder - initial cylinder number; *
|
|
|
|
;* ATAHead - initial head number; *
|
|
|
|
;* ATAAddressMode - addressing mode (0-CHS, 1-LBA); *
|
|
|
|
;* ATACommand - command code. *
|
|
|
|
;* If the function finished successfully: *
|
|
|
|
;* in ATABasePortAddr - base address of HDD; *
|
|
|
|
;* in DevErrorCode - zero. *
|
|
|
|
;* If error has occured then in DevErrorCode will *
|
|
|
|
;* be the error code. *
|
2011-10-14 23:38:50 +02:00
|
|
|
;****************************************************
|
|
|
|
SendCommandToHDD_1:
|
2020-07-31 00:28:57 +02:00
|
|
|
; Check the addressing mode code
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [ATAAddressMode], 1
|
|
|
|
ja @@Err2_4
|
2020-07-31 00:28:57 +02:00
|
|
|
; Check the channel number correctness
|
2016-07-29 13:12:13 +02:00
|
|
|
movzx ebx, [ChannelNumber]
|
|
|
|
dec ebx
|
|
|
|
cmp ebx, 1
|
2011-10-14 23:38:50 +02:00
|
|
|
ja @@Err3_4
|
2020-07-31 00:28:57 +02:00
|
|
|
; Set the base address
|
2014-03-27 21:44:32 +01:00
|
|
|
shl ebx, 2
|
|
|
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
; Waiting for HDD ready to receive a command
|
|
|
|
; Choose desired disk
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ATABasePortAddr]
|
2020-07-31 00:28:57 +02:00
|
|
|
add dx, 6 ; address of the heads register
|
2014-03-27 21:44:32 +01:00
|
|
|
mov al, [DiskNumber]
|
2020-07-31 00:28:57 +02:00
|
|
|
cmp al, 1 ; check the disk number
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
; Waiting for disk ready
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
; Check waiting time
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, [timer_ticks]
|
|
|
|
sub eax, [TickCounter_1]
|
2020-07-31 00:28:57 +02:00
|
|
|
cmp eax, BSYWaitTime ;300 ; wait for 3 seconds
|
|
|
|
ja @@Err1_4 ; time out error
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.test:
|
2020-07-31 00:28:57 +02:00
|
|
|
in al, dx ; Read the state register
|
|
|
|
; Check the state of BSY signal
|
2014-03-27 21:44:32 +01:00
|
|
|
test al, 0x80
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @@WaitHDReady_2
|
2020-07-31 00:28:57 +02:00
|
|
|
; Check the state of DRQ signal
|
2014-03-27 21:44:32 +01:00
|
|
|
test al, 0x8
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @@WaitHDReady_2
|
2020-07-31 00:28:57 +02:00
|
|
|
; load command to controller's registers
|
2011-10-14 23:38:50 +02:00
|
|
|
cli
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ATABasePortAddr]
|
2020-07-31 00:28:57 +02:00
|
|
|
inc dx ; "features" register
|
2014-03-27 21:44:32 +01:00
|
|
|
mov al, [ATAFeatures]
|
|
|
|
out dx, al
|
2020-07-31 00:28:57 +02:00
|
|
|
inc dx ; sector counter
|
2014-03-27 21:44:32 +01:00
|
|
|
mov al, [ATASectorCount]
|
|
|
|
out dx, al
|
2020-07-31 00:28:57 +02:00
|
|
|
inc dx ; sector number register
|
2014-03-27 21:44:32 +01:00
|
|
|
mov al, [ATASectorNumber]
|
|
|
|
out dx, al
|
2020-07-31 00:28:57 +02:00
|
|
|
inc dx ; cylinder number (low byte)
|
2014-03-27 21:44:32 +01:00
|
|
|
mov ax, [ATACylinder]
|
|
|
|
out dx, al
|
2020-07-31 00:28:57 +02:00
|
|
|
inc dx ; cylinder number (high byte)
|
2014-03-27 21:44:32 +01:00
|
|
|
mov al, ah
|
|
|
|
out dx, al
|
2020-07-31 00:28:57 +02:00
|
|
|
inc dx ; head number / disk number
|
2014-03-27 21:44:32 +01:00
|
|
|
mov al, [DiskNumber]
|
|
|
|
shl al, 4
|
2020-07-31 00:28:57 +02:00
|
|
|
cmp [ATAHead], 0xF ; check head number
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send command
|
2014-03-27 21:44:32 +01:00
|
|
|
mov al, [ATACommand]
|
2020-07-31 00:28:57 +02:00
|
|
|
inc dx ; command register
|
2014-03-27 21:44:32 +01:00
|
|
|
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
|
|
|
;--------------------------------------
|
2020-07-31 00:28:57 +02:00
|
|
|
; Write error code
|
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
|
|
|
;*************************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
;* WAIT FOR THE DEVICE IS READY FOR WORK *
|
|
|
|
;* Input parameters are passed through global *
|
|
|
|
;* variables: *
|
|
|
|
;* ChannelNumber - channel number; *
|
|
|
|
;* DiskNumber - disk number on channel. *
|
2011-10-14 23:38:50 +02:00
|
|
|
;*************************************************
|
|
|
|
WaitUnitReady:
|
|
|
|
pusha
|
2020-07-31 00:28:57 +02:00
|
|
|
; Remember the peration start time
|
2014-03-27 21:44:32 +01:00
|
|
|
mov eax, [timer_ticks]
|
|
|
|
mov [WURStartTime], eax
|
2020-07-31 00:28:57 +02:00
|
|
|
; Clear the packet command buffer
|
2011-10-14 23:38:50 +02:00
|
|
|
call clear_packet_buffer
|
2020-07-31 00:28:57 +02:00
|
|
|
; Generate TEST UNIT READY command
|
2014-03-27 21:44:32 +01:00
|
|
|
mov [PacketCommand], word 0
|
2020-07-31 00:28:57 +02:00
|
|
|
; waiting loop for device readiness
|
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:
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send readiness check command
|
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
|
2020-07-31 00:28:57 +02:00
|
|
|
; Check the error code
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [DevErrorCode], 0
|
|
|
|
je @@End_11
|
2020-07-31 00:28:57 +02:00
|
|
|
; Check waiting time
|
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:
|
2020-07-31 00:28:57 +02:00
|
|
|
; time out error
|
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
|
|
|
;*************************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
;* FORBID DISK CHANGE *
|
|
|
|
;* Input parameters are passed through global *
|
|
|
|
;* variables: *
|
|
|
|
;* ChannelNumber - channel number; *
|
|
|
|
;* DiskNumber - disk number on channel. *
|
2011-10-14 23:38:50 +02:00
|
|
|
;*************************************************
|
|
|
|
prevent_medium_removal:
|
|
|
|
pusha
|
2020-07-31 00:28:57 +02:00
|
|
|
; Clear the packet command buffer
|
2011-10-14 23:38:50 +02:00
|
|
|
call clear_packet_buffer
|
2020-07-31 00:28:57 +02:00
|
|
|
; Set command code
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [PacketCommand], byte 0x1E
|
2020-07-31 00:28:57 +02:00
|
|
|
; Set "Forbid" code
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [PacketCommand+4], byte 11b
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send command
|
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
|
|
|
;*************************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
;* ALLOW DISK CHANGE *
|
|
|
|
;* Input parameters are passed through global *
|
|
|
|
;* variables: *
|
|
|
|
;* ChannelNumber - channel number; *
|
|
|
|
;* DiskNumber - disk number on channel. *
|
2011-10-14 23:38:50 +02:00
|
|
|
;*************************************************
|
|
|
|
allow_medium_removal:
|
|
|
|
pusha
|
2020-07-31 00:28:57 +02:00
|
|
|
; Clear the packet command buffer
|
2011-10-14 23:38:50 +02:00
|
|
|
call clear_packet_buffer
|
2020-07-31 00:28:57 +02:00
|
|
|
; Set command code
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [PacketCommand], byte 0x1E
|
2020-07-31 00:28:57 +02:00
|
|
|
; unset "Forbid" code
|
2014-03-27 21:44:32 +01:00
|
|
|
mov [PacketCommand+4], byte 0
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send command
|
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
|
|
|
;*************************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
;* LOAD DISK TO THE DRIVE *
|
|
|
|
;* Input parameters are passed through global *
|
|
|
|
;* variables: *
|
|
|
|
;* ChannelNumber - channel number; *
|
|
|
|
;* DiskNumber - disk number on channel. *
|
2011-10-14 23:38:50 +02:00
|
|
|
;*************************************************
|
|
|
|
LoadMedium:
|
|
|
|
pusha
|
2020-07-31 00:28:57 +02:00
|
|
|
; Clear the packet command buffer
|
2011-10-14 23:38:50 +02:00
|
|
|
call clear_packet_buffer
|
2020-07-31 00:28:57 +02:00
|
|
|
; Generate START/STOP UNIT command
|
|
|
|
; Set command code
|
2014-03-27 21:44:32 +01:00
|
|
|
mov [PacketCommand], word 0x1B
|
2020-07-31 00:28:57 +02:00
|
|
|
; Set disk loading operation
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [PacketCommand+4], word 00000011b
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send command
|
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
|
|
|
;*************************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
;* REMOVE THE DISK FROM THE DRIVE *
|
|
|
|
;* Input parameters are passed through global *
|
|
|
|
;* variables: *
|
|
|
|
;* ChannelNumber - channel number; *
|
|
|
|
;* DiskNumber - disk number on channel. *
|
2011-10-14 23:38:50 +02:00
|
|
|
;*************************************************
|
|
|
|
EjectMedium:
|
|
|
|
pusha
|
2020-07-31 00:28:57 +02:00
|
|
|
; Clear the packet command buffer
|
2011-10-14 23:38:50 +02:00
|
|
|
call clear_packet_buffer
|
2020-07-31 00:28:57 +02:00
|
|
|
; Generate START/STOP UNIT command
|
|
|
|
; Set command code
|
2014-03-27 21:44:32 +01:00
|
|
|
mov [PacketCommand], word 0x1B
|
2020-07-31 00:28:57 +02:00
|
|
|
; Set the operation to eject disk
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [PacketCommand+4], word 00000010b
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send command
|
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
|
|
|
;*************************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
;* Check the event of pressing the eject button *
|
|
|
|
;* *
|
|
|
|
;* Input parameters are passed through global *
|
|
|
|
;* variables: *
|
|
|
|
;* ChannelNumber - channel number; *
|
|
|
|
;* DiskNumber - disk number on channel. *
|
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
|
|
|
;*************************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
;* Get an event or device status message *
|
|
|
|
;* *
|
|
|
|
;* Input parameters are passed through global *
|
|
|
|
;* variables: *
|
|
|
|
;* ChannelNumber - channel number; *
|
|
|
|
;* DiskNumber - disk number on channel *
|
2011-10-14 23:38:50 +02:00
|
|
|
;*************************************************
|
|
|
|
GetEvent_StatusNotification:
|
|
|
|
pusha
|
|
|
|
mov [CDDataBuf_pointer], CDDataBuf
|
2020-07-31 00:28:57 +02:00
|
|
|
; Clear the packet command buffer
|
2011-10-14 23:38:50 +02:00
|
|
|
call clear_packet_buffer
|
2020-07-31 00:28:57 +02:00
|
|
|
; Set command code
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [PacketCommand], byte 4Ah
|
|
|
|
mov [PacketCommand+1], byte 00000001b
|
2020-07-31 00:28:57 +02:00
|
|
|
; Set message class request
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [PacketCommand+4], byte 00010000b
|
2020-07-31 00:28:57 +02:00
|
|
|
; Size of allocated area
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [PacketCommand+7], byte 8h
|
|
|
|
mov [PacketCommand+8], byte 0h
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send command
|
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
|
|
|
;*************************************************
|
2020-07-31 00:28:57 +02:00
|
|
|
; Read information from TOC (Table of contents) *
|
|
|
|
;* Input parameters are passed through global *
|
|
|
|
;* variables: *
|
|
|
|
;* ChannelNumber - channel number; *
|
|
|
|
;* DiskNumber - disk number on channel *
|
2011-10-14 23:38:50 +02:00
|
|
|
;*************************************************
|
|
|
|
Read_TOC:
|
|
|
|
pusha
|
|
|
|
mov [CDDataBuf_pointer], CDDataBuf
|
2020-07-31 00:28:57 +02:00
|
|
|
; Clear the packet command buffer
|
2011-10-14 23:38:50 +02:00
|
|
|
call clear_packet_buffer
|
2020-07-31 00:28:57 +02:00
|
|
|
; Generate a packet command to read a data sector
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [PacketCommand], byte 0x43
|
2020-07-31 00:28:57 +02:00
|
|
|
; Set format
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [PacketCommand+2], byte 1
|
2020-07-31 00:28:57 +02:00
|
|
|
; Size of allocated area
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [PacketCommand+7], byte 0xFF
|
|
|
|
mov [PacketCommand+8], byte 0h
|
2020-07-31 00:28:57 +02:00
|
|
|
; Send a command
|
2011-10-14 23:38:50 +02:00
|
|
|
call SendPacketDatCommand
|
|
|
|
popa
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2020-07-31 00:28:57 +02:00
|
|
|
;*****************************************************
|
|
|
|
;* DETERMINE THE TOTAL NUMBER OF SECTORS ON THE DISK *
|
|
|
|
;* Input parameters are passed through global *
|
|
|
|
;* variables: *
|
|
|
|
;* ChannelNumber - channel number; *
|
|
|
|
;* DiskNumber - disk number on channel *
|
|
|
|
;*****************************************************
|
2011-10-14 23:38:50 +02:00
|
|
|
;ReadCapacity:
|
|
|
|
; pusha
|
2020-07-31 00:28:57 +02:00
|
|
|
;; Clear the packet command buffer
|
2011-10-14 23:38:50 +02:00
|
|
|
; call clear_packet_buffer
|
2020-07-31 00:28:57 +02:00
|
|
|
;; Set the buffer size in bytes
|
2011-10-14 23:38:50 +02:00
|
|
|
; mov [CDBlockSize],8
|
2020-07-31 00:28:57 +02:00
|
|
|
;; Generate READ CAPACITY command
|
2011-10-14 23:38:50 +02:00
|
|
|
; mov [PacketCommand],word 25h
|
2020-07-31 00:28:57 +02:00
|
|
|
;; Send command
|
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:
|
2020-07-31 00:28:57 +02:00
|
|
|
; Clear the packet command buffer
|
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
|
|
|
;-----------------------------------------------------------------------------
|