答复: help:How to map a physical address into a kernel address?
imp at bsdimp.com
Tue May 16 08:46:23 PDT 2006
> I find that busdma can not help on this. Please note that we need access the
> data buffer in kernel space, so we must get the kernel virtual address of
> the data buffer. Using busdma can only access the data buffer in firmware,
> however, I need to access the data buffer in kernel space! Please help me!
I'm unclear why busdma can't help you. You get access to both the PA
and VA via the busdma interface. Otherwise, it would be impossible to
write a network driver. The PA is given to you in the
bus_dmamap_load's callback function's segs and nseg argument. The VA
is passed in via the bus_dmamap_load's 'buf' address and is allocated
elsewhere. The typical usage is to fill in what you are calling the
sg_table in the callback and start the device's DMA.
You can get to this information at runtime, but it causes driver
portability problems and its use is strongly discouraged. Since the
busdma functions deal with all these details, including bounce
buffering on large memory configurations, thier use is strongly
encouraged. If I'm not understanding your needs, then you can find
all you need in the i386/i386/pmap.c and i386/include/pmap.h. The vm
mapping functions can be found in include/vm*.h and vm/vm*.c. Careful
study is needed to use them correctly, although some of them are
documented in man pages.
> Best wishes,
> 发件人: M. Warner Losh [mailto:imp at bsdimp.com]
> 发送时间: 2006年5月13日 8:33
> 收件人: hongz at promisechina.com
> 抄送: freebsd-hackers at freebsd.org
> 主题: Re: help:How to map a physical address into a kernel address?
> In message: <1147340690$36076$55833599 at email@example.com>
> <hongz at promisechina.com> writes:
> : To access sg_table in kernel address, I need to map the starting physical
> : address of a segment into a kernel address. As I know that, we can use
> : phystovirt()/bustovirt(), or kmap()/kmap_atomic() to map a bus/physical
> : address or a physical page into a kernel address in Linux, but I did not
> : find such a function in FreeBSD. Please help me on this, it is very
> Use busdma.
More information about the freebsd-hackers