MPC5200 mmap, ioremap
Kunkel, Ulrich
Ulrich.Kunkel at hbm.com
Mon Aug 22 18:47:39 EST 2005
Hello,
I am using a Motorola PPC Hardware (MPC5200) with linux kernel 2.4.25 and 32
MB RAM.
I would like to map a large contiguous kernel memory buffer (6 MB) into
user space with mmap and remap_page_range. For this action I reserved memory
at the end of the phyiscal memory at boot time. (Kernel boot option mem =12
M) Now, the kernel only knows about 20 MB of memory. The high_memory border
is at 0x1400000 (physical address).
I have to do a ioremap() on the high_memory (0x1400000) to map the high
physical memory into a virtual kernel memory.
ioremap_ptr = ioremap_nocache (__pa(high_memory), 6*1024*1024); //6 MB
ioremap_ptr is a virtual kernel address.
Now I do a mem_map_reserve () on every page in this memory block.
On the ioremap ptr I do a memset to check the data in user space later.
memset(ioremap_ptr, 0xAB, 6*1024*1024);
With bdi2000 I looked to the memory values at 0x1400000 and everything is
ok, I see 0xABABABAB.
If I do a virt_to_phys() on ioremap_ptr, I get a really strange address. I
expected to get the physical address 0x1400000.
Example:
__pa(high_memory): 0x1400000
ioremap_ptr: 0xc22a4000
virt_to_phys(ioremap_ptr): 0x22a4000
virt_to_bus(ioremap_ptr): 0x22a4000
Now I want to map the buffer into to user space with mmap and
remap_page_range.
static int mmmap (struct file *file, struct vm_area_struct *vma)
{
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
int error;
unsigned long start = (unsigned long)vma->vm_start;
unsigned long size = (unsigned long)(vma->vm_end - vma->vm_start);
if (offset != 0)
{
printk ("rt_iso1394_mmap: invalid offset: must be 0\n");
return -ENXIO;
}
if(size == PAGE_ALIGN(6*1024*1024)
{
start,virt_to_phys(shared_buffer_ptr), size, protect);
error = remap_page_range (vma->vm_start, 0x1400000 , size, PAGE_SHARED);
if (error)
{
printk ("rt_iso1394_mmap: remap_page_range failed\n");
return -EAGAIN;
}
}
else
{
printk ("rt_iso1394_mmap: invalid mmap size, size is: %d\n", (int) size);
return -EAGAIN;
}
return 0;
}
The function returned with no errors.
If I call mmap () in user space, the function returnes a virtual user
address. But if do a read on this memory, I don't see the data I have
written in the kernel data block in kernel space. I only get zeros. It seems
that remap_page_range maps a completely different data block.
Are the any ideas to solve the problem? What I am doing wrong? What is
missing? Where ist the problem with the addresses???
Thanks for your help
Ulrich Kunkel
Hottinger Baldwin Messtechnik GmbH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ozlabs.org/pipermail/linuxppc-embedded/attachments/20050822/ceacb859/attachment.htm
More information about the Linuxppc-embedded
mailing list