Add a test app for the hpet driver (which I'll commit later)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42836 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2011-10-13 08:16:45 +00:00
parent e774cb4b0a
commit 2e77a03d92
3 changed files with 58 additions and 0 deletions
+1
View File
@@ -1,5 +1,6 @@
SubDir HAIKU_TOP src tests add-ons kernel drivers ;
SubInclude HAIKU_TOP src tests add-ons kernel drivers audio ;
SubInclude HAIKU_TOP src tests add-ons kernel drivers hpet ;
SubInclude HAIKU_TOP src tests add-ons kernel drivers random ;
SubInclude HAIKU_TOP src tests add-ons kernel drivers tty ;
@@ -0,0 +1,10 @@
SubDir HAIKU_TOP src tests add-ons kernel drivers hpet ;
UseHeaders [ FDirName $(HAIKU_TOP) src add-ons kernel drivers timer ] : true ;
Application hpet_test :
main.cpp
: be $(TARGET_LIBSUPC++)
;
@@ -0,0 +1,47 @@
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <OS.h>
#include <hpet_interface.h>
int main()
{
int hpetFD = open("/dev/misc/hpet", O_RDWR);
if (hpetFD < 0) {
printf("Cannot open HPET driver: %s\n", strerror(errno));
return -1;
}
uint64 value, newValue;
read(hpetFD, &value, sizeof(uint64));
snooze(1000000);
read(hpetFD, &newValue, sizeof(uint64));
printf("HPET counter value difference (1 sec): %lld\n", newValue - value);
status_t status;
bigtime_t timeValue = 2000000;
printf("Waiting 2 seconds...\n");
status = ioctl(hpetFD, HPET_WAIT_TIMER, &timeValue, sizeof(timeValue));
printf("%s.\n", strerror(status));
timeValue = 5000000;
printf("Waiting 5 seconds...\n");
status = ioctl(hpetFD, HPET_WAIT_TIMER, &timeValue, sizeof(timeValue));
printf("%s.\n", strerror(status));
timeValue = 1000000;
printf("Waiting 1 second...\n");
status = ioctl(hpetFD, HPET_WAIT_TIMER, &timeValue, sizeof(timeValue));
printf("%s.\n", strerror(status));
close(hpetFD);
return 0;
}