[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: external PCI board direct access
>I've got an external PCI board
>
>/proc/pci gives me :
> Non-prefetchable 32 bit memory at 0xfeaff800 [0xfeaff800].
> I/O at 0xd800 [0xd801].
> Non-prefetchable 32 bit memory at 0xfeaa0000 [0xfeaa0000].
> Non-prefetchable 32 bit memory at 0xfea80000 [0xfea80000].
>
>I'd like to access to memory at 0xfea80000 which is a SDRAM on my
>external board
>
>in my driver I made
>baseAddress=0xfea80000;
>sramSize=0x00020000;
>ptr = (u_int *) ioremap (baseAddress, sramSize)
>
>thanks to the pointer ptr I can access to the memory :
> for (i = 0; i < 0x10; i++)
> writel (i, the.ptrAccess + i);
>
> for (i = 0; i < 0x10; i++)
> printk ("at 0x%08x got 0x%08x\n", i, readl
>(the.ptrAccess + i));
>
>
>---------
>
>I want to do the same thing from my application.
>I can export ptr via an ioctl () access in order to do :
> for (i = 0; i < 0x10; i++)
> (*(volatile u_int *) (ptr + i)) = i;
>
> for (i = 0; i < 0x10; i++)
> printf ("at 0x%08x got 0x%08x\n", i, (*(volatile u_int
>*) (ptr + i)));
>
>as soon as I access to (*(volatile u_int *) (ptr + i)) I've got a
>"Segmentation fault (core dumped)"
you are passing kernel mode ptr to an user application, which will
obiviously crash on access that pointer. try to use mmap that region.
Regards,
Anil
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.surriel.com/kernelnewbies.shtml