diff options
Diffstat (limited to 'include/sbi')
-rw-r--r-- | include/sbi/sbi_bitops.h | 74 | ||||
-rw-r--r-- | include/sbi/sbi_ipi.h | 5 |
2 files changed, 76 insertions, 3 deletions
diff --git a/include/sbi/sbi_bitops.h b/include/sbi/sbi_bitops.h index ece6ec4..9d99299 100644 --- a/include/sbi/sbi_bitops.h +++ b/include/sbi/sbi_bitops.h @@ -95,4 +95,78 @@ static inline int __ffs(unsigned long word) */ #define ffz(x) __ffs(~(x)) +/** + * fls - find last (most-significant) bit set + * @x: the word to search + * + * This is defined the same way as ffs. + * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. + */ + +static inline int fls(int x) +{ + int r = 32; + + if (!x) + return 0; + if (!(x & 0xffff0000u)) { + x <<= 16; + r -= 16; + } + if (!(x & 0xff000000u)) { + x <<= 8; + r -= 8; + } + if (!(x & 0xf0000000u)) { + x <<= 4; + r -= 4; + } + if (!(x & 0xc0000000u)) { + x <<= 2; + r -= 2; + } + if (!(x & 0x80000000u)) { + x <<= 1; + r -= 1; + } + return r; +} + +/** + * __fls - find last (most-significant) set bit in a long word + * @word: the word to search + * + * Undefined if no set bit exists, so code should check against 0 first. + */ +static inline unsigned long __fls(unsigned long word) +{ + int num = BITS_PER_LONG - 1; + +#if BITS_PER_LONG == 64 + if (!(word & (~0ul << 32))) { + num -= 32; + word <<= 32; + } +#endif + if (!(word & (~0ul << (BITS_PER_LONG-16)))) { + num -= 16; + word <<= 16; + } + if (!(word & (~0ul << (BITS_PER_LONG-8)))) { + num -= 8; + word <<= 8; + } + if (!(word & (~0ul << (BITS_PER_LONG-4)))) { + num -= 4; + word <<= 4; + } + if (!(word & (~0ul << (BITS_PER_LONG-2)))) { + num -= 2; + word <<= 2; + } + if (!(word & (~0ul << (BITS_PER_LONG-1)))) + num -= 1; + return num; +} + #endif diff --git a/include/sbi/sbi_ipi.h b/include/sbi/sbi_ipi.h index 5f7192a..109e9af 100644 --- a/include/sbi/sbi_ipi.h +++ b/include/sbi/sbi_ipi.h @@ -27,9 +27,8 @@ struct sbi_ipi_data { unsigned long ipi_type; }; -int sbi_ipi_send_many(struct sbi_scratch *scratch, - struct sbi_trap_info *uptrap, - ulong *pmask, u32 event, void *data); +int sbi_ipi_send_many(struct sbi_scratch *scratch, ulong hmask, + ulong hbase, u32 event, void *data); void sbi_ipi_clear_smode(struct sbi_scratch *scratch); |