patch-2.4.21 linux-2.4.21/arch/x86_64/kernel/vsyscall.c
Next file: linux-2.4.21/arch/x86_64/kernel/x8664_ksyms.c
Previous file: linux-2.4.21/arch/x86_64/kernel/traps.c
Back to the patch index
Back to the overall index
- Lines: 136
- Date:
2003-06-13 07:51:32.000000000 -0700
- Orig file:
linux-2.4.20/arch/x86_64/kernel/vsyscall.c
- Orig date:
2002-11-28 15:53:12.000000000 -0800
diff -urN linux-2.4.20/arch/x86_64/kernel/vsyscall.c linux-2.4.21/arch/x86_64/kernel/vsyscall.c
@@ -12,7 +12,7 @@
* vsyscalls. One vsyscall can reserve more than 1 slot to avoid
* jumping out of line if necessary.
*
- * $Id: vsyscall.c,v 1.19 2002/07/19 02:24:08 vojtech Exp $
+ * $Id: vsyscall.c,v 1.26 2003/02/18 11:55:47 ak Exp $
*/
/*
@@ -45,16 +45,15 @@
#include <asm/errno.h>
#include <asm/io.h>
#include <asm/msr.h>
+#include <asm/unistd.h>
#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
-long __vxtime_sequence[2] __section_vxtime_sequence;
-
-#undef USE_VSYSCALL
+#define force_inline inline __attribute__((always_inline))
-#ifdef USE_VSYSCALL
+long __vxtime_sequence[2] __section_vxtime_sequence;
-static inline void do_vgettimeofday(struct timeval * tv)
+static force_inline void do_vgettimeofday(struct timeval * tv)
{
long sequence, t;
unsigned long sec, usec;
@@ -63,11 +62,22 @@
sequence = __vxtime_sequence[1];
rmb();
- rdtscll(t);
sec = __xtime.tv_sec;
- usec = __xtime.tv_usec +
- (__jiffies - __wall_jiffies) * (1000000 / HZ) +
- (t - __hpet.last_tsc) * (1000000 / HZ) / __hpet.ticks + __hpet.offset;
+ usec = __xtime.tv_usec + (__jiffies - __wall_jiffies) * (1000000 / HZ);
+
+ switch (__vxtime.mode) {
+
+ case VXTIME_TSC:
+ sync_core();
+ rdtscll(t);
+ usec += (((t - __vxtime.last_tsc) * __vxtime.tsc_quot) >> 32);
+ break;
+
+ case VXTIME_HPET:
+ usec += ((readl(fix_to_virt(VSYSCALL_HPET) + 0xf0) - __vxtime.last) * __vxtime.quot) >> 32;
+ break;
+
+ }
rmb();
} while (sequence != __vxtime_sequence[0]);
@@ -76,7 +86,8 @@
tv->tv_usec = usec % 1000000;
}
-static inline void do_get_tz(struct timezone * tz)
+
+static force_inline void do_get_tz(struct timezone * tz)
{
long sequence;
@@ -92,27 +103,15 @@
static long __vsyscall(0) vgettimeofday(struct timeval * tv, struct timezone * tz)
{
- if (tv) do_vgettimeofday(tv);
- if (tz) do_get_tz(tz);
- return 0;
-}
-
-#else
+ if (tv)
+ do_vgettimeofday(tv);
-#include <asm/unistd.h>
+ if (tz)
+ do_get_tz(tz);
-static long __vsyscall(0) vgettimeofday(struct timeval * tv, struct timezone * tz)
-{
- int r;
- asm volatile("syscall"
- : "=a" (r)
- : "0" (__NR_gettimeofday), "D" (tv), "S" (tz)
- : "r11", "rcx","memory");
- return r;
+ return 0;
}
-#endif
-
static time_t __vsyscall(1) vtime(time_t * tp)
{
struct timeval tv;
@@ -131,19 +130,18 @@
return -ENOSYS;
}
+extern char vsyscall_syscall[], __vsyscall_0[];
+
static void __init map_vsyscall(void)
{
- extern char __vsyscall_0;
- unsigned long physaddr_page0 = (unsigned long) &__vsyscall_0 - __START_KERNEL_map;
-
+ unsigned long physaddr_page0 = __pa_symbol(&__vsyscall_0);
__set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL);
- if (hpet.address)
- __set_fixmap(VSYSCALL_HPET, hpet.address, PAGE_KERNEL_VSYSCALL);
+ if (hpet_address)
+ __set_fixmap(VSYSCALL_HPET, hpet_address, PAGE_KERNEL_VSYSCALL);
}
static int __init vsyscall_init(void)
{
- printk("VSYSCALL: consistency checks...");
if ((unsigned long) &vgettimeofday != VSYSCALL_ADDR(__NR_vgettimeofday))
panic("vgettimeofday link addr broken");
if ((unsigned long) &vtime != VSYSCALL_ADDR(__NR_vtime))
@@ -151,10 +149,7 @@
if (VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE))
panic("fixmap first vsyscall %lx should be %lx", __fix_to_virt(VSYSCALL_FIRST_PAGE),
VSYSCALL_ADDR(0));
- printk("passed...mapping...");
map_vsyscall();
- printk("done.\n");
-
return 0;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)