Page 1 of 1

Ide Data Port Confusion Please help

Posted: Tue Nov 02, 2010 12:56 pm
by Muneer
I read that the Primary IDE Data port is Located at 0x1F0 and transfers are made as 16 Bit data.
Also I/O port 0x1F1 is the 8 Bit error register. All other registers make 8 Bit Transfers.

Well if that is the case, does that mean a Data Read/Write from/to Port 0x1F0 (8 Bit) in 16 bit would also include data in Port 0x1F1 ( 8 Bit of error register ).
Did I get it wrong . If so please correct me. If I am right then why do all the web pages fail to specify it.
Please help .. I am stuck.
Thanks in Advance :?

Re: Ide Data Port Confusion Please help

Posted: Tue Nov 02, 2010 1:31 pm
by mariuszp
I looked at an example code somewhere you just do this:

Code: Select all

unsigned char * buffer = whatever;
int count = (512/2)*sector_count; // no. of words to read
int i=0;
while (count--)
{
    u16int word = inw(0x1F0);
    buffer[i] = (word >> 8) & 0xFF;
    i++;
    buffer[i] = word & 0xFF;
    i++;
};
if thats what u mean

Re: Ide Data Port Confusion Please help

Posted: Wed Nov 03, 2010 3:01 am
by JamesM
Hi,
Well if that is the case, does that mean a Data Read/Write from/to Port 0x1F0 (8 Bit) in 16 bit would also include data in Port 0x1F1 ( 8 Bit of error register ).
Did I get it wrong . If so please correct me. If I am right then why do all the web pages fail to specify it.
Please help .. I am stuck.
I can see why you'd get confused. The I/O address space isn't like memory. Think of the port number as being a unique channel through which you can communicate with a device - conceptually like a TCP port. A write of 16-bits to port 0x1F0 won't affect port 0x1F1 in the same way that reading 2 bytes from http://localhost:80/ won't read one byte from :80 and one from :81.

James

Also, please don't add "please help" or somesuch on the end of your post titles. If you didn't need help, you wouldn't be posting.

Re: Ide Data Port Confusion Please help

Posted: Fri Nov 05, 2010 7:56 am
by Muneer
Hi MariusZp,
My piece of code already worked. All I needed was an explanation.
Could you please just explain.

Hi JamesM,

After reading your reply i was confused. How could a 16 bit read to port 0x1F0 not affect port 0x1F1. I am newbie into assembly. I have programmed before but have absolutely no idea with networking and the TCP port, localhost etc.. My piece of code worked well but i needed to understand why.
"Think of the port number as being a unique channel through which you can communicate with a device" Could you explain in detail..
Well For your comments on "Please Help", I am for the first time posting in a forum and was a bit nervous. Thanks

Re: Ide Data Port Confusion Please help

Posted: Fri Nov 05, 2010 12:48 pm
by Muneer
Ok I Get it .. If I read One byte from port 1f0 . I get One Byte. And If I read one word, then i get 16 bit data.
But just to clarify..... x86 Pcs have 16 bit IO addresses. and each address corresponds to one byte . So if you read 16 bits from 1f0 , does it mean that it is some sort of serial connection wherein you get 8 bits at a time and deliver it to Ah, and Another 8 bit and put into Al register so that Ax Register recieves 16 bit data for a code like
Mov Dx,0x1F0
In Ax,Dx

Re: Ide Data Port Confusion Please help

Posted: Fri Nov 05, 2010 2:10 pm
by Muneer
Yeah I Got It at last. It was that I was Confused about the Io Address Lines and the data lines.
The IO Address Lines are 16 bit. And an address can select a Port and
The Data Lines are 32 bit or 64 bit (depending on Processor) and the 16 bit data comes through the Data Lines.
Image


Did I get it Right?........Or Again lost something.?

Re: Ide Data Port Confusion Please help

Posted: Fri Nov 05, 2010 3:28 pm
by Hangin10
It's more like the device gets the three pieces of information: size, port, and read or write (and the value written for a write), and if the combination means something to the device, it'll either return data or the write will take effect.

Sometimes, for example, a device could get a 8bit read on port XXX, but the status register on port XXX is only expecting 16bit reads, so nothing will get returned by the device (whatever was on the bus previously (ie junk)). Or if it wanted to, a 16bit read could return a completely different status register than an 32bit read (meaning you can get 48 bits of status from port XXX).

It's more common for a read to be a status register, but a write to be an unrelated control register both with the same port number (and usually size).

Ide Data Port Confusion Please help [SOLVED]

Posted: Fri Nov 05, 2010 4:08 pm
by Muneer
Yeah. I finally got it. Thanks to all who helped me solve this problem