aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/patch-kernel.sh
Commit message (Collapse)AuthorAgeFilesLines
* small patch from Johannes 5 JoemannWaldemar Brodkorb2005-03-261-0/+1
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@467 3c298f89-4303-0410-b956-a3cf2f4a3e73
* nbd's makefile/menuconfig rewriteMike Baker2005-03-061-0/+53
git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@307 3c298f89-4303-0410-b956-a3cf2f4a3e73
'#n53'>53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
/*
 * xen/arch/ia64/time.c
 *
 * Copyright (C) 2005 Hewlett-Packard Co
 *	Dan Magenheimer <dan.magenheimer@hp.com>
 */

#include <linux/config.h>

#include <linux/cpu.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/profile.h>
#include <linux/sched.h>
#include <linux/time.h>
#include <linux/interrupt.h>
#include <linux/efi.h>
#include <linux/profile.h>
#include <linux/timex.h>

#include <asm/machvec.h>
#include <asm/delay.h>
#include <asm/hw_irq.h>
#include <asm/ptrace.h>
#include <asm/sal.h>
#include <asm/sections.h>
#include <asm/system.h>
#include <asm/vcpu.h>
#include <linux/jiffies.h>	// not included by xen/sched.h
#include <xen/softirq.h>
#include <xen/event.h>

/* FIXME: where these declarations should be there ? */
extern void ia64_init_itm(void);

seqlock_t xtime_lock __cacheline_aligned_in_smp = SEQLOCK_UNLOCKED;

#define TIME_KEEPER_ID  0
unsigned long domain0_ready = 0;
static s_time_t stime_irq = 0x0;       /* System time at last 'time update' */
static unsigned long itc_scale __read_mostly, ns_scale __read_mostly;
static unsigned long itc_at_irq;

static u32 wc_sec, wc_nsec; /* UTC time at last 'time update'. */
static void ia64_wallclock_set(void);

/* We don't expect an absolute cycle value here, since then no way
 * to prevent overflow for large norminator. Normally this conversion
 * is used for relative offset.
 */
u64 cycle_to_ns(u64 cycle)
{
    return (cycle * itc_scale) >> 32;
}

static u64 ns_to_cycle(u64 ns)
{
    return (ns * ns_scale) >> 32;
}

static inline u64 get_time_delta(void)
{
    s64      delta_itc;
    u64      cur_itc;
    
    cur_itc = ia64_get_itc();

    delta_itc = (s64)(cur_itc - itc_at_irq);

    /* Ensure that the returned system time is monotonically increasing. */
    if ( unlikely(delta_itc < 0) ) delta_itc = 0;
    return cycle_to_ns(delta_itc);
}


s_time_t get_s_time(void)
{
    s_time_t now;
    unsigned long seq;

    do {
	seq = read_seqbegin(&xtime_lock);
	now = stime_irq + get_time_delta();
    } while (unlikely(read_seqretry(&xtime_lock, seq)));

    return now; 
}

void update_vcpu_system_time(struct vcpu *v)
{
    /* N-op here, and let dom0 to manage system time directly */
    return;
}

void
xen_timer_interrupt (int irq, void *dev_id, struct pt_regs *regs)
{
	unsigned long new_itm, old_itc;

	new_itm = local_cpu_data->itm_next;
	while (1) {
		if (smp_processor_id() == TIME_KEEPER_ID) {
			/*
			 * Here we are in the timer irq handler. We have irqs locally
			 * disabled, but we don't know if the timer_bh is running on
			 * another CPU. We need to avoid to SMP race by acquiring the
			 * xtime_lock.
			 */
			write_seqlock(&xtime_lock);
			/* Updates system time (nanoseconds since boot). */
			old_itc = itc_at_irq;
			itc_at_irq = ia64_get_itc();
			stime_irq += cycle_to_ns(itc_at_irq - old_itc);

			write_sequnlock(&xtime_lock);