how to convert a virutal address to physical address in Solaris driver

Below discussion posted in osol-code mailing list tells how to use ddi interface to convert virtual address to physical address in Solaris driver.

====

If you are writing a device driver, or porting one, then you're going about this entirely the wrong way. These APIs should only be used by low level platform code, not from within device drivers. In fact, hat_getkpfnum generates warnings if you use it!

Assuming that this is an ordinary device driver, and not something really unusual (really unusual would mean something like a new MMU layer or somesuch), then you need to use the Solaris DDI DMA interfaces.

ddi_dma_alloc_handle() to get a handle.
ddi_dma_mem_alloc() to allocate memory (unless you already have memory).
ddi_dma_addr_bind_handle() to bind DMA addresses, and get the "cookie" for the corresponding physical address.
ddi_dma_buf_bind_handle() if you're working buf(9S) structures instead of arbitrary memory

This may sound like more work, but the end result is portable and safe, and will even work on amd64 and SPARC systems.

=====

你可能感兴趣的:(Solaris)