Xenomai  3.0.8
tsc.h
1 /*
2  * Copyright (C) 2001,2002,2003,2004 Philippe Gerum <rpm@xenomai.org>.
3  * Copyright (C) 2013 Gilles Chanteperdrix <gch@xenomai.org>.
4  *
5  * ARM port
6  * Copyright (C) 2005 Stelian Pop
7  *
8  * Copyright (C) 2007 Sebastian Smolorz <sesmo@gmx.net>
9  * Support for TSC emulation in user space for decrementing counters
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24  */
25 #ifndef _LIB_COBALT_ARM_TSC_H
26 #define _LIB_COBALT_ARM_TSC_H
27 
28 #include <asm/xenomai/uapi/tsc.h>
29 #include <asm/xenomai/features.h>
30 
31 /*
32  * Putting kuser_tsc_get and kinfo.counter in the same struct results
33  * in less operations in PIC code, thus optimizes.
34  */
35 typedef unsigned long long __xn_rdtsc_t(volatile unsigned *vaddr);
36 struct __xn_full_tscinfo {
37  __xn_rdtsc_t *kuser_tsc_get;
38  struct __xn_tscinfo kinfo;
39 };
40 extern struct __xn_full_tscinfo __xn_tscinfo;
41 
42 static inline __attribute__((always_inline))
43 unsigned long long cobalt_read_tsc(void)
44 {
45  return __xn_tscinfo.kuser_tsc_get(__xn_tscinfo.kinfo.counter);
46 }
47 
48 #endif /* !_LIB_COBALT_ARM_TSC_H */