FreeBSD/Linux Kernel Cross Reference
sys/i386/timer.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1993,1991 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26
27 /*
28 * HISTORY
29 * $Log: timer.h,v $
30 * Revision 2.3 93/11/17 16:40:16 dbg
31 * Added TIMER_TO_TIMESPEC.
32 * [93/04/15 dbg]
33 *
34 * Changed TIMER_RATE to USAGE_RATE.
35 * [93/02/23 dbg]
36 *
37 * Revision 2.2 91/07/31 17:41:51 dbg
38 * Created.
39 * [91/07/30 16:58:38 dbg]
40 *
41 */
42
43 #ifndef _I386_TIMER_H_
44 #define _I386_TIMER_H_
45
46 /*
47 * Machine dependent timer definitions.
48 */
49
50 #include <platforms.h>
51
52 #ifdef SYMMETRY
53
54 /*
55 * TIMER_MAX is not used on the Sequent because a 32-bit rollover
56 * timer does not need to be adjusted for maximum value.
57 */
58
59 /*
60 * USAGE_RATE is the rate of the timer in ticks per second.
61 * It is used to calculate percent cpu usage.
62 */
63
64 #define USAGE_RATE 1000000
65
66 /*
67 * TIMER_HIGH_UNIT is the unit for high_bits in terms of low_bits.
68 * Setting it to USAGE_RATE makes the high unit seconds.
69 */
70
71 #define TIMER_HIGH_UNIT USAGE_RATE
72
73 /*
74 * These routines convert the components of a timer
75 * to USAGE_RATE.
76 *
77 * For the Sequent, since the low unit is microseconds,
78 * TIMER_LOW_TO_USAGE is the identity function.
79 */
80 #define TIMER_LOW_TO_USAGE(micros) (micros)
81 #define TIMER_HIGH_TO_USAGE(secs) ((secs)*TIMER_HIGH_UNIT)
82
83 /*
84 * TIMER_TO_TIMESPEC is used to adjust the value of a timer after
85 * it has been copied into a time_spec_t.
86 *
87 * We convert the low word from microseconds to nanoseconds.
88 * The high word is already in seconds.
89 *
90 * We normalize the result before conversion, since the
91 * multiplication may overflow 32 bits.
92 */
93 #define TIMER_TO_TIMESPEC(timer) \
94 ((timer)->high += (timer)->low / TIMER_HIGH_UNIT, \
95 (timer)->low = ((timer)->low % TIMER_HIGH_UNIT) * 1000)
96
97 /*
98 * MACHINE_TIMER_ROUTINES should be defined if the timer routines are
99 * implemented in machine-dependent code (e.g. assembly language).
100 */
101 #define MACHINE_TIMER_ROUTINES
102
103 #endif
104
105 #endif /* _I386_TIMER_H_ */
Cache object: 44f91030730f9f9fde0c9e294f7653df
|