tests: x86/info: make it work with CONFIG_COUNTER_CMOS=n
There are boards without CMOS RTC, where blind accesses to the RTC registers will freeze the system. So make the test works with these boards if CONFIG_COUNTER_CMOS=n. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
170c9026cb
commit
5a38451332
1 changed files with 5 additions and 3 deletions
|
@ -9,6 +9,7 @@
|
|||
|
||||
#define NR_SAMPLES 10 /* sample timer 10 times */
|
||||
|
||||
#if defined(CONFIG_COUNTER_CMOS)
|
||||
static uint32_t sync(const struct device *cmos)
|
||||
{
|
||||
uint32_t this, last;
|
||||
|
@ -31,11 +32,10 @@ static uint32_t sync(const struct device *cmos)
|
|||
|
||||
return sys_clock_cycle_get_32();
|
||||
}
|
||||
#endif
|
||||
|
||||
void timer(void)
|
||||
{
|
||||
const struct device *cmos;
|
||||
|
||||
#if defined(CONFIG_APIC_TIMER)
|
||||
printk("TIMER: new local APIC");
|
||||
#elif defined(CONFIG_HPET_TIMER)
|
||||
|
@ -47,7 +47,8 @@ void timer(void)
|
|||
printk(", configured frequency = %dHz\n",
|
||||
sys_clock_hw_cycles_per_sec());
|
||||
|
||||
cmos = device_get_binding("CMOS");
|
||||
#if defined(CONFIG_COUNTER_CMOS)
|
||||
const struct device *cmos = device_get_binding("CMOS");
|
||||
if (cmos == NULL) {
|
||||
printk("\tCan't get reference CMOS clock device.\n");
|
||||
} else {
|
||||
|
@ -68,6 +69,7 @@ void timer(void)
|
|||
|
||||
printk("\taverage = %uHz\n", (unsigned) (sum / NR_SAMPLES));
|
||||
}
|
||||
#endif
|
||||
|
||||
printk("\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue