Xenomai  3.1
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_ARM64_TSC_H
26 #define _LIB_COBALT_ARM64_TSC_H
27 
28 #include <asm/xenomai/uapi/tsc.h>
29 #include <asm/xenomai/features.h>
30 #include <inttypes.h>
31 #include <sys/time.h>
32 
33 typedef unsigned long long __xn_rdtsc_t(volatile unsigned *vaddr);
34 struct __xn_full_tscinfo {
35  struct __xn_tscinfo kinfo;
36 };
37 extern struct __xn_full_tscinfo __xn_tscinfo;
38 
39 static inline uint64_t get_counter(void)
40 {
41  uint64_t cval;
42 
43  asm volatile("isb; mrs %0, cntvct_el0; isb; " : "=r" (cval) :: "memory");
44 
45  return cval;
46 }
47 
48 static inline __attribute__((always_inline))
49 unsigned long long cobalt_read_tsc(void)
50 {
51  return get_counter();
52 }
53 
54 #endif /* !_LIB_COBALT_ARM64_TSC_H */
static int __attribute__((cold))
Test if a mutex structure contains a valid autoinitializer.
Definition: mutex.c:177