hv/mod_timer: separate delay functions from the timer module
Modules that use udelay() should include "delay.h" explicitly. Tracked-On: #5920 Signed-off-by: Rong Liu <rong2.liu@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
parent
5a2b89b0a4
commit
51204a8d11
|
@ -819,6 +819,7 @@ INPUT = custom-doxygen/mainpage.md \
|
|||
../hypervisor/include/common/hypercall.h \
|
||||
../hypervisor/include/common/irq.h \
|
||||
../hypervisor/include/common/ticks.h \
|
||||
../hypervisor/include/common/delay.h \
|
||||
../hypervisor/include/common/ptdev.h \
|
||||
../hypervisor/include/public/acrn_common.h \
|
||||
../hypervisor/include/public/acrn_hv_defs.h \
|
||||
|
|
|
@ -230,6 +230,7 @@ HW_S_SRCS += arch/x86/sched.S
|
|||
HW_C_SRCS += arch/x86/rdt.c
|
||||
HW_C_SRCS += arch/x86/sgx.c
|
||||
HW_C_SRCS += common/ticks.c
|
||||
HW_C_SRCS += common/delay.c
|
||||
HW_C_SRCS += common/irq.c
|
||||
HW_C_SRCS += common/softirq.c
|
||||
HW_C_SRCS += common/schedule.c
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <asm/rtcm.h>
|
||||
#include <reloc.h>
|
||||
#include <ticks.h>
|
||||
#include <delay.h>
|
||||
|
||||
#define CPU_UP_TIMEOUT 100U /* millisecond */
|
||||
#define CPU_DOWN_TIMEOUT 100U /* millisecond */
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <asm/cpu_caps.h>
|
||||
#include <asm/lapic.h>
|
||||
#include <asm/apicreg.h>
|
||||
#include <delay.h>
|
||||
|
||||
/* intr_lapic_icr_delivery_mode */
|
||||
#define INTR_LAPIC_ICR_FIXED 0x0U
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <asm/ioapic.h>
|
||||
#include <asm/vtd.h>
|
||||
#include <asm/lapic.h>
|
||||
#include <delay.h>
|
||||
|
||||
struct cpu_context cpu_ctx;
|
||||
|
||||
|
|
|
@ -200,16 +200,3 @@ void timer_init(void)
|
|||
init_tsc_deadline_timer();
|
||||
}
|
||||
}
|
||||
|
||||
void udelay(uint32_t us)
|
||||
{
|
||||
uint64_t dest_tsc, delta_tsc;
|
||||
|
||||
/* Calculate number of ticks to wait */
|
||||
delta_tsc = us_to_ticks(us);
|
||||
dest_tsc = rdtsc() + delta_tsc;
|
||||
|
||||
/* Loop until time expired */
|
||||
while (rdtsc() < dest_tsc) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (C) 2021 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <common/ticks.h>
|
||||
#include <common/delay.h>
|
||||
|
||||
void udelay(uint32_t us)
|
||||
{
|
||||
uint64_t end, delta;
|
||||
|
||||
/* Calculate number of ticks to wait */
|
||||
delta = us_to_ticks(us);
|
||||
end = cpu_ticks() + delta;
|
||||
|
||||
/* Loop until time expired */
|
||||
while (cpu_ticks() < end) {
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@
|
|||
#include <vpci.h>
|
||||
#include <asm/pci_dev.h>
|
||||
#include <logmsg.h>
|
||||
#include <delay.h>
|
||||
|
||||
#include "vpci_priv.h"
|
||||
|
||||
|
|
|
@ -48,8 +48,6 @@ struct hv_timer {
|
|||
|
||||
/* External Interfaces */
|
||||
|
||||
void udelay(uint32_t us);
|
||||
|
||||
/**
|
||||
* @brief Initialize a timer structure.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (C) 2021 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef COMMON_DELAY_H
|
||||
#define COMMON_DELAY_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
/**
|
||||
* @brief Busy wait a few micro seconds.
|
||||
*
|
||||
* @param[in] us micro seconds to delay.
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
void udelay(uint32_t us);
|
||||
|
||||
#endif /* COMMON_DELAY_H */
|
Loading…
Reference in New Issue