2 * Copyright (c) 2005 Marcel Moolenaar
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
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>
36 #include <sys/timetc.h>
39 #include <machine/clock.h>
40 #include <machine/cpu.h>
41 #include <machine/efi.h>
43 uint64_t ia64_clock_reload;
46 static timecounter_get_t ia64_get_timecount;
48 static struct timecounter ia64_timecounter = {
49 ia64_get_timecount, /* get_timecount */
51 ~0u, /* counter_mask */
57 ia64_get_timecount(struct timecounter* tc)
59 return ia64_get_itc();
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 */
75 * Start the real-time and statistics clocks. We use cr.itc and cr.itm
76 * to implement a 1000hz clock.
82 if (itc_frequency == 0)
83 panic("Unknown clock frequency");
86 ia64_clock_reload = (itc_frequency + hz/2) / hz;
89 ia64_timecounter.tc_frequency = itc_frequency;
90 tc_init(&ia64_timecounter);
97 cpu_startprofclock(void)
104 cpu_stopprofclock(void)