Convert virtual address to physical address
Pratik Singhal
ps06756 at gmail.com
Tue May 26 13:09:00 UTC 2015
Sir, Thanks for the help. I was missing the busdma 9 part and was passing
physical address directly to the hardware. I'll look into the busdma
interface of the kernel and use it instead.
On Mon, May 25, 2015 at 9:37 PM, Ian Lepore <ian at freebsd.org> wrote:
> On Mon, 2015-05-25 at 19:16 +0530, Pratik Singhal wrote:
> > I need to convert a kernel virtual address to physical address. To do
> that,
> > as far as I know, we have 2 macros :-
> >
> > vtophys :- In sys/arm/include/pmap.h
> > VTOP :- In sys/boot/i386/libi386/amd64_tramp.S
> >
> > Since, I am working on arm kernel with ARM_NEW_PMAP option, I am using
> > vtophys macro by including the pmap.h file.
> >
> > Now, if I compile the kernel after including the pmap.h file, I am
> getting
> > the error :-
> >
> > error: field has incomplete type 'struct pmap_statistics'
> > struct pmap_statistics pm_stats; /* pmap statictics */
> > ^
> > ./machine/pmap-v6.h:127:9: note: forward declaration of 'struct
> > pmap_statistics'
> > struct pmap_statistics pm_stats; /* pmap statictics */
> >
> > How, should I resolve this error ? Or is there some other way to convert
> > virtual address to physical address for arm kernel ?
>
> IMO, almost any question that begins with "I need to convert a virtual
> address to physical" is the wrong question to be asking.
>
> The reason you typically need physical addresses is to hand them to some
> piece of hardware to act on. You can't do that properly using
> vtophys(), you'll have cache coherency problems when the hardware
> touches the memory. The busdma family of functions does the right thing.
>
> If it's memory-mapped registers you're accessing rather than ram, you
> probably need bus_space_map() to create a proper device-memory mapping
> for it.
>
> -- Ian
>
>
>
--
Regards,
Pratik Singhal
More information about the freebsd-hackers
mailing list