2

I have a somewhat unusual situation where I'm developing a simulation module for an Ethernet device. Ideally, the simulation layer would just be identical to the real hardware with regard to the register set. The issue I've run into is that the DMA registers in the hardware are loaded with the DMA mapping (physical) address of the data. I need to use those physical addresses to copy the data from the Tx buffer on the source device to the Rx buffer on the destination device. To do that in module code, I need pointers to virtual memory. I looked at phys_to_virt() and I didn't understand this comment in the man page:

This function does not handle bus mappings for DMA transfers.

Does this mean that a physical address that is retrieved via dma_map_single cannot be converted back to a virtual address using phys_to_virt()? Is there another way to accomplish this conversion?

4

3 に答える 3

0

DMA アドレスを仮想アドレスにマップする一般的な方法はありません。dma_map_single() 関数は IOMMU (Intel x86 システムの VT-d など) をプログラミングしている可能性があり、その結果、元の物理アドレスまたは仮想アドレスとはまったく関係のない DMA アドレスが生成されます。ただし、このプレゼンテーションとリンクされたスライドは、エミュレートされたハードウェア モデルを実際のドライバーに接続するための 1 つのアプローチを提供します (基本的には、仮想化を使用します)。

于 2013-02-20T17:37:37.360 に答える
0

私はこの質問についてあまり明確ではありませんが、使用している"phys_to_virt()"場合、バス上で使用可能なアドレスがこの関数によって仮想に変換できない理由である可能性があります。関数を試すだけではわかりませんbus_to_virt(bus_addr);

于 2013-02-19T13:44:38.760 に答える