ia64/xen-unstable

changeset 4733:e47e0444dcb7

bitkeeper revision 1.1327.1.20 (4276651cSwFEIaVv-X0LcrzNw_Dxfw)

Last round of cleanup: Forgot a new file
author djm@kirby.fc.hp.com
date Mon May 02 17:36:28 2005 +0000 (2005-05-02)
parents 593703cf4935
children 59467f76b967
files .rootkeys xen/arch/ia64/xentime.c
line diff
     1.1 --- a/.rootkeys	Mon May 02 17:34:28 2005 +0000
     1.2 +++ b/.rootkeys	Mon May 02 17:36:28 2005 +0000
     1.3 @@ -1169,6 +1169,7 @@ 4272adaeit9raZ9KnjO_wR4Ii9LJNQ xen/arch/
     1.4  427162263zDUiPmTj-lP4eGyXs5eIg xen/arch/ia64/xenmem.c
     1.5  421098b6mWyFPtkhPz9h1LCmKpoCLg xen/arch/ia64/xenmisc.c
     1.6  421098b6lY2JzrV1oFDbrt7XQhtElg xen/arch/ia64/xensetup.c
     1.7 +427664f5eygrc3nEhI3RKf0Y37PzyA xen/arch/ia64/xentime.c
     1.8  3ddb79bcZbRBzT3elFWSX7u6NtMagQ xen/arch/x86/Makefile
     1.9  3ddb79bcBQF85CfLS4i1WGZ4oLLaCA xen/arch/x86/Rules.mk
    1.10  3e5636e5FAYZ5_vQnmgwFJfSdmO5Mw xen/arch/x86/acpi.c
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/xen/arch/ia64/xentime.c	Mon May 02 17:36:28 2005 +0000
     2.3 @@ -0,0 +1,204 @@
     2.4 +/*
     2.5 + * xen/arch/ia64/time.c
     2.6 + *
     2.7 + * Copyright (C) 2005 Hewlett-Packard Co
     2.8 + *	Dan Magenheimer <dan.magenheimer@hp.com>
     2.9 + */
    2.10 +
    2.11 +#include <linux/config.h>
    2.12 +
    2.13 +#include <linux/cpu.h>
    2.14 +#include <linux/init.h>
    2.15 +#include <linux/kernel.h>
    2.16 +#include <linux/module.h>
    2.17 +#include <linux/profile.h>
    2.18 +#include <linux/sched.h>
    2.19 +#include <linux/time.h>
    2.20 +#include <linux/interrupt.h>
    2.21 +#include <linux/efi.h>
    2.22 +#include <linux/profile.h>
    2.23 +#include <linux/timex.h>
    2.24 +
    2.25 +#include <asm/machvec.h>
    2.26 +#include <asm/delay.h>
    2.27 +#include <asm/hw_irq.h>
    2.28 +#include <asm/ptrace.h>
    2.29 +#include <asm/sal.h>
    2.30 +#include <asm/sections.h>
    2.31 +#include <asm/system.h>
    2.32 +#ifdef XEN
    2.33 +#include <linux/jiffies.h>	// not included by xen/sched.h
    2.34 +#endif
    2.35 +
    2.36 +#define TIME_KEEPER_ID  0
    2.37 +extern unsigned long wall_jiffies;
    2.38 +
    2.39 +static s_time_t        stime_irq;       /* System time at last 'time update' */
    2.40 +
    2.41 +unsigned long domain0_ready = 0;
    2.42 +
    2.43 +static inline u64 get_time_delta(void)
    2.44 +{
    2.45 +	return ia64_get_itc();
    2.46 +}
    2.47 +
    2.48 +s_time_t get_s_time(void)
    2.49 +{
    2.50 +    s_time_t now;
    2.51 +    unsigned long flags;
    2.52 +
    2.53 +    read_lock_irqsave(&xtime_lock, flags);
    2.54 +
    2.55 +    now = stime_irq + get_time_delta();
    2.56 +
    2.57 +    /* Ensure that the returned system time is monotonically increasing. */
    2.58 +    {
    2.59 +        static s_time_t prev_now = 0;
    2.60 +        if ( unlikely(now < prev_now) )
    2.61 +            now = prev_now;
    2.62 +        prev_now = now;
    2.63 +    }
    2.64 +
    2.65 +    read_unlock_irqrestore(&xtime_lock, flags);
    2.66 +
    2.67 +    return now; 
    2.68 +}
    2.69 +
    2.70 +void update_dom_time(struct exec_domain *ed)
    2.71 +{
    2.72 +// FIXME: implement this?
    2.73 +//	printf("update_dom_time: called, not implemented, skipping\n");
    2.74 +	return;
    2.75 +}
    2.76 +
    2.77 +/* Set clock to <secs,usecs> after 00:00:00 UTC, 1 January, 1970. */
    2.78 +void do_settime(unsigned long secs, unsigned long usecs, u64 system_time_base)
    2.79 +{
    2.80 +// FIXME: Should this be do_settimeofday (from linux)???
    2.81 +	printf("do_settime: called, not implemented, stopping\n");
    2.82 +	dummy();
    2.83 +}
    2.84 +
    2.85 +irqreturn_t
    2.86 +xen_timer_interrupt (int irq, void *dev_id, struct pt_regs *regs)
    2.87 +{
    2.88 +	unsigned long new_itm;
    2.89 +
    2.90 +#ifndef XEN
    2.91 +	if (unlikely(cpu_is_offline(smp_processor_id()))) {
    2.92 +		return IRQ_HANDLED;
    2.93 +	}
    2.94 +#endif
    2.95 +#ifdef XEN
    2.96 +	if (current->domain == dom0) {
    2.97 +		// FIXME: there's gotta be a better way of doing this...
    2.98 +		// We have to ensure that domain0 is launched before we
    2.99 +		// call vcpu_timer_expired on it
   2.100 +		//domain0_ready = 1; // moved to xensetup.c
   2.101 +		current->vcpu_info->arch.pending_interruption = 1;
   2.102 +	}
   2.103 +	if (domain0_ready && vcpu_timer_expired(dom0->exec_domain[0])) {
   2.104 +		vcpu_pend_timer(dom0->exec_domain[0]);
   2.105 +		//vcpu_set_next_timer(dom0->exec_domain[0]);
   2.106 +		domain_wake(dom0->exec_domain[0]);
   2.107 +	}
   2.108 +	if (!is_idle_task(current->domain) && current->domain != dom0) {
   2.109 +		if (vcpu_timer_expired(current)) {
   2.110 +			vcpu_pend_timer(current);
   2.111 +			// ensure another timer interrupt happens even if domain doesn't
   2.112 +			vcpu_set_next_timer(current);
   2.113 +			domain_wake(current);
   2.114 +		}
   2.115 +	}
   2.116 +	raise_actimer_softirq();
   2.117 +#endif
   2.118 +
   2.119 +#ifndef XEN
   2.120 +	platform_timer_interrupt(irq, dev_id, regs);
   2.121 +#endif
   2.122 +
   2.123 +	new_itm = local_cpu_data->itm_next;
   2.124 +
   2.125 +	if (!time_after(ia64_get_itc(), new_itm))
   2.126 +#ifdef XEN
   2.127 +		return;
   2.128 +#else
   2.129 +		printk(KERN_ERR "Oops: timer tick before it's due (itc=%lx,itm=%lx)\n",
   2.130 +		       ia64_get_itc(), new_itm);
   2.131 +#endif
   2.132 +
   2.133 +#ifdef XEN
   2.134 +//	printf("GOT TO HERE!!!!!!!!!!!\n");
   2.135 +	//while(1);
   2.136 +#else
   2.137 +	profile_tick(CPU_PROFILING, regs);
   2.138 +#endif
   2.139 +
   2.140 +	while (1) {
   2.141 +#ifndef XEN
   2.142 +		update_process_times(user_mode(regs));
   2.143 +#endif
   2.144 +
   2.145 +		new_itm += local_cpu_data->itm_delta;
   2.146 +
   2.147 +		if (smp_processor_id() == TIME_KEEPER_ID) {
   2.148 +			/*
   2.149 +			 * Here we are in the timer irq handler. We have irqs locally
   2.150 +			 * disabled, but we don't know if the timer_bh is running on
   2.151 +			 * another CPU. We need to avoid to SMP race by acquiring the
   2.152 +			 * xtime_lock.
   2.153 +			 */
   2.154 +#ifdef TURN_ME_OFF_FOR_NOW_IA64_XEN
   2.155 +			write_seqlock(&xtime_lock);
   2.156 +#endif
   2.157 +#ifdef TURN_ME_OFF_FOR_NOW_IA64_XEN
   2.158 +			do_timer(regs);
   2.159 +#endif
   2.160 +			local_cpu_data->itm_next = new_itm;
   2.161 +#ifdef TURN_ME_OFF_FOR_NOW_IA64_XEN
   2.162 +			write_sequnlock(&xtime_lock);
   2.163 +#endif
   2.164 +		} else
   2.165 +			local_cpu_data->itm_next = new_itm;
   2.166 +
   2.167 +		if (time_after(new_itm, ia64_get_itc()))
   2.168 +			break;
   2.169 +	}
   2.170 +
   2.171 +	do {
   2.172 +		/*
   2.173 +		 * If we're too close to the next clock tick for
   2.174 +		 * comfort, we increase the safety margin by
   2.175 +		 * intentionally dropping the next tick(s).  We do NOT
   2.176 +		 * update itm.next because that would force us to call
   2.177 +		 * do_timer() which in turn would let our clock run
   2.178 +		 * too fast (with the potentially devastating effect
   2.179 +		 * of losing monotony of time).
   2.180 +		 */
   2.181 +		while (!time_after(new_itm, ia64_get_itc() + local_cpu_data->itm_delta/2))
   2.182 +			new_itm += local_cpu_data->itm_delta;
   2.183 +//#ifdef XEN
   2.184 +//		vcpu_set_next_timer(current);
   2.185 +//#else
   2.186 +//printf("***** timer_interrupt: Setting itm to %lx\n",new_itm);
   2.187 +		ia64_set_itm(new_itm);
   2.188 +//#endif
   2.189 +		/* double check, in case we got hit by a (slow) PMI: */
   2.190 +	} while (time_after_eq(ia64_get_itc(), new_itm));
   2.191 +	return IRQ_HANDLED;
   2.192 +}
   2.193 +
   2.194 +static struct irqaction xen_timer_irqaction = {
   2.195 +	.handler =	xen_timer_interrupt,
   2.196 +#ifndef XEN
   2.197 +	.flags =	SA_INTERRUPT,
   2.198 +#endif
   2.199 +	.name =		"timer"
   2.200 +};
   2.201 +
   2.202 +void __init
   2.203 +xen_time_init (void)
   2.204 +{
   2.205 +	register_percpu_irq(IA64_TIMER_VECTOR, &xen_timer_irqaction);
   2.206 +	ia64_init_itm();
   2.207 +}