jack1 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.0KB

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