mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
qtest: add rtc periodic timer test
It tests the accuracy of rtc periodic timer which is recently improved & fixed by commit 7ffcb539a3 ("mc146818rtc: precisely count the clock for periodic timer", 2017-05-19). Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com> Message-Id: <20170527025301.23499-1-xiaoguangrong@tencent.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
e0c8b950d1
commit
bd618eab76
3 changed files with 72 additions and 12 deletions
|
@ -65,4 +65,24 @@
|
|||
#define REG_C_AF 0x20
|
||||
#define REG_C_MASK 0x70
|
||||
|
||||
static inline uint32_t periodic_period_to_clock(int period_code)
|
||||
{
|
||||
if (!period_code) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (period_code <= 2) {
|
||||
period_code += 7;
|
||||
}
|
||||
/* period in 32 Khz cycles */
|
||||
return 1 << (period_code - 1);
|
||||
}
|
||||
|
||||
#define RTC_CLOCK_RATE 32768
|
||||
|
||||
static inline int64_t periodic_clock_to_ns(int64_t clocks)
|
||||
{
|
||||
return muldiv64(clocks, NANOSECONDS_PER_SECOND, RTC_CLOCK_RATE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue