diff options
| author | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-04 19:27:50 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-04 19:27:50 -0500 |
| commit | 602d4a7e2f4b843d1a67375d4d7104073495b758 (patch) | |
| tree | 0b9f184e54fa693c27bd5986c114bdcf6949f788 /include | |
| parent | 0bbacc402e67abca8794a8401c1621dc0c0202e9 (diff) | |
| parent | c51e3a417bb0f295e13a5bad86302b5212eafdf3 (diff) | |
Merge master.kernel.org:/pub/scm/linux/kernel/git/paulus/powerpc-merge
Diffstat (limited to 'include')
69 files changed, 1629 insertions, 3024 deletions
diff --git a/include/asm-powerpc/bitops.h b/include/asm-powerpc/bitops.h new file mode 100644 index 000000000000..dc25c53704d5 --- /dev/null +++ b/include/asm-powerpc/bitops.h | |||
| @@ -0,0 +1,437 @@ | |||
| 1 | /* | ||
| 2 | * PowerPC atomic bit operations. | ||
| 3 | * | ||
| 4 | * Merged version by David Gibson <david@gibson.dropbear.id.au>. | ||
| 5 | * Based on ppc64 versions by: Dave Engebretsen, Todd Inglett, Don | ||
| 6 | * Reed, Pat McCarthy, Peter Bergner, Anton Blanchard. They | ||
| 7 | * originally took it from the ppc32 code. | ||
| 8 | * | ||
| 9 | * Within a word, bits are numbered LSB first. Lot's of places make | ||
| 10 | * this assumption by directly testing bits with (val & (1<<nr)). | ||
| 11 | * This can cause confusion for large (> 1 word) bitmaps on a | ||
| 12 | * big-endian system because, unlike little endian, the number of each | ||
| 13 | * bit depends on the word size. | ||
| 14 | * | ||
| 15 | * The bitop functions are defined to work on unsigned longs, so for a | ||
| 16 | * ppc64 system the bits end up numbered: | ||
| 17 | * |63..............0|127............64|191...........128|255...........196| | ||
| 18 | * and on ppc32: | ||
| 19 | * |31.....0|63....31|95....64|127...96|159..128|191..160|223..192|255..224| | ||
| 20 | * | ||
| 21 | * There are a few little-endian macros used mostly for filesystem | ||
| 22 | * bitmaps, these work on similar bit arrays layouts, but | ||
| 23 | * byte-oriented: | ||
| 24 | * |7...0|15...8|23...16|31...24|39...32|47...40|55...48|63...56| | ||
| 25 | * | ||
| 26 | * The main difference is that bit 3-5 (64b) or 3-4 (32b) in the bit | ||
| 27 | * number field needs to be reversed compared to the big-endian bit | ||
| 28 | * fields. This can be achieved by XOR with 0x38 (64b) or 0x18 (32b). | ||
| 29 | * | ||
| 30 | * This program is free software; you can redistribute it and/or | ||
| 31 | * modify it under the terms of the GNU General Public License | ||
| 32 | * as published by the Free Software Foundation; either version | ||
| 33 | * 2 of the License, or (at your option) any later version. | ||
| 34 | */ | ||
| 35 | |||
| 36 | #ifndef _ASM_POWERPC_BITOPS_H | ||
| 37 | #define _ASM_POWERPC_BITOPS_H | ||
| 38 | |||
| 39 | #ifdef __KERNEL__ | ||
| 40 | |||
| 41 | #include <linux/compiler.h> | ||
| 42 | #include <asm/atomic.h> | ||
| 43 | #include <asm/synch.h> | ||
| 44 | |||
| 45 | /* | ||
| 46 | * clear_bit doesn't imply a memory barrier | ||
| 47 | */ | ||
| 48 | #define smp_mb__before_clear_bit() smp_mb() | ||
| 49 | #define smp_mb__after_clear_bit() smp_mb() | ||
| 50 | |||
| 51 | #define BITOP_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | ||
| 52 | #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) | ||
| 53 | #define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) | ||
| 54 | |||
| 55 | #ifdef CONFIG_PPC64 | ||
| 56 | #define LARXL "ldarx" | ||
| 57 | #define STCXL "stdcx." | ||
| 58 | #define CNTLZL "cntlzd" | ||
| 59 | #else | ||
| 60 | #define LARXL "lwarx" | ||
| 61 | #define STCXL "stwcx." | ||
| 62 | #define CNTLZL "cntlzw" | ||
| 63 | #endif | ||
| 64 | |||
| 65 | static __inline__ void set_bit(int nr, volatile unsigned long *addr) | ||
| 66 | { | ||
| 67 | unsigned long old; | ||
| 68 | unsigned long mask = BITOP_MASK(nr); | ||
| 69 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
| 70 | |||
| 71 | __asm__ __volatile__( | ||
| 72 | "1:" LARXL " %0,0,%3 # set_bit\n" | ||
| 73 | "or %0,%0,%2\n" | ||
| 74 | PPC405_ERR77(0,%3) | ||
| 75 | STCXL " %0,0,%3\n" | ||
| 76 | "bne- 1b" | ||
| 77 | : "=&r"(old), "=m"(*p) | ||
| 78 | : "r"(mask), "r"(p), "m"(*p) | ||
| 79 | |||
