ia64/xen-unstable

view extras/mini-os/include/time.h @ 12473:0839db0aa611

[MINIOS] Add timer support.

Based on an original patch by Robert Kaiser.

Signed-off-by: Grzegorz Milos <gm281@cam.ac.uk>
author kfraser@localhost.localdomain
date Wed Nov 15 09:33:01 2006 +0000 (2006-11-15)
parents 06d84bf87159
children b0a7612ae372
line source
1 /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*-
2 ****************************************************************************
3 * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
4 * (C) 2005 - Grzegorz Milos - Intel Research Cambridge
5 ****************************************************************************
6 *
7 * File: time.h
8 * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk)
9 * Changes: Grzegorz Milos (gm281@cam.ac.uk)
10 * Robert Kaiser (kaiser@informatik.fh-wiesbaden.de)
11 *
12 * Date: Jul 2003, changes: Jun 2005, Sep 2006
13 *
14 * Environment: Xen Minimal OS
15 * Description: Time and timer functions
16 *
17 ****************************************************************************
18 */
20 #ifndef _TIME_H_
21 #define _TIME_H_
23 /*
24 * System Time
25 * 64 bit value containing the nanoseconds elapsed since boot time.
26 * This value is adjusted by frequency drift.
27 * NOW() returns the current time.
28 * The other macros are for convenience to approximate short intervals
29 * of real time into system time
30 */
31 typedef s64 s_time_t;
32 #define NOW() ((s_time_t)monotonic_clock())
33 #define SECONDS(_s) (((s_time_t)(_s)) * 1000000000UL )
34 #define TENTHS(_ts) (((s_time_t)(_ts)) * 100000000UL )
35 #define HUNDREDTHS(_hs) (((s_time_t)(_hs)) * 10000000UL )
36 #define MILLISECS(_ms) (((s_time_t)(_ms)) * 1000000UL )
37 #define MICROSECS(_us) (((s_time_t)(_us)) * 1000UL )
38 #define Time_Max ((s_time_t) 0x7fffffffffffffffLL)
39 #define FOREVER Time_Max
40 #define NSEC_TO_USEC(_nsec) (_nsec / 1000UL)
41 #define NSEC_TO_SEC(_nsec) (_nsec / 1000000000ULL)
43 /* wall clock time */
44 typedef long time_t;
45 typedef long suseconds_t;
46 struct timeval {
47 time_t tv_sec; /* seconds */
48 suseconds_t tv_usec; /* microseconds */
49 };
51 struct timespec {
52 time_t ts_sec;
53 long ts_nsec;
54 };
57 /* prototypes */
58 void init_time(void);
59 s_time_t get_s_time(void);
60 s_time_t get_v_time(void);
61 u64 monotonic_clock(void);
62 void gettimeofday(struct timeval *tv);
63 void block_domain(s_time_t until);
65 #endif /* _TIME_H_ */