요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
========================================
Writing Device Drivers for Zorro Devices
========================================
:Author: Written by Geert Uytterhoeven <[email protected]>
:Last revised: September 5, 2003
Introduction
------------
The Zorro bus is the bus used in the Amiga family of computers. Thanks to
AutoConfig(tm), it's 100% Plug-and-Play.
There are two types of Zorro buses, Zorro II and Zorro III:
- The Zorro II address space is 24-bit and lies within the first 16 MB of the
Amiga's address map.
- Zorro III is a 32-bit extension of Zorro II, which is backwards compatible
with Zorro II. The Zorro III address space lies outside the first 16 MB.
Probing for Zorro Devices
-------------------------
Zorro devices are found by calling ``zorro_find_device()``, which returns a
pointer to the ``next`` Zorro device with the specified Zorro ID. A probe loop
for the board with Zorro ID ``ZORRO_PROD_xxx`` looks like::
struct zorro_dev *z = NULL;
while ((z = zorro_find_device(ZORRO_PROD_xxx, z))) {
if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
"My explanation"))
...
}
``ZORRO_WILDCARD`` acts as a wildcard and finds any Zorro device. If your driver
supports different types of boards, you can use a construct like::
struct zorro_dev *z = NULL;
while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
if (z->id != ZORRO_PROD_xxx1 && z->id != ZORRO_PROD_xxx2 && ...)
continue;
if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
"My explanation"))
...
}
Zorro Resources
---------------
Before you can access a Zorro device's registers, you have to make sure it's
not yet in use. This is done using the I/O memory space resource management
functions::
request_mem_region()
release_mem_region()
Shortcuts to claim the whole device's address space are provided as well::
zorro_request_device
zorro_release_device
Accessing the Zorro Address Space
---------------------------------
The address regions in the Zorro device resources are Zorro bus address
regions. Due to the identity bus-physical address mapping on the Zorro bus,
they are CPU physical addresses as well.
The treatment of these regions depends on the type of Zorro space:
- Zorro II address space is always mapped and does not have to be mapped
explicitly using z_ioremap().
Conversion from bus/physical Zorro II addresses to kernel virtual addresses
and vice versa is done using::
virt_addr = ZTWO_VADDR(bus_addr);
bus_addr = ZTWO_PADDR(virt_addr);
- Zorro III address space must be mapped explicitly using z_ioremap() first
before it can be accessed::
virt_addr = z_ioremap(bus_addr, size);
...
z_iounmap(virt_addr);
References
----------
#. linux/include/linux/zorro.h
#. linux/include/uapi/linux/zorro.h
#. linux/include/uapi/linux/zorro_ids.h
#. linux/arch/m68k/include/asm/zorro.h
#. linux/drivers/zorro
#. /proc/bus/zorro
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Zorro 버스와 AutoConfig
1-23Geert Uytterhoeven가 작성하고 2003년 9월 5일 마지막으로 개정한 이 문서는 Amiga 컴퓨터의 Zorro 장치 드라이버 작성법을 설명합니다.
Zorro는 Amiga 계열 컴퓨터의 확장 버스이며 `AutoConfig(tm)` 덕분에 완전한 Plug-and-Play 구성을 제공합니다.
Zorro II의 주소 공간은 24비트이며 Amiga 주소 맵의 첫 16MB 안에 있습니다. Zorro III는 Zorro II와 하위 호환되는 32비트 확장으로, 주소 공간은 첫 16MB 바깥에 놓입니다.
========================================
Writing Device Drivers for Zorro Devices
========================================
:Author: Written by Geert Uytterhoeven <[email protected]>
:Last revised: September 5, 2003
Introduction
------------
The Zorro bus is the bus used in the Amiga family of computers. Thanks to
AutoConfig(tm), it's 100% Plug-and-Play.
There are two types of Zorro buses, Zorro II and Zorro III:
- The Zorro II address space is 24-bit and lies within the first 16 MB of the
Amiga's address map.
- Zorro III is a 32-bit extension of Zorro II, which is backwards compatible
with Zorro II. The Zorro III address space lies outside the first 16 MB.
Zorro 장치 검색과 주소 영역 확보
24-52`zorro_find_device()`는 지정한 Zorro ID와 일치하는 다음 장치를 찾아 `struct zorro_dev` 포인터를 반환합니다. 첫 호출에서는 이전 장치 포인터를 `NULL`로 전달하고, 이후에는 방금 반환된 장치를 다시 전달해 반복 검색합니다.
`ZORRO_PROD_xxx` 보드를 찾는 루프에서는 각 장치의 `z->resource.start + MY_START`부터 `MY_SIZE`만큼을 `zorro_request_region()`으로 확보합니다. 요청이 실패하면 해당 영역은 이미 사용 중이므로 장치 레지스터에 접근해서는 안 됩니다.
`ZORRO_WILDCARD`는 모든 Zorro 장치와 일치합니다. 여러 보드 종류를 지원하는 드라이버는 wildcard로 순회한 뒤 `z->id`를 지원 목록과 비교하고, 일치하는 장치의 영역만 요청할 수 있습니다.
반환된 장치를 다음 검색의 시작점으로 넘기고, 지원하는 장치의 필요한 하위 영역을 독점합니다.
Probing for Zorro Devices
-------------------------
Zorro devices are found by calling ``zorro_find_device()``, which returns a
pointer to the ``next`` Zorro device with the specified Zorro ID. A probe loop
for the board with Zorro ID ``ZORRO_PROD_xxx`` looks like::
struct zorro_dev *z = NULL;
while ((z = zorro_find_device(ZORRO_PROD_xxx, z))) {
if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
"My explanation"))
...
}
``ZORRO_WILDCARD`` acts as a wildcard and finds any Zorro device. If your driver
supports different types of boards, you can use a construct like::
struct zorro_dev *z = NULL;
while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
if (z->id != ZORRO_PROD_xxx1 && z->id != ZORRO_PROD_xxx2 && ...)
continue;
if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
"My explanation"))
...
}
Zorro I/O 메모리 자원 관리
53-68Zorro 장치 레지스터에 접근하기 전에 다른 드라이버가 이미 사용 중인지 확인하고 주소 영역을 독점해야 합니다. 일반 I/O 메모리 자원 관리 함수인 `request_mem_region()`과 `release_mem_region()`을 사용합니다.
장치 주소 공간 전체를 확보하거나 반환할 때는 Zorro 전용 단축 함수 `zorro_request_device`와 `zorro_release_device`를 사용할 수 있습니다.
Zorro Resources
---------------
Before you can access a Zorro device's registers, you have to make sure it's
not yet in use. This is done using the I/O memory space resource management
functions::
request_mem_region()
release_mem_region()
Shortcuts to claim the whole device's address space are provided as well::
zorro_request_device
zorro_release_device
Zorro II·III 주소 공간 매핑
69-94`struct zorro_dev`의 resource가 나타내는 주소 영역은 Zorro 버스 주소입니다. Zorro 버스는 버스 주소와 물리 주소가 동일하게 매핑되므로 이 값은 CPU 물리 주소이기도 합니다.
Zorro II 주소 공간은 항상 매핑되어 있어 `z_ioremap()`을 별도로 호출할 필요가 없습니다. 버스·물리 주소에서 커널 가상 주소로 바꿀 때 `ZTWO_VADDR(bus_addr)`, 반대 변환에는 `ZTWO_PADDR(virt_addr)`를 사용합니다.
Zorro III 주소 공간은 접근 전에 `z_ioremap(bus_addr, size)`로 명시적으로 매핑해야 합니다. 사용이 끝나면 `z_iounmap(virt_addr)`으로 매핑을 해제합니다.
Accessing the Zorro Address Space
---------------------------------
The address regions in the Zorro device resources are Zorro bus address
regions. Due to the identity bus-physical address mapping on the Zorro bus,
they are CPU physical addresses as well.
The treatment of these regions depends on the type of Zorro space:
- Zorro II address space is always mapped and does not have to be mapped
explicitly using z_ioremap().
Conversion from bus/physical Zorro II addresses to kernel virtual addresses
and vice versa is done using::
virt_addr = ZTWO_VADDR(bus_addr);
bus_addr = ZTWO_PADDR(virt_addr);
- Zorro III address space must be mapped explicitly using z_ioremap() first
before it can be accessed::
virt_addr = z_ioremap(bus_addr, size);
...
z_iounmap(virt_addr);
Zorro 헤더·구현·런타임 참조
95-104Zorro 드라이버의 API와 ID 정의는 `linux/include/linux/zorro.h`, `linux/include/uapi/linux/zorro.h`, `linux/include/uapi/linux/zorro_ids.h`에서 확인합니다.
m68k 아키텍처별 매핑 정의는 `linux/arch/m68k/include/asm/zorro.h`, 드라이버 구현은 `linux/drivers/zorro`, 런타임 장치 정보는 `/proc/bus/zorro`에 있습니다.
References
----------
#. linux/include/linux/zorro.h
#. linux/include/uapi/linux/zorro.h
#. linux/include/uapi/linux/zorro_ids.h
#. linux/arch/m68k/include/asm/zorro.h
#. linux/drivers/zorro
#. /proc/bus/zorro
요약·해설
zorro.rst:1-104Zorro 드라이버는 `zorro_find_device()`로 Amiga Zorro II·III 장치를 순회하고, 레지스터 접근 전에 메모리 resource를 확보해야 합니다. Zorro II는 항상 매핑되어 `ZTWO_VADDR()`·`ZTWO_PADDR()`로 변환하지만 Zorro III는 `z_ioremap()`과 `z_iounmap()`을 사용합니다.
검색, 자원 확보, 주소 매핑, 장치 초기화 순서를 지킵니다.