Page 1 of 1

Another PCI - ATA - Question - Need some direction

Posted: Sat Apr 26, 2014 2:06 am
by tsdnz
Hi Guys, The OS has been booting using SATA for month's now.

But I am having issues when booting from IDE.

I can find the IDE in PCI, which returns BAR0 to BAR4.

But when I query the device it returns error = ABRT indicates the requested command has been aborted due to a drive status error (such as not ready or write fault) or because the command is invalid.

Before this command there is no error and the device is ready.

Does anyone have any ideas??

Using VirtualBox, latest version.

Here is my code, in long mode, it returns error or 4h

Code: Select all

align 16
ProcX Start64
	; Master Drive Select
	Mov2	al, 0xA0
	Mov2	dx, 0x1F6
	out		dx, al
	
	; wait 400ns for drive select to work
	mov		dx, 0x3F6
	in		al, dx
	in		al, dx
	in		al, dx
	in		al, dx

	;  set the Sectorcount, LBAlo, LBAmid, and LBAhi IO ports to 0 (port 0x1F2 to 0x1F5)
	Mov2	al, 0
	Mov2	dx, 0x1F2
	out		dx, al
	call	Pause

	Mov2	al, 0
	Mov2	dx, 0x1F3
	out		dx, al
	call	Pause

	Mov2	al, 0
	Mov2	dx, 0x1F4
	out		dx, al
	call	Pause

	Mov2	al, 0
	Mov2	dx, 0x1F5
	out		dx, al
	call	Pause

	; send the IDENTIFY command (0xEC) to the Command IO port (0x1F7)
	Mov2	al, 0xEC
	Mov2	dx, 0x1F7
	out		dx, al
	call	Pause

	mov		dx, 0x1F1
	in		al, dx
	in		al, dx
	in		al, dx

	xor		rax, rax
	in		al, dx
	Mov2	rsi, msgHere
	Mov2	r15, rax
	call	MessageHEX64

	jmp $

Re: Another PCI - ATA - Question - Need some direction

Posted: Wed Jul 16, 2014 10:21 am
by SpyderTL
You might want to reset the controller before selecting the drive, just to be sure it is in a known state.

Also, sector count should probably not be set to zero...

Edit: I just noticed that you aren't actually reading any sectors. :)

I assume that this is a ATA hard drive, and not an ATAPI CD-ROM.

There may be something wrong with the Pause code as well. You might want to post that so that we can take a look.