X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fhelper%2Fbits.h;h=cdcac9eafa4de7c988d814b66b964db06c820149;hp=464584db8c6d93b02305965ae89984862be39f93;hb=HEAD;hpb=e5177a5ad455ac0c353fd6bb48ff288912168428 diff --git a/src/helper/bits.h b/src/helper/bits.h index 464584db8c..4e2a3456cf 100644 --- a/src/helper/bits.h +++ b/src/helper/bits.h @@ -1,19 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + /* * Copyright (C) 2018, STMicroelectronics - All Rights Reserved * Author(s): Antonio Borneo for STMicroelectronics - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ /* @@ -24,11 +13,16 @@ #ifndef OPENOCD_HELPER_BITS_H #define OPENOCD_HELPER_BITS_H +#include #include #define BIT(nr) (1UL << (nr)) +#define BIT_ULL(nr) (1ULL << (nr)) #define BITS_PER_BYTE 8 #define BITS_PER_LONG (BITS_PER_BYTE * sizeof(long)) +#define BITS_PER_LONG_LONG (BITS_PER_BYTE * sizeof(long long)) +#define GENMASK(h, l) (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) +#define GENMASK_ULL(h, l) (((~0ULL) - (1ULL << (l)) + 1) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) @@ -36,8 +30,8 @@ /** * bitmap_zero - Clears all the bits in memory - * @dst: the address of the bitmap - * @nbits: the number of bits to clear + * @param dst the address of the bitmap + * @param nbits the number of bits to clear */ static inline void bitmap_zero(unsigned long *dst, unsigned int nbits) { @@ -47,8 +41,8 @@ static inline void bitmap_zero(unsigned long *dst, unsigned int nbits) /** * clear_bit - Clear a bit in memory - * @nr: the bit to set - * @addr: the address to start counting from + * @param nr the bit to set + * @param addr the address to start counting from */ static inline void clear_bit(unsigned int nr, volatile unsigned long *addr) { @@ -60,8 +54,8 @@ static inline void clear_bit(unsigned int nr, volatile unsigned long *addr) /** * set_bit - Set a bit in memory - * @nr: the bit to set - * @addr: the address to start counting from + * @param nr the bit to set + * @param addr the address to start counting from */ static inline void set_bit(unsigned int nr, volatile unsigned long *addr) { @@ -73,8 +67,8 @@ static inline void set_bit(unsigned int nr, volatile unsigned long *addr) /** * test_bit - Determine whether a bit is set - * @nr: bit number to test - * @addr: Address to start counting from + * @param nr bit number to test + * @param addr Address to start counting from */ static inline int test_bit(unsigned int nr, const volatile unsigned long *addr) {