Hello!
On 11:25 Sat 13 Dec , Peerless Deepak wrote:
> Hi,
>
> I am trying to get a page from RAM write some values in it in kernel
> space and then read them in user space using mmap.
> Below is the code i use, to fill the memory with a pattern in kernel space.
>
> ptr =get_zeroed_page (__GFP_DMA);
>
> printk("Peerless:The Virtual addr ptr: %08lx \n",ptr);
> phyaddr = virt_to_phys(ptr);
> printk("Phy addr is :%08lx \n",phyaddr);
> printk(" Virtual addr s :%08lx \n",phys_to_virt(phyaddr) );
> printk("At %x is %x \n",phyaddr,(*ptr));
> memset(ptr,0xaabb,4096);
Read memset description (lib/string.c:524):
memset - Fill a region of memory with the given value
@s: Pointer to the start of the area.
@c: The byte to fill the area with
@count: The size of the area.
Do not use memset() to access IO space, use memset_io() instead.
'c' should be a byte (it's impossible to write '0xaabb's using memset).
I don't know in what cases 'phys_to_virt' and 'virt_to_phys' are
applicable, but they might not be working with a page given by
get_zeroed_page (__GFP_DMA).
>
> printk("At %ld is %x \n",phyaddr,(*ptr));
> printk("At %ld is %x \n",++phyaddr,++(*ptr));
>
>
> But when i insmod the above module I dont see the pattern 0xaabb in
> the printk's. Guess I am missing the basics.Help will be greatly
> appreciated.
>
> Thanks
> Deepak
>
Alexander
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ