|
|
1.1 root 1: /*
2: * Copyright (C) 2006, 2007 Free Software Foundation, Inc.
3: *
4: * This program is free software; you can redistribute it and/or modify
5: * it under the terms of the GNU General Public License as published by
6: * the Free Software Foundation; either version 2, or (at your option)
7: * any later version.
8: *
9: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17: *
18: * Author: Barry deFreese and others.
19: */
20:
21: #ifndef _KERN_MACH_CLOCK_H_
22: #define _KERN_MACH_CLOCK_H_
23:
24: /*
25: * Mach time-out and time-of-day facility.
26: */
27:
28: #include <mach/machine/kern_return.h>
29: #include <mach/time_value.h>
30: #include <kern/host.h>
31: #include <kern/queue.h>
32:
33:
34: /* Timers in kernel. */
35: extern unsigned long elapsed_ticks; /* number of ticks elapsed since bootup */
36: extern int hz; /* number of ticks per second */
37: extern int tick; /* number of usec per tick */
38:
39:
40: typedef void timer_func_t(void *);
41:
42: /* Time-out element. */
43: struct timer_elt {
44: queue_chain_t chain; /* chain in order of expiration */
45: timer_func_t *fcn; /* function to call */
46: void * param; /* with this parameter */
47: unsigned long ticks; /* expiration time, in ticks */
48: int set; /* unset | set | allocated */
49: };
50: #define TELT_UNSET 0 /* timer not set */
51: #define TELT_SET 1 /* timer set */
52: #define TELT_ALLOC 2 /* timer allocated from pool */
53:
54: typedef struct timer_elt timer_elt_data_t;
55: typedef struct timer_elt *timer_elt_t;
56:
57:
58: extern void clock_interrupt(
59: int usec,
60: boolean_t usermode,
61: boolean_t basepri);
62:
63: extern void softclock (void);
64:
65: /* For `private' timer elements. */
66: extern void set_timeout(
67: timer_elt_t telt,
68: unsigned int interval);
69: extern boolean_t reset_timeout(timer_elt_t telt);
70:
71: #define set_timeout_setup(telt,fcn,param,interval) \
72: ((telt)->fcn = (fcn), \
73: (telt)->param = (param), \
74: (telt)->private = TRUE, \
75: set_timeout((telt), (interval)))
76:
77: #define reset_timeout_check(t) \
78: MACRO_BEGIN \
79: if ((t)->set) \
80: reset_timeout((t)); \
81: MACRO_END
82:
83: extern void init_timeout (void);
84:
85: /* Read the current time into STAMP. */
86: extern void record_time_stamp (time_value_t *stamp);
87:
88: extern kern_return_t host_get_time(
89: host_t host,
90: time_value_t *current_time);
91:
92: extern kern_return_t host_set_time(
93: host_t host,
94: time_value_t new_time);
95:
96: extern kern_return_t host_adjust_time(
97: host_t host,
98: time_value_t new_adjustment,
99: time_value_t *old_adjustment);
100:
101: extern void mapable_time_init (void);
102:
103: /* For public timer elements. */
104: extern void timeout(timer_func_t *fcn, void *param, int interval);
105: extern boolean_t untimeout(timer_func_t *fcn, void *param);
106:
107: #endif /* _KERN_MACH_CLOCK_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.