Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1 | #ifndef ARCH_PPC_H |
| 2 | #define ARCH_PPH_H |
| 3 | |
Jens Axboe | cca8464 | 2011-10-07 12:47:57 +0200 | [diff] [blame] | 4 | #define FIO_ARCH (arch_ppc) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 5 | |
| 6 | #ifndef __NR_ioprio_set |
| 7 | #define __NR_ioprio_set 273 |
| 8 | #define __NR_ioprio_get 274 |
| 9 | #endif |
| 10 | |
| 11 | #ifndef __NR_fadvise64 |
| 12 | #define __NR_fadvise64 233 |
| 13 | #endif |
| 14 | |
Jens Axboe | 8756e4d | 2006-05-27 20:24:53 +0200 | [diff] [blame] | 15 | #ifndef __NR_sys_splice |
| 16 | #define __NR_sys_splice 283 |
| 17 | #define __NR_sys_tee 284 |
| 18 | #define __NR_sys_vmsplice 285 |
| 19 | #endif |
| 20 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 21 | #define nop do { } while (0) |
| 22 | |
Jens Axboe | db6defc | 2007-12-11 08:55:53 +0100 | [diff] [blame] | 23 | #ifdef __powerpc64__ |
Jens Axboe | 44c47fe | 2008-06-04 14:31:25 +0200 | [diff] [blame] | 24 | #define read_barrier() __asm__ __volatile__ ("lwsync" : : : "memory") |
Jens Axboe | db6defc | 2007-12-11 08:55:53 +0100 | [diff] [blame] | 25 | #else |
Jens Axboe | 44c47fe | 2008-06-04 14:31:25 +0200 | [diff] [blame] | 26 | #define read_barrier() __asm__ __volatile__ ("sync" : : : "memory") |
Jens Axboe | db6defc | 2007-12-11 08:55:53 +0100 | [diff] [blame] | 27 | #endif |
| 28 | |
Jens Axboe | 44c47fe | 2008-06-04 14:31:25 +0200 | [diff] [blame] | 29 | #define write_barrier() __asm__ __volatile__ ("sync" : : : "memory") |
| 30 | |
Jens Axboe | 8f7e39d | 2008-06-01 19:45:10 +0200 | [diff] [blame] | 31 | static inline int __ilog2(unsigned long bitmask) |
| 32 | { |
| 33 | int lz; |
| 34 | |
| 35 | asm ("cntlzw %0,%1" : "=r" (lz) : "r" (bitmask)); |
| 36 | return 31 - lz; |
| 37 | } |
| 38 | |
| 39 | static inline int arch_ffz(unsigned long bitmask) |
| 40 | { |
| 41 | if ((bitmask = ~bitmask) == 0) |
| 42 | return 32; |
| 43 | return __ilog2(bitmask & -bitmask); |
| 44 | } |
Cigy Cyriac | 5f39d8f | 2010-08-10 19:18:11 -0400 | [diff] [blame] | 45 | |
| 46 | static inline unsigned long long get_cpu_clock(void) |
| 47 | { |
Jens Axboe | 2995607 | 2010-08-11 08:03:20 -0400 | [diff] [blame] | 48 | unsigned int tbl, tbu0, tbu1; |
| 49 | unsigned long long ret; |
Cigy Cyriac | 5f39d8f | 2010-08-10 19:18:11 -0400 | [diff] [blame] | 50 | |
Jens Axboe | 2995607 | 2010-08-11 08:03:20 -0400 | [diff] [blame] | 51 | do { |
| 52 | __asm__ __volatile__ ("mftbu %0" : "=r"(tbu0)); |
| 53 | __asm__ __volatile__ ("mftb %0" : "=r"(tbl) ); |
| 54 | __asm__ __volatile__ ("mftbu %0" : "=r"(tbu1)); |
| 55 | } while (tbu0 != tbu1); |
Cigy Cyriac | 5f39d8f | 2010-08-10 19:18:11 -0400 | [diff] [blame] | 56 | |
Jens Axboe | 2995607 | 2010-08-11 08:03:20 -0400 | [diff] [blame] | 57 | ret = (((unsigned long long)tbu0) << 32) | tbl; |
| 58 | return ret; |
Cigy Cyriac | 5f39d8f | 2010-08-10 19:18:11 -0400 | [diff] [blame] | 59 | } |
| 60 | |
Jens Axboe | 8f7e39d | 2008-06-01 19:45:10 +0200 | [diff] [blame] | 61 | #define ARCH_HAVE_FFZ |
Cigy Cyriac | 5f39d8f | 2010-08-10 19:18:11 -0400 | [diff] [blame] | 62 | #define ARCH_HAVE_CPU_CLOCK |
Jens Axboe | 8f7e39d | 2008-06-01 19:45:10 +0200 | [diff] [blame] | 63 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 64 | #endif |