Page 1 of 1

HPET can only produce 100 interrupts per second?

Posted: Sun Nov 24, 2013 12:47 am
by windows8
Now I'm trying to use HPET instead of PIT.
But I have a problem:I'm using QEMU.I try to configure HPET and let it produce 1000 interrupt per second.

First,I get the period of HPET.
Next,I clear the counter of HPET and enable it.
Then I wait a minute and check if the counter is counting.The result is true.
Finally,I start the interrupt of HPET and set the configure of the timer0.

Code: Select all

/*Index = 0.*/
u32 conf = hpetIn(HPET_TIMER_CONF_REG(index));
conf |= HPET_TIMER_CONF_PERIODIC;
conf |= HPET_TIMER_CONF_ENABLE;
hpetOut(HPET_TIMER_CONF_REG(index),conf);
And set the compare register of timer0:

Code: Select all

hpetOut(HPET_TIMER_CMP_REG(index),time);
I want to change "time" to change how many interrupts HPET produce per second.
If I set "time" to a big number,it will be successful!
But when I set "time" to a small number even 1,I failed!It can only produce about 100 interrupts per second.

I want HPET to produce about 1000 interrupts per second,how should I do?
(I also try to use one shot mode and change the compare register when interrupts come,but I also failed.)
Thank you very mush!

Re: HPET can only produce 100 interrupts per second?

Posted: Sun Nov 24, 2013 1:40 am
by Brendan
Hi,
windows8 wrote:Now I'm trying to use HPET instead of PIT.
But I have a problem:I'm using QEMU.
I'd begin by testing on other emulators and real computers - I wouldn't be surprised if the problem was Qemu.

For example, internally Qemu might be using something like "HPET_main_counter += (clock() - previous_clock) * HPET_TICKS_PER_SECOND / CLOCKS_PER_SEC" on a host OS where "CLOCKS_PER_SEC == 100".

Note: If the problem is Qemu, then I also wouldn't be too surprised if there are sane reasons for it (e.g. guest performance or portability).


Cheers,

Brendan

Re: HPET can only produce 100 interrupts per second?

Posted: Sun Nov 24, 2013 3:26 am
by windows8
Brendan wrote:Hi,
windows8 wrote:Now I'm trying to use HPET instead of PIT.
But I have a problem:I'm using QEMU.
I'd begin by testing on other emulators and real computers - I wouldn't be surprised if the problem was Qemu.

For example, internally Qemu might be using something like "HPET_main_counter += (clock() - previous_clock) * HPET_TICKS_PER_SECOND / CLOCKS_PER_SEC" on a host OS where "CLOCKS_PER_SEC == 100".

Note: If the problem is Qemu, then I also wouldn't be too surprised if there are sane reasons for it (e.g. guest performance or portability).


Cheers,

Brendan

I think you are right,I am going to try it not on QEMU.
Thanks a lot.

Re: HPET can only produce 100 interrupts per second?

Posted: Sun Nov 24, 2013 6:51 am
by windows8
Oh,I tried to run it in VirtualBox just now,it runs very successfully.
It can produce 1000 interrupts per second!
The problem is QEMU,thank you again. :D