Code: Select all
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
Code: Select all
;((~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~))
;(( ATA DRIVER ))
;((~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~))
%define ATA
%include "system.inc"
[BITS 32]
; define primary bus ports
%define PB_0 0x1F0
%define PB_1 0x1F1
%define PB_2 0x1F2
%define PB_3 0x1F3
%define PB_4 0x1F4
%define PB_5 0x1F5
%define PB_6 0x1F6
%define PB_7 0x1F7
%define PB_8 0x1F8
; define secondary bus ports
%define SB_0 0x170
%define SB_1 0x171
%define SB_2 0x172
%define SB_3 0x173
%define SB_4 0x174
%define SB_5 0x175
%define SB_6 0x176
%define SB_7 0x177
%define SB_8 0x178
global _init_in_PIO
_init_in_PIO:
; setup stack frame
push ebp
mov ebp,esp
pushad
; get the primary bus's status byte
xor eax,eax
mov dx,PB_7
in al,dx
; check to make sure the primary bus isn't "floating"
cmp al,0xFF
jz .primary_floats
jmp .primary_okay
.primary_floats:
; do ops
call _dbg_no
jmp .end
.primary_okay:
; get the secondary bus's status byte
xor eax,eax
mov dx,SB_7
in al,dx
; check to make sure the secondary bus isn't "floating"
cmp al,0xFF
jz .secondary_floats
jmp .secondary_okay
.secondary_floats:
; do ops
call _dbg_no
jmp .end
.secondary_okay:
; select the master drive on the primary bus
mov dx,PB_6
mov al,BYTE 0xA0
out dx,al
; 400ns delay for status byte to indicate readiness
mov dx,PB_7
in al,dx
in al,dx
in al,dx
in al,dx
; send the "identify" command (0xEC)
mov dx,PB_7
mov al,BYTE 0xEC
out dx,al
; 400ns delay for status byte to indicate readiness
mov dx,PB_7
in al,dx
in al,dx
in al,dx
in al,dx
; now read the status byte
xor eax,eax
in al,dx
;DEBUG
push eax
push dword 4
mov eax,esp
add eax,0x04
push eax
call VGA_PRINT_MEM_HEX
add esp,0x0c
;/DEBUG
.end:
; clean up stack frame
popad
mov esp,ebp
pop ebp
ret
Brodeur235