2
* Copyright (C) 2005-2008 by Pieter Palmers
4
* This file is part of FFADO
5
* FFADO = Free Firewire (pro-)audio drivers for linux
7
* FFADO is based upon FreeBoB.
9
* This program is free software: you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation, either version 2 of the License, or
12
* (at your option) version 3 of the License.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
25
* Based upon cycles.h from the jackdmp package.
28
* Copyright (C) 2001 Paul Davis
29
* Code derived from various headers from the Linux kernel
31
* This program is free software; you can redistribute it and/or modify
32
* it under the terms of the GNU General Public License as published by
33
* the Free Software Foundation; either version 2 of the License, or
34
* (at your option) version 3 of the License.
36
* This program is distributed in the hope that it will be useful,
37
* but WITHOUT ANY WARRANTY; without even the implied warranty of
38
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39
* GNU General Public License for more details.
41
* You should have received a copy of the GNU General Public License
42
* along with this program; if not, write to the Free Software
43
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
47
#ifndef __FFADO_CYCLES_H__
48
#define __FFADO_CYCLES_H__
51
* Standard way to access the cycle timer on i586+ CPUs.
52
* Currently only used on SMP.
54
* If you really have a SMP machine with i486 chips or older,
55
* compile for that, and this will just always return zero.
56
* That's ok, it just means that the nicer scheduling heuristics
59
* We only use the low 32 bits, and we'd simply better make sure
60
* that we reschedule before that wraps. Scheduling at least every
61
* four billion cycles just basically sounds like a good idea,
62
* regardless of how fast the machine is.
71
#define CPU_FTR_601 0x00000100
73
typedef unsigned long cycles_t;
75
/* For the "cycle" counter we use the timebase lower half. */
77
extern cycles_t cacheflush_time;
79
static inline cycles_t get_cycles(void)
86
".section __ftr_fixup,\"a\"\n"
92
: "=r" (ret) : "i" (CPU_FTR_601));
100
typedef unsigned long long cycles_t;
102
extern cycles_t cacheflush_time;
104
#define rdtscll(val) \
105
__asm__ __volatile__("rdtsc" : "=A" (val))
107
static inline cycles_t get_cycles (void)
109
unsigned long long ret;
119
#endif // __FFADO_CYCLES_H__