10 #include <sys/types.h>
15 #include <linux/hpet.h>
19 extern void hpet_info(
int,
const char **);
20 extern void hpet_poll(
int,
const char **);
22 extern void hpet_read(
int,
const char **);
25 #include <sys/ioctl.h>
58 fprintf(stderr,
"-hpet: requires command\n");
67 fprintf(stderr,
"-hpet: executing %s\n",
73 fprintf(stderr,
"do_hpet: command %s not implemented\n", argv[0]);
84 fprintf(stderr,
"hpet_open_close: device-name\n");
90 fprintf(stderr,
"hpet_open_close: open failed\n");
104 fprintf(stderr,
"hpet_info: device-name\n");
110 fprintf(stderr,
"hpet_info: open of %s failed\n", argv[0]);
115 fprintf(stderr,
"hpet_info: failed to get info\n");
119 fprintf(stderr,
"hpet_info: hi_irqfreq 0x%lx hi_flags 0x%lx ",
121 fprintf(stderr,
"hi_hpet %d hi_timer %d\n",
133 int iterations,
i,
fd;
141 fprintf(stderr,
"hpet_poll: device-name freq iterations\n");
145 freq = atoi(argv[1]);
146 iterations = atoi(argv[2]);
151 fprintf(stderr,
"hpet_poll: open of %s failed\n", argv[0]);
156 fprintf(stderr,
"hpet_poll: HPET_IRQFREQ failed\n");
161 fprintf(stderr,
"hpet_poll: failed to get info\n");
168 fprintf(stderr,
"hpet_poll: HPET_EPI failed\n");
173 fprintf(stderr,
"hpet_poll, HPET_IE_ON failed\n");
180 for (i = 0; i < iterations; i++) {
183 if (
poll(&pfd, 1, -1) < 0)
184 fprintf(stderr,
"hpet_poll: poll failed\n");
193 "hpet_poll: expired time = 0x%lx\n", usec);
195 fprintf(stderr,
"hpet_poll: revents = 0x%x\n",
198 if (
read(fd, &data,
sizeof(data)) !=
sizeof(data)) {
199 fprintf(stderr,
"hpet_poll: read failed\n");
202 fprintf(stderr,
"hpet_poll: data 0x%lx\n",
212 static int hpet_sigio_count;
217 fprintf(stderr,
"hpet_sigio: called\n");
229 hpet_sigio_count = 0;
233 fprintf(stderr,
"hpet_fasync: failed to set signal handler\n");
238 fprintf(stderr,
"hpet_fasync: device-name freq iterations\n");
245 fprintf(stderr,
"hpet_fasync: failed to open %s\n", argv[0]);
250 if ((fcntl(fd,
F_SETOWN, getpid()) == 1) ||
251 ((value = fcntl(fd,
F_GETFL)) == 1) ||
252 (fcntl(fd,
F_SETFL, value | O_ASYNC) == 1)) {
253 fprintf(stderr,
"hpet_fasync: fcntl failed\n");
257 freq = atoi(argv[1]);
258 iterations = atoi(argv[2]);
261 fprintf(stderr,
"hpet_fasync: HPET_IRQFREQ failed\n");
266 fprintf(stderr,
"hpet_fasync: failed to get info\n");
273 fprintf(stderr,
"hpet_fasync: HPET_EPI failed\n");
278 fprintf(stderr,
"hpet_fasync, HPET_IE_ON failed\n");
282 for (i = 0; i < iterations; i++) {
284 fprintf(stderr,
"hpet_fasync: count = %d\n", hpet_sigio_count);
288 signal(
SIGIO, oldsig);