Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 May 2015 10:07:18 -0600
From:      Ian Lepore <ian@freebsd.org>
To:        Pratik Singhal <ps06756@gmail.com>
Cc:        freebsd-hackers <freebsd-hackers@freebsd.org>
Subject:   Re: Convert virtual address to physical address
Message-ID:  <1432570038.1200.41.camel@freebsd.org>
In-Reply-To: <CAGf2gkNuO6b71pDhenZdyyRQPUtGCDn8UTyVrAwu0_TimKcMFg@mail.gmail.com>
References:  <CAGf2gkNuO6b71pDhenZdyyRQPUtGCDn8UTyVrAwu0_TimKcMFg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1432570038.1200.41.camel>