요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
/dev/hpet와 kernel config
hpet.rst:19-31Driver는 CONFIG_HPET과 관련 character-device option에 따라 /dev/hpet interface를 제공할 수 있습니다. User space는 ioctl과 mmap capability를 platform support 범위에서 사용하지만 일반 application timer에는 clock_gettime과 timerfd 같은 표준 API를 우선합니다.
HPET access는 MMIO read 비용이 TSC보다 클 수 있습니다. 이름의 high precision이 항상 가장 낮은 read latency나 가장 좋은 clocksource를 뜻하지 않습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
===========================================
High Precision Event Timer Driver for Linux
===========================================
The High Precision Event Timer (HPET) hardware follows a specification
by Intel and Microsoft, revision 1.
Each HPET has one fixed-rate counter (at 10+ MHz, hence "High Precision")
and up to 32 comparators. Normally three or more comparators are provided,
each of which can generate oneshot interrupts and at least one of which has
additional hardware to support periodic interrupts. The comparators are
also called "timers", which can be misleading since usually timers are
independent of each other ... these share a counter, complicating resets.
HPET devices can support two interrupt routing modes. In one mode, the
comparators are additional interrupt sources with no particular system
role. Many x86 BIOS writers don't route HPET interrupts at all, which
prevents use of that mode. They support the other "legacy replacement"
mode where the first two comparators block interrupts from 8254 timers
and from the RTC.
The driver supports detection of HPET driver allocation and initialization
of the HPET before the driver module_init routine is called. This enables
platform code which uses timer 0 or 1 as the main timer to intercept HPET
initialization. An example of this initialization can be found in
arch/x86/kernel/hpet.c.
The driver provides a userspace API which resembles the API found in the
RTC driver framework. An example user space program is provided in
file:samples/timers/hpet_example.c
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Linux용 High Precision Event Timer driver
1-16High Precision Event Timer, 즉 HPET hardware는 Intel과 Microsoft가 만든 revision 1 specification을 따른다.
각 HPET에는 10 MHz 이상의 고정 주파수 counter 하나와 최대 32개의 comparator가 있다. 보통 세 개 이상의 comparator가 제공된다. 각 comparator는 one-shot interrupt를 발생시킬 수 있고, 그중 최소 하나는 periodic interrupt를 지원하는 추가 hardware를 갖는다.
Comparator를 timer라고도 부르지만 이 표현은 오해를 부를 수 있다. 일반적인 timer는 서로 독립적인 반면 HPET comparator는 하나의 counter를 공유하므로 reset 처리가 복잡해진다.
Interrupt routing mode
18-25HPET device는 두 가지 interrupt routing mode를 지원할 수 있다. 첫 번째 mode에서는 comparator가 특별한 system 역할 없이 추가 interrupt source로 동작한다. 많은 x86 BIOS가 HPET interrupt를 전혀 routing하지 않아 이 mode를 사용할 수 없는 경우가 있다.
두 번째 mode는 legacy replacement mode다. 이 mode에서는 처음 두 comparator가 8254 timer와 RTC에서 오는 interrupt를 막고 그 역할을 대신한다.
Driver 초기화와 userspace API
27-39Driver는 HPET driver allocation을 감지하고 driver의 module_init routine이 호출되기 전에 HPET를 초기화할 수 있다. 따라서 timer 0 또는 timer 1을 main timer로 사용하는 platform code가 HPET 초기화 과정에 개입할 수 있다. 이러한 초기화의 예는 arch/x86/kernel/hpet.c에서 볼 수 있다.
Driver가 제공하는 userspace API는 RTC driver framework의 API와 비슷하다. 예제 userspace program은 samples/timers/hpet_example.c에 있다.
Main counter와 comparator
hpet.rst:1-18HPET는 10MHz 이상 fixed-rate로 증가하는 main counter와 여러 comparator를 제공합니다. Comparator는 one-shot 또는 hardware가 지원하면 periodic interrupt를 만들며 platform routing을 통해 CPU interrupt에 연결됩니다.
Main counter는 clocksource 후보가 되고 comparator는 clockevent나 user-space timer source가 될 수 있습니다. 실제 선택은 TSC stability, ACPI table, interrupt routing과 kernel rating에 따라 달라집니다.