六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 114|回复: 0

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

[复制链接]

升级  53.65%

673

主题

673

主题

673

主题

探花

Rank: 6Rank: 6

积分
2073
 楼主| 发表于 2013-1-16 16:36:25 | 显示全部楼层 |阅读模式
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.
=====
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表