1214571Sdim/*	$NetBSD: cpu_counter.h,v 1.1 2006/09/20 13:33:04 kochi Exp $	*/
2214571Sdim
3214571Sdim/*-
4214571Sdim * Copyright (c) 2006 The NetBSD Foundation, Inc.
5214571Sdim * All rights reserved.
6214571Sdim *
7214571Sdim * This code is derived from software contributed to The NetBSD Foundation
8214571Sdim * by Takayoshi Kochi.
9214571Sdim *
10214571Sdim * Redistribution and use in source and binary forms, with or without
11214571Sdim * modification, are permitted provided that the following conditions
12214571Sdim * are met:
13214571Sdim * 1. Redistributions of source code must retain the above copyright
14214571Sdim *    notice, this list of conditions and the following disclaimer.
15214571Sdim * 2. Redistributions in binary form must reproduce the above copyright
16214571Sdim *    notice, this list of conditions and the following disclaimer in the
17214571Sdim *    documentation and/or other materials provided with the distribution.
18214571Sdim *
19214571Sdim * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20214571Sdim * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21214571Sdim * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22214571Sdim * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23214571Sdim * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24214571Sdim * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25214571Sdim * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26214571Sdim * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27214571Sdim * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28214571Sdim * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29214571Sdim * POSSIBILITY OF SUCH DAMAGE.
30214571Sdim */
31214571Sdim
32214571Sdim#ifndef _IA64_CPU_COUNTER_H_
33214571Sdim#define _IA64_CPU_COUNTER_H_
34214571Sdim
35214571Sdim/*
36214571Sdim * Machine-specific support for CPU counter.
37214571Sdim */
38214571Sdim
39214571Sdim#ifdef _KERNEL
40214571Sdim
41214571Sdim#include <machine/ia64_cpu.h>
42214571Sdim
43214571Sdimstatic __inline int
44214571Sdimcpu_hascounter(void)
45214571Sdim{
46214571Sdim	return 1;
47214571Sdim}
48214571Sdim
49214571Sdimstatic __inline uint64_t
50214571Sdimcpu_counter(void)
51214571Sdim{
52214571Sdim	return ia64_get_itc();
53214571Sdim}
54214571Sdim
55214571Sdimstatic __inline uint32_t
56214571Sdimcpu_counter32(void)
57214571Sdim{
58214571Sdim	return (ia64_get_itc() & 0xffffffffUL);
59214571Sdim}
60214571Sdim
61214571Sdimstatic __inline uint64_t
62214571Sdimcpu_frequency(struct cpu_info *ci)
63214571Sdim{
64214571Sdim	extern uint64_t itc_frequency;
65214571Sdim
66214571Sdim	return itc_frequency;
67214571Sdim}
68214571Sdim
69214571Sdim#endif /* _KERNEL */
70214571Sdim
71214571Sdim#endif /* !_IA64_CPU_COUNTER_H_ */
72214571Sdim