Skip to content

Commit 5585084

Browse files
mingqiangchiwenlingz
authored andcommitted
hv:move 'udelay' to timer.c
-- move this api from misc.c to timer.c to avoid reverse dependency, and remove misc.c Tracked-On: #1842 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
1 parent 370998b commit 5585084

File tree

5 files changed

+15
-22
lines changed

5 files changed

+15
-22
lines changed

hypervisor/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ C_SRCS += arch/x86/guest/vmexit.c
189189
S_SRCS += arch/x86/guest/vmx_asm.S
190190
C_SRCS += arch/x86/guest/trusty.c
191191
C_SRCS += arch/x86/cat.c
192-
C_SRCS += lib/misc.c
193192
C_SRCS += lib/string.c
194193
C_SRCS += lib/memory.c
195194
C_SRCS += lib/crypto/crypto_api.c

hypervisor/arch/x86/timer.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,16 @@ uint64_t ticks_to_ms(uint64_t ticks)
318318
{
319319
return ticks / (uint64_t)tsc_khz;
320320
}
321+
322+
void udelay(uint32_t us)
323+
{
324+
uint64_t dest_tsc, delta_tsc;
325+
326+
/* Calculate number of ticks to wait */
327+
delta_tsc = us_to_ticks(us);
328+
dest_tsc = rdtsc() + delta_tsc;
329+
330+
/* Loop until time expired */
331+
while (rdtsc() < dest_tsc) {
332+
}
333+
}

hypervisor/include/arch/x86/timer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ struct hv_timer {
4949

5050
#define CYCLES_PER_MS us_to_ticks(1000U)
5151

52+
void udelay(uint32_t us);
53+
5254
/**
5355
* @brief convert us to ticks.
5456
*

hypervisor/include/lib/rtl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ static inline bool is_space(char c)
3030
}
3131

3232
/* Function prototypes */
33-
void udelay(uint32_t us);
3433
int32_t strcmp(const char *s1_arg, const char *s2_arg);
3534
int32_t strncmp(const char *s1_arg, const char *s2_arg, size_t n_arg);
3635
char *strncpy_s(char *d_arg, size_t dmax, const char *s_arg, size_t slen_arg);

hypervisor/lib/misc.c

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)