HPET (High Precision Event Timer) ドライバ /drivers/char/hpet.c の動作を理解するために、実際に動かすアプリケーション・プログラム hpet_example.tar.gz を使います。このプログラムは /Documentation/timers/hpet_example.c を修正して作成してあります。/Documentation/timers/hpet.txt で hpet_example.c について概要が書かれています。情報量は多く有りません。ioctl() API の仕様詳細は書かれていません。
int ioctl(int fd, HPET_IE_ON);
int ioctl(int fd, HPET_IE_OFF);
struct hpet_info { unsigned long hi_ireqfreq; /* Period or time in Hz */ unsigned long hi_flags; /* Information: 0x0: Not supported periodic int., 0x10: Supported periodic int. */ unsigned short hi_hpet; /* HPET device number, [0..TheNumberOfHPETDevicesInPlatform-1] */ unsigned short hi_timer; /* Timer number in HPET device, [0..31] */ }; int ioctl(int fd, HPET_INFO, /* out */ struct hpet_info *info);
member | description |
hi_ireqfreq | Interrupt frequency in Hz. |
hi_flags | Timer capability. The value will be as follows, 0x00UL This timer doesn't have hardware implemented periodic interrupt. 0x10UL This timer has hardware implemented periodic interrupt. |
hi_hpet | HPET device number on platform. It satisfies (hi_hpet >= 0) && (hi_hpet < M), where M is the number of HPET devices (circuit blocks) on platform. |
hi_timer | Timer number in HPET device. It satisfies (hi_timer >= 0) && (hi_timer < N), where N is the number of timers in HPET device and N <= 32. NOTE: You may see {hi_hpet, hi_timer} == {0, 2} at first opened HPET timer, because the timer 0 and timer 1 replaces PIT(programmable Interval Timer) and RTC(Real Time Clock). |
int ioctl(int fd, HPET_EPI);
int ioctl(int fd, HPET_DPI);
int ioctl(int fd, HPET_IRQFREQ, unsigned long frequency);
To see more details refer to man 2 fcntl.
int open(const char *hpet_path, O_RDONLY);
int close(int fd);
int fcntl(int fd, F_GETOWN);
struct f_owner_ex { int type; /* F_OWNER_PID, F_OWNER_PGRP, or F_OWNER_TID */ pid_t pid; /* process id, process group id, or thread id. */ } int fcntl(int fd, F_GETOWN_EX, /* out */ struct f_owner_ex *owner_ex);
int fcntl(int fd, F_SETOWN, int owner);
struct f_owner_ex { int type; /* F_OWNER_PID, F_OWNER_PGRP, or F_OWNER_TID */ pid_t pid; /* process id, process group id, or thread id. */ } int fcntl(int fd, F_GETOWN_EX, /* in */ struct f_owner_ex *owner_ex);
int fcntl(int fd, F_GETFL);
int fcntl(int fd, F_SETFL, int flags);
int fcntl(int fd, F_GETSIG);
int fcntl(int fd, F_SETSIG, int signal);