ia64/xen-unstable

changeset 190:74a183b3173d

bitkeeper revision 1.52 (3e4f6933RobiLdX5romhBHDYXp95mQ)

time.c:
Fixed tabbing in time.c
author kaf24@labyrinth.cl.cam.ac.uk
date Sun Feb 16 10:34:27 2003 +0000 (2003-02-16)
parents dbf8bc3ff290
children 03794b32489f
files xen-2.4.16/arch/i386/time.c
line diff
     1.1 --- a/xen-2.4.16/arch/i386/time.c	Sun Feb 16 10:25:43 2003 +0000
     1.2 +++ b/xen-2.4.16/arch/i386/time.c	Sun Feb 16 10:34:27 2003 +0000
     1.3 @@ -48,8 +48,6 @@
     1.4  #define TRC(_x)
     1.5  #endif
     1.6  
     1.7 -
     1.8 -
     1.9  unsigned long cpu_khz;	/* Detected as we calibrate the TSC */
    1.10  unsigned long ticks_per_usec; /* TSC ticks per microsecond. */
    1.11  
    1.12 @@ -63,10 +61,10 @@ static inline void do_timer_interrupt(in
    1.13  #ifdef CONFIG_X86_IO_APIC
    1.14      if (timer_ack) {
    1.15          /*
    1.16 -         * Subtle, when I/O APICs are used we have to ack timer IRQ
    1.17 -         * manually to reset the IRR bit for do_slow_gettimeoffset().
    1.18 -         * This will also deassert NMI lines for the watchdog if run
    1.19 -         * on an 82489DX-based system.
    1.20 +         * Subtle, when I/O APICs are used we have to ack timer IRQ manually 
    1.21 +         * to reset the IRR bit for do_slow_gettimeoffset(). This will also 
    1.22 +         * deassert NMI lines for the watchdog if run on an 82489DX-based 
    1.23 +         * system.
    1.24           */
    1.25          spin_lock(&i8259A_lock);
    1.26          outb(0x0c, 0x20);
    1.27 @@ -103,13 +101,13 @@ static unsigned long __init calibrate_ts
    1.28      /* Set the Gate high, disable speaker */
    1.29      outb((inb(0x61) & ~0x02) | 0x01, 0x61);
    1.30  
    1.31 -	/*
    1.32 -	 * Now let's take care of CTC channel 2
    1.33 -	 *
    1.34 -	 * Set the Gate high, program CTC channel 2 for mode 0,
    1.35 -	 * (interrupt on terminal count mode), binary count,
    1.36 -	 * load 5 * LATCH count, (LSB and MSB) to begin countdown.
    1.37 -	 */
    1.38 +    /*
    1.39 +     * Now let's take care of CTC channel 2
    1.40 +     *
    1.41 +     * Set the Gate high, program CTC channel 2 for mode 0, (interrupt on
    1.42 +     * terminal count mode), binary count, load 5 * LATCH count, (LSB and MSB)
    1.43 +     * to begin countdown.
    1.44 +     */
    1.45      outb(0xb0, 0x43);			/* binary, mode 0, LSB/MSB, Ch 2 */
    1.46      outb(CALIBRATE_LATCH & 0xff, 0x42);	/* LSB of count */
    1.47      outb(CALIBRATE_LATCH >> 8, 0x42);	/* MSB of count */
    1.48 @@ -145,8 +143,8 @@ static unsigned long __init calibrate_ts
    1.49      }
    1.50  
    1.51      /*
    1.52 -     * The CTC wasn't reliable: we got a hit on the very first read, or the 
    1.53 -     * CPU was so fast/slow that the quotient wouldn't fit in 32 bits..
    1.54 +     * The CTC wasn't reliable: we got a hit on the very first read, or the CPU
    1.55 +     * was so fast/slow that the quotient wouldn't fit in 32 bits..
    1.56       */
    1.57   bad_ctc:
    1.58      return 0;
    1.59 @@ -176,12 +174,12 @@ mktime (unsigned int year, unsigned int 
    1.60          unsigned int day, unsigned int hour,
    1.61          unsigned int min, unsigned int sec)
    1.62  {
    1.63 -	if (0 >= (int) (mon -= 2)) {    /* 1..12 -> 11,12,1..10 */
    1.64 -		mon += 12;              /* Puts Feb last since it has leap day */
    1.65 -		year -= 1;
    1.66 +    if (0 >= (int) (mon -= 2)) {   /* 1..12 -> 11,12,1..10 */
    1.67 +        mon += 12;                 /* Puts Feb last since it has leap day */
    1.68 +        year -= 1;
    1.69  	}
    1.70 -	return ((((unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day)+
    1.71 -			  year*365 - 719499
    1.72 +    return ((((unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day)+
    1.73 +              year*365 - 719499
    1.74          )*24 + hour /* now have hours */
    1.75          )*60 + min /* now have minutes */
    1.76          )*60 + sec; /* finally seconds */
    1.77 @@ -189,45 +187,45 @@ mktime (unsigned int year, unsigned int 
    1.78  
    1.79  static unsigned long get_cmos_time(void)
    1.80  {
    1.81 -	unsigned int year, mon, day, hour, min, sec;
    1.82 -	int i;
    1.83 +    unsigned int year, mon, day, hour, min, sec;
    1.84 +    int i;
    1.85  
    1.86 -	spin_lock(&rtc_lock);
    1.87 -	/* The Linux interpretation of the CMOS clock register contents:
    1.88 -	 * When the Update-In-Progress (UIP) flag goes from 1 to 0, the
    1.89 -	 * RTC registers show the second which has precisely just started.
    1.90 -	 * Let's hope other operating systems interpret the RTC the same way.
    1.91 -	 */
    1.92 -	/* read RTC exactly on falling edge of update flag */
    1.93 -	for (i = 0 ; i < 1000000 ; i++)	/* may take up to 1 second... */
    1.94 -		if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)
    1.95 -			break;
    1.96 -	for (i = 0 ; i < 1000000 ; i++)	/* must try at least 2.228 ms */
    1.97 -		if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))
    1.98 -			break;
    1.99 +    spin_lock(&rtc_lock);
   1.100 +    /* The Linux interpretation of the CMOS clock register contents:
   1.101 +     * When the Update-In-Progress (UIP) flag goes from 1 to 0, the
   1.102 +     * RTC registers show the second which has precisely just started.
   1.103 +     * Let's hope other operating systems interpret the RTC the same way.
   1.104 +     */
   1.105 +    /* read RTC exactly on falling edge of update flag */
   1.106 +    for (i = 0 ; i < 1000000 ; i++)	/* may take up to 1 second... */
   1.107 +        if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)
   1.108 +            break;
   1.109 +    for (i = 0 ; i < 1000000 ; i++)	/* must try at least 2.228 ms */
   1.110 +        if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))
   1.111 +            break;
   1.112  	do { /* Isn't this overkill ? UIP above should guarantee consistency */
   1.113 -		sec = CMOS_READ(RTC_SECONDS);
   1.114 -		min = CMOS_READ(RTC_MINUTES);
   1.115 -		hour = CMOS_READ(RTC_HOURS);
   1.116 -		day = CMOS_READ(RTC_DAY_OF_MONTH);
   1.117 -		mon = CMOS_READ(RTC_MONTH);
   1.118 -		year = CMOS_READ(RTC_YEAR);
   1.119 -	} while (sec != CMOS_READ(RTC_SECONDS));
   1.120 -	if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
   1.121 +        sec = CMOS_READ(RTC_SECONDS);
   1.122 +        min = CMOS_READ(RTC_MINUTES);
   1.123 +        hour = CMOS_READ(RTC_HOURS);
   1.124 +        day = CMOS_READ(RTC_DAY_OF_MONTH);
   1.125 +        mon = CMOS_READ(RTC_MONTH);
   1.126 +        year = CMOS_READ(RTC_YEAR);
   1.127 +    } while (sec != CMOS_READ(RTC_SECONDS));
   1.128 +    if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
   1.129      {
   1.130 -	    BCD_TO_BIN(sec);
   1.131 -	    BCD_TO_BIN(min);
   1.132 +        BCD_TO_BIN(sec);
   1.133 +        BCD_TO_BIN(min);
   1.134  	    BCD_TO_BIN(hour);
   1.135  	    BCD_TO_BIN(day);
   1.136  	    BCD_TO_BIN(mon);
   1.137  	    BCD_TO_BIN(year);
   1.138      }
   1.139 -	spin_unlock(&rtc_lock);
   1.140 -	if ((year += 1900) < 1970)
   1.141 -		year += 100;
   1.142 -	printk(".... CMOS Clock:  %02d/%02d/%04d %02d:%02d:%02d\n",
   1.143 -		   day, mon, year, hour, min, sec);
   1.144 -	return mktime(year, mon, day, hour, min, sec);
   1.145 +    spin_unlock(&rtc_lock);
   1.146 +    if ((year += 1900) < 1970)
   1.147 +        year += 100;
   1.148 +    printk(".... CMOS Clock:  %02d/%02d/%04d %02d:%02d:%02d\n",
   1.149 +           day, mon, year, hour, min, sec);
   1.150 +    return mktime(year, mon, day, hour, min, sec);
   1.151  }
   1.152  
   1.153  /***************************************************************************
   1.154 @@ -244,24 +242,24 @@ s_time_t	stime_now;   /* time in ns at l
   1.155  
   1.156  s_time_t get_s_time(void)
   1.157  {
   1.158 -	unsigned long flags;
   1.159 +    unsigned long flags;
   1.160      u32 	 delta_tsc, low, pcc;
   1.161 -	u64      delta;
   1.162 -	s_time_t now;
   1.163 +    u64      delta;
   1.164 +    s_time_t now;
   1.165  
   1.166 -	spin_lock_irqsave(&stime_lock, flags);
   1.167 +    spin_lock_irqsave(&stime_lock, flags);
   1.168  
   1.169      pcc = stime_pcc;		
   1.170      now = stime_now;
   1.171  
   1.172      /* only use bottom 32bits of TSC. This should be sufficient */
   1.173 -	rdtscl(low);
   1.174 +    rdtscl(low);
   1.175      delta_tsc = low - pcc;
   1.176 -	delta = ((u64)delta_tsc * st_scale_f);
   1.177 -	delta >>= 32;
   1.178 -	delta += ((u64)delta_tsc * st_scale_i);
   1.179 +    delta = ((u64)delta_tsc * st_scale_f);
   1.180 +    delta >>= 32;
   1.181 +    delta += ((u64)delta_tsc * st_scale_i);
   1.182  
   1.183 -	spin_unlock_irqrestore(&stime_lock, flags);
   1.184 +    spin_unlock_irqrestore(&stime_lock, flags);
   1.185  
   1.186      return now + delta; 
   1.187  }
   1.188 @@ -274,28 +272,26 @@ s_time_t	      wctime_st;       /* syste
   1.189  
   1.190  void do_gettimeofday(struct timeval *tv)
   1.191  {
   1.192 -	unsigned long flags;
   1.193 -	unsigned long usec, sec;
   1.194 -
   1.195 -	spin_lock_irqsave(&wctime_lock, flags);
   1.196 -
   1.197 -	usec = ((unsigned long)(NOW() - wctime_st))/1000;
   1.198 -	sec = wall_clock_time.tv_sec;
   1.199 -	usec += wall_clock_time.tv_usec;
   1.200 +    unsigned long flags;
   1.201 +    unsigned long usec, sec;
   1.202  
   1.203 -	spin_unlock_irqrestore(&wctime_lock, flags);
   1.204 +    spin_lock_irqsave(&wctime_lock, flags);
   1.205 +    usec = ((unsigned long)(NOW() - wctime_st))/1000;
   1.206 +    sec = wall_clock_time.tv_sec;
   1.207 +    usec += wall_clock_time.tv_usec;
   1.208 +    spin_unlock_irqrestore(&wctime_lock, flags);
   1.209  
   1.210 -	while (usec >= 1000000) {
   1.211 -		usec -= 1000000;
   1.212 -		sec++;
   1.213 -	}
   1.214 -	tv->tv_sec = sec;
   1.215 -	tv->tv_usec = usec;
   1.216 +    while (usec >= 1000000) {
   1.217 +        usec -= 1000000;
   1.218 +        sec++;
   1.219 +    }
   1.220 +    tv->tv_sec = sec;
   1.221 +    tv->tv_usec = usec;
   1.222  }
   1.223  
   1.224  void do_settimeofday(struct timeval *tv)
   1.225  {
   1.226 -	printk("XXX: do_settimeofday not implemented\n");
   1.227 +    printk("XXX: do_settimeofday not implemented\n");
   1.228  }
   1.229  
   1.230  /***************************************************************************
   1.231 @@ -305,21 +301,21 @@ void do_settimeofday(struct timeval *tv)
   1.232  /* update a domains notion of time */
   1.233  void update_dom_time(shared_info_t *si)
   1.234  {
   1.235 -	unsigned long flags;
   1.236 +    unsigned long flags;
   1.237  
   1.238 -	spin_lock_irqsave(&stime_lock, flags);
   1.239 -	si->system_time  = stime_now;
   1.240 -	si->st_timestamp = stime_pcc;
   1.241 -	spin_unlock_irqrestore(&stime_lock, flags);
   1.242 +    spin_lock_irqsave(&stime_lock, flags);
   1.243 +    si->system_time  = stime_now;
   1.244 +    si->st_timestamp = stime_pcc;
   1.245 +    spin_unlock_irqrestore(&stime_lock, flags);
   1.246  
   1.247 -	spin_lock_irqsave(&wctime_lock, flags);
   1.248 -	si->tv_sec       = wall_clock_time.tv_sec;
   1.249 -	si->tv_usec      = wall_clock_time.tv_usec;
   1.250 -	si->wc_timestamp = wctime_st;
   1.251 -	si->wc_version++;
   1.252 -	spin_unlock_irqrestore(&wctime_lock, flags);	
   1.253 +    spin_lock_irqsave(&wctime_lock, flags);
   1.254 +    si->tv_sec       = wall_clock_time.tv_sec;
   1.255 +    si->tv_usec      = wall_clock_time.tv_usec;
   1.256 +    si->wc_timestamp = wctime_st;
   1.257 +    si->wc_version++;
   1.258 +    spin_unlock_irqrestore(&wctime_lock, flags);	
   1.259  
   1.260 -	TRC(printk(" 0x%08X%08X\n", (u32)(wctime_st>>32), (u32)wctime_st));
   1.261 +    TRC(printk(" 0x%08X%08X\n", (u32)(wctime_st>>32), (u32)wctime_st));
   1.262  }
   1.263  
   1.264  /*
   1.265 @@ -329,43 +325,42 @@ void update_dom_time(shared_info_t *si)
   1.266  static struct ac_timer update_timer;
   1.267  static void update_time(unsigned long foo)
   1.268  {
   1.269 -	unsigned long  flags;
   1.270 -	u32		       new_pcc;
   1.271 -	s_time_t       new_st;
   1.272 -	unsigned long  usec;
   1.273 +    unsigned long  flags;
   1.274 +    u32		       new_pcc;
   1.275 +    s_time_t       new_st;
   1.276 +    unsigned long  usec;
   1.277  
   1.278 -	new_st = NOW();
   1.279 -	rdtscl(new_pcc);
   1.280 +    new_st = NOW();
   1.281 +    rdtscl(new_pcc);
   1.282  
   1.283 -	/* Update system time. */
   1.284 -	spin_lock_irqsave(&stime_lock, flags);
   1.285 -	stime_now = new_st;
   1.286 -	stime_pcc=new_pcc;
   1.287 +    /* Update system time. */
   1.288 +    spin_lock_irqsave(&stime_lock, flags);
   1.289 +    stime_now = new_st;
   1.290 +    stime_pcc=new_pcc;
   1.291      /* Don't reeenable IRQs until we release wctime_lock. */
   1.292 -	spin_unlock(&stime_lock);
   1.293 +    spin_unlock(&stime_lock);
   1.294  
   1.295 -	/* Update wall clock time. */
   1.296 -	spin_lock(&wctime_lock);
   1.297 -	usec = ((unsigned long)(new_st - wctime_st))/1000;
   1.298 -	usec += wall_clock_time.tv_usec;
   1.299 -	while (usec >= 1000000) {
   1.300 -		usec -= 1000000;
   1.301 -		wall_clock_time.tv_sec++;
   1.302 -	}
   1.303 -	wall_clock_time.tv_usec = usec;
   1.304 -	wctime_st = new_st;
   1.305 -	spin_unlock_irqrestore(&wctime_lock, flags);
   1.306 +    /* Update wall clock time. */
   1.307 +    spin_lock(&wctime_lock);
   1.308 +    usec = ((unsigned long)(new_st - wctime_st))/1000;
   1.309 +    usec += wall_clock_time.tv_usec;
   1.310 +    while (usec >= 1000000) {
   1.311 +        usec -= 1000000;
   1.312 +        wall_clock_time.tv_sec++;
   1.313 +    }
   1.314 +    wall_clock_time.tv_usec = usec;
   1.315 +    wctime_st = new_st;
   1.316 +    spin_unlock_irqrestore(&wctime_lock, flags);
   1.317  
   1.318 -	TRC(printk("TIME[%02d] update time: stime_now=%lld now=%lld,wct=%ld:%ld\n",
   1.319 -			   smp_processor_id(), stime_now, new_st, wall_clock_time.tv_sec,
   1.320 -			   wall_clock_time.tv_usec));
   1.321 +    TRC(printk("TIME[%02d] update time: stime_now=%lld now=%lld,wct=%ld:%ld\n",
   1.322 +               smp_processor_id(), stime_now, new_st, wall_clock_time.tv_sec,
   1.323 +               wall_clock_time.tv_usec));
   1.324  
   1.325 -	/* Reload the timer. */
   1.326 +    /* Reload the timer. */
   1.327   again:
   1.328 -	update_timer.expires  = new_st + MILLISECS(200);
   1.329 -	if(add_ac_timer(&update_timer) == 1) {
   1.330 -		goto again;
   1.331 -	}
   1.332 +    update_timer.expires  = new_st + MILLISECS(200);
   1.333 +    if(add_ac_timer(&update_timer) == 1)
   1.334 +        goto again;
   1.335  }
   1.336  
   1.337  /***************************************************************************
   1.338 @@ -374,47 +369,47 @@ static void update_time(unsigned long fo
   1.339   ***************************************************************************/
   1.340  int __init init_xeno_time()
   1.341  {
   1.342 -	int      cpu = smp_processor_id();
   1.343 -	u32	     cpu_cycle;  /* time of one cpu cyle in pico-seconds */
   1.344 -	u64      scale;      /* scale factor  */
   1.345 +    int      cpu = smp_processor_id();
   1.346 +    u32	     cpu_cycle;  /* time of one cpu cyle in pico-seconds */
   1.347 +    u64      scale;      /* scale factor  */
   1.348  
   1.349 -	spin_lock_init(&stime_lock);
   1.350 -	spin_lock_init(&wctime_lock);
   1.351 +    spin_lock_init(&stime_lock);
   1.352 +    spin_lock_init(&wctime_lock);
   1.353  
   1.354 -	printk("Init Time[%02d]:\n", cpu);
   1.355 +    printk("Init Time[%02d]:\n", cpu);
   1.356  
   1.357 -	/* System Time */
   1.358 -	cpu_cycle   = (u32) (1000000000LL/cpu_khz); /* in pico seconds */
   1.359 -	scale = 1000000000LL << 32;
   1.360 -	scale /= cpu_freq;
   1.361 -	st_scale_f = scale & 0xffffffff;
   1.362 -	st_scale_i = scale >> 32;
   1.363 +    /* System Time */
   1.364 +    cpu_cycle   = (u32) (1000000000LL/cpu_khz); /* in pico seconds */
   1.365 +    scale = 1000000000LL << 32;
   1.366 +    scale /= cpu_freq;
   1.367 +    st_scale_f = scale & 0xffffffff;
   1.368 +    st_scale_i = scale >> 32;
   1.369  
   1.370 -	/* Wall Clock time */
   1.371 -	wall_clock_time.tv_sec  = get_cmos_time();
   1.372 -	wall_clock_time.tv_usec = 0;
   1.373 +    /* Wall Clock time */
   1.374 +    wall_clock_time.tv_sec  = get_cmos_time();
   1.375 +    wall_clock_time.tv_usec = 0;
   1.376  
   1.377 -	/* set starting times */
   1.378 -	stime_now = (s_time_t)0;
   1.379 -	rdtscl(stime_pcc);
   1.380 -	wctime_st = NOW();
   1.381 +    /* set starting times */
   1.382 +    stime_now = (s_time_t)0;
   1.383 +    rdtscl(stime_pcc);
   1.384 +    wctime_st = NOW();
   1.385  
   1.386 -	/* start timer to update time periodically */
   1.387 -	init_ac_timer(&update_timer);
   1.388 -	update_timer.function = &update_time;
   1.389 -	update_time(0);
   1.390 +    /* start timer to update time periodically */
   1.391 +    init_ac_timer(&update_timer);
   1.392 +    update_timer.function = &update_time;
   1.393 +    update_time(0);
   1.394  
   1.395 -	printk(".... System Time: %lldns\n", NOW());
   1.396 -	printk(".....cpu_cycle:   %u ps\n",  cpu_cycle);
   1.397 -	printk(".... st_scale_f:  %X\n",     st_scale_f);
   1.398 -	printk(".... st_scale_i:  %X\n",     st_scale_i);
   1.399 -	printk(".... stime_pcc:   %u\n",     stime_pcc);
   1.400 +    printk(".... System Time: %lldns\n", NOW());
   1.401 +    printk(".....cpu_cycle:   %u ps\n",  cpu_cycle);
   1.402 +    printk(".... st_scale_f:  %X\n",     st_scale_f);
   1.403 +    printk(".... st_scale_i:  %X\n",     st_scale_i);
   1.404 +    printk(".... stime_pcc:   %u\n",     stime_pcc);
   1.405  
   1.406 -	printk(".... Wall Clock:  %lds %ldus\n", wall_clock_time.tv_sec,
   1.407 -		   wall_clock_time.tv_usec);
   1.408 -	printk(".... wctime_st:   %lld\n", wctime_st);
   1.409 +    printk(".... Wall Clock:  %lds %ldus\n", wall_clock_time.tv_sec,
   1.410 +           wall_clock_time.tv_usec);
   1.411 +    printk(".... wctime_st:   %lld\n", wctime_st);
   1.412  
   1.413 -	return 0;
   1.414 +    return 0;
   1.415  }
   1.416  
   1.417