Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7bd867df authored by Feng Tang's avatar Feng Tang Committed by Thomas Gleixner
Browse files

x86: Move get/set_wallclock to x86_platform_ops



get/set_wallclock() have already a set of platform dependent
implementations (default, EFI, paravirt). MRST will add another
variant.

Moving them to platform ops simplifies the existing code and minimizes
the effort to integrate new variants.

Signed-off-by: default avatarFeng Tang <feng.tang@intel.com>
LKML-Reference: <new-submission>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 54e2603f
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -24,16 +24,6 @@ static inline void load_sp0(struct tss_struct *tss,
	PVOP_VCALL2(pv_cpu_ops.load_sp0, tss, thread);
}

static inline unsigned long get_wallclock(void)
{
	return PVOP_CALL0(unsigned long, pv_time_ops.get_wallclock);
}

static inline int set_wallclock(unsigned long nowtime)
{
	return PVOP_CALL1(int, pv_time_ops.set_wallclock, nowtime);
}

/* The paravirtualized CPUID instruction. */
static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
			   unsigned int *ecx, unsigned int *edx)
+0 −4
Original line number Diff line number Diff line
@@ -88,10 +88,6 @@ struct pv_lazy_ops {
};

struct pv_time_ops {
	/* Set and set time of day */
	unsigned long (*get_wallclock)(void);
	int (*set_wallclock)(unsigned long);

	unsigned long long (*sched_clock)(void);
	unsigned long (*get_tsc_khz)(void);
};
+0 −50
Original line number Diff line number Diff line
@@ -4,57 +4,7 @@
extern void hpet_time_init(void);

#include <asm/mc146818rtc.h>
#ifdef CONFIG_X86_32
#include <linux/efi.h>

static inline unsigned long native_get_wallclock(void)
{
	unsigned long retval;

	if (efi_enabled)
		retval = efi_get_time();
	else
		retval = mach_get_cmos_time();

	return retval;
}

static inline int native_set_wallclock(unsigned long nowtime)
{
	int retval;

	if (efi_enabled)
		retval = efi_set_rtc_mmss(nowtime);
	else
		retval = mach_set_rtc_mmss(nowtime);

	return retval;
}

#else
extern void native_time_init_hook(void);

static inline unsigned long native_get_wallclock(void)
{
	return mach_get_cmos_time();
}

static inline int native_set_wallclock(unsigned long nowtime)
{
	return mach_set_rtc_mmss(nowtime);
}

#endif

extern void time_init(void);

#ifdef CONFIG_PARAVIRT
#include <asm/paravirt.h>
#else /* !CONFIG_PARAVIRT */

#define get_wallclock() native_get_wallclock()
#define set_wallclock(x) native_set_wallclock(x)

#endif /* CONFIG_PARAVIRT */

#endif /* _ASM_X86_TIME_H */
+4 −0
Original line number Diff line number Diff line
@@ -114,9 +114,13 @@ struct x86_cpuinit_ops {
/**
 * struct x86_platform_ops - platform specific runtime functions
 * @calibrate_tsc:		calibrate TSC
 * @get_wallclock:		get time from HW clock like RTC etc.
 * @set_wallclock:		set time back to HW clock
 */
struct x86_platform_ops {
	unsigned long (*calibrate_tsc)(void);
	unsigned long (*get_wallclock)(void);
	int (*set_wallclock)(unsigned long nowtime);
};

extern struct x86_init_ops x86_init;
+4 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include <asm/time.h>
#include <asm/cacheflush.h>
#include <asm/tlbflush.h>
#include <asm/x86_init.h>

#define EFI_DEBUG	1
#define PFX 		"EFI: "
@@ -453,6 +454,9 @@ void __init efi_init(void)
	if (add_efi_memmap)
		do_add_efi_memmap();

	x86_platform.get_wallclock = efi_get_time;
	x86_platform.set_wallclock = efi_set_rtc_mmss;

	/* Setup for EFI runtime service */
	reboot_type = BOOT_EFI;

Loading