OpenOCD
bits.h File Reference
Include dependency graph for bits.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BIT(nr)   (1UL << (nr))
 
#define BIT_MASK(nr)   (1UL << ((nr) % BITS_PER_LONG))
 
#define BIT_ULL(nr)   (1ULL << (nr))
 
#define BIT_WORD(nr)   ((nr) / BITS_PER_LONG)
 
#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 BITS_TO_LONGS(nr)   DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
 
#define DECLARE_BITMAP(name, bits)   unsigned long name[BITS_TO_LONGS(bits)]
 
#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))))
 

Functions

static void bitmap_zero (unsigned long *dst, unsigned int nbits)
 bitmap_zero - Clears all the bits in memory More...
 
static void clear_bit (unsigned int nr, volatile unsigned long *addr)
 clear_bit - Clear a bit in memory More...
 
static void set_bit (unsigned int nr, volatile unsigned long *addr)
 set_bit - Set a bit in memory More...
 
static int test_bit (unsigned int nr, const volatile unsigned long *addr)
 test_bit - Determine whether a bit is set More...
 

Macro Definition Documentation

◆ BIT

#define BIT (   nr)    (1UL << (nr))

Definition at line 19 of file bits.h.

◆ BIT_MASK

#define BIT_MASK (   nr)    (1UL << ((nr) % BITS_PER_LONG))

Definition at line 27 of file bits.h.

◆ BIT_ULL

#define BIT_ULL (   nr)    (1ULL << (nr))

Definition at line 20 of file bits.h.

◆ BIT_WORD

#define BIT_WORD (   nr)    ((nr) / BITS_PER_LONG)

Definition at line 28 of file bits.h.

◆ BITS_PER_BYTE

#define BITS_PER_BYTE   8

Definition at line 21 of file bits.h.

◆ BITS_PER_LONG

#define BITS_PER_LONG   (BITS_PER_BYTE * sizeof(long))

Definition at line 22 of file bits.h.

◆ BITS_PER_LONG_LONG

#define BITS_PER_LONG_LONG   (BITS_PER_BYTE * sizeof(long long))

Definition at line 23 of file bits.h.

◆ BITS_TO_LONGS

#define BITS_TO_LONGS (   nr)    DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))

Definition at line 26 of file bits.h.

◆ DECLARE_BITMAP

#define DECLARE_BITMAP (   name,
  bits 
)    unsigned long name[BITS_TO_LONGS(bits)]

Definition at line 29 of file bits.h.

◆ GENMASK

#define GENMASK (   h,
 
)    (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))

Definition at line 24 of file bits.h.

◆ GENMASK_ULL

#define GENMASK_ULL (   h,
 
)    (((~0ULL) - (1ULL << (l)) + 1) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))

Definition at line 25 of file bits.h.

Function Documentation

◆ bitmap_zero()

static void bitmap_zero ( unsigned long *  dst,
unsigned int  nbits 
)
inlinestatic

bitmap_zero - Clears all the bits in memory

Parameters
dstthe address of the bitmap
nbitsthe number of bits to clear

Definition at line 36 of file bits.h.

References BITS_TO_LONGS.

Referenced by COMMAND_HANDLER(), and stm32l4_protect_same_bank().

◆ clear_bit()

static void clear_bit ( unsigned int  nr,
volatile unsigned long *  addr 
)
inlinestatic

clear_bit - Clear a bit in memory

Parameters
nrthe bit to set
addrthe address to start counting from

Definition at line 47 of file bits.h.

References addr, BIT_MASK, BIT_WORD, and mask.

Referenced by stlink_dap_closeall_ap(), stlink_dap_reinit_interface(), and stm32l4_protect_same_bank().

◆ set_bit()

static void set_bit ( unsigned int  nr,
volatile unsigned long *  addr 
)
inlinestatic

set_bit - Set a bit in memory

Parameters
nrthe bit to set
addrthe address to start counting from

Definition at line 60 of file bits.h.

References addr, BIT_MASK, BIT_WORD, and mask.

Referenced by COMMAND_HANDLER(), stlink_usb_open_ap(), and stm32l4_protect_same_bank().

◆ test_bit()

static int test_bit ( unsigned int  nr,
const volatile unsigned long *  addr 
)
inlinestatic

test_bit - Determine whether a bit is set

Parameters
nrbit number to test
addrAddress to start counting from

Definition at line 73 of file bits.h.

References addr, BIT_WORD, and BITS_PER_LONG.

Referenced by bitmap_to_ranges(), rsl10_protect_check(), stlink_dap_closeall_ap(), stlink_dap_reinit_interface(), and stlink_usb_open_ap().