Another PCI - ATA - Question - Need some direction

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
tsdnz
Member
Member
Posts: 333
Joined: Sun Jun 16, 2013 4:09 am

Another PCI - ATA - Question - Need some direction

Post 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 $
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

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

Post 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.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Post Reply