Error while accessing physical address

Garcia Jérémie GARCIAJ at 3il.fr
Thu Sep 1 23:44:23 EST 2005


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 = (unsigned short *) ioremap((unsigned short)address,0x1);

  printk("ioremap returned : %x\n",regHdwAddress);
  
  /* write hardware register data value */ 
  *regHdwAddress = 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...)







More information about the Linuxppc-dev mailing list