요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
Parport
+++++++
The ``parport`` code provides parallel-port support under Linux. This
includes the ability to share one port between multiple device
drivers.
You can pass parameters to the ``parport`` code to override its automatic
detection of your hardware. This is particularly useful if you want
to use IRQs, since in general these can't be autoprobed successfully.
By default IRQs are not used even if they **can** be probed. This is
because there are a lot of people using the same IRQ for their
parallel port and a sound card or network card.
The ``parport`` code is split into two parts: generic (which deals with
port-sharing) and architecture-dependent (which deals with actually
using the port).
Parport as modules
==================
If you load the `parport`` code as a module, say::
# insmod parport
to load the generic ``parport`` code. You then must load the
architecture-dependent code with (for example)::
# insmod parport_pc io=0x3bc,0x378,0x278 irq=none,7,auto
to tell the ``parport`` code that you want three PC-style ports, one at
0x3bc with no IRQ, one at 0x378 using IRQ 7, and one at 0x278 with an
auto-detected IRQ. Currently, PC-style (``parport_pc``), Sun ``bpp``,
Amiga, Atari, and MFC3 hardware is supported.
PCI parallel I/O card support comes from ``parport_pc``. Base I/O
addresses should not be specified for supported PCI cards since they
are automatically detected.
modprobe
--------
If you use modprobe , you will find it useful to add lines as below to a
configuration file in /etc/modprobe.d/ directory::
alias parport_lowlevel parport_pc
options parport_pc io=0x378,0x278 irq=7,auto
modprobe will load ``parport_pc`` (with the options ``io=0x378,0x278 irq=7,auto``)
whenever a parallel port device driver (such as ``lp``) is loaded.
Note that these are example lines only! You shouldn't in general need
to specify any options to ``parport_pc`` in order to be able to use a
parallel port.
Parport probe [optional]
------------------------
In 2.2 kernels there was a module called ``parport_probe``, which was used
for collecting IEEE 1284 device ID information. This has now been
enhanced and now lives with the IEEE 1284 support. When a parallel
port is detected, the devices that are connected to it are analysed,
and information is logged like this::
parport0: Printer, BJC-210 (Canon)
The probe information is available from files in ``/proc/sys/dev/parport/``.
Parport linked into the kernel statically
=========================================
If you compile the ``parport`` code into the kernel, then you can use
kernel boot parameters to get the same effect. Add something like the
following to your LILO command line::
parport=0x3bc parport=0x378,7 parport=0x278,auto,nofifo
You can have many ``parport=...`` statements, one for each port you want
to add. Adding ``parport=0`` to the kernel command-line will disable
parport support entirely. Adding ``parport=auto`` to the kernel
command-line will make ``parport`` use any IRQ lines or DMA channels that
it auto-detects.
Files in /proc
==============
If you have configured the ``/proc`` filesystem into your kernel, you will
see a new directory entry: ``/proc/sys/dev/parport``. In there will be a
directory entry for each parallel port for which parport is
configured. In each of those directories are a collection of files
describing that parallel port.
The ``/proc/sys/dev/parport`` directory tree looks like::
parport
|-- default
| |-- spintime
| `-- timeslice
|-- parport0
| |-- autoprobe
| |-- autoprobe0
| |-- autoprobe1
| |-- autoprobe2
| |-- autoprobe3
| |-- devices
| | |-- active
| | `-- lp
| | `-- timeslice
| |-- base-addr
| |-- irq
| |-- dma
| |-- modes
| `-- spintime
`-- parport1
|-- autoprobe
|-- autoprobe0
|-- autoprobe1
|-- autoprobe2
|-- autoprobe3
|-- devices
| |-- active
| `-- ppa
| `-- timeslice
|-- base-addr
|-- irq
|-- dma
|-- modes
`-- spintime
.. tabularcolumns:: |p{4.0cm}|p{13.5cm}|
======================= =======================================================
File Contents
======================= =======================================================
``devices/active`` A list of the device drivers using that port. A "+"
will appear by the name of the device currently using
the port (it might not appear against any). The
string "none" means that there are no device drivers
using that port.
``base-addr`` Parallel port's base address, or addresses if the port
has more than one in which case they are separated
with tabs. These values might not have any sensible
meaning for some ports.
``irq`` Parallel port's IRQ, or -1 if none is being used.
``dma`` Parallel port's DMA channel, or -1 if none is being
used.
``modes`` Parallel port's hardware modes, comma-separated,
meaning:
- PCSPP
PC-style SPP registers are available.
- TRISTATE
Port is bidirectional.
- COMPAT
Hardware acceleration for printers is
available and will be used.
- EPP
Hardware acceleration for EPP protocol
is available and will be used.
- ECP
Hardware acceleration for ECP protocol
is available and will be used.
- DMA
DMA is available and will be used.
Note that the current implementation will only take
advantage of COMPAT and ECP modes if it has an IRQ
line to use.
``autoprobe`` Any IEEE-1284 device ID information that has been
acquired from the (non-IEEE 1284.3) device.
``autoprobe[0-3]`` IEEE 1284 device ID information retrieved from
daisy-chain devices that conform to IEEE 1284.3.
``spintime`` The number of microseconds to busy-loop while waiting
for the peripheral to respond. You might find that
adjusting this improves performance, depending on your
peripherals. This is a port-wide setting, i.e. it
applies to all devices on a particular port.
``timeslice`` The number of milliseconds that a device driver is
allowed to keep a port claimed for. This is advisory,
and driver can ignore it if it must.
``default/*`` The defaults for spintime and timeslice. When a new
port is registered, it picks up the default spintime.
When a new device is registered, it picks up the
default timeslice.
======================= =======================================================
Device drivers
==============
Once the parport code is initialised, you can attach device drivers to
specific ports. Normally this happens automatically; if the lp driver
is loaded it will create one lp device for each port found. You can
override this, though, by using parameters either when you load the lp
driver::
# insmod lp parport=0,2
or on the LILO command line::
lp=parport0 lp=parport2
Both the above examples would inform lp that you want ``/dev/lp0`` to be
the first parallel port, and /dev/lp1 to be the **third** parallel port,
with no lp device associated with the second port (parport1). Note
that this is different to the way older kernels worked; there used to
be a static association between the I/O port address and the device
name, so ``/dev/lp0`` was always the port at 0x3bc. This is no longer the
case - if you only have one port, it will default to being ``/dev/lp0``,
regardless of base address.
Also:
* If you selected the IEEE 1284 support at compile time, you can say
``lp=auto`` on the kernel command line, and lp will create devices
only for those ports that seem to have printers attached.
* If you give PLIP the ``timid`` parameter, either with ``plip=timid`` on
the command line, or with ``insmod plip timid=1`` when using modules,
it will avoid any ports that seem to be in use by other devices.
* IRQ autoprobing works only for a few port types at the moment.
Reporting printer problems with parport
=======================================
If you are having problems printing, please go through these steps to
try to narrow down where the problem area is.
When reporting problems with parport, really you need to give all of
the messages that ``parport_pc`` spits out when it initialises. There are
several code paths:
- polling
- interrupt-driven, protocol in software
- interrupt-driven, protocol in hardware using PIO
- interrupt-driven, protocol in hardware using DMA
The kernel messages that ``parport_pc`` logs give an indication of which
code path is being used. (They could be a lot better actually..)
For normal printer protocol, having IEEE 1284 modes enabled or not
should not make a difference.
To turn off the 'protocol in hardware' code paths, disable
``CONFIG_PARPORT_PC_FIFO``. Note that when they are enabled they are not
necessarily **used**; it depends on whether the hardware is available,
enabled by the BIOS, and detected by the driver.
So, to start with, disable ``CONFIG_PARPORT_PC_FIFO``, and load ``parport_pc``
with ``irq=none``. See if printing works then. It really should,
because this is the simplest code path.
If that works fine, try with ``io=0x378 irq=7`` (adjust for your
hardware), to make it use interrupt-driven in-software protocol.
If **that** works fine, then one of the hardware modes isn't working
right. Enable ``CONFIG_FIFO`` (no, it isn't a module option,
and yes, it should be), set the port to ECP mode in the BIOS and note
the DMA channel, and try with::
io=0x378 irq=7 dma=none (for PIO)
io=0x378 irq=7 dma=3 (for DMA)
----------
philb@gnu.org
tim@cyberelk.net
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Parport 구조와 IRQ 기본 정책
1-18`parport` code는 Linux의 parallel-port 지원을 제공하며, 하나의 port를 여러 device driver가 공유할 수 있게 합니다.
Hardware 자동 검출 결과를 덮어쓰도록 `parport` parameter를 전달할 수 있습니다. 특히 IRQ는 일반적으로 autoprobed 결과를 안정적으로 얻기 어려워 이 기능이 유용합니다.
IRQ를 probe할 수 있더라도 기본값은 IRQ를 사용하지 않는 것입니다. Parallel port와 sound card 또는 network card가 같은 IRQ를 공유하는 system이 많기 때문입니다.
`parport` code는 port-sharing을 처리하는 generic 부분과 실제 port 사용을 처리하는 architecture-dependent 부분으로 나뉩니다.
Module로 parport 구성
19-40먼저 generic `parport` code를 module로 load합니다.
# insmod parport
그 뒤 architecture-dependent code를 load해야 합니다. 다음 예시는 PC-style port 세 개를 요청합니다.
# insmod parport_pc io=0x3bc,0x378,0x278 irq=none,7,auto
이 command는 `0x3bc` port에는 IRQ를 쓰지 않고, `0x378` port에는 IRQ 7을 사용하며, `0x278` port의 IRQ는 자동 검출하도록 지정합니다.
현재 PC-style `parport_pc`, Sun `bpp`, Amiga, Atari, MFC3 hardware를 지원합니다.
PCI parallel I/O card 지원은 `parport_pc`가 제공합니다. 지원되는 PCI card는 자동 검출되므로 base I/O address를 지정하지 않아야 합니다.
modprobe 설정과 IEEE 1284 probe
41-71`modprobe`를 사용한다면 `/etc/modprobe.d/` directory의 configuration file에 다음과 같은 줄을 둘 수 있습니다.
alias parport_lowlevel parport_pc
options parport_pc io=0x378,0x278 irq=7,auto
그러면 `lp` 같은 parallel port device driver를 load할 때마다 `modprobe`가 `io=0x378,0x278 irq=7,auto` option과 함께 `parport_pc`를 load합니다.
위 줄은 예시일 뿐입니다. 일반적으로 parallel port를 사용하기 위해 `parport_pc` option을 지정할 필요는 없습니다.
2.2 kernel의 `parport_probe` module은 IEEE 1284 device ID 정보를 수집했습니다. 이 기능은 향상되어 현재 IEEE 1284 support에 포함됩니다.
Parallel port를 검출하면 연결된 device를 분석해 다음과 같은 정보를 log에 남깁니다.
parport0: Printer, BJC-210 (Canon)
Probe 정보는 `/proc/sys/dev/parport/` 아래 file에서 확인할 수 있습니다.
Kernel built-in의 boot parameter
72-87`parport` code를 kernel에 정적으로 compile했다면 kernel boot parameter로 module option과 같은 효과를 낼 수 있습니다. LILO command line 예시는 다음과 같습니다.
parport=0x3bc parport=0x378,7 parport=0x278,auto,nofifo
추가하려는 port마다 `parport=...` statement를 하나씩 여러 개 둘 수 있습니다. `parport=0`은 parport support 전체를 비활성화합니다.
`parport=auto`는 자동 검출한 IRQ line 또는 DMA channel을 `parport`가 사용하게 합니다.
/proc interface와 file 의미
88-204Kernel에 `/proc` filesystem을 구성했다면 `/proc/sys/dev/parport` directory가 생깁니다. Parport가 구성된 parallel port마다 하위 directory가 있고 그 안의 file들이 해당 port를 설명합니다.
원문의 ASCII directory tree를 port별 설정, probe 정보와 driver별 timeslice 경로로 구조화했습니다.
| File | 내용 |
|---|---|
| `devices/active` | 이 port를 사용하는 device driver 목록입니다. 현재 port를 점유한 driver 이름에는 `+`가 붙으며 아무 driver도 없으면 `none`입니다. |
| `base-addr` | Parallel port의 base address입니다. 주소가 여러 개면 tab으로 구분하며 일부 port에서는 의미 있는 값이 아닐 수 있습니다. |
| `irq` | 사용 중인 IRQ이며 IRQ를 사용하지 않으면 `-1`입니다. |
| `dma` | 사용 중인 DMA channel이며 DMA를 사용하지 않으면 `-1`입니다. |
| `modes` | Comma-separated hardware mode 목록입니다: PCSPP, TRISTATE, COMPAT, EPP, ECP, DMA. |
| `autoprobe` | IEEE 1284.3 장치가 아닌 peripheral에서 얻은 IEEE-1284 device ID 정보입니다. |
| `autoprobe[0-3]` | IEEE 1284.3을 따르는 daisy-chain device에서 얻은 IEEE 1284 device ID 정보입니다. |
| `spintime` | Peripheral 응답을 기다리며 busy-loop할 microsecond 수입니다. Port 전체의 모든 device에 적용됩니다. |
| `timeslice` | Device driver가 port 점유를 유지하도록 허용하는 millisecond 수입니다. 권고값이므로 필요하면 driver가 무시할 수 있습니다. |
| `default/*` | 새 port는 기본 spintime을, 새 device는 기본 timeslice를 등록 시점에 가져옵니다. |
`modes`에 나타나는 hardware mode의 의미는 다음과 같습니다.
| Mode | 의미 |
|---|---|
| `PCSPP` | PC-style SPP register를 사용할 수 있습니다. |
| `TRISTATE` | Port가 bidirectional입니다. |
| `COMPAT` | Printer용 hardware acceleration을 사용할 수 있고 실제로 사용합니다. |
| `EPP` | EPP protocol용 hardware acceleration을 사용할 수 있고 실제로 사용합니다. |
| `ECP` | ECP protocol용 hardware acceleration을 사용할 수 있고 실제로 사용합니다. |
| `DMA` | DMA를 사용할 수 있고 실제로 사용합니다. |
현재 구현은 사용할 IRQ line이 있을 때만 `COMPAT`와 `ECP` mode를 활용합니다.
Device driver와 port 연결
205-241Parport code가 초기화되면 device driver를 특정 port에 연결할 수 있습니다. 보통은 자동으로 이뤄지며, `lp` driver를 load하면 발견한 port마다 `lp` device 하나를 만듭니다.
Module load parameter로 기본 연결을 덮어쓸 수 있습니다.
# insmod lp parport=0,2
LILO command line에서도 같은 연결을 지정할 수 있습니다.
lp=parport0 lp=parport2
두 예시는 모두 첫 parallel port를 `/dev/lp0`으로, 세 번째 parallel port를 `/dev/lp1`으로 만들고 두 번째 port인 `parport1`에는 lp device를 연결하지 않습니다.
이는 예전 kernel과 다릅니다. 과거에는 I/O port address와 device name이 정적으로 연결되어 `/dev/lp0`이 항상 `0x3bc` port였지만, 이제는 그렇지 않습니다. Port가 하나뿐이면 base address와 무관하게 기본적으로 `/dev/lp0`이 됩니다.
Compile 시 IEEE 1284 support를 선택했다면 kernel command line에 `lp=auto`를 지정할 수 있습니다. 그러면 `lp`는 printer가 연결된 것으로 보이는 port에만 device를 만듭니다.
PLIP에 command line의 `plip=timid` 또는 module load의 `insmod plip timid=1`로 `timid` parameter를 주면 다른 device가 사용 중인 것으로 보이는 port를 피합니다.
현재 IRQ autoprobing은 일부 port type에서만 동작합니다.
Printer 문제 보고와 code path 분리
242-282Printing 문제가 있다면 아래 단계로 문제 영역을 좁힙니다. Parport 문제를 보고할 때는 `parport_pc`가 초기화 중 출력한 message를 모두 제공해야 합니다.
가능한 code path는 polling, software protocol을 쓰는 interrupt-driven 경로, PIO로 hardware protocol을 쓰는 interrupt-driven 경로, DMA로 hardware protocol을 쓰는 interrupt-driven 경로입니다.
`parport_pc` kernel message는 사용 중인 code path를 알려 줍니다. 일반 printer protocol에서는 IEEE 1284 mode 활성화 여부가 차이를 만들지 않아야 합니다.
`protocol in hardware` code path를 끄려면 `CONFIG_PARPORT_PC_FIFO`를 비활성화합니다. 이 option을 켰다고 항상 hardware path를 사용하는 것은 아니며 hardware 가용성, BIOS 활성화와 driver 검출 결과에 따라 달라집니다.
먼저 `CONFIG_PARPORT_PC_FIFO`를 끄고 `irq=none`으로 `parport_pc`를 load해 printing을 시험합니다. 가장 단순한 code path이므로 정상 동작해야 합니다.
정상이라면 hardware에 맞춰 `io=0x378 irq=7`로 바꾸어 software protocol을 쓰는 interrupt-driven 경로를 시험합니다.
이 경로도 정상이라면 hardware mode 중 하나가 잘못된 것입니다. `CONFIG_FIFO`를 활성화하고 port를 BIOS에서 ECP mode로 설정한 뒤 DMA channel을 확인하여 다음 PIO와 DMA 경로를 각각 시험합니다.
io=0x378 irq=7 dma=none (for PIO)
io=0x378 irq=7 dma=3 (for DMA)
원문 연락처
283-286원문 끝에는 `philb@gnu.org`와 `tim@cyberelk.net` 연락처가 기재되어 있습니다.
운영 핵심
parport.rst:1-286Generic sharing layer와 hardware driver를 구분하고, 가장 단순한 polling 경로부터 IRQ·PIO·DMA 순서로 검증하면 설정과 hardware mode 문제를 분리할 수 있습니다.