* RE : Error while accessing physical address
@ 2005-09-01 14:20 Garcia Jérémie
0 siblings, 0 replies; 3+ messages in thread
From: Garcia Jérémie @ 2005-09-01 14:20 UTC (permalink / raw)
To: Marcin Dawidowicz; +Cc: linuxppc-dev
Tks for your answer Marcin. This is a good idea but unfortunately,=20
the result remains the same...
When using "ioremap", do I need need to use inb/oub... family to=20
handle those remapped address??
-------- Message d'origine--------
De: Marcin Dawidowicz [mailto:marcin.dawidowicz@kontron.pl]
Date: jeu. 01/09/2005 16:11
=C0: Garcia J=E9r=E9mie
Objet : Re: Error while accessing physical address
=20
Maybe you could try to change this:
> regHdwAddress =3D (unsigned short *) ioremap((unsigned =
short)address,0x1);
into this:
regHdwAddress =3D (unsigned short *) ioremap((unsigned =
short)address,sizeof=20
(unsigned short));
Cause you are accessing unsigned short register later.... and "unsigned =
short"=20
I assume is 2 bytes long.
Marcin
On Thursday 01 of September 2005 15:44, you wrote:
> Hi everybody.
>
> As a kernel newbie, I still encounter basic problems. I read a lot of
> things on the memory management, but obviously I didn't understand =
some
> things.
>
> I have some kernel source code that only write data to our card =
registers:
>
> void bhWriteCardRegister(unsigned short * address, unsigned short =
data)
> {
> unsigned short * regHdwAddress;
>
> printk("Writing data: %x at address:%x\n",data,address);
>
> /* Get the virtual address for the physical one */
> regHdwAddress =3D (unsigned short *) ioremap((unsigned =
short)address,0x1);
>
> printk("ioremap returned : %x\n",regHdwAddress);
>
> /* write hardware register data value */
> *regHdwAddress =3D data;
>
> iounmap((void *)regHdwAddress);
> }
> <<<<<<<<
>
> In a module init I call this function:
>
> #define CARD_PROCESSOR_CTRL_IN_SERVICE 0x8000
> #define CARD_PROCESSOR_CTRL_REG_P 0x40000400
> bhWriteCardRegister((unsigned short *)(CARD_PROCESSOR_CTRL_REG_P),
> (unsigned short)CARD_PROCESSOR_CTRL_IN_SERVICE); <<<<<<<<
>
> When I load this module on our powerPC 405EP based arch, the execution
> gives that:
>
> Writing data: 8000 at address:40000400
> ioremap returned : c2090400
> <<<<<<<<
>
> The problem is that after this write operation, every shell cmd I try =
give
> a "segmentation fault". What I did wrong ??
>
> Please help me cause I have to go on fast... (tks boss...)
>
>
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: RE : Error while accessing physical address
@ 2005-09-01 14:40 Nghiem, Tien
2005-09-01 16:00 ` Segher Boessenkool
0 siblings, 1 reply; 3+ messages in thread
From: Nghiem, Tien @ 2005-09-01 14:40 UTC (permalink / raw)
To: Garcia Jérémie, Marcin Dawidowicz; +Cc: linuxppc-dev
Hi Garcia,
unsigned short is 2 bytes, so you should use:
regHdwAddress =3D (unsigned short *) ioremap((unsigned =
short)address,0x2);
Tien
-----Original Message-----
From: linuxppc-dev-bounces@ozlabs.org
[mailto:linuxppc-dev-bounces@ozlabs.org]On Behalf Of Garcia J=E9r=E9mie
Sent: Thursday, September 01, 2005 10:20 AM
To: Marcin Dawidowicz
Cc: linuxppc-dev@ozlabs.org
Subject: RE : Error while accessing physical address
Tks for your answer Marcin. This is a good idea but unfortunately,=20
the result remains the same...
When using "ioremap", do I need need to use inb/oub... family to=20
handle those remapped address??
-------- Message d'origine--------
De: Marcin Dawidowicz [mailto:marcin.dawidowicz@kontron.pl]
Date: jeu. 01/09/2005 16:11
=C0: Garcia J=E9r=E9mie
Objet : Re: Error while accessing physical address
=20
Maybe you could try to change this:
> regHdwAddress =3D (unsigned short *) ioremap((unsigned =
short)address,0x1);
into this:
regHdwAddress =3D (unsigned short *) ioremap((unsigned =
short)address,sizeof=20
(unsigned short));
Cause you are accessing unsigned short register later.... and "unsigned =
short"=20
I assume is 2 bytes long.
Marcin
On Thursday 01 of September 2005 15:44, you wrote:
> Hi everybody.
>
> As a kernel newbie, I still encounter basic problems. I read a lot of
> things on the memory management, but obviously I didn't understand =
some
> things.
>
> I have some kernel source code that only write data to our card =
registers:
>
> void bhWriteCardRegister(unsigned short * address, unsigned short =
data)
> {
> unsigned short * regHdwAddress;
>
> printk("Writing data: %x at address:%x\n",data,address);
>
> /* Get the virtual address for the physical one */
> regHdwAddress =3D (unsigned short *) ioremap((unsigned =
short)address,0x1);
>
> printk("ioremap returned : %x\n",regHdwAddress);
>
> /* write hardware register data value */
> *regHdwAddress =3D data;
>
> iounmap((void *)regHdwAddress);
> }
> <<<<<<<<
>
> In a module init I call this function:
>
> #define CARD_PROCESSOR_CTRL_IN_SERVICE 0x8000
> #define CARD_PROCESSOR_CTRL_REG_P 0x40000400
> bhWriteCardRegister((unsigned short *)(CARD_PROCESSOR_CTRL_REG_P),
> (unsigned short)CARD_PROCESSOR_CTRL_IN_SERVICE); <<<<<<<<
>
> When I load this module on our powerPC 405EP based arch, the execution
> gives that:
>
> Writing data: 8000 at address:40000400
> ioremap returned : c2090400
> <<<<<<<<
>
> The problem is that after this write operation, every shell cmd I try =
give
> a "segmentation fault". What I did wrong ??
>
> Please help me cause I have to go on fast... (tks boss...)
>
>
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: RE : Error while accessing physical address
2005-09-01 14:40 RE : Error while accessing physical address Nghiem, Tien
@ 2005-09-01 16:00 ` Segher Boessenkool
0 siblings, 0 replies; 3+ messages in thread
From: Segher Boessenkool @ 2005-09-01 16:00 UTC (permalink / raw)
To: Nghiem, Tien; +Cc: linuxppc-dev, Marcin Dawidowicz, Garcia Jérémie
> unsigned short is 2 bytes, so you should use:
>
> regHdwAddress = (unsigned short *) ioremap((unsigned
> short)address,0x2);
Nah. The size doesn't matter that much (it will be mapped
with a page granularity anyway). You just want to use
regHdwAddress = (unsigned short *)ioremap(address, 2);
Casting the address to unsigned short made the address 0x0400
instead of the address you wanted, so you destroy the ISI
vector when writing to it (and you might cause a cache paradox
as well, as the ioremap maps it uncacheable, and it might
already be in the cache at that time).
Segher
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-09-01 16:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-01 14:40 RE : Error while accessing physical address Nghiem, Tien
2005-09-01 16:00 ` Segher Boessenkool
-- strict thread matches above, loose matches on Subject: below --
2005-09-01 14:20 Garcia Jérémie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).