"Kernel logical address" vs "Physical address"

"Kernel logical address" vs "Physical address"

Post by Frederic Goddeeri » Fri, 14 Sep 2001 23:50:43



 I have a fairly basic question about "Kernel logical address" and "Physical
address".

In the book about Linux Device Drivers from Alessandro Rubini I read:

"Logical addresses make up the normal address-space of the kernel. . On most
architectures, logical and their associated physical addresses differ only
by a constant offset." __pa() is used to go from logical address to Physical
address; __va() the other way round.

I have been working on a PPC platform, running Linux 2.2. This platform has
a register where you can enable different options and where you can control
several LED's. The vendor mentions that this register is mapped in memory at
FA400000.

When I write (in a driver)

char *p=0xFA40000;

*p = ..; (I know I should use writeb to be more portable.)

it seems to work; the leds can be manipulated. But as FA400000 is a physical
address, I thought that it had to be *p=__va(0xFA40000);

Who can help me out? Where do I find a nice document about this?

Thanks,

Frederic

 
 
 

"Kernel logical address" vs "Physical address"

Post by vill » Sun, 16 Sep 2001 20:38:39


Quote:> I have been working on a PPC platform, running Linux 2.2. This platform
has
> a register where you can enable different options and where you can
control
> several LED's. The vendor mentions that this register is mapped in memory
at
> FA400000.

> When I write (in a driver)

> char *p=0xFA40000;

> *p = ..; (I know I should use writeb to be more portable.)

> it seems to work; the leds can be manipulated. But as FA400000 is a
physical
> address, I thought that it had to be *p=__va(0xFA40000);

Hi.
Don't know if my answer will be meaningless, but , I've supposed since here
that physical-logical address translations are made in that way for x86
architectures.
Probably I've not understood your question; you are working on an embedded
system right? in that case I suppose register addresses are not translated
in logical addresses so you can deal with them as if you were accessing
directly...
Otherwise I don't know, I'm reading LDD as well, where did you found that
phrase?

hope this helps, bye
Villo

 
 
 

"Kernel logical address" vs "Physical address"

Post by Frederic Goddeeri » Tue, 18 Sep 2001 17:21:45


I found this phrase in the second edition on page 372. I do not remember
reading this in the first edition. Do you know the second edition can be
donloaded? http://www.xml.com/ldd/chapter/book/

Yes I am working on an embedded system.

Regards,
Fred


Quote:

> > I have been working on a PPC platform, running Linux 2.2. This platform
> has
> > a register where you can enable different options and where you can
> control
> > several LED's. The vendor mentions that this register is mapped in
memory
> at
> > FA400000.

> > When I write (in a driver)

> > char *p=0xFA40000;

> > *p = ..; (I know I should use writeb to be more portable.)

> > it seems to work; the leds can be manipulated. But as FA400000 is a
> physical
> > address, I thought that it had to be *p=__va(0xFA40000);

> Hi.
> Don't know if my answer will be meaningless, but , I've supposed since
here
> that physical-logical address translations are made in that way for x86
> architectures.
> Probably I've not understood your question; you are working on an embedded
> system right? in that case I suppose register addresses are not translated
> in logical addresses so you can deal with them as if you were accessing
> directly...
> Otherwise I don't know, I'm reading LDD as well, where did you found that
> phrase?

> hope this helps, bye
> Villo

 
 
 

"Kernel logical address" vs "Physical address"

Post by Pete Zaitc » Wed, 19 Sep 2001 02:17:37


Quote:> > > I have been working on a PPC platform, running Linux 2.2.

> > > char *p=0xFA40000;
> > > address, I thought that it had to be *p=__va(0xFA40000);

OK, explaining 1000th time...

1. PPC is different in that its PA is split in two. If bit 31 is
set, the address goes directly out to the bus. So, here you
are using a PPC specific way. You can continue doing as you did,
as long as you do not port.

2. __va is only defined for translation of PA for memory, but
not for peripherals PA. JUST REMEMBER THAT ALREADY.

3. The portable way to access MMIO registers is ioremap/writeb.

-- Pete