mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-21 08:50:27 +00:00
hv: timer: add calibrate tsc hz by cpuid 0x15
Get tsc hz by cpuid 0x15 if we supported, otherwise calibrate tsc by pit timer. Signed-off-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -258,8 +258,6 @@ extern struct cpuinfo_x86 boot_cpu_data;
|
||||
|
||||
/* Function prototypes */
|
||||
void cpu_dead(uint32_t logical_id);
|
||||
uint64_t cpu_cycles_per_second(void);
|
||||
uint64_t tsc_cycles_in_period(uint16_t timer_period_in_us);
|
||||
void cpu_secondary_reset(void);
|
||||
int hv_main(int cpu_id);
|
||||
bool is_vapic_supported(void);
|
||||
|
@@ -42,5 +42,6 @@ int timer_softirq(int pcpu_id);
|
||||
void timer_init(void);
|
||||
void timer_cleanup(void);
|
||||
void check_tsc(void);
|
||||
void calibrate_tsc(void);
|
||||
|
||||
#endif /* TIMER_H */
|
||||
|
@@ -65,12 +65,12 @@ void *memcpy_s(void *d, size_t dmax, const void *s, size_t slen);
|
||||
int udiv64(uint64_t dividend, uint64_t divisor, struct udiv_result *res);
|
||||
int udiv32(uint32_t dividend, uint32_t divisor, struct udiv_result *res);
|
||||
|
||||
extern uint64_t tsc_clock_freq;
|
||||
#define US_TO_TICKS(x) ((x)*tsc_clock_freq/1000000UL)
|
||||
extern uint64_t tsc_hz;
|
||||
#define US_TO_TICKS(x) ((x) * tsc_hz / 1000000UL)
|
||||
#define CYCLES_PER_MS US_TO_TICKS(1000UL)
|
||||
|
||||
#define TICKS_TO_US(x) ((((x) * (1000000UL >> 8)) / tsc_clock_freq) << 8)
|
||||
#define TICKS_TO_MS(x) (((x) * 1000UL) / tsc_clock_freq)
|
||||
#define TICKS_TO_US(x) ((((x) * (1000000UL >> 8)) / tsc_hz) << 8)
|
||||
#define TICKS_TO_MS(x) (((x) * 1000UL) / tsc_hz)
|
||||
|
||||
static inline uint64_t rdtsc(void)
|
||||
{
|
||||
|
Reference in New Issue
Block a user