Xenomai  3.0.8
tsc.h
1 /*
2  * Copyright (C) 2005 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18 #ifndef _LIB_COBALT_BLACKFIN_TSC_H
19 #define _LIB_COBALT_BLACKFIN_TSC_H
20 
21 static inline unsigned long long cobalt_read_tsc(void)
22 {
23  union {
24  struct {
25  unsigned long l;
26  unsigned long h;
27  } s;
28  unsigned long long t;
29  } u;
30  unsigned long cy2;
31 
32  __asm__ __volatile__ ( "1: %0 = CYCLES2\n"
33  "%1 = CYCLES\n"
34  "%2 = CYCLES2\n"
35  "CC = %2 == %0\n"
36  "if !cc jump 1b\n"
37  :"=d" (u.s.h),
38  "=d" (u.s.l),
39  "=d" (cy2)
40  : /*no input*/ : "cc");
41  return u.t;
42 }
43 
44 #endif /* !_LIB_COBALT_BLACKFIN_TSC_H */