lkml.org 
[lkml]   [2010]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Question on HPET timer reading from device driver?
Samuel Xu wrote:
> While I failed to find a way to get time stamp value of HPET in Linux
> kenerl (I am doing a driver and want to know elapsed cycle from driver
> code).

The HPET is x86-specific any might not be available on every machine.

> I tried hpet_readl() from my driver code, while hit compiling error.

This function is intended for internal use by the kernel and not for
drivers, so it is not exported for modules.

You can hack your own accessor function by calling ioremap() on the HPET
address (0xfed00000 or 0xfefff000 or whatever) and reading from that
memory.

A more portable way to get a time stamp is getrawmonotonic().

> I also read the Linux Documentation of HPET, which contain a user mode
> demo app to generate a periodic timer via HPET, while missing the time
> stamp reading.

There is no ioctl for this; call mmap() on /dev/hpet and then read the
main counter value from offset 0xf0 of that memory.

A more portable way to get a time stamp is to use clock_gettime() with
CLOCK_MONOTONIC_RAW.


Regards,
Clemens


\
 
 \ /
  Last update: 2010-07-13 13:53    [W:0.032 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site