Ide Data Port Confusion Please help

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
User avatar
Muneer
Member
Member
Posts: 104
Joined: Tue Nov 02, 2010 2:05 am
Location: India

Ide Data Port Confusion Please help

Post 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 :?
Even the smallest person could change the course of the future - Lord Of The Rings.

In the end all that matters is what you have done - Alexander.

Even after a decade oh god those still gives me the shivers.
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: Ide Data Port Confusion Please help

Post 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
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Ide Data Port Confusion Please help

Post 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.
User avatar
Muneer
Member
Member
Posts: 104
Joined: Tue Nov 02, 2010 2:05 am
Location: India

Re: Ide Data Port Confusion Please help

Post 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
Even the smallest person could change the course of the future - Lord Of The Rings.

In the end all that matters is what you have done - Alexander.

Even after a decade oh god those still gives me the shivers.
User avatar
Muneer
Member
Member
Posts: 104
Joined: Tue Nov 02, 2010 2:05 am
Location: India

Re: Ide Data Port Confusion Please help

Post 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
Even the smallest person could change the course of the future - Lord Of The Rings.

In the end all that matters is what you have done - Alexander.

Even after a decade oh god those still gives me the shivers.
User avatar
Muneer
Member
Member
Posts: 104
Joined: Tue Nov 02, 2010 2:05 am
Location: India

Re: Ide Data Port Confusion Please help

Post 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.?
Even the smallest person could change the course of the future - Lord Of The Rings.

In the end all that matters is what you have done - Alexander.

Even after a decade oh god those still gives me the shivers.
Hangin10
Member
Member
Posts: 162
Joined: Wed Feb 27, 2008 12:40 am

Re: Ide Data Port Confusion Please help

Post 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).
User avatar
Muneer
Member
Member
Posts: 104
Joined: Tue Nov 02, 2010 2:05 am
Location: India

Ide Data Port Confusion Please help [SOLVED]

Post by Muneer »

Yeah. I finally got it. Thanks to all who helped me solve this problem
Even the smallest person could change the course of the future - Lord Of The Rings.

In the end all that matters is what you have done - Alexander.

Even after a decade oh god those still gives me the shivers.
Post Reply