2010-10-01 11:21:55 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2015-06-01 21:18:07 +02:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
|
2010-10-01 11:21:55 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
2015-07-17 16:16:36 +02:00
|
|
|
; HDD driver
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2013-09-14 20:55:13 +02:00
|
|
|
struct HD_DATA
|
|
|
|
hdbase dd ?
|
|
|
|
hdid dd ?
|
|
|
|
hdpos dd ?
|
|
|
|
ends
|
2015-07-17 16:16:36 +02:00
|
|
|
;-----------------------------------------------------------------
|
2013-09-14 20:55:13 +02:00
|
|
|
iglobal
|
|
|
|
align 4
|
|
|
|
ide_callbacks:
|
|
|
|
dd ide_callbacks.end - ide_callbacks ; strucsize
|
|
|
|
dd 0 ; no close function
|
|
|
|
dd 0 ; no closemedia function
|
|
|
|
dd ide_querymedia
|
|
|
|
dd ide_read
|
|
|
|
dd ide_write
|
|
|
|
dd 0 ; no flush function
|
|
|
|
dd 0 ; use default cache size
|
|
|
|
.end:
|
|
|
|
|
|
|
|
hd0_data HD_DATA ?, 0, 1
|
|
|
|
hd1_data HD_DATA ?, 0x10, 2
|
|
|
|
hd2_data HD_DATA ?, 0, 3
|
|
|
|
hd3_data HD_DATA ?, 0x10, 4
|
2014-12-01 04:51:07 +01:00
|
|
|
hd4_data HD_DATA ?, 0, 5
|
|
|
|
hd5_data HD_DATA ?, 0x10, 6
|
|
|
|
hd6_data HD_DATA ?, 0, 7
|
|
|
|
hd7_data HD_DATA ?, 0x10, 8
|
|
|
|
hd8_data HD_DATA ?, 0, 9
|
|
|
|
hd9_data HD_DATA ?, 0x10, 10
|
|
|
|
hd10_data HD_DATA ?, 0, 11
|
|
|
|
hd11_data HD_DATA ?, 0x10, 12
|
2013-11-24 08:02:55 +01:00
|
|
|
|
2014-12-01 04:51:07 +01:00
|
|
|
ide_mutex_table:
|
|
|
|
dd ide_channel1_mutex
|
|
|
|
dd ide_channel2_mutex
|
|
|
|
dd ide_channel3_mutex
|
|
|
|
dd ide_channel4_mutex
|
|
|
|
dd ide_channel5_mutex
|
|
|
|
dd ide_channel6_mutex
|
2013-09-14 20:55:13 +02:00
|
|
|
endg
|
2015-07-17 16:16:36 +02:00
|
|
|
;-----------------------------------------------------------------
|
2013-09-14 20:55:13 +02:00
|
|
|
uglobal
|
|
|
|
ide_mutex MUTEX
|
|
|
|
ide_channel1_mutex MUTEX
|
|
|
|
ide_channel2_mutex MUTEX
|
2014-12-01 04:51:07 +01:00
|
|
|
ide_channel3_mutex MUTEX
|
|
|
|
ide_channel4_mutex MUTEX
|
|
|
|
ide_channel5_mutex MUTEX
|
|
|
|
ide_channel6_mutex MUTEX
|
2015-07-17 16:16:36 +02:00
|
|
|
blockSize:
|
|
|
|
rb 4
|
|
|
|
sector:
|
|
|
|
rb 6
|
|
|
|
allow_dma_access db ?
|
|
|
|
IDE_common_irq_param db ?
|
|
|
|
eventPointer dd ?
|
|
|
|
eventID dd ?
|
2013-09-14 20:55:13 +02:00
|
|
|
endg
|
2015-07-17 16:16:36 +02:00
|
|
|
;-----------------------------------------------------------------
|
|
|
|
ide_read:
|
|
|
|
mov al, 25h ; READ DMA EXT
|
|
|
|
jmp ide_read_write
|
|
|
|
|
|
|
|
ide_write:
|
|
|
|
mov al, 35h ; WRITE DMA EXT
|
|
|
|
; fall through to ide_read_write
|
|
|
|
|
|
|
|
proc ide_read_write stdcall uses esi edi ebx, \
|
2013-09-14 20:55:13 +02:00
|
|
|
hd_data, buffer, startsector:qword, numsectors
|
|
|
|
; hd_data = pointer to hd*_data
|
2015-07-17 16:16:36 +02:00
|
|
|
; buffer = pointer to buffer with/for data
|
2013-09-14 20:55:13 +02:00
|
|
|
; startsector = 64-bit start sector
|
|
|
|
; numsectors = pointer to number of sectors on input,
|
2015-07-17 16:16:36 +02:00
|
|
|
; must be filled with number of sectors really read/written
|
2013-09-14 20:55:13 +02:00
|
|
|
locals
|
|
|
|
sectors_todo dd ?
|
|
|
|
channel_lock dd ?
|
2015-07-17 16:16:36 +02:00
|
|
|
operation db ?
|
2013-09-14 20:55:13 +02:00
|
|
|
endl
|
2015-07-17 16:16:36 +02:00
|
|
|
mov [operation], al
|
|
|
|
; get number of requested sectors and say that no sectors were read yet
|
2013-09-14 20:55:13 +02:00
|
|
|
mov ecx, [numsectors]
|
|
|
|
mov eax, [ecx]
|
|
|
|
mov dword [ecx], 0
|
|
|
|
mov [sectors_todo], eax
|
2015-07-17 16:16:36 +02:00
|
|
|
; acquire the global lock
|
2013-09-14 20:55:13 +02:00
|
|
|
mov ecx, ide_mutex
|
|
|
|
call mutex_lock
|
2014-12-01 04:51:07 +01:00
|
|
|
mov ecx, [hd_data]
|
|
|
|
mov ecx, [ecx+HD_DATA.hdpos]
|
|
|
|
dec ecx
|
|
|
|
shr ecx, 1
|
|
|
|
shl ecx, 2
|
|
|
|
mov ecx, [ecx + ide_mutex_table]
|
2013-09-14 20:55:13 +02:00
|
|
|
mov [channel_lock], ecx
|
|
|
|
call mutex_lock
|
2015-07-17 16:16:36 +02:00
|
|
|
; prepare worker procedures variables
|
2013-09-14 20:55:13 +02:00
|
|
|
mov ecx, [hd_data]
|
|
|
|
mov eax, [ecx+HD_DATA.hdbase]
|
|
|
|
mov [hdbase], eax
|
|
|
|
mov eax, [ecx+HD_DATA.hdid]
|
|
|
|
mov [hdid], eax
|
|
|
|
mov eax, [ecx+HD_DATA.hdpos]
|
|
|
|
mov [hdpos], eax
|
|
|
|
mov eax, dword [startsector]
|
2015-07-17 16:16:36 +02:00
|
|
|
mov [sector], eax
|
|
|
|
mov ax, word [startsector+4]
|
|
|
|
mov [sector+4], ax
|
|
|
|
mov esi, [buffer]
|
|
|
|
mov edi, esi
|
|
|
|
mov bl, [operation]
|
2014-12-01 04:51:07 +01:00
|
|
|
mov ecx, [hdpos]
|
|
|
|
dec ecx
|
|
|
|
shr ecx, 2
|
|
|
|
imul ecx, sizeof.IDE_DATA
|
|
|
|
add ecx, IDE_controller_1
|
|
|
|
mov [IDE_controller_pointer], ecx
|
|
|
|
mov eax, [hdpos]
|
|
|
|
dec eax
|
|
|
|
and eax, 11b
|
|
|
|
shr eax, 1
|
|
|
|
add eax, ecx
|
|
|
|
cmp [eax+IDE_DATA.dma_hdd_channel_1], 1
|
2015-07-17 16:16:36 +02:00
|
|
|
jz .next
|
|
|
|
dec ebx ; READ/WRITE SECTOR(S) EXT
|
|
|
|
; worker procedures take max 8000h sectors per time
|
|
|
|
; loop until all sectors will be processed
|
|
|
|
.next:
|
|
|
|
mov ecx, 8000h
|
2013-09-14 20:55:13 +02:00
|
|
|
cmp ecx, [sectors_todo]
|
|
|
|
jbe @f
|
|
|
|
mov ecx, [sectors_todo]
|
|
|
|
@@:
|
2015-07-17 16:16:36 +02:00
|
|
|
mov [blockSize], ecx
|
|
|
|
push ecx
|
|
|
|
call IDE_transfer
|
|
|
|
pop ecx
|
|
|
|
jc .out
|
2013-09-14 20:55:13 +02:00
|
|
|
mov eax, [numsectors]
|
|
|
|
add [eax], ecx
|
|
|
|
sub [sectors_todo], ecx
|
2015-07-17 16:16:36 +02:00
|
|
|
jz .out
|
|
|
|
add [sector], ecx
|
|
|
|
adc word [sector+4], 0
|
|
|
|
jmp .next
|
|
|
|
; loop is done, either due to error or because everything is done
|
|
|
|
; release the global lock and return the corresponding status
|
|
|
|
.out:
|
|
|
|
sbb eax, eax
|
|
|
|
push eax
|
2013-09-14 20:55:13 +02:00
|
|
|
mov ecx, [channel_lock]
|
|
|
|
call mutex_unlock
|
|
|
|
mov ecx, ide_mutex
|
|
|
|
call mutex_unlock
|
2015-07-17 16:16:36 +02:00
|
|
|
pop eax
|
2013-09-14 20:55:13 +02:00
|
|
|
ret
|
|
|
|
endp
|
2015-07-17 16:16:36 +02:00
|
|
|
;-----------------------------------------------------------------
|
|
|
|
; this is a stub
|
2013-09-14 20:55:13 +02:00
|
|
|
proc ide_querymedia stdcall, hd_data, mediainfo
|
|
|
|
mov eax, [mediainfo]
|
|
|
|
mov [eax+DISKMEDIAINFO.Flags], 0
|
|
|
|
mov [eax+DISKMEDIAINFO.SectorSize], 512
|
|
|
|
or dword [eax+DISKMEDIAINFO.Capacity], 0xFFFFFFFF
|
|
|
|
or dword [eax+DISKMEDIAINFO.Capacity+4], 0xFFFFFFFF
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
endp
|
2015-07-17 16:16:36 +02:00
|
|
|
;-----------------------------------------------------------------
|
|
|
|
; input: esi -> buffer, bl = command, [sector], [blockSize]
|
|
|
|
; output: esi -> next block in buffer
|
|
|
|
; for pio read esi equal edi
|
|
|
|
IDE_transfer:
|
2013-06-28 10:02:49 +02:00
|
|
|
mov edx, [hdbase]
|
2015-07-17 16:16:36 +02:00
|
|
|
add edx, 6
|
2013-06-28 10:02:49 +02:00
|
|
|
mov al, byte [hdid]
|
2015-07-17 16:16:36 +02:00
|
|
|
add al, 224
|
|
|
|
out dx, al ; select the desired drive
|
|
|
|
call save_hd_wait_timeout
|
|
|
|
inc edx
|
|
|
|
@@:
|
|
|
|
call check_hd_wait_timeout
|
|
|
|
jc .hd_error
|
|
|
|
in al, dx
|
|
|
|
test al, 128 ; ready for command?
|
|
|
|
jnz @b
|
|
|
|
pushfd ; fill the ports
|
2013-05-28 21:09:31 +02:00
|
|
|
cli
|
2012-03-08 09:33:38 +01:00
|
|
|
mov edx, [hdbase]
|
2013-05-28 21:09:31 +02:00
|
|
|
inc edx
|
|
|
|
inc edx
|
2015-07-17 16:16:36 +02:00
|
|
|
mov al, [blockSize+1]
|
|
|
|
out dx, al ; Sector count (15:8)
|
2013-05-28 21:09:31 +02:00
|
|
|
inc edx
|
2015-07-17 16:16:36 +02:00
|
|
|
mov eax, [sector+3]
|
|
|
|
out dx, al ; LBA (31:24)
|
2013-05-28 21:09:31 +02:00
|
|
|
inc edx
|
2012-03-08 09:33:38 +01:00
|
|
|
shr eax, 8
|
2015-07-17 16:16:36 +02:00
|
|
|
out dx, al ; LBA (39:32)
|
2013-05-28 21:09:31 +02:00
|
|
|
inc edx
|
2012-03-08 09:33:38 +01:00
|
|
|
shr eax, 8
|
2015-07-17 16:16:36 +02:00
|
|
|
out dx, al ; LBA (47:40)
|
|
|
|
sub edx, 3
|
|
|
|
mov al, [blockSize]
|
|
|
|
out dx, al ; Sector count (7:0)
|
2013-05-28 21:09:31 +02:00
|
|
|
inc edx
|
2015-07-17 16:16:36 +02:00
|
|
|
mov eax, [sector]
|
|
|
|
out dx, al ; LBA (7:0)
|
2013-06-28 10:02:49 +02:00
|
|
|
inc edx
|
|
|
|
shr eax, 8
|
2015-07-17 16:16:36 +02:00
|
|
|
out dx, al ; LBA (15:8)
|
2013-06-28 10:02:49 +02:00
|
|
|
inc edx
|
|
|
|
shr eax, 8
|
2015-07-17 16:16:36 +02:00
|
|
|
out dx, al ; LBA (23:16)
|
2013-06-28 10:02:49 +02:00
|
|
|
inc edx
|
|
|
|
mov al, byte [hdid]
|
2015-07-17 16:16:36 +02:00
|
|
|
add al, 224
|
|
|
|
out dx, al
|
|
|
|
test bl, 1
|
|
|
|
jz .PIO
|
|
|
|
; DMA
|
|
|
|
mov dword [esp], 0x1000
|
|
|
|
call kernel_alloc
|
|
|
|
mov edi, eax
|
|
|
|
push eax
|
|
|
|
shl dword [blockSize], 9
|
|
|
|
mov eax, esi
|
|
|
|
add eax, [blockSize]
|
|
|
|
push eax
|
|
|
|
; check buffer pages physical addresses and fill the scatter-gather list
|
|
|
|
; buffer may be not aligned and may have size not divisible by page size
|
|
|
|
; [edi] = block physical address, [edi+4] = block size in bytes
|
|
|
|
; block addresses can not cross 10000h borders
|
|
|
|
mov ecx, esi
|
|
|
|
and ecx, 0xFFF
|
|
|
|
jz .aligned
|
|
|
|
mov eax, esi
|
|
|
|
call get_pg_addr
|
|
|
|
add eax, ecx
|
|
|
|
neg ecx
|
|
|
|
add ecx, 0x1000
|
|
|
|
mov [edi], eax
|
|
|
|
cmp ecx, [blockSize]
|
|
|
|
jnc .end
|
|
|
|
mov [edi+4], ecx
|
|
|
|
add esi, 0x1000
|
|
|
|
add edi, 8
|
|
|
|
sub [blockSize], ecx
|
|
|
|
.aligned:
|
|
|
|
mov eax, esi
|
|
|
|
call get_pg_addr
|
|
|
|
mov ecx, eax
|
|
|
|
mov [edi], eax
|
|
|
|
and ecx, 0xFFFF
|
|
|
|
neg ecx
|
|
|
|
add ecx, 0x10000
|
|
|
|
cmp [blockSize], ecx
|
|
|
|
jnc @f
|
|
|
|
mov ecx, [blockSize]
|
|
|
|
and ecx, 0xF000
|
|
|
|
jz .end
|
|
|
|
@@:
|
|
|
|
push ecx
|
|
|
|
@@:
|
|
|
|
add esi, 0x1000
|
|
|
|
add eax, 0x1000
|
|
|
|
sub ecx, 0x1000
|
|
|
|
jz @f
|
|
|
|
mov edx, eax
|
|
|
|
mov eax, esi
|
|
|
|
call get_pg_addr
|
|
|
|
cmp eax, edx
|
|
|
|
jz @b
|
|
|
|
@@:
|
|
|
|
pop edx
|
|
|
|
sub edx, ecx
|
|
|
|
mov [edi+4], edx
|
|
|
|
add edi, 8
|
|
|
|
sub [blockSize], edx
|
|
|
|
jnz .aligned
|
|
|
|
sub edi, 8
|
|
|
|
jmp @f
|
|
|
|
.end:
|
|
|
|
mov ecx, [blockSize]
|
|
|
|
mov [edi+4], ecx
|
|
|
|
@@:
|
|
|
|
mov byte [edi+7], 80h ; list end
|
|
|
|
pop esi
|
|
|
|
pop edi
|
|
|
|
; select controller Primary or Secondary
|
|
|
|
mov ecx, [IDE_controller_pointer]
|
|
|
|
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
|
|
|
|
mov eax, [hdpos]
|
|
|
|
dec eax
|
|
|
|
test eax, 10b
|
|
|
|
jz @f
|
|
|
|
add edx, 8
|
|
|
|
@@:
|
|
|
|
add edx, 2 ; Bus Master IDE Status register
|
|
|
|
mov al, 6
|
|
|
|
out dx, al ; clear Error bit and Interrupt bit
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2015-07-17 16:16:36 +02:00
|
|
|
add edx, 2 ; Bus Master IDE PRD Table Address
|
|
|
|
mov eax, edi
|
|
|
|
call get_pg_addr
|
|
|
|
out dx, eax ; send scatter-gather list physical address
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2015-07-17 16:16:36 +02:00
|
|
|
push edx
|
2012-03-08 09:33:38 +01:00
|
|
|
mov edx, [hdbase]
|
2015-07-17 16:16:36 +02:00
|
|
|
add edx, 7 ; ATACommand
|
|
|
|
mov al, bl
|
|
|
|
out dx, al ; Start hard drive
|
|
|
|
pop edx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2015-07-17 16:16:36 +02:00
|
|
|
sub edx, 4 ; Bus Master IDE Command register
|
|
|
|
mov al, 1 ; set direction
|
|
|
|
cmp bl, 35h ; write
|
|
|
|
jz @f
|
|
|
|
add al, 8 ; read
|
|
|
|
@@:
|
|
|
|
out dx, al ; Start Bus Master
|
|
|
|
mov [IDE_common_irq_param], 14
|
|
|
|
mov eax, [hdpos]
|
|
|
|
dec eax
|
|
|
|
test eax, 10b
|
|
|
|
jz @f
|
|
|
|
inc [IDE_common_irq_param]
|
|
|
|
@@:
|
|
|
|
push edi esi ebx
|
|
|
|
xor ecx, ecx
|
|
|
|
xor esi, esi
|
|
|
|
call create_event
|
|
|
|
mov [eventPointer], eax
|
|
|
|
mov [eventID], edx
|
|
|
|
sti
|
|
|
|
mov ebx, edx
|
|
|
|
mov ecx, 300
|
|
|
|
call wait_event_timeout
|
|
|
|
test eax, eax
|
|
|
|
jnz @f
|
|
|
|
mov [IDE_common_irq_param], 0
|
|
|
|
mov eax, [eventPointer]
|
|
|
|
mov ebx, [eventID]
|
|
|
|
call destroy_event
|
|
|
|
mov [eventPointer], 0
|
|
|
|
@@:
|
|
|
|
pop ebx esi
|
|
|
|
call kernel_free
|
|
|
|
cmp [eventPointer], 0
|
|
|
|
jz .hd_error
|
2013-05-28 21:09:31 +02:00
|
|
|
ret
|
2015-07-17 16:16:36 +02:00
|
|
|
.PIO:
|
|
|
|
inc edx ; ATACommand
|
|
|
|
mov al, bl
|
|
|
|
out dx, al ; Start hard drive
|
2013-09-14 20:55:13 +02:00
|
|
|
popfd
|
2015-07-17 16:16:36 +02:00
|
|
|
.sectorTransfer:
|
|
|
|
call save_hd_wait_timeout
|
|
|
|
in al, dx
|
|
|
|
in al, dx
|
|
|
|
in al, dx
|
|
|
|
in al, dx
|
|
|
|
@@:
|
|
|
|
call check_hd_wait_timeout
|
|
|
|
jc .hd_error
|
|
|
|
in al, dx
|
|
|
|
test al, 8 ; ready for transfer?
|
|
|
|
jz @b
|
|
|
|
cmp [hd_setup], 1 ; do not mark error for setup request
|
|
|
|
jz @f
|
|
|
|
test al, 1 ; previous command ended up with an error
|
|
|
|
jnz .hd_error
|
|
|
|
@@:
|
2013-06-28 10:02:49 +02:00
|
|
|
pushfd
|
2013-05-28 21:09:31 +02:00
|
|
|
cli
|
2015-07-17 16:16:36 +02:00
|
|
|
cld
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ecx, 256
|
|
|
|
mov edx, [hdbase]
|
2015-07-17 16:16:36 +02:00
|
|
|
cmp bl, 34h
|
|
|
|
jz .write
|
|
|
|
rep insw
|
|
|
|
jmp @f
|
|
|
|
.write:
|
2013-05-28 21:09:31 +02:00
|
|
|
rep outsw
|
2015-07-17 16:16:36 +02:00
|
|
|
@@:
|
2013-06-28 10:02:49 +02:00
|
|
|
popfd
|
2015-07-17 16:16:36 +02:00
|
|
|
add edx, 7
|
|
|
|
dec dword [blockSize]
|
|
|
|
jnz .sectorTransfer
|
2013-05-28 21:09:31 +02:00
|
|
|
ret
|
2015-07-17 16:16:36 +02:00
|
|
|
.hd_error:
|
|
|
|
cmp bl, 30h
|
|
|
|
jnc hd_write_error
|
|
|
|
;-----------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
hd_read_error:
|
2013-09-14 20:55:13 +02:00
|
|
|
if lang eq sp
|
|
|
|
DEBUGF 1,"K : FS - HD error de lectura\n"
|
|
|
|
else
|
|
|
|
DEBUGF 1,"K : FS - HD read error\n"
|
|
|
|
end if
|
2015-07-17 16:16:36 +02:00
|
|
|
stc
|
2013-05-28 21:09:31 +02:00
|
|
|
ret
|
2015-07-17 16:16:36 +02:00
|
|
|
;-----------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
hd_write_error:
|
2013-09-14 20:55:13 +02:00
|
|
|
if lang eq sp
|
|
|
|
DEBUGF 1,"K : FS - HD error de escritura\n"
|
|
|
|
else
|
|
|
|
DEBUGF 1,"K : FS - HD write error\n"
|
|
|
|
end if
|
2015-07-17 16:16:36 +02:00
|
|
|
stc
|
2013-05-28 21:09:31 +02:00
|
|
|
ret
|
2015-07-17 16:16:36 +02:00
|
|
|
;-----------------------------------------------------------------
|
|
|
|
save_hd_wait_timeout:
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
add eax, 300 ; 3 sec timeout
|
|
|
|
mov [hd_wait_timeout], eax
|
2013-05-28 21:09:31 +02:00
|
|
|
ret
|
2015-07-17 16:16:36 +02:00
|
|
|
;-----------------------------------------------------------------
|
|
|
|
check_hd_wait_timeout:
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
cmp [hd_wait_timeout], eax
|
|
|
|
jc @f
|
2014-01-01 22:16:27 +01:00
|
|
|
ret
|
|
|
|
@@:
|
2015-07-17 16:16:36 +02:00
|
|
|
if lang eq sp
|
|
|
|
DEBUGF 1,"K : FS - HD tiempo de espera agotado\n"
|
|
|
|
else
|
|
|
|
DEBUGF 1,"K : FS - HD timeout\n"
|
|
|
|
end if
|
|
|
|
stc
|
2010-10-01 11:21:55 +02:00
|
|
|
ret
|
2015-07-17 16:16:36 +02:00
|
|
|
;-----------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
align 4
|
2015-07-17 16:16:36 +02:00
|
|
|
IDE_irq_14_handler:
|
2013-09-14 20:55:13 +02:00
|
|
|
IDE_irq_15_handler:
|
|
|
|
IDE_common_irq_handler:
|
2015-07-17 16:16:36 +02:00
|
|
|
; DEBUGF 1, 'K : IDE_irq_handler %x\n', [IDE_common_irq_param]:2
|
|
|
|
cmp [IDE_common_irq_param], 0
|
|
|
|
jz .exit
|
2014-12-01 04:51:07 +01:00
|
|
|
pushfd
|
|
|
|
cli
|
2013-09-14 20:55:13 +02:00
|
|
|
pushad
|
2014-12-01 04:51:07 +01:00
|
|
|
mov ecx, [IDE_controller_pointer]
|
|
|
|
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
|
2015-07-17 16:16:36 +02:00
|
|
|
cmp [IDE_common_irq_param], 14
|
|
|
|
jz @f
|
2013-09-14 20:55:13 +02:00
|
|
|
add dx, 8
|
|
|
|
@@:
|
2015-07-17 16:16:36 +02:00
|
|
|
add edx, 2 ; Bus Master IDE Status register
|
2014-01-01 22:16:27 +01:00
|
|
|
in al, dx
|
2015-07-17 16:16:36 +02:00
|
|
|
test al, 4
|
2014-01-01 22:16:27 +01:00
|
|
|
jz @f
|
2015-07-17 16:16:36 +02:00
|
|
|
mov [IDE_common_irq_param], 0
|
|
|
|
out dx, al ; clear Interrupt bit
|
2014-01-01 22:16:27 +01:00
|
|
|
sub edx, 2
|
|
|
|
xor eax, eax
|
2015-07-17 16:16:36 +02:00
|
|
|
out dx, al ; clear Bus Master IDE Command register
|
2014-01-01 22:16:27 +01:00
|
|
|
mov edx, [hdbase]
|
2015-07-17 16:16:36 +02:00
|
|
|
add edx, 7
|
|
|
|
in al, dx ; read status register
|
|
|
|
mov eax, [eventPointer]
|
|
|
|
mov ebx, [eventID]
|
|
|
|
xor edx, edx
|
|
|
|
xor esi, esi
|
|
|
|
call raise_event
|
2014-01-01 22:16:27 +01:00
|
|
|
popad
|
|
|
|
popfd
|
2015-07-17 16:16:36 +02:00
|
|
|
mov al, 1 ; remove the interrupt request
|
2014-01-01 22:16:27 +01:00
|
|
|
ret
|
|
|
|
@@:
|
2010-10-01 11:21:55 +02:00
|
|
|
popad
|
2013-06-28 10:02:49 +02:00
|
|
|
popfd
|
2015-07-17 16:16:36 +02:00
|
|
|
.exit:
|
|
|
|
xor eax, eax ; not our interrupt
|
2010-10-01 11:21:55 +02:00
|
|
|
ret
|
2015-07-17 16:16:36 +02:00
|
|
|
;-----------------------------------------------------------------
|
2014-12-01 04:51:07 +01:00
|
|
|
proc clear_pci_ide_interrupts
|
|
|
|
mov esi, pcidev_list
|
2013-09-14 20:55:13 +02:00
|
|
|
align 4
|
2014-12-01 04:51:07 +01:00
|
|
|
.loop:
|
|
|
|
mov esi, [esi+PCIDEV.fd]
|
|
|
|
cmp esi, pcidev_list
|
|
|
|
jz .done
|
|
|
|
|
|
|
|
; cmp [esi+PCIDEV.class], 0x01018F
|
|
|
|
mov eax, [esi+PCIDEV.class]
|
|
|
|
shr eax, 4
|
|
|
|
cmp eax, 0x01018
|
|
|
|
jnz .loop
|
|
|
|
|
|
|
|
mov ah, [esi+PCIDEV.bus]
|
|
|
|
mov al, 2
|
|
|
|
mov bh, [esi+PCIDEV.devfn]
|
|
|
|
mov bl, 0x20
|
|
|
|
call pci_read_reg
|
|
|
|
|
|
|
|
and eax, 0FFFCh
|
|
|
|
mov edx, eax
|
|
|
|
add edx, 2
|
|
|
|
in al, dx
|
|
|
|
DEBUGF 1,'K : clear_pci_ide_interrupts: port[%x] = %x ',dx,al
|
|
|
|
out dx, al
|
|
|
|
in al, dx
|
|
|
|
DEBUGF 1,'-> %x; ',al
|
|
|
|
add edx, 8
|
|
|
|
in al, dx
|
|
|
|
DEBUGF 1,'port[%x] = %x ',dx,al
|
|
|
|
out dx, al
|
|
|
|
in al, dx
|
|
|
|
DEBUGF 1,'-> %x\n',al
|
|
|
|
jmp .loop
|
|
|
|
.done:
|
|
|
|
ret
|
|
|
|
endp
|