Re: Accessing file mapped data inside the kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 9 Nov 2005, Paulo da Silva wrote:

> Hi.
>
> I posted about this a few days ago but got no responses
> so far! I think this should be a trivial question for those
> involved in the kernel internals. May be I didn't develop
> the problem enough to be understood.
>
> So, here is the question reformulated.
>
> A given file system must supply a procedure for mmap.
>
> int <fsname>_file_mmap(struct file * file, struct vm_area_struct * vma)
> {
>   int addr;
>   addr=generic_file_mmap(file,vma);
>   <Code to access addr pointed bytes or vma->vm_start>
>   return addr;
> }
>

The mmap() code in the kernel in your module contains the physical
location of the memory-mapped data as the third parameter to
remap_pfn_range(a, b, c, d, e);
                       |____________ here.

Your code should have put the bus address of your memory
into that location as PAGES, which means you shifted it right
by PAGE_SHIFT. If you got your memory from get_dma_pages()
or similar, you needed to convert the virtual address using
virt_to_bus() so you already have the virtual address. If
not, you need to get the virtual address by taking this
page address and shifting it left by PAGE_SHIFT. Then you
convert that address to virtual using bus_to_virt().

[SNIPPED...]


Cheers,
Dick Johnson
Penguin : Linux version 2.6.13.4 on an i686 machine (5589.55 BogoMips).
Warning : 98.36% of all statistics are fiction.
.

****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux