From: Clemens Ladisch <clemens@ladisch.de>
To: Samuel Xu <samuel.xu.tech@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Question on HPET timer reading from device driver?
Date: Tue, 13 Jul 2010 13:49:54 +0200 [thread overview]
Message-ID: <4C3C52E2.1000801@ladisch.de> (raw)
In-Reply-To: <AANLkTimTN3FZjRAjFDV-3pSnwq9EEPzfs5-xXBH5KomO@mail.gmail.com>
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
next prev parent reply other threads:[~2010-07-13 11:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-13 9:45 Question on HPET timer reading from device driver? Samuel Xu
2010-07-13 11:49 ` Clemens Ladisch [this message]
2010-07-13 13:45 ` Samuel Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C3C52E2.1000801@ladisch.de \
--to=clemens@ladisch.de \
--cc=linux-kernel@vger.kernel.org \
--cc=samuel.xu.tech@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox