src/include: Introduce a new BIT_FLAG_32(x) macro

Introduces the BIT_FLAG_32(x) macro to create a 32-bit mask with the
designated bit set. This ensures compatibility with the 32-bit
'GEN_PMCON_A' register on 64-bit systems, where 1ul is 64 bits wide and
could potentially cause an overflow when shifted beyond 31 bits.

Change-Id: I70be1ccba59d25af2ba85a2014232072abf2f87d
Signed-off-by: Saurabh Mishra <mishra.saurabh@intel.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84142
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Reviewed-by: Subrata Banik <subratabanik@google.com>
Reviewed-by: Pratikkumar V Prajapati <pratikkumar.v.prajapati@intel.com>
This commit is contained in:
Saurabh Mishra 2024-08-30 14:02:06 +05:30 committed by Subrata Banik
commit 640d1c456c

View file

@ -21,6 +21,15 @@
#define BIT(x) (1ul << (x))
#endif
/*
* This macro declares a bit as a 32-bits unsigned integer. The common BIT_32(x)
* macro is already used by some external header file. To avoid any conflicts, we
* use a different name.
*/
#ifndef BIT_FLAG_32
#define BIT_FLAG_32(x) (1u << (x))
#endif
#define BITS_PER_BYTE 8
#endif /* __TYPES_H */