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:
@@ -1,5 +1,6 @@
|
|||||||
SubDir HAIKU_TOP src tests add-ons kernel drivers ;
|
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 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 random ;
|
||||||
SubInclude HAIKU_TOP src tests add-ons kernel drivers tty ;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user