このページは HPET driver が提供する API をまとめたページです。map ページに似た書式を使います。man page の書式に次の修正・追加をしています。
HPET ドライバには次の機能が備わっています。
より詳細な情報は HPET 仕様書 を見て下さい。
多くの Linux ディストリビューション では HPET ドライバを有効化して構築されています。/dev/hpet ノードが用意されています。/dev/hpet ノードはキャラクタ・デバイス・ノードで major=10, minor=228 という番号が付いています。"misc device" の一つです。
HPET を使うには /dev/hpet を O_RDONLY モードで開きます。未使用の HPET timer が有れば、一つの timer を開いたファイル・ディスクリプタに割り当てます。timer は HPET 回路ブロックに複数ある timer のうちの一つです。ioctl() システム・コールでファイル・ディスクリプタに割り当てられた timer を操作します。
user space (Linux アプリケーション) から HPET device を使うには次のヘッダファイルを取り込んで下さい。
#define _GNU_SOURCE #include <features.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <unistd.h> #include <fcntl.h> #include <linux/hpet.h>
poll() を使うには次のヘッダファイルを取り込んで下さい。
#include <poll.h>
select() を使うには次のヘッダファイルを取り込んで下さい。
#include <sys/time.h> #include <sys/select.h>
signal() を使うには次のヘッダファイルを取り込んで下さい。
#include <signal.h>
mmap() を使うには次のヘッダファイルを取り込んで下さい。
#include <sys/mman.h>
システム・コール エラーを使うには次のヘッダファイルを取り込んで下さい。
#include <string.h> /* strerror() */ #include <errno.h> /* errno, Exxx macros. */
ここでは HPET ドライバの ioctl() API を示します。HPET ドライバは次に示す ioctl() API を提供しています。
ioctl 要求番号 | 説明 |
HPET_INFO | timer の情報を取得します int ioctl(int fd, HPET_INFO, /* out */ struct hpet_info *info); |
HPET_IRQFREQ | 割り込み周期を周波数(Hz)で設定します int ioctl(int fd, HPET_IRQFREQ, unsigned long frequency); |
HPET_EPI | ハードウエアによる周期割り込み機能を使うようにします int ioctl(int fd, HPET_EPI); |
HPET_DPI | ハードウエアによる周期割り込み機能を使わないようにします (ソフトウエアによって周期割り込みを起こします) int ioctl(int fd, HPET_DPI); |
HPET_IE_ON | timer からの割り込みを許可します int ioctl(int fd, HPET_IE_ON); |
HPET_IE_OFF | timer からの割り込みを禁止します int ioctl(int fd, HPET_IE_OFF); |
このページでは HPET ドライバ固有の仕様を示します。ioctl() システム・コールの基本的な仕様については man 2 ioctl を参照して下さい。
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_IRQFREQ, unsigned long frequency);
int ioctl(int fd, HPET_EPI);
int ioctl(int fd, HPET_DPI);
int ioctl(int fd, HPET_IE_ON);
int ioctl(int fd, HPET_IE_OFF);
In this section shows File System and Memory Mapping API related to HPET driver. When using open(), close(), read(), mmap(), munmap(), fcntl(), and these alternate functions to access HPET, these API have HPET specific behaviour. Here shows HPET specific behavior. To see file system specific basic behavior and details, refer to system call man pages. man 2 fcntl shows about sending signal from file descriptor in detail.
int open(const char *hpet_path, /* open mode */ O_RDONLY);
int close(int fd);
int read(int fd, unsigned long *buf, /* size */ sizeof(unsigned long));
void *mmap(void *addr, size_t length, int prot, int flags, int fd, /* offset */ 0); int munmap(void *addr, size_t length);
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);