Chinese translated version of Documentation/pcmcia/devicetable
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: 530999000@qq.com
---------------------------------------------------------------------
Documentation/pcmcia/devicetable的中文翻译
如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。
中文版维护者: 王明达 530999000@qq.com
中文版翻译者: 王明达 530999000@qq.com
中文版校译者: 王明达 530999000@qq.com
以下为正文
---------------------------------------------------------------------
Accessing PCI device resources through sysfs
通过sysfs访问PCI设备资源
--------------------------------------------
sysfs, usually mounted at /sys, provides access to PCI resources on platforms
that support it. For example, a given bus might look like this:
sysfs,通常安装在/ sys目录,提供的平台上使用PCI资源
支持它。例如,对于一个给定总线可能看起来像这样:
/sys/devices/pci0000:17
|-- 0000:17:00.0
| |-- class
| |-- config
| |-- device
| |-- enable
| |-- irq
| |-- local_cpus
| |-- remove
| |-- resource
| |-- resource0
| |-- resource1
| |-- resource2
| |-- rom
| |-- subsystem_device
| |-- subsystem_vendor
| `-- vendor
`-- ...
The topmost element describes the PCI domain and bus number. In this case,
the domain number is 0000 and the bus number is 17 (both values are in hex).
This bus contains a single function device in slot 0. The domain and bus
numbers are reproduced for convenience. Under the device directory are several
files, each with their own function.
最顶层的元素描述了PCI的域和总线号码。在这种情况下,域名数为0000,总线编号为17
(两个值都为十六进制)。该总线在槽0包含一个单一功能的设备,域和总线数字再现了方
便。设备目录下有几个文件,用自己的功能。
file function
---- --------
class PCI class (ascii, ro)
config PCI config space (binary, rw)
device PCI device (ascii, ro)
enable Whether the device is enabled (ascii, rw)
irq IRQ number (ascii, ro)
local_cpus nearby CPU mask (cpumask, ro)
remove remove device from kernel's list (ascii, wo)
resource PCI resource host addresses (ascii, ro)
resource0..N PCI resource N, if present (binary, mmap, rw[1])
resource0_wc..N_wc PCI WC map resource N, if prefetchable (binary, mmap)
rom PCI ROM resource, if present (binary, ro)
subsystem_device PCI subsystem device (ascii, ro)
subsystem_vendor PCI subsystem vendor (ascii, ro)
vendor PCI vendor (ascii, ro)
ro - read only file
rw - file is readable and writable
wo - write only file
mmap - file is mmapable
ascii - file contains ascii text
binary - file contains binary data
cpumask - file contains a cpumask type
[1] rw for RESOURCE_IO (I/O port) regions only
The read only files are informational, writes to them will be ignored, with
the exception of the 'rom' file. Writable files can be used to perform
actions on the device (e.g. changing config space, detaching a device).
mmapable files are available via an mmap of the file at offset 0 and can be
used to do actual device programming from userspace. Note that some platforms
don't support mmapping of certain resources, so be sure to check the return
value from any attempted mmap. The most notable of these are I/O port
resources, which also provide read/write access.
只读文件是信息性的,写入他们将被忽略,除了‘rom’文件。可写的文件可以被用来执行
行动装置上(例如变化的配置空间,分离设备)。 mmapable文件可通过mmap的偏移量为0
的文件,并可以从用户空间用来做实际的设备编程。需要注意的是某些平台上不支持某些
资源mmapping,所以一定要检查返回从任何企图的mmap值。其中最引人注目的是I / O端口
资源,还提供读/写访问。
The 'enable' file provides a counter that indicates how many times the device
has been enabled. If the 'enable' file currently returns '4', and a '1' is
echoed into it, it will then return '5'. Echoing a '0' into it will decrease
the count. Even when it returns to 0, though, some of the initialisation
may not be reversed.
“启用”文件提供了一个计数器,指示多少次的设备已启用。如果“启用”文件目前返回'4','1'
回荡到它,它就会返回'5'。相应'0'将减少计数。甚至当它返回到0,不过,一些初始化很可
能不会转回。
The 'rom' file is special in that it provides read-only access to the device's
ROM file, if available. It's disabled by default, however, so applications
should write the string "1" to the file to enable it before attempting a read
call, and disable it following the access by writing "0" to the file. Note
that the device must be enabled for a rom read to return data successfully.
In the event a driver is not bound to the device, it can be enabled using the
'enable' file, documented above.
“ROM”文件是特殊的,因为它提供只读访问设备的ROM文件如果有的话。默认情况下禁用的,但是
,这样的应用程序应该写字符串“1”的文件来启用它,然后再尝试一个读操作,通过写“0”到文件
的访问后禁用它。注意该设备必须启用一个ROM读取成功返回数据。 如果驱动程序不绑定到设备,
它可以启用使用“启用”文件,上面记载。
The 'remove' file is used to remove the PCI device, by writing a non-zero
integer to the file. This does not involve any kind of hot-plug functionality,
e.g. powering off the device. The device is removed from the kernel's list of
PCI devices, the sysfs directory for it is removed, and the device will be
removed from any drivers attached to it. Removal of PCI root buses is
disallowed.
“删除”文件是用来卸下PCI设备,通过写一个非零整数文件。这不涉及任何形式的热插拔功能,
例如关闭设备电源。该设备从内核的列表中删除的PCI设备的sysfs目录被删除,并且该设备将
删除任何驱动程序连接到它。去除PCI根总线禁止。
Accessing legacy resources through sysfs
通过sysfs访问传统资源
----------------------------------------
Legacy I/O port and ISA memory resources are also provided in sysfs if the
underlying platform supports them. They're located in the PCI class hierarchy,
旧式I / O端口和ISA内存资源的sysfs中提供底层平台支持他们。他们位于PCI类层次结构,
e.g.
/sys/class/pci_bus/0000:17/
|-- bridge -> ../../../devices/pci0000:17
|-- cpuaffinity
|-- legacy_io
`-- legacy_mem
The legacy_io file is a read/write file that can be used by applications to
do legacy port I/O. The application should open the file, seek to the desired
port (e.g. 0x3e8) and do a read or a write of 1, 2 or 4 bytes. The legacy_mem
file should be mmapped with an offset corresponding to the memory offset
desired, e.g. 0xa0000 for the VGA frame buffer. The application can then
simply dereference the returned pointer (after checking for errors of course)
to access legacy memory space.
legacy_io文件是一个读/写文件,可以由应用程序用于做传统的I/O端口。该应用程序应该
打开文件,寻找到所需的端口(例如0X3E8),并做1个,2个或4个字节的读或写。legacy_mem
文件应该被映射对应于存储器所需偏移量。例如VGA帧缓冲区为0xa0000。然后,应用程序
可以简单引用返回的指针(当然是在检查错误后)访问旧的内存空间。
Supporting PCI access on new platforms
在新的平台上支持PCI访问
--------------------------------------
In order to support PCI resource mapping as described above, Linux platform
code must define HAVE_PCI_MMAP and provide a pci_mmap_page_range function.
Platforms are free to only support subsets of the mmap functionality, but
useful return codes should be provided.
如上所述,为了支持PCI资源映射,Linux平台代码必须定义HAVE_PCI_MMAP并提供
pci_mmap_page_range功能。平台是免费的,只支持mmap的功能子集,但应提供有用的返回代码。
Legacy resources are protected by the HAVE_PCI_LEGACY define. Platforms
wishing to support legacy functionality should define it and provide
pci_legacy_read, pci_legacy_write and pci_mmap_legacy_page_range functions.
遗产资源由HAVE_PCI_LEGACY定义保护。平台希望以支持传统的功能应该定义它,并提供
pci_legacy_read, pci_legacy_write and pci_mmap_legacy_page_range functions.
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: 530999000@qq.com
---------------------------------------------------------------------
Documentation/pcmcia/devicetable的中文翻译
如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。
中文版维护者: 王明达 530999000@qq.com
中文版翻译者: 王明达 530999000@qq.com
中文版校译者: 王明达 530999000@qq.com
以下为正文
---------------------------------------------------------------------
Accessing PCI device resources through sysfs
通过sysfs访问PCI设备资源
--------------------------------------------
sysfs, usually mounted at /sys, provides access to PCI resources on platforms
that support it. For example, a given bus might look like this:
sysfs,通常安装在/ sys目录,提供的平台上使用PCI资源
支持它。例如,对于一个给定总线可能看起来像这样:
/sys/devices/pci0000:17
|-- 0000:17:00.0
| |-- class
| |-- config
| |-- device
| |-- enable
| |-- irq
| |-- local_cpus
| |-- remove
| |-- resource
| |-- resource0
| |-- resource1
| |-- resource2
| |-- rom
| |-- subsystem_device
| |-- subsystem_vendor
| `-- vendor
`-- ...
The topmost element describes the PCI domain and bus number. In this case,
the domain number is 0000 and the bus number is 17 (both values are in hex).
This bus contains a single function device in slot 0. The domain and bus
numbers are reproduced for convenience. Under the device directory are several
files, each with their own function.
最顶层的元素描述了PCI的域和总线号码。在这种情况下,域名数为0000,总线编号为17
(两个值都为十六进制)。该总线在槽0包含一个单一功能的设备,域和总线数字再现了方
便。设备目录下有几个文件,用自己的功能。
file function
---- --------
class PCI class (ascii, ro)
config PCI config space (binary, rw)
device PCI device (ascii, ro)
enable Whether the device is enabled (ascii, rw)
irq IRQ number (ascii, ro)
local_cpus nearby CPU mask (cpumask, ro)
remove remove device from kernel's list (ascii, wo)
resource PCI resource host addresses (ascii, ro)
resource0..N PCI resource N, if present (binary, mmap, rw[1])
resource0_wc..N_wc PCI WC map resource N, if prefetchable (binary, mmap)
rom PCI ROM resource, if present (binary, ro)
subsystem_device PCI subsystem device (ascii, ro)
subsystem_vendor PCI subsystem vendor (ascii, ro)
vendor PCI vendor (ascii, ro)
ro - read only file
rw - file is readable and writable
wo - write only file
mmap - file is mmapable
ascii - file contains ascii text
binary - file contains binary data
cpumask - file contains a cpumask type
[1] rw for RESOURCE_IO (I/O port) regions only
The read only files are informational, writes to them will be ignored, with
the exception of the 'rom' file. Writable files can be used to perform
actions on the device (e.g. changing config space, detaching a device).
mmapable files are available via an mmap of the file at offset 0 and can be
used to do actual device programming from userspace. Note that some platforms
don't support mmapping of certain resources, so be sure to check the return
value from any attempted mmap. The most notable of these are I/O port
resources, which also provide read/write access.
只读文件是信息性的,写入他们将被忽略,除了‘rom’文件。可写的文件可以被用来执行
行动装置上(例如变化的配置空间,分离设备)。 mmapable文件可通过mmap的偏移量为0
的文件,并可以从用户空间用来做实际的设备编程。需要注意的是某些平台上不支持某些
资源mmapping,所以一定要检查返回从任何企图的mmap值。其中最引人注目的是I / O端口
资源,还提供读/写访问。
The 'enable' file provides a counter that indicates how many times the device
has been enabled. If the 'enable' file currently returns '4', and a '1' is
echoed into it, it will then return '5'. Echoing a '0' into it will decrease
the count. Even when it returns to 0, though, some of the initialisation
may not be reversed.
“启用”文件提供了一个计数器,指示多少次的设备已启用。如果“启用”文件目前返回'4','1'
回荡到它,它就会返回'5'。相应'0'将减少计数。甚至当它返回到0,不过,一些初始化很可
能不会转回。
The 'rom' file is special in that it provides read-only access to the device's
ROM file, if available. It's disabled by default, however, so applications
should write the string "1" to the file to enable it before attempting a read
call, and disable it following the access by writing "0" to the file. Note
that the device must be enabled for a rom read to return data successfully.
In the event a driver is not bound to the device, it can be enabled using the
'enable' file, documented above.
“ROM”文件是特殊的,因为它提供只读访问设备的ROM文件如果有的话。默认情况下禁用的,但是
,这样的应用程序应该写字符串“1”的文件来启用它,然后再尝试一个读操作,通过写“0”到文件
的访问后禁用它。注意该设备必须启用一个ROM读取成功返回数据。 如果驱动程序不绑定到设备,
它可以启用使用“启用”文件,上面记载。
The 'remove' file is used to remove the PCI device, by writing a non-zero
integer to the file. This does not involve any kind of hot-plug functionality,
e.g. powering off the device. The device is removed from the kernel's list of
PCI devices, the sysfs directory for it is removed, and the device will be
removed from any drivers attached to it. Removal of PCI root buses is
disallowed.
“删除”文件是用来卸下PCI设备,通过写一个非零整数文件。这不涉及任何形式的热插拔功能,
例如关闭设备电源。该设备从内核的列表中删除的PCI设备的sysfs目录被删除,并且该设备将
删除任何驱动程序连接到它。去除PCI根总线禁止。
Accessing legacy resources through sysfs
通过sysfs访问传统资源
----------------------------------------
Legacy I/O port and ISA memory resources are also provided in sysfs if the
underlying platform supports them. They're located in the PCI class hierarchy,
旧式I / O端口和ISA内存资源的sysfs中提供底层平台支持他们。他们位于PCI类层次结构,
e.g.
/sys/class/pci_bus/0000:17/
|-- bridge -> ../../../devices/pci0000:17
|-- cpuaffinity
|-- legacy_io
`-- legacy_mem
The legacy_io file is a read/write file that can be used by applications to
do legacy port I/O. The application should open the file, seek to the desired
port (e.g. 0x3e8) and do a read or a write of 1, 2 or 4 bytes. The legacy_mem
file should be mmapped with an offset corresponding to the memory offset
desired, e.g. 0xa0000 for the VGA frame buffer. The application can then
simply dereference the returned pointer (after checking for errors of course)
to access legacy memory space.
legacy_io文件是一个读/写文件,可以由应用程序用于做传统的I/O端口。该应用程序应该
打开文件,寻找到所需的端口(例如0X3E8),并做1个,2个或4个字节的读或写。legacy_mem
文件应该被映射对应于存储器所需偏移量。例如VGA帧缓冲区为0xa0000。然后,应用程序
可以简单引用返回的指针(当然是在检查错误后)访问旧的内存空间。
Supporting PCI access on new platforms
在新的平台上支持PCI访问
--------------------------------------
In order to support PCI resource mapping as described above, Linux platform
code must define HAVE_PCI_MMAP and provide a pci_mmap_page_range function.
Platforms are free to only support subsets of the mmap functionality, but
useful return codes should be provided.
如上所述,为了支持PCI资源映射,Linux平台代码必须定义HAVE_PCI_MMAP并提供
pci_mmap_page_range功能。平台是免费的,只支持mmap的功能子集,但应提供有用的返回代码。
Legacy resources are protected by the HAVE_PCI_LEGACY define. Platforms
wishing to support legacy functionality should define it and provide
pci_legacy_read, pci_legacy_write and pci_mmap_legacy_page_range functions.
遗产资源由HAVE_PCI_LEGACY定义保护。平台希望以支持传统的功能应该定义它,并提供
pci_legacy_read, pci_legacy_write and pci_mmap_legacy_page_range functions.