1 /* $NetBSD: clock.c,v 1.7 2020/05/29 12:30:40 rin Exp $ */ 2 3 /* 4 * Copyright (c) 2006 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * 8 * Author: 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* Comments about functions from alpha/clock.c */ 33 34 #include <sys/cdefs.h> 35 36 #include <sys/param.h> 37 #include <sys/kernel.h> 38 #include <sys/systm.h> 39 #include <sys/timetc.h> 40 41 #include <machine/clock.h> 42 #include <machine/cpu.h> 43 #include <machine/ia64_cpu.h> 44 45 46 uint64_t ia64_clock_reload; 47 48 49 #if !defined(MULTIPROCESSOR) 50 static unsigned 51 ia64_get_timecount(struct timecounter* tc) 52 { 53 54 return ia64_get_itc(); 55 } 56 #endif 57 58 void 59 pcpu_initclock(void) 60 { 61 struct cpu_info *ci = curcpu(); 62 63 ci->ci_clockadj = 0; 64 ci->ci_clock = ia64_get_itc(); 65 ia64_set_itm(ci->ci_clock + ia64_clock_reload); 66 #if 0 67 ia64_set_itv(CLOCK_VECTOR); /* highest priority class */ 68 #endif 69 ia64_srlz_d(); 70 } 71 72 /* 73 * Start the real-time and statistics clocks. We use cr.itc and cr.itm 74 * to implement a 1000hz clock. 75 */ 76 void 77 cpu_initclocks(void) 78 { 79 #if !defined(MULTIPROCESSOR) 80 static struct timecounter tc = { 81 .tc_get_timecount = ia64_get_timecount, 82 .tc_counter_mask = ~0u, 83 .tc_name = "ia64_timecounter", 84 .tc_quality = 100, 85 }; 86 #endif 87 88 if (itc_frequency == 0) 89 panic("Unknown clock frequency"); 90 91 stathz = hz; 92 ia64_clock_reload = (itc_frequency + hz / 2) / hz; 93 94 #if !defined(MULTIPROCESSOR) 95 tc.tc_frequency = itc_frequency; 96 tc_init(&tc); 97 #endif 98 99 pcpu_initclock(); 100 } 101 102 void 103 setstatclockrate(int newhz) 104 { 105 106 /* nothing to do? */ 107 } 108