~ubuntu-branches/ubuntu/trusty/jack-audio-connection-kit/trusty

« back to all changes in this revision

Viewing changes to config/cpu/powerpc/cycles.h

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2008-12-06 11:05:15 UTC
  • mfrom: (4.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20081206110515-xa9v9pajr9jqvfvg
Tags: 0.115.6-1ubuntu1
* Merge from Debian unstable, remaining Ubuntu changes:
  - Redirect stderr in bash completion (Debian #504488).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (C) 2001 Paul Davis
 
3
    Code derived from various headers from the Linux kernel
 
4
    
 
5
    This program is free software; you can redistribute it and/or modify
 
6
    it under the terms of the GNU General Public License as published by
 
7
    the Free Software Foundation; either version 2 of the License, or
 
8
    (at your option) any later version.
 
9
 
 
10
    This program is distributed in the hope that it will be useful,
 
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
    GNU General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU General Public License
 
16
    along with this program; if not, write to the Free Software
 
17
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
 
 
19
*/
 
20
 
 
21
#ifndef __jack_cycles_h__
 
22
#define __jack_cycles_h__
 
23
 
 
24
/* PowerPC */
 
25
 
 
26
#define CPU_FTR_601                     0x00000100
 
27
#ifdef __powerpc64__
 
28
#define CPU_FTR_CELL_TB_BUG             0x0000800000000000UL
 
29
#endif /* __powerpc64__ */
 
30
 
 
31
typedef unsigned long cycles_t;
 
32
 
 
33
/* For the "cycle" counter we use the timebase lower half. */
 
34
 
 
35
extern cycles_t cacheflush_time;
 
36
 
 
37
static inline cycles_t get_cycles(void)
 
38
{
 
39
        cycles_t ret = 0;
 
40
 
 
41
#ifdef __powerpc64__
 
42
#ifdef ENABLE_CELLBE
 
43
        asm volatile(                                   \
 
44
                "90:    mftb %0;\n"                     \
 
45
                "97:    cmpwi %0,0;\n"                  \
 
46
                "       beq- 90b;\n"                    \
 
47
                "99:\n"                                 \
 
48
                ".section __ftr_fixup,\"a\"\n"          \
 
49
                ".align 3\n"                            \
 
50
                "98:\n"                                 \
 
51
                "       .llong %1\n"                    \
 
52
                "       .llong %1\n"                    \
 
53
                "       .llong 97b-98b\n"               \
 
54
                "       .llong 99b-98b\n"               \
 
55
                ".previous"                             \
 
56
                : "=r" (ret) : "i" (CPU_FTR_CELL_TB_BUG));
 
57
#else /* !ENABLE_CELLBE */
 
58
        __asm__ __volatile__("mftb %0" : "=r" (ret));
 
59
#endif /* !ENABLE_CELLBE */
 
60
#else /* !__powerpc64__ */
 
61
        __asm__ __volatile__(
 
62
                "98:    mftb %0\n"
 
63
                "99:\n"
 
64
                ".section __ftr_fixup,\"a\"\n"
 
65
                "       .long %1\n"
 
66
                "       .long 0\n"
 
67
                "       .long 98b\n"
 
68
                "       .long 99b\n"
 
69
                ".previous"
 
70
                : "=r" (ret) : "i" (CPU_FTR_601));
 
71
#endif /* !__powerpc64__ */
 
72
        return ret;
 
73
}
 
74
 
 
75
#endif /* __jack_cycles_h__ */