Page 1 of 1

IDE Tutorial Again

Posted: Fri Oct 19, 2012 12:24 pm
by ateno3
I want to make you a question, I hope you could understand me because my English is poor ( I am spanish ). At the beginning of the function "ide_initialize" you have written this:

Code: Select all

   channels[ATA_PRIMARY  ].base  = (BAR0 & 0xFFFFFFFC) + 0x1F0 * (!BAR0);
   channels[ATA_PRIMARY  ].ctrl  = (BAR1 & 0xFFFFFFFC) + 0x3F4 * (!BAR1);
   channels[ATA_SECONDARY].base  = (BAR2 & 0xFFFFFFFC) + 0x170 * (!BAR2);
   channels[ATA_SECONDARY].ctrl  = (BAR3 & 0xFFFFFFFC) + 0x374 * (!BAR3);
And you said that base should be 0x1F0, but I don't know why you do these operations ( channels[ATA_PRIMARY ].base = (BAR0 & 0xFFFFFFFC) + 0x1F0 * (!BAR0); ) Wouldn't it be better if put:

Code: Select all

channels[ATA_PRIMARY  ].base  = BAR0;
??
I think it, because I have done the operation you have written and the base is not what has BAR0.

Could you explain me the reason of this operations?

Thanks a lot :)

Re: IDE Tutorial

Posted: Fri Oct 19, 2012 12:42 pm
by Combuster
Learn to read, thanks.
BAR0: Base address of primary channel (I/O space), if it is 0x0 or 0x1, the port is 0x1F0.
BAR1: Base address of primary channel control port (I/O space), if it is 0x0 or 0x1, the port is 0x3F4.
BAR2: Base address of secondary channel (I/O space), if it is 0x0 or 0x1, the port is 0x170.
BAR3: Base address of secondary channel control port, if it is 0x0 or 0x1, the port is 0x374.

Re: IDE Tutorial

Posted: Fri Oct 19, 2012 1:37 pm
by ateno3
Combuster wrote:Learn to read, thanks.
BAR0: Base address of primary channel (I/O space), if it is 0x0 or 0x1, the port is 0x1F0.
BAR1: Base address of primary channel control port (I/O space), if it is 0x0 or 0x1, the port is 0x3F4.
BAR2: Base address of secondary channel (I/O space), if it is 0x0 or 0x1, the port is 0x170.
BAR3: Base address of secondary channel control port, if it is 0x0 or 0x1, the port is 0x374.
Thanks for your answer.
But, you have not answered my question. If we suppose that the parameter BAR0, which I send to the function, is 0x1F0:

( BAR0 & 0xFFFFFFFC ) + 0x1F0 * ( !BAR0 );
( 0x1F0 & 0xFFFFFFFC ) + 0x1F0 * ( !0x1F0) =
= 0x1F0 + 0x1F0 * 0xFFFFFE0F = 0x1F0 + 0xFFFC3D10 = 0xFFFF3F00 (???)

And if we suppose that the parameter is 0x00:

( 0x00 & 0xFFFFFFFC ) + 0x1F0 * ( !0x00) =
= 0x00 + 0x1F0 * 0xFFFFFFFF = 0xFFFFFE10 ( ??? )

As I can see it, the results aren't the correct ( I think )
Moreover, you haven't answered the another question: Why this??

But, Thanks a lot for answer. :)

Re: IDE Tutorial

Posted: Fri Oct 19, 2012 2:12 pm
by Griwes
You seem to fail to differentiate operators ! and ~ in C...

(tip: logical vs bitwise negation)

Re: IDE Tutorial

Posted: Sat Oct 20, 2012 4:32 am
by ateno3
Griwes wrote:You seem to fail to differentiate operators ! and ~ in C...

(tip: logical vs bitwise negation)
ahhh....
Thank you very much, I have already understood. :)

Re: IDE Tutorial

Posted: Sat Oct 20, 2012 7:29 am
by qw
Griwes wrote:You seem to fail to differentiate operators ! and ~ in C...
He may, but using boolean operators like this is considered bad practice for good reason.