HPET can only produce 100 interrupts per second?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
windows8
Member
Member
Posts: 33
Joined: Sat Feb 23, 2013 3:52 am

HPET can only produce 100 interrupts per second?

Post 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!
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: HPET can only produce 100 interrupts per second?

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
windows8
Member
Member
Posts: 33
Joined: Sat Feb 23, 2013 3:52 am

Re: HPET can only produce 100 interrupts per second?

Post 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.
windows8
Member
Member
Posts: 33
Joined: Sat Feb 23, 2013 3:52 am

Re: HPET can only produce 100 interrupts per second?

Post 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
Post Reply