==================================
ϡ
linux-2.6.13-rc5/Documentation/filesystems/sysfs-pci.txt 
Ǥ
Ρ JF ץ < http://www.linux.or.jp/JF/ >
  2005/8/28
  Hiroshi.Suzuki < setter at reset dot jp >
  Chie Nakatani  <jeanne at mbox dot kyoto-inet dot or dot jp>
         Seiji Kaneko  <skaneko at a2 dot mbn dot or dot jp>
==================================


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
     |   |-- irq
     |   |-- local_cpus
     |   |-- 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 (줾ͤ 16ʿ) 
ǤΥХˤϡå 0 ñǽǥХޤɥᥤȥХֹϡ
ص塢ɽƤޤǥХǥ쥯ȥˤϤĤΥե뤬ꡢ
줾줬ǽäƤޤ

       file		   function
       ----		   --------
       class		   PCI class (ascii, ro)
       config		   PCI config space (binary, rw)
       device		   PCI device (ascii, ro)
       irq		   IRQ number (ascii, ro)
       local_cpus	   nearby CPU mask (cpumask, ro)
       resource		   PCI resource host addresses (ascii, ro)
       resource0..N	   PCI resource N, if present (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
  mmap - file is mmapable
  ascii - file contains ascii text
  binary - file contains binary data
  cpumask - file contains a cpumask type

       ե		   ǽ
       ----		   --------
       class		   PCI 饹 (ascii, ro)
       config		   PCI  (binary, rw)
       device		   PCI ǥХ (ascii, ro)
       irq		   IRQ ֹ (ascii, ro)
       local_cpus	    CPU ޥ (cpumask, ro)
       resource		   PCI 񸻤Υۥȥɥ쥹 (ascii, ro)
       resource0..N	   ¸ߤʤ顢PCI  N (binary, mmap)
       rom		   ¸ߤʤ顢PCI ROM  (binary, ro)
       subsystem_device	   PCI ֥ƥǥХ (ascii, ro)
       subsystem_vendor	   PCI ֥ƥ٥ (ascii, ro)
       vendor		   PCI ٥ (ascii, ro)

  ro - ɤ߹ѥե
  rw - ɤ߽񤭤Ǥե
  mmap - ե mmap Ǥޤ
  ascii - ƥȤݻե
  binary - Хʥǡݻե
  cpumask - cpumask פݻե

The read only files are informational, writes to them will be ignored.
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.

ɤ߹ѥեϾ󶡤񤭹ߤ̵뤵ޤ
񤭹ߤǤեϡǥХν (㤨С֤ѹꡢǥХ)
¹ԤΤ˻Ȥޤmmap ǤեϡΥե mmap Τ
եå 0 饢뤳ȤѤǤޤ桼֤ºݤΥǥХ
ץߥ󥰤򤹤Τ˻ȤޤĤΥץåȥեǤϡλ񸻤 mmap 
ݡȤƤʤΤǡߤ줿ɤΤ褦 mmap ͤ⸡ʤФʤ
ʤȤդƤ

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 heirarchy,
e.g.

ƤץåȥեबݡȤƤʤ顢ŤϥݡȤȡISA 
񸻤⡢sysfs 󶡤ޤ ϡ˼褦ˡPCI 饹ؤ֤ޤ

	/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 եϡɤ߽񤭤Ǥեǡץꥱ󤬸ŤݡȤ
򤹤Τ˻Ȥޤץꥱϡե򳫤ŪΥݡ (㤨С0x3e8) 
õ1ޤϡ2 ޤϡ4ХȤɤ߹फ񤭹ޤʤФʤޤ
legacy_mem եϡŪΥꥪեå (㤨СVGA ե졼ХåեѤ 0xa0000)
бեåȤ mmap ʤФʤޤ
ץꥱϡñˡ֤줿ݥ (󥨥顼θ) ܻ
('*' 黻ҤȤäƻ)뤳ȤǡŤ֤˥Ǥޤ

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 ݸƤޤ
ץåȥեबŤǽ򥵥ݡȤȤHAVE_PCI_LEGACY 
pci_legacy_read, pci_legacy_write, pci_mmap_legacy_page_range ǽ
󶡤ʤФʤޤ
