Subversion Repositories Kolibri OS

Rev

Rev 6934 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6934 Rev 7143
1
#ifndef _ASM_X86_PVCLOCK_H
1
#ifndef _ASM_X86_PVCLOCK_H
2
#define _ASM_X86_PVCLOCK_H
2
#define _ASM_X86_PVCLOCK_H
3
 
3
 
4
#include 
4
#include 
5
#include 
5
#include 
6
 
6
 
7
/* some helper functions for xen and kvm pv clock sources */
7
/* some helper functions for xen and kvm pv clock sources */
8
cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src);
8
cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src);
9
u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src);
9
u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src);
10
void pvclock_set_flags(u8 flags);
10
void pvclock_set_flags(u8 flags);
11
unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src);
11
unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src);
12
void pvclock_read_wallclock(struct pvclock_wall_clock *wall,
12
void pvclock_read_wallclock(struct pvclock_wall_clock *wall,
13
			    struct pvclock_vcpu_time_info *vcpu,
13
			    struct pvclock_vcpu_time_info *vcpu,
14
			    struct timespec *ts);
14
			    struct timespec *ts);
15
void pvclock_resume(void);
15
void pvclock_resume(void);
16
 
16
 
17
void pvclock_touch_watchdogs(void);
17
void pvclock_touch_watchdogs(void);
18
 
18
 
19
/*
19
/*
20
 * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
20
 * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
21
 * yielding a 64-bit result.
21
 * yielding a 64-bit result.
22
 */
22
 */
23
static inline u64 pvclock_scale_delta(u64 delta, u32 mul_frac, int shift)
23
static inline u64 pvclock_scale_delta(u64 delta, u32 mul_frac, int shift)
24
{
24
{
25
	u64 product;
25
	u64 product;
26
#ifdef __i386__
26
#ifdef __i386__
27
	u32 tmp1, tmp2;
27
	u32 tmp1, tmp2;
28
#else
28
#else
29
	ulong tmp;
29
	ulong tmp;
30
#endif
30
#endif
31
 
31
 
32
	if (shift < 0)
32
	if (shift < 0)
33
		delta >>= -shift;
33
		delta >>= -shift;
34
	else
34
	else
35
		delta <<= shift;
35
		delta <<= shift;
36
 
36
 
37
#ifdef __i386__
37
#ifdef __i386__
38
	__asm__ (
38
	__asm__ (
39
		"mul  %5       ; "
39
		"mul  %5       ; "
40
		"mov  %4,%%eax ; "
40
		"mov  %4,%%eax ; "
41
		"mov  %%edx,%4 ; "
41
		"mov  %%edx,%4 ; "
42
		"mul  %5       ; "
42
		"mul  %5       ; "
43
		"xor  %5,%5    ; "
43
		"xor  %5,%5    ; "
44
		"add  %4,%%eax ; "
44
		"add  %4,%%eax ; "
45
		"adc  %5,%%edx ; "
45
		"adc  %5,%%edx ; "
46
		: "=A" (product), "=r" (tmp1), "=r" (tmp2)
46
		: "=A" (product), "=r" (tmp1), "=r" (tmp2)
47
		: "a" ((u32)delta), "1" ((u32)(delta >> 32)), "2" (mul_frac) );
47
		: "a" ((u32)delta), "1" ((u32)(delta >> 32)), "2" (mul_frac) );
48
#elif defined(__x86_64__)
48
#elif defined(__x86_64__)
49
	__asm__ (
49
	__asm__ (
50
		"mulq %[mul_frac] ; shrd $32, %[hi], %[lo]"
50
		"mulq %[mul_frac] ; shrd $32, %[hi], %[lo]"
51
		: [lo]"=a"(product),
51
		: [lo]"=a"(product),
52
		  [hi]"=d"(tmp)
52
		  [hi]"=d"(tmp)
53
		: "0"(delta),
53
		: "0"(delta),
54
		  [mul_frac]"rm"((u64)mul_frac));
54
		  [mul_frac]"rm"((u64)mul_frac));
55
#else
55
#else
56
#error implement me!
56
#error implement me!
57
#endif
57
#endif
58
 
58
 
59
	return product;
59
	return product;
60
}
60
}
61
 
61
 
62
 
62
 
63
struct pvclock_vsyscall_time_info {
63
struct pvclock_vsyscall_time_info {
64
	struct pvclock_vcpu_time_info pvti;
64
	struct pvclock_vcpu_time_info pvti;
65
} __attribute__((__aligned__(SMP_CACHE_BYTES)));
65
} __attribute__((__aligned__(SMP_CACHE_BYTES)));
66
 
66
 
67
#define PVTI_SIZE sizeof(struct pvclock_vsyscall_time_info)
67
#define PVTI_SIZE sizeof(struct pvclock_vsyscall_time_info)
68
#define PVCLOCK_VSYSCALL_NR_PAGES (((NR_CPUS-1)/(PAGE_SIZE/PVTI_SIZE))+1)
-
 
69
 
-
 
70
int __init pvclock_init_vsyscall(struct pvclock_vsyscall_time_info *i,
-
 
71
				 int size);
-
 
72
struct pvclock_vcpu_time_info *pvclock_get_vsyscall_time_info(int cpu);
-
 
73
 
68
 
74
#endif /* _ASM_X86_PVCLOCK_H */
69
#endif /* _ASM_X86_PVCLOCK_H */