]> CyberLeo.Net >> Repos - FreeBSD/releng/8.0.git/blob - sys/ia64/ia64/clock.c
Adjust to reflect 8.0-RELEASE.
[FreeBSD/releng/8.0.git] / sys / ia64 / ia64 / clock.c
1 /*-
2  * Copyright (c) 2005 Marcel Moolenaar
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
29
30 #include <sys/param.h>
31 #include <sys/kernel.h>
32 #include <sys/queue.h>
33 #include <sys/sysctl.h>
34 #include <sys/systm.h>
35 #include <sys/bus.h>
36 #include <sys/timetc.h>
37 #include <sys/pcpu.h>
38
39 #include <machine/clock.h>
40 #include <machine/cpu.h>
41 #include <machine/efi.h>
42
43 uint64_t ia64_clock_reload;
44
45 #ifndef SMP
46 static timecounter_get_t ia64_get_timecount;
47
48 static struct timecounter ia64_timecounter = {
49         ia64_get_timecount,     /* get_timecount */
50         0,                      /* no poll_pps */
51         ~0u,                    /* counter_mask */
52         0,                      /* frequency */
53         "ITC"                   /* name */
54 };
55
56 static unsigned
57 ia64_get_timecount(struct timecounter* tc)
58 {
59         return ia64_get_itc();
60 }
61 #endif
62
63 void
64 pcpu_initclock(void)
65 {
66
67         PCPU_SET(clockadj, 0);
68         PCPU_SET(clock, ia64_get_itc());
69         ia64_set_itm(PCPU_GET(clock) + ia64_clock_reload);
70         ia64_set_itv(CLOCK_VECTOR);     /* highest priority class */
71         ia64_srlz_d();
72 }
73
74 /*
75  * Start the real-time and statistics clocks. We use cr.itc and cr.itm
76  * to implement a 1000hz clock.
77  */
78 void
79 cpu_initclocks()
80 {
81
82         if (itc_frequency == 0)
83                 panic("Unknown clock frequency");
84
85         stathz = hz;
86         ia64_clock_reload = (itc_frequency + hz/2) / hz;
87
88 #ifndef SMP
89         ia64_timecounter.tc_frequency = itc_frequency;
90         tc_init(&ia64_timecounter);
91 #endif
92
93         pcpu_initclock();
94 }
95
96 void
97 cpu_startprofclock(void)
98 {
99
100         /* nothing to do */
101 }
102
103 void
104 cpu_stopprofclock(void)
105 {
106
107         /* nothing to do */
108 }