요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
========
i2c-stub
========
Description
===========
This module is a very simple fake I2C/SMBus driver. It implements six
types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, (r/w)
word data, (r/w) I2C block data, and (r/w) SMBus block data.
You need to provide chip addresses as a module parameter when loading this
driver, which will then only react to SMBus commands to these addresses.
No hardware is needed nor associated with this module. It will accept write
quick commands to the specified addresses; it will respond to the other
commands (also to the specified addresses) by reading from or writing to
arrays in memory. It will also spam the kernel logs for every command it
handles.
A pointer register with auto-increment is implemented for all byte
operations. This allows for continuous byte reads like those supported by
EEPROMs, among others.
SMBus block command support is disabled by default, and must be enabled
explicitly by setting the respective bits (0x03000000) in the functionality
module parameter.
SMBus block commands must be written to configure an SMBus command for
SMBus block operations. Writes can be partial. Block read commands always
return the number of bytes selected with the largest write so far.
The typical use-case is like this:
1. load this module
2. use i2cset (from the i2c-tools project) to pre-load some data
3. load the target chip driver module
4. observe its behavior in the kernel log
There's a script named i2c-stub-from-dump in the i2c-tools package which
can load register values automatically from a chip dump.
Parameters
==========
int chip_addr[10]:
The SMBus addresses to emulate chips at.
unsigned long functionality:
Functionality override, to disable some commands. See I2C_FUNC_*
constants in <linux/i2c.h> for the suitable values. For example,
value 0x1f0000 would only enable the quick, byte and byte data
commands.
u8 bank_reg[10], u8 bank_mask[10], u8 bank_start[10], u8 bank_end[10]:
Optional bank settings. They tell which bits in which register
select the active bank, as well as the range of banked registers.
Caveats
=======
If your target driver polls some byte or word waiting for it to change, the
stub could lock it up. Use i2cset to unlock it.
If you spam it hard enough, printk can be lossy. This module really wants
something like relayfs.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
가상 I2C/SMBus 장치의 동작
1-31`i2c-stub` 모듈은 매우 단순한 가짜 I2C/SMBus 드라이버입니다. write quick, 읽기·쓰기 byte, 읽기·쓰기 byte data, 읽기·쓰기 word data, 읽기·쓰기 I2C block data, 읽기·쓰기 SMBus block data의 여섯 종류 SMBus 명령을 구현합니다.
드라이버를 로드할 때 모듈 매개변수로 칩 주소를 제공해야 하며, 모듈은 지정된 주소에 대한 SMBus 명령에만 반응합니다.
이 모듈에는 실제 하드웨어가 필요하지도, 연결되지도 않습니다. 지정 주소의 write quick 명령은 받아들이고, 다른 명령에는 메모리 배열을 읽거나 써서 응답합니다. 처리하는 모든 명령을 커널 로그에도 반복해서 기록합니다.
모든 바이트 연산에는 자동 증가하는 포인터 레지스터가 구현되어 있습니다. 이를 통해 EEPROM 등이 지원하는 연속 바이트 읽기를 재현할 수 있습니다.
SMBus 블록 명령 지원은 기본적으로 꺼져 있습니다. 사용하려면 `functionality` 모듈 매개변수의 해당 비트 `0x03000000`을 명시적으로 설정해야 합니다.
SMBus 블록 연산을 위한 SMBus 명령을 구성하려면 먼저 SMBus 블록 명령으로 써야 합니다. 쓰기는 일부만 수행할 수 있으며, 블록 읽기는 지금까지 수행한 쓰기 중 가장 큰 쓰기에서 선택된 바이트 수를 항상 반환합니다.
모듈이 구현하는 여섯 종류의 SMBus 명령입니다.
지정 주소에만 반응하고 메모리 배열로 값을 모사합니다.
========
i2c-stub
========
Description
===========
This module is a very simple fake I2C/SMBus driver. It implements six
types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, (r/w)
word data, (r/w) I2C block data, and (r/w) SMBus block data.
You need to provide chip addresses as a module parameter when loading this
driver, which will then only react to SMBus commands to these addresses.
No hardware is needed nor associated with this module. It will accept write
quick commands to the specified addresses; it will respond to the other
commands (also to the specified addresses) by reading from or writing to
arrays in memory. It will also spam the kernel logs for every command it
handles.
A pointer register with auto-increment is implemented for all byte
operations. This allows for continuous byte reads like those supported by
EEPROMs, among others.
SMBus block command support is disabled by default, and must be enabled
explicitly by setting the respective bits (0x03000000) in the functionality
module parameter.
SMBus block commands must be written to configure an SMBus command for
SMBus block operations. Writes can be partial. Block read commands always
return the number of bytes selected with the largest write so far.
일반 사용 절차와 모듈 매개변수
32-58전형적인 사용 순서는 먼저 이 모듈을 로드하고, i2c-tools 프로젝트의 `i2cset`으로 시험 데이터를 미리 채운 다음, 시험할 칩 드라이버 모듈을 로드해 커널 로그에서 동작을 관찰하는 것입니다.
i2c-tools 패키지의 `i2c-stub-from-dump` 스크립트는 실제 칩 덤프에서 레지스터 값을 자동으로 불러올 수 있습니다.
`int chip_addr[10]`은 가상 칩을 에뮬레이션할 SMBus 주소 배열입니다. 최대 열 개의 주소를 지정할 수 있습니다.
`unsigned long functionality`는 일부 명령을 끄기 위한 기능 재정의 값입니다. 적절한 비트 값은 `<linux/i2c.h>`의 `I2C_FUNC_*` 상수를 따릅니다. 예를 들어 `0x1f0000`은 quick, byte, byte data 명령만 활성화합니다.
`u8 bank_reg[10]`, `u8 bank_mask[10]`, `u8 bank_start[10]`, `u8 bank_end[10]`은 선택적인 뱅크 설정입니다. 활성 뱅크를 선택하는 레지스터와 비트, 그리고 뱅크 방식 레지스터 범위를 지정합니다.
주소, 기능 마스크, 선택적 뱅크 구성을 정리합니다.
데이터를 먼저 준비한 뒤 대상 드라이버의 probe와 접근을 관찰합니다.
The typical use-case is like this:
1. load this module
2. use i2cset (from the i2c-tools project) to pre-load some data
3. load the target chip driver module
4. observe its behavior in the kernel log
There's a script named i2c-stub-from-dump in the i2c-tools package which
can load register values automatically from a chip dump.
Parameters
==========
int chip_addr[10]:
The SMBus addresses to emulate chips at.
unsigned long functionality:
Functionality override, to disable some commands. See I2C_FUNC_*
constants in <linux/i2c.h> for the suitable values. For example,
value 0x1f0000 would only enable the quick, byte and byte data
commands.
u8 bank_reg[10], u8 bank_mask[10], u8 bank_start[10], u8 bank_end[10]:
Optional bank settings. They tell which bits in which register
select the active bank, as well as the range of banked registers.
폴링과 로그 손실 주의사항
59-66시험 대상 드라이버가 어떤 바이트나 워드가 바뀌기를 기다리며 계속 폴링한다면, 값이 저절로 변하지 않는 stub 때문에 드라이버가 멈출 수 있습니다. 이때 `i2cset`으로 기다리는 값을 바꾸어 잠금을 풀어야 합니다.
명령을 지나치게 빠르게 많이 보내면 `printk` 로그가 손실될 수 있습니다. 이 모듈의 대량 이벤트 기록에는 원문이 언급한 relayfs 같은 방식이 더 적합합니다.
가상 장치의 정적 상태와 로그 대역폭 한계입니다.
Caveats
=======
If your target driver polls some byte or word waiting for it to change, the
stub could lock it up. Use i2cset to unlock it.
If you spam it hard enough, printk can be lossy. This module really wants
something like relayfs.
요약·해설
i2c-stub.rst:1-66i2c-stub은 지정한 주소와 메모리 배열로 여섯 종류 SMBus 명령을 모사하며, i2cset이나 칩 덤프로 값을 준비해 대상 드라이버의 probe와 접근 동작을 커널 로그에서 시험합니다.
원문 분량과 핵심 검토 대상을 요약합니다.
문서의 주요 사용 또는 탐색 순서를 압축합니다.