您的位置:首页 > 移动开发

Documentation/io-mapping.txt

2013-10-23 12:00 447 查看
Chinese translated version of Documentation/io-mapping.txt

If you have any comment or update to the content, please contact the

original document maintainer directly. However, if you have a problem

communicating in English you can also ask the Chinese maintainer for

help. Contact the Chinese maintainer if this translation is outdated

or if there is a problem with the translation.

Chinese maintainer: 秦芹 18768122412@163.com

---------------------------------------------------------------------

Documentation/io-mapping.txt的中文翻译

如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文

交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻

译存在问题,请联系中文版维护者。

中文版维护者: 秦芹 18768122412@163.com

中文版翻译者:秦芹 18768122412@163.com

以下为正文

---------------------------------------------------------------------

The io_mapping functions in linux/io-mapping.h provide an abstraction for

efficiently mapping small regions of an I/O device to the CPU. The initial

usage is to support the large graphics aperture on 32-bit processors where

ioremap_wc cannot be used to statically map the entire aperture to the CPU

as it would consume too much of the kernel address space.

在linux/io-mapping.h文件中的io_mapping函数提供了一个高效的将i/o设备的小

区域部分映射到CPU的抽象。初始的用途是支持32位处理器上的大型图形孔径,

而不能用于ioremap_wc静态映射整个孔径到CPU,因为它会消耗 太多的内核地址空间。

A mapping object is created during driver initialization using

在驱动程序初始化过程中,使用如下方式创建映射对象:

struct io_mapping *io_mapping_create_wc(unsigned long base,

unsigned long size)

'base' is the bus address of the region to be made

mappable, while 'size' indicates how large a mapping region to

enable. Both are in bytes.

‘base;是该区域用来制图的总线地址,而’size‘表示有多大的映射区

域能过使用。两者均以字节为单位。

This _wc variant provides a mapping which may only be used

with the io_mapping_map_atomic_wc or io_mapping_map_wc.

_wc变体仅为io_mapping_map_atomic_wc 和 io_mapping_map_wc提供映射。

With this mapping object, individual pages can be mapped either atomically

or not, depending on the necessary scheduling environment. Of course, atomic

maps are more efficient:

有了这个映射对象,独立页面是原子映射还是非原子映射取决于所需的环境调度。

当然,原子映射更为高效。

void *io_mapping_map_atomic_wc(struct io_mapping *mapping,

unsigned long offset)

'offset' is the offset within the defined mapping region.

Accessing addresses beyond the region specified in the

creation function yields undefined results. Using an offset

which is not page aligned yields an undefined result. The

return value points to a single page in CPU address space.

’offset‘是定义映射区域内的偏移量。超过指定区域内访问地址创

建函数就会产生不确定的结果。使用不是页对齐的偏移量产生不

确定结果。该返回值指向CPU地址空间的唯一页面。

This _wc variant returns a write-combining map to the

page and may only be used with mappings created by

io_mapping_create_wc

_wc变种返回一个写合并映射到页,可能只被用于创建

io_mapping_create_wc映射。

Note that the task may not sleep while holding this page

mapped.

请注意:该任务可能不能休眠而持续映射页。

void io_mapping_unmap_atomic(void *vaddr)

'vaddr' must be the the value returned by the last

io_mapping_map_atomic_wc call. This unmaps the specified

page and allows the task to sleep once again.

’vaddr‘必须是最后一次调用io_mapping_map_atomic_wc函数的

返回值。它取消映射到指定页面,并且允许该任务再次休眠。

If you need to sleep while holding the lock, you can use the non-atomic

variant, although they may be significantly slower.

当持有锁时,如果需要休眠,你就要使用非原子变体,尽管他们可能显得非常慢。

void *io_mapping_map_wc(struct io_mapping *mapping,

unsigned long offset)

This works like io_mapping_map_atomic_wc except it allows

the task to sleep while holding the page mapped.

这个函数有像io_mapping_map_atomic_wc函数一样的功能,

此外,他还允许当持有页面映射锁时任务的休眠。

void io_mapping_unmap(void *vaddr)

This works like io_mapping_unmap_atomic, except it is used

for pages mapped with io_mapping_map_wc.

这个函数像io_mapping_unmap_atomic函数一样,除了他被用作伴随

io_mapping_map_wc函数的页面映射。

At driver close time, the io_mapping object must be freed:

在驱动器关闭时,必须释放i/o_mapping对象。

void io_mapping_free(struct io_mapping *mapping)

Current Implementation:

目前的实现:

The initial implementation of these functions uses existing mapping

mechanisms and so provides only an abstraction layer and no new

functionality.

使用映射机制初步实现这些功能,所以仅仅提供一个抽象层,且没有新功能。

On 64-bit processors, io_mapping_create_wc calls ioremap_wc for the whole

range, creating a permanent kernel-visible mapping to the resource. The

map_atomic and map functions add the requested offset to the base of the

virtual address returned by ioremap_wc.

在64位处理器上,io_mapping_create_wc整个范围调用ioremap_wc,创建一个持

久的可见内核映射到资源库。自动映射和映射功能添加请求的偏移量到通

过ioremap_wc函数返回虚拟地址的基址上。

On 32-bit processors with HIGHMEM defined, io_mapping_map_atomic_wc uses

kmap_atomic_pfn to map the specified page in an atomic fashion;

kmap_atomic_pfn isn't really supposed to be used with device pages, but it

provides an efficient mapping for this usage.

在配置有HIGHMEM定义的32位处理器上,io_mapping_map_atomic_wc函数使

用kmap_atomic_pfn函数来以原子方式映射到指定页;在移动设备页上,

kmap_atomic_pfn函数并没有真正被使用,但是它为这个用途提供了高效的映射。

On 32-bit processors without HIGHMEM defined, io_mapping_map_atomic_wc and

io_mapping_map_wc both use ioremap_wc, a terribly inefficient function which

performs an IPI to inform all processors about the new mapping. This results

in a significant performance penalty.

在没有配置HIGHMEM定义的32位处理器上,io_mapping_map_atomic_wc和

io_mapping_map_wc都使用ioremap_wc函数,执行IPI来告知所有处理器关于

新的映射是一个非常低效的功能。这导致一个显著的性能损失。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: