Lines Matching +full:value +full:- +full:start

1 /* SPDX-License-Identifier: GPL-2.0 */
14 #include <linux/bitmap-str.h>
25 * specific are in various include/asm-<arch>/bitops.h headers
38 * compile-time and at most BITS_PER_LONG.
80 * bitmap_get_value8(map, start) Get 8bit value from map at start
81 * bitmap_set_value8(map, value, start) Set 8bit value to map at start
99 * test_and_set_bit(bit, addr) Set bit and return old value
100 * test_and_clear_bit(bit, addr) Clear bit and return old value
101 * test_and_change_bit(bit, addr) Change bit and return old value
117 * contain all bit positions from 0 to 'bits' - 1.
172 void __bitmap_set(unsigned long *map, unsigned int start, int len);
173 void __bitmap_clear(unsigned long *map, unsigned int start, int len);
177 unsigned long start,
183 * bitmap_find_next_zero_area - find a contiguous aligned zero area
186 * @start: The bitnumber to start searching at
197 unsigned long start, in bitmap_find_next_zero_area() argument
201 return bitmap_find_next_zero_area_off(map, size, start, nr, in bitmap_find_next_zero_area()
214 #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) argument
215 #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
260 * On 32-bit systems bitmaps are represented as u32 arrays internally. On LE64
264 * to out-of-bound access. To avoid that, both LE and BE variants of 64-bit
282 * On 64-bit systems bitmaps are represented as u64 arrays internally. So,
343 #define BITMAP_MEM_MASK (BITMAP_MEM_ALIGNMENT - 1)
357 * bitmap_or_equal - Check whether the or of two bitmaps is equal to a third
428 static __always_inline void bitmap_set(unsigned long *map, unsigned int start, in bitmap_set() argument
432 __set_bit(start, map); in bitmap_set()
433 else if (small_const_nbits(start + nbits)) in bitmap_set()
434 *map |= GENMASK(start + nbits - 1, start); in bitmap_set()
435 else if (__builtin_constant_p(start & BITMAP_MEM_MASK) && in bitmap_set()
436 IS_ALIGNED(start, BITMAP_MEM_ALIGNMENT) && in bitmap_set()
439 memset((char *)map + start / 8, 0xff, nbits / 8); in bitmap_set()
441 __bitmap_set(map, start, nbits); in bitmap_set()
444 static __always_inline void bitmap_clear(unsigned long *map, unsigned int start, in bitmap_clear() argument
448 __clear_bit(start, map); in bitmap_clear()
449 else if (small_const_nbits(start + nbits)) in bitmap_clear()
450 *map &= ~GENMASK(start + nbits - 1, start); in bitmap_clear()
451 else if (__builtin_constant_p(start & BITMAP_MEM_MASK) && in bitmap_clear()
452 IS_ALIGNED(start, BITMAP_MEM_ALIGNMENT) && in bitmap_clear()
455 memset((char *)map + start / 8, 0, nbits / 8); in bitmap_clear()
457 __bitmap_clear(map, start, nbits); in bitmap_clear()
499 * bitmap_release_region - release allocated bitmap region
513 * bitmap_allocate_region - allocate bitmap region
520 * Returns: 0 on success, or %-EBUSY if specified region wasn't
528 return -EBUSY; in bitmap_allocate_region()
534 * bitmap_find_free_region - find a contiguous aligned mem region
545 * or -errno on failure.
555 return -ENOMEM; in bitmap_find_free_region()
559 * BITMAP_FROM_U64() - Represent u64 value in the format suitable for bitmap.
560 * @n: u64 value
562 * Linux bitmaps are internally arrays of unsigned longs, i.e. 32-bit
563 * integers in 32-bit environment, and 64-bit integers in 64-bit one.
568 * On 64-bit kernels 64-bit LE and BE numbers are naturally ordered in
571 * On 32-bit kernels 32-bit LE ABI orders lo word of 64-bit number in memory
572 * prior to hi, and 32-bit BE orders hi word prior to lo. The bitmap on the
573 * other hand is represented as an array of 32-bit words and the position of
576 * It matches 32-bit LE ABI, and we can simply let the compiler store 64-bit
592 * bitmap_from_u64 - Check and swap words within u64.
596 * In 32-bit Big Endian kernel, when using ``(u32 *)(&val)[*]``
599 * but we expect the lower 32-bits of u64.
607 * bitmap_get_value8 - get an 8-bit value within a memory region
609 * @start: bit offset of the 8-bit value; must be a multiple of 8
611 * Returns the 8-bit value located at the @start bit offset within the @src
615 unsigned long start) in bitmap_get_value8() argument
617 const size_t index = BIT_WORD(start); in bitmap_get_value8()
618 const unsigned long offset = start % BITS_PER_LONG; in bitmap_get_value8()
624 * bitmap_set_value8 - set an 8-bit value within a memory region
626 * @value: the 8-bit value; values wider than 8 bits may clobber bitmap
627 * @start: bit offset of the 8-bit value; must be a multiple of 8
629 static inline void bitmap_set_value8(unsigned long *map, unsigned long value, in bitmap_set_value8() argument
630 unsigned long start) in bitmap_set_value8() argument
632 const size_t index = BIT_WORD(start); in bitmap_set_value8()
633 const unsigned long offset = start % BITS_PER_LONG; in bitmap_set_value8()
636 map[index] |= value << offset; in bitmap_set_value8()